Rally X
ELEN3009 Project by Justin Wernick and David Schneider
|
Reads the game objects from a text file and calls relevant constructors. More...
#include <LevelReader.h>
Public Member Functions | |
LevelReader (string filename) | |
Constructor that stores the path of the file containing the level to be read with the readLevel function. | |
void | readLevel (Maze &maze, list< PlayerCar > &players, list< EnemyCar > &enemies, list< Checkpoint > &checkpoints, list< Rock > &rocks) |
Function to read the chosen file into the data structures used in the game. | |
Private Attributes | |
string | _filename |
Path of the file containing the level. | |
Static Private Attributes | |
static const char | PLAYER_CHAR = '@' |
Character represented a PlayerCar in the level file. | |
static const char | ENEMY_CHAR = 'X' |
Character represented an EnemyCar in the level file. | |
static const char | CHECKPOINT_CHAR = 'P' |
Character represented a Checkpoint in the level file. | |
static const char | ROCK_CHAR = 'O' |
Character represented a Rock in the level file. | |
static const char | WALL_CHAR = '#' |
Character represented a solid part of the maze in the level file. |
Reads the game objects from a text file and calls relevant constructors.
Definition at line 35 of file LevelReader.h.
LevelReader::LevelReader | ( | string | filename | ) |
Constructor that stores the path of the file containing the level to be read with the readLevel function.
[in] | filename | The path of the file containing the level. |
Definition at line 3 of file LevelReader.cpp.
void LevelReader::readLevel | ( | Maze & | maze, |
list< PlayerCar > & | players, | ||
list< EnemyCar > & | enemies, | ||
list< Checkpoint > & | checkpoints, | ||
list< Rock > & | rocks | ||
) |
Function to read the chosen file into the data structures used in the game.
Each character in the file is iterated through, and added to the appropriate data structure if it matches one of the defined constants. Lists should be cleared prior to calling this function.
[out] | maze | Object representing the walls, populated with a vector of x,y pairs. |
[out] | players | List representing the player(s) in the game. |
[out] | enemies | List representing the enemies in the game. |
[out] | checkpoints | List representing the checkpoints in the game. |
[out] | rocks | List representing the rocks in the game. |
Definition at line 7 of file LevelReader.cpp.
string LevelReader::_filename [private] |
Path of the file containing the level.
Definition at line 68 of file LevelReader.h.
const char LevelReader::CHECKPOINT_CHAR = 'P' [static, private] |
Character represented a Checkpoint in the level file.
Definition at line 64 of file LevelReader.h.
const char LevelReader::ENEMY_CHAR = 'X' [static, private] |
Character represented an EnemyCar in the level file.
Definition at line 63 of file LevelReader.h.
const char LevelReader::PLAYER_CHAR = '@' [static, private] |
Character represented a PlayerCar in the level file.
Definition at line 62 of file LevelReader.h.
const char LevelReader::ROCK_CHAR = 'O' [static, private] |
Character represented a Rock in the level file.
Definition at line 65 of file LevelReader.h.
const char LevelReader::WALL_CHAR = '#' [static, private] |
Character represented a solid part of the maze in the level file.
Definition at line 66 of file LevelReader.h.