CPSC 170 Post Lab 11
2D Game
Due Before Class on Tuesday, April 12th

The two dimensional map implemented in the last assignment performed multiple binary searches when iterating over the spites in a region. A binary search tree implementation of a two-dimensional map would have this same disadvantage. The solution is to use a different type of tree, a binary space partition.


For this assignment you will modify your game from assignment ten to utilize either a list, map, or binary space partition for storing sprites. Like the last assignment you will need both a class that represents the binary space partition and a class that stores the game's sprites using the binary space partition. The StorageMode enum will need a new entry for the binary space partition 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 BinarySpacePartition 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 non-player controlled moving sprites and a sound effect to the game. The sprites can be moving platforms, obstacles, enemies, power-ups, etc. The moving sprites should not be stored in the same data structure as the non-moving sprites because their movement would affect where they are stored. Instead create a class that represents all of the moving objects and stores the sprites in an array or list. The game should have at least one sound effect. The sound should be played in response to some event such as user input or sprite collision.

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