The object that controls the flow of the game, and the launch point of the game.
More...
Public Member Functions |
| Game () |
| Constructor, that creates the relevant Allegro entities.
|
| ~Game () |
| Constructor, that destroys the relevant Allegro entities.
|
void | start () |
| Entry point for the program. This should be called from main.
|
Static Public Attributes |
static const unsigned int | FPS = 30 |
| Frames per second, the number of times the gameloop is run every second.
|
Private Member Functions |
| Game (const Game &ref) |
| Unimplemented copy constructor, prevents copying of Game objects.
|
Game & | operator= (const Game &rhs) |
| Unimplemented assignment operator.
|
void | initLevel (const string &levelFile) |
| Initialises all of the GameObject lists using a file.
|
void | runloop () |
| Main part of the game, performs the actions in each frame FPS times per second until the game is over.
|
void | update () |
| Calls the update method on each of the GameObjects in the game.
|
void | cleanup () |
| Removes any GameObjects that have been destroyed from their lists.
|
void | clearLists () |
| Destroys all GameObjects in the game, resetting the lists for a new level to be loaded.
|
Private Attributes |
AllegroInit | _allegro |
| Handles dependencies on Allegro being installed.
|
Config | _config |
| Loads configuration from file on construction, used to set resolution of screen.
|
Screen | _screen |
| Handles all drawing operations.
|
ALLEGRO_TIMER * | _timer |
| Creates FPS events per second, that are put into _timerEvents.
|
ALLEGRO_EVENT_QUEUE * | _timerEvents |
| Catches events from _timer, used to regulate speed of runloop.
|
Maze | _maze |
| The environment that confines the movements of GameObjects, specifically Cars.
|
list< PlayerCar > | _players |
| Typically a single PlayerCar, controlled by the person playing the game.
|
list< EnemyCar > | _enemies |
| List of all EnemyCars chasing the player.
|
list< Checkpoint > | _checkpoints |
| List of checkpoints that the player needs to collect.
|
list< Rock > | _rocks |
| List of rocks that the player and EnemyCars need to avoid.
|
list< Smokescreen > | _smokescreens |
| List of Smokescreen objects that are currently able to delay EnemyCars.
|
list< DestroyedObjectPopup > | _popups |
| List of purely visual DestroyedObjectPopups that need to be drawn.
|
CollisionDetector | _collisionDetector |
| Object that checks for collisions each frame.
|
The object that controls the flow of the game, and the launch point of the game.
Game contains the various components, including the screen, the maze, and all of the objects in the maze. The timing of the gameloop also falls under Game's control. Essencially, Game is the central point that everything connects to.
- Author:
- Justin Wernick
-
David Schneider
Definition at line 36 of file Game.h.
void Game::runloop |
( |
| ) |
[private] |
Main part of the game, performs the actions in each frame FPS times per second until the game is over.
Each frame runs the update methods of each of the GameObjects in the lists. The CollisionDetector then checks for collisions between objects. Any GameObjects that have been destroyed are then removed from their lists. Finally, the Screen is called to draw all of the GameObjects that still exist in their new positions.
Before the next iteration begins, a check is done for the victory and loss conditions. The loop is ended if either of these are met, or if the player has quit the game.
Definition at line 39 of file Game.cpp.
Typically a single PlayerCar, controlled by the person playing the game.
A list was used for _players to allow the Game object to be constructed without needing to initialise a meaningless PlayerCar object. This also allows the PlayerCar to be destroyed by Rocks or EnemyCars. An added benefit is that it adds the ease of extending the game to allow multiple players. To add multiplayer, the KeyboardHandler would need to be modified to allow different sets of input keys, and the Screen would need to be modified to keep all players visible, but the Game class would be able to remain largely unchanged.
Definition at line 124 of file Game.h.