CPSC 170 Post Lab 12
2D Game
Due Before Class on Monday, April 25th

In the last assignment the binary space partition reduced the initial find performed by the iterator to logarithmic complexity. However, it introduced cases where the iteration was not constant. The final sprite storage method we will explore, a two dimensional hash table, is able to have constant iteration initialization and a constant number of iterations, if the hash function is well defined.


For this assignment you will modify your game from assignment eleven to utilize either an array, sorted list, binary space partition, or hashtable for storing sprites. Like the last assignment you will need both a class that represents the hashtable and a class that stores the game's sprites using the hashtable. The StorageMode enum will need a new entry for the hashtable and the Level class constructor will need a new case to check the enum. You will also need to add an iterate method to your HashMap2D class. This method should return an iterator that efficiently iterates over the sprites in the map that are contained inside the specified rectangle.

Finally, add a title screen and either a win condition or a lose condition. The title screen should display the name of the game and a give short description of how to play. The game should have either a goal that when achieved displays a congratulatory screen or for a game with infinite game-play, a condition that ends the game and displays a game over message. The three different game states (title, game, and end) should be controlled with an enum. Both the paint and the update methods should have switch statements that check this enum to draw or update the game according to the current state.

Submission: Tar and submit your code on the course blackboard site.