Rally X
ELEN3009 Project by Justin Wernick and David Schneider
Public Member Functions | Private Attributes | Static Private Attributes
LevelReader Class Reference

Reads the game objects from a text file and calls relevant constructors. More...

#include <LevelReader.h>

List of all members.

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.

Detailed Description

Reads the game objects from a text file and calls relevant constructors.

Author:
Justin Wernick
David Schneider

Definition at line 35 of file LevelReader.h.


Constructor & Destructor Documentation

LevelReader::LevelReader ( string  filename)

Constructor that stores the path of the file containing the level to be read with the readLevel function.

Parameters:
[in]filenameThe path of the file containing the level.

Definition at line 3 of file LevelReader.cpp.


Member Function Documentation

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.

Parameters:
[out]mazeObject representing the walls, populated with a vector of x,y pairs.
[out]playersList representing the player(s) in the game.
[out]enemiesList representing the enemies in the game.
[out]checkpointsList representing the checkpoints in the game.
[out]rocksList representing the rocks in the game.

Definition at line 7 of file LevelReader.cpp.


Member Data Documentation

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.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator