CMPS164, Spring 2014, Section 01: Refactoring, HUD, Scoring

Pre-requisites for this assignment :

  A working minigolf game with the following parts:

1) Loading courses from .db files and rendering them (18 hole course file available on Piazza -- new specification below)

2) Moving ball along tiles

3) Collision Detection and Resolution (with Walls and with the Hole to detect end of game)   \

Part I : Refactoring and code cleanup 
In this part you will refactor your code into a clean design where you will separate out core engine code and minigolf specific code.   There are several refactoring patterns that will be useful to you:   Check out this link : Refactoring Patterns  

While each of you will have different code organization, here are some general guidelines for organizing:  

1) Have a utility library for general mathematical operations that is shared among different engine modules. It is a good idea to start with basic data structures like Vertex, Matrix, etc. and operations on these. It is also a good idea to have file management code separated out to your utility library including writing out your own debug information.

2) Data Management: Start thinking about managing data from 18 hole courses and functions for swapping out levels. You will have to think about adding utilities for better memory management.

3) Physics and Collision: Later you might have external objects (like bridges and obstacles) that could be placed in the level. Your physics and collision systems should be written so that these could easily be integrated in the engine.

4) Commenting and Documentation: Your code should (post-refactoring) be cleanly documented with comments and an API reference that would make it easy for developers to adopt your engine. 5) Error handling and debug support: Write exception handlers and checks for level formats, physics bugs, rendering bugs, and visual debugging features.  

Part II: HUD
With ball movement and collision you now have the set up for a complete playable experience. What is missing is a scoring system and HUD elements for your level. For this lab you will do the following:  

  • Identify and design HUD elements. Set up a HUD class with data elements (not drawing functions yet) and provide concept sketches for your HUD

 

Minigolf Course File Format

A minigolf course is a collection of between one and eighteen minigolf holes. The input language defined in Assignment #1 will be extended to support minigolf course definitions. Every minigolf course file must begin with the line:

course course-name n

where:

  • course is a keyword denoting that this file contains a minigolf course definition,
  • course-name is the name of the course, and
  • n is the number of minigolf holes that make up the course.

This initial line is followed by n minigolf hole layouts. In order to simplify processing, each layout begins with a line:

begin_hole

and ends with a line:

end_hole

A minigolf hole layout is defined using the same tile, cup, and tee commands described in Assignment #1. Your program must also support two new commands that provide additional information about a minigolf hole:

par par-val
name hole-name

where:

  • par is a keyword denoting that this line contains the minigolf hole's par value,
  • name is a keyword denoting that this line contains the minigolf hole's name,
  • par-val is the par value for the minigolf hole (i.e., the standard number of strokes a player should need to move the ball into the cup), and
  • hole-name is the name of the minigolf hole.

Based on these new definitions, a minigolf course containing a single hole would be defined as:

course "A Single Hole Course" 1
begin_hole
name "Simple Little Minigolf Hole"
par 2
tile 1 4 -0.5 0 1 0.5 0 1 0.5 0 0 -0.5 0 0 0 0 3 0
tile 2 4 -1.5 0 0 -0.5 0 0 -0.5 0 -1 -1.5 0 -1 0 3 0 0
tile 3 4 -0.5 0 0 0.5 0 0 0.5 0 -1 -0.5 0 -1 1 4 0 2
tile 4 4 0.5 0 0 1.5 0 0 1.5 0 -1 0.5 0 -1 0 0 0 3
tee 1 0 0 0.5
cup 2 -1 0 -0.5
end_hole

Note that commands between begin_hole and end_hole can be defined in any order. A course with more minigolf holes would have a different number for the initial course line, together with the appropriate number of additional minigolf hole layouts (bracketed with begin_hole andend_hole).


Grading  
Your assignment will be graded as follows:

Part I (60%)   

 - Refactored code (25% of total grade)   

 - Error handling and debugging support (15% of total grade)   

 - Commented and Documented code (15% of total grade)   

 - Change log and your process of refactoring (5% - written document)

Part II (40%)   

 - HUD design (20%) -- concept sketches

 - HUD data structures and rendering (20%)