- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

# Level Class Reference

`#include <Level.h>`

List of all members.

## Public Member Functions
| Level ()
| ~Level ()
void | reset ()
bool | update ()
void | draw ()
void | levelLoad (std::string filenamebase)
void | registerObject (Object *o)
void | registerTile (Tile *t, int h, int w)
std::vector< Object * > & | getObjects ()
Tile * | getTile (int w, int h)
Tile * | getTileFromPixels (int w, int h)
void | deleteObject (Object *o)
void | scheduleDelete (Object *o)
int | getHeight ()
int | getWidth ()
Object * | getObject (std::string id)
Mix_Music * | getMusic ()
void | setMusic (Mix_Music *music)
Mix_Chunk * | getSound (std::string filename)
void | loadSound (std::string filename)
Player * | getPlayer ()
void | setCutScene (bool cutScene)
void | setCutSceneText (std::string text)
void | addScore (int score)
void | addKill ()
int | getScore ()
void | setScore (int score)
void | drawHUD ()
void | save ()
void | restore ()
bool | getWon ()
void | setWon (bool won)
## Static Public Member Functions
static Level * | instance ()
## Static Public Attributes
static const int | tileHeight = 32
static const int | tileWidth = 32
## Private Member Functions
void | loadObjects ()
void | readTextures (std::string extension)
void | readObjects (std::string dir)
void | levelTextureLoad (std::string filenamebase)
void | levelObjectLoad (std::string filenamebase)
void | levelSpecsLoad (std::string filenamebase)
void | addObject (Object *o, std::vector< Object * > &vec)
Uint32 | loadPixelFile (std::string filename)
## Private Attributes
bool | _won
bool | _timed
int | _levelTimer
int | _killed
int | _totBad
int | _height
int | _width
std::string | _filenamebase
bool | _cutScene
std::string | _cutSceneText
int | _score
Player * | _player
std::vector< Object * > | _objects
std::vector< Tile * > | _tiles
std::vector< Object * > | _drawnObjects
std::vector< Object * > | _deleteQueue
std::queue< Object * > | _addQueue
std::map< std::string, Object * > | _ids
Mix_Music * | _music
std::map< std::string, Mix_Chunk * > | _sounds
Background * | _background
std::vector< Object * > | _save
## Static Private Attributes
static Level * | _instance = NULL
static Uint32 | WALKBEHIND = 0
static Uint32 | WALKINTO = 0
static Uint32 | WALKINFRONT = 0
static std::map< Uint32, Sprite * > | TEXTURES
static std::map< Uint32, std::string > | OBJECTS
static bool | _objectsLoaded = false

## Detailed Description

Definition at line 22 of file Level.h.

## Constructor & Destructor Documentation

Level::Level | ( |  | ) |

| Definition at line 27 of file Level.cpp. References _instance, and loadObjects(). Referenced by instance().

Level::~Level | ( |  | ) |

| Definition at line 36 of file Level.cpp. References _background, _music, _sounds, Sprite::cleanSprites(), CommandManager::flush(), and CommandManager::instance().

## Member Function Documentation

void Level::addKill | ( |  | ) | `[inline]`

| Definition at line 62 of file Level.h. References _killed. Referenced by Enemy::die().

void Level::addObject | ( | Object * | o,
|  | std::vector< Object * > & | vec
| ) | `[private]`

| Definition at line 628 of file Level.cpp. References _drawnObjects, _ids, Object::getDepth(), and Object::id(). Referenced by levelObjectLoad().

void Level::addScore | ( | int | score | ) | `[inline]`

| Definition at line 61 of file Level.h. References _score. Referenced by Enemy::die(), and AddScoreCommand::execute().

void Level::deleteObject | ( | Object * | o | ) |

| Definition at line 668 of file Level.cpp. References _drawnObjects, _ids, _objects, Control::detachController(), Object::getType(), Object::id(), and TILE. Referenced by update().

void Level::draw | ( |  | ) |

| Definition at line 524 of file Level.cpp. References _background, _drawnObjects, and Background::draw(). Referenced by Game::mainLoop().

void Level::drawHUD | ( |  | ) |

| Definition at line 542 of file Level.cpp. References _player, Sprite::draw(), Person::getHealth(), Sprite::loadSprite(), Sprite::SCREEN, and Sprite::width().

int Level::getHeight | ( |  | ) | `[inline]`

| Definition at line 42 of file Level.h. References _height. Referenced by Background::draw().

Mix_Music* Level::getMusic | ( |  | ) | `[inline]`

| Definition at line 51 of file Level.h. References _music.

Object * Level::getObject | ( | std::string | id | ) |

| Definition at line 650 of file Level.cpp. References _ids. Referenced by AddHealthCommand::AddHealthCommand(), AddWeaponCommand::AddWeaponCommand(), CrouchCommand::CrouchCommand(), StopPersonCommand::execute(), ShootCommand::execute(), SetPositionCommand::execute(), MoveCommand::execute(), LiveCommand::execute(), KillCommand::execute(), JumpResetCommand::execute(), JumpCommand::execute(), InvincibleCommand::execute(), AimCommand::execute(), ActivateEnemyCommand::execute(), ActivateCutSceneCommand::execute(), FollowPlayerCommand::FollowPlayerCommand(), FollowPlayerInRangeCommand::FollowPlayerInRangeCommand(), RunFromPlayerInRangeCommand::RunFromPlayerInRangeCommand(), SecondaryShootCommand::SecondaryShootCommand(), SetCameraCommand::SetCameraCommand(), SetControlCommand::SetControlCommand(), SetDoorLockCommand::SetDoorLockCommand(), ShootInRangeCommand::ShootInRangeCommand(), and TurnCommand::TurnCommand().

std::vector< Object* >& Level::getObjects | ( |  | ) | `[inline]`

| Definition at line 35 of file Level.h. References _objects. Referenced by CollisionHandler::ObjsColliding().

Player* Level::getPlayer | ( |  | ) | `[inline]`

| Definition at line 55 of file Level.h. References _player. Referenced by AimCommand::AimCommand(), ShootInRangeCommand::execute(), RunFromPlayerInRangeCommand::execute(), FollowPlayerInRangeCommand::execute(), FollowPlayerCommand::execute(), and EndLevelCommand::execute().

int Level::getScore | ( |  | ) | `[inline]`

| Definition at line 64 of file Level.h. References _score.

Mix_Chunk * Level::getSound | ( | std::string | filename | ) |

| Definition at line 683 of file Level.cpp. References _sounds.

Tile* Level::getTile | ( | int | w,
|  | int | h
| ) | `[inline]`

| Definition at line 36 of file Level.h. References _tiles, and _width. Referenced by CollisionHandler::ObjsColliding().

Tile* Level::getTileFromPixels | ( | int | w,
|  | int | h
| ) | `[inline]`

| Definition at line 38 of file Level.h. References _tiles, _width, tileHeight, and tileWidth. Referenced by Tile::calcDrawBox(), and Tile::getSquare().

int Level::getWidth | ( |  | ) | `[inline]`

| Definition at line 43 of file Level.h. References _width. Referenced by Background::draw().

bool Level::getWon | ( |  | ) | `[inline]`

| Definition at line 72 of file Level.h. References _won. Referenced by Game::wonLevel().

Level * Level::instance | ( |  | ) | `[static]`

| Definition at line 655 of file Level.cpp. References _instance, and Level(). Referenced by AddHealthCommand::AddHealthCommand(), AddWeaponCommand::AddWeaponCommand(), AimCommand::AimCommand(), Tile::calcDrawBox(), CrouchCommand::CrouchCommand(), Player::die(), Person::die(), Enemy::die(), Background::draw(), StopPersonCommand::execute(), ShootInRangeCommand::execute(), ShootCommand::execute(), SetPositionCommand::execute(), SetCutSceneCommand::execute(), SaveCommand::execute(), RunFromPlayerInRangeCommand::execute(), RestoreCommand::execute(), PlaySoundCommand::execute(), PlayMusicCommand::execute(), MoveCommand::execute(), LiveCommand::execute(), KillCommand::execute(), JumpResetCommand::execute(), JumpCommand::execute(), InvincibleCommand::execute(), FollowPlayerInRangeCommand::execute(), FollowPlayerCommand::execute(), EndLevelCommand::execute(), CutSceneTextCommand::execute(), AimCommand::execute(), AddScoreCommand::execute(), ActivateEnemyCommand::execute(), ActivateCutSceneCommand::execute(), FollowPlayerCommand::FollowPlayerCommand(), FollowPlayerInRangeCommand::FollowPlayerInRangeCommand(), Tile::getSquare(), CollisionHandler::ObjsColliding(), PlayMusicCommand::PlayMusicCommand(), PlaySoundCommand::PlaySoundCommand(), RunFromPlayerInRangeCommand::RunFromPlayerInRangeCommand(), SecondaryShootCommand::SecondaryShootCommand(), SetCameraCommand::SetCameraCommand(), SetControlCommand::SetControlCommand(), SetDoorLockCommand::SetDoorLockCommand(), Weapon::shoot(), ShootInRangeCommand::ShootInRangeCommand(), TurnCommand::TurnCommand(), and Bullet::update().

void Level::levelLoad | ( | std::string | filenamebase | ) |

| Definition at line 261 of file Level.cpp. References _filenamebase, _ids, _player, Screen::instance(), levelObjectLoad(), levelSpecsLoad(), levelTextureLoad(), and Screen::registerFollowObj(). Referenced by Game::loadLevel().

void Level::levelObjectLoad | ( | std::string | filenamebase | ) | `[private]`

| Definition at line 342 of file Level.cpp. References _height, _ids, _objects, _width, addObject(), Object::id(), glfuncs::load_image(), Object::loadObject(), OBJECTS, tileHeight, and tileWidth. Referenced by levelLoad().

void Level::levelSpecsLoad | ( | std::string | filenamebase | ) | `[private]`

| Definition at line 304 of file Level.cpp. References _levelTimer, _timed, List::empty(), List::firstList(), and Parser::parse(). Referenced by levelLoad().

void Level::levelTextureLoad | ( | std::string | filenamebase | ) | `[private]`

| Definition at line 387 of file Level.cpp. References _background, _height, _tiles, _width, glfuncs::load_image(), registerTile(), Object::setCollidable(), Object::setDepth(), TEXTURES, tileHeight, tileWidth, WALKBEHIND, WALKINFRONT, and WALKINTO. Referenced by levelLoad().

void Level::loadObjects | ( |  | ) | `[private]`

| Definition at line 151 of file Level.cpp. References _objectsLoaded, loadPixelFile(), readObjects(), readTextures(), WALKBEHIND, WALKINFRONT, and WALKINTO. Referenced by Level().

Uint32 Level::loadPixelFile | ( | std::string | filename | ) | `[private]`

| Definition at line 170 of file Level.cpp. References glfuncs::instance(), and glfuncs::load_image(). Referenced by loadObjects().

void Level::loadSound | ( | std::string | filename | ) |

| Definition at line 689 of file Level.cpp. References _sounds. Referenced by PlaySoundCommand::PlaySoundCommand().

void Level::readObjects | ( | std::string | dir | ) | `[private]`

| Definition at line 180 of file Level.cpp. References glfuncs::instance(), glfuncs::load_image(), and OBJECTS. Referenced by loadObjects().

void Level::readTextures | ( | std::string | extension | ) | `[private]`

| Definition at line 221 of file Level.cpp. References glfuncs::instance(), glfuncs::load_image(), Sprite::loadSprite(), and TEXTURES. Referenced by loadObjects().

void Level::registerObject | ( | Object * | o | ) |

| Definition at line 606 of file Level.cpp. References _addQueue. Referenced by Person::die(), and Weapon::shoot().

void Level::registerTile | ( | Tile * | t,
|  | int | h,
|  | int | w
| ) |

| Definition at line 611 of file Level.cpp. References _drawnObjects, _tiles, _width, and Object::getDepth(). Referenced by levelTextureLoad().

void Level::reset | ( |  | ) |

| Definition at line 122 of file Level.cpp. References restore(). Referenced by Game::resetLevel().

void Level::restore | ( |  | ) |

| Definition at line 80 of file Level.cpp. References _drawnObjects, _objects, _save, and Control::detachController(). Referenced by RestoreCommand::execute(), and reset().

void Level::save | ( |  | ) |

| Definition at line 68 of file Level.cpp. References _objects, _save, and BULLET. Referenced by SaveCommand::execute().

void Level::scheduleDelete | ( | Object * | o | ) |

| Definition at line 663 of file Level.cpp. References _deleteQueue. Referenced by Person::die(), and Bullet::update().

void Level::setCutScene | ( | bool | cutScene | ) |

| Definition at line 678 of file Level.cpp. References _cutScene. Referenced by SetCutSceneCommand::execute().

void Level::setCutSceneText | ( | std::string | text | ) | `[inline]`

| Definition at line 59 of file Level.h. References _cutSceneText. Referenced by CutSceneTextCommand::execute().

void Level::setMusic | ( | Mix_Music * | music | ) |

| Definition at line 335 of file Level.cpp. References _music. Referenced by PlayMusicCommand::PlayMusicCommand().

void Level::setScore | ( | int | score | ) | `[inline]`

| Definition at line 65 of file Level.h. References _score. Referenced by Player::die().

void Level::setWon | ( | bool | won | ) | `[inline]`

| Definition at line 73 of file Level.h. References _won. Referenced by EndLevelCommand::execute().

bool Level::update | ( |  | ) |

| Definition at line 474 of file Level.cpp. References _cutScene, _deleteQueue, _levelTimer, _player, _timed, _won, Player::copy(), deleteObject(), and Player::die(). Referenced by Game::mainLoop().

## Member Data Documentation

std::queue< Object* > Level::_addQueue`[private]`

| Definition at line 123 of file Level.h. Referenced by registerObject().

Background* Level::_background`[private]`

| Definition at line 127 of file Level.h. Referenced by draw(), levelTextureLoad(), and ~Level().

bool Level::_cutScene`[private]`

| Definition at line 104 of file Level.h. Referenced by setCutScene(), and update().

std::string Level::_cutSceneText`[private]`

| Definition at line 105 of file Level.h. Referenced by setCutSceneText().

std::vector< Object* > Level::_deleteQueue`[private]`

| Definition at line 122 of file Level.h. Referenced by scheduleDelete(), and update().

std::vector< Object* > Level::_drawnObjects`[private]`

| Definition at line 121 of file Level.h. Referenced by addObject(), deleteObject(), draw(), registerTile(), and restore().

std::string Level::_filenamebase`[private]`

| Definition at line 101 of file Level.h. Referenced by levelLoad().

int Level::_height`[private]`

| Definition at line 98 of file Level.h. Referenced by getHeight(), levelObjectLoad(), and levelTextureLoad().

std::map<std::string,Object*> Level::_ids`[private]`

| Definition at line 124 of file Level.h. Referenced by addObject(), deleteObject(), getObject(), levelLoad(), and levelObjectLoad().

Level * Level::_instance = NULL`[static, private]`

| Definition at line 107 of file Level.h. Referenced by instance(), and Level().

int Level::_killed`[private]`

| Definition at line 95 of file Level.h. Referenced by addKill().

int Level::_levelTimer`[private]`

| Definition at line 93 of file Level.h. Referenced by levelSpecsLoad(), and update().

Mix_Music* Level::_music`[private]`

| Definition at line 125 of file Level.h. Referenced by getMusic(), setMusic(), and ~Level().

std::vector< Object* > Level::_objects`[private]`

| Definition at line 119 of file Level.h. Referenced by deleteObject(), getObjects(), levelObjectLoad(), restore(), and save().

bool Level::_objectsLoaded = false`[static, private]`

| Definition at line 131 of file Level.h. Referenced by loadObjects().

Player* Level::_player`[private]`

| Definition at line 117 of file Level.h. Referenced by drawHUD(), getPlayer(), levelLoad(), and update().

std::vector< Object* > Level::_save`[private]`

| Definition at line 129 of file Level.h. Referenced by restore(), and save().

int Level::_score`[private]`

| Definition at line 115 of file Level.h. Referenced by addScore(), getScore(), and setScore().

std::map< std::string, Mix_Chunk* > Level::_sounds`[private]`

| Definition at line 126 of file Level.h. Referenced by getSound(), loadSound(), and ~Level().

std::vector< Tile* > Level::_tiles`[private]`

| Definition at line 120 of file Level.h. Referenced by getTile(), getTileFromPixels(), levelTextureLoad(), and registerTile().

bool Level::_timed`[private]`

| Definition at line 92 of file Level.h. Referenced by levelSpecsLoad(), and update().

int Level::_totBad`[private]`

| Definition at line 96 of file Level.h.

int Level::_width`[private]`

| Definition at line 99 of file Level.h. Referenced by getTile(), getTileFromPixels(), getWidth(), levelObjectLoad(), levelTextureLoad(), and registerTile().

bool Level::_won`[private]`

| Definition at line 90 of file Level.h. Referenced by getWon(), setWon(), and update().

map< Uint32, string > Level::OBJECTS`[static, private]`

| Definition at line 113 of file Level.h. Referenced by levelObjectLoad(), and readObjects().

map< Uint32, Sprite * > Level::TEXTURES`[static, private]`

| Definition at line 112 of file Level.h. Referenced by levelTextureLoad(), and readTextures().

const int Level::tileHeight = 32`[static]`

| Definition at line 45 of file Level.h. Referenced by Tile::calcDrawBox(), Person::collide(), Tile::getSquare(), getTileFromPixels(), levelObjectLoad(), levelTextureLoad(), and CollisionHandler::ObjsColliding().

const int Level::tileWidth = 32`[static]`

| Definition at line 46 of file Level.h. Referenced by Tile::calcDrawBox(), Tile::getSquare(), getTileFromPixels(), levelObjectLoad(), levelTextureLoad(), and CollisionHandler::ObjsColliding().

Uint32 Level::WALKBEHIND = 0`[static, private]`

| Definition at line 109 of file Level.h. Referenced by levelTextureLoad(), and loadObjects().

Uint32 Level::WALKINFRONT = 0`[static, private]`

| Definition at line 111 of file Level.h. Referenced by levelTextureLoad(), and loadObjects().

Uint32 Level::WALKINTO = 0`[static, private]`

| Definition at line 110 of file Level.h. Referenced by levelTextureLoad(), and loadObjects().

The documentation for this class was generated from the following files:

- C:/Documents and Settings/jegan/Desktop/projectX/Level.h
- C:/Documents and Settings/jegan/Desktop/projectX/Level.cpp