The Game Engine  1
Level Class Reference

This is a stand alone Level that will have varying jobs. More...

#include <Level.h>

+ Collaboration diagram for Level:

Public Member Functions

 Level (string name, Condition winCond, Behavior loadBehave=NULL, Behavior updateBehave=NULL, Behavior endBehave=NULL, Behavior pBehave=NULL)
 Level constructor. More...
 
 ~Level ()
 
void drawScene ()
 Draws everything that is set to draw on the screen. More...
 
void LoadBG (string name)
 Loads the Background. More...
 
virtual void postEvent (SDL_Event event)
 Passes along SDL events. More...
 
void update ()
 Loop that runs every game frame that calculates movement, placement, etc. More...
 
void load ()
 Runs load action. More...
 
void unload ()
 Runs load action. More...
 
void addObject (WorldObject *o)
 add a WorldObject to the list of objects More...
 
void removeObject (WorldObject *o)
 remove the WorldObject sp from the list of sprites More...
 
void removeAllSprites (string name)
 remove the WorldObject sp from the list of sprites More...
 
void addParticleSystem (ParticleSystem *sp)
 add a ParticleSystem to the list of sprites More...
 
void removeParticleSystem (ParticleSystem *sp)
 remove the ParticleSystem sp from the list of sprites More...
 
void removeAllParticleSystems (string name)
 remove the ParticleSystem sp from the list of sprites More...
 
string getName ()
 returns the current level's name More...
 
void setBackground (Background *b)
 sets the current level's background and deletes the old one More...
 
BackgroundgetBackground ()
 gets the current level's name More...
 
SpritefindSprite (string name)
 gets the first sprite with the given name More...
 
vector< Sprite * > findSprites (string name, int count=-1)
 returns the first count Sprites contained in this level More...
 
ParticleSystemfindParticleSystem (string name)
 gets the first ParticleSystem with the given name More...
 
vector< ParticleSystem * > findParticleSystems (string name, int count=-1)
 returns the first count ParticleSystems contained in this level More...
 
unsigned int getNumPlayers ()
 Returns the Player at a given index. More...
 
unsigned int getMaxNumPlayers ()
 Returns the Maximum number of players a Level can contain. More...
 
void setMaxNumPlayers (unsigned int i)
 Sets the Maximum number of players a Level can contain. More...
 
PlayergetPlayer (unsigned int index)
 Returns the Player at a given index. More...
 
bool addPlayer (Player *p)
 Adds a Player to the game if the number of players in the current level is not exceeded. More...
 
bool removePlayer (Player *p)
 Removes the specified player p. More...
 
int removePlayers (int count)
 Removes the specified player p. More...
 

Public Attributes

bool Loaded
 Shows if the level has loaded or not (level changing) More...
 

Protected Member Functions

void DrawCollisions ()
 Draws all CollisionObject data. More...
 
void DrawMenus ()
 Draws all Menu elements on the screen. More...
 
void clearData ()
 This will clear the data and make this level as if new. More...
 

Protected Attributes

string mName
 
BackgroundmBackground
 Pointer to the current Background. More...
 
vector< WorldObject * > mWorldObjects
 Vector of all objects on the level. More...
 
vector< Sprite * > mSprites
 Vector of all Sprites on the level. More...
 
vector< WorldObject * > ToAdd
 List of Sprites that should be added this game loop. More...
 
vector< WorldObject * > ToRemove
 List of Sprites that should die after this game loop. More...
 
vector< ParticleSystem * > mParticleSystems
 Vector of all ParticleSystems on the level. More...
 
HUD mHUD
 Display to draw on everything else. More...
 
Behavior mInitialBehavior
 will be used to define the Load action of the level More...
 
Behavior mMainBehavior
 will be used to define the update action of the level More...
 
Behavior mUnloadBehavior
 will be used to define the end action of the level as it close More...
 
Condition mWinCondition
 Conditions for the level to wait upon before exiting. More...
 
Behavior mPauseBehavior
 Enacts a Pause menu or any set of menus based on what we have. More...
 
vector< MenumMenus
 Menus mMenus[0] will always be the pause menu. More...
 
vector< Player * > mPlayers
 All the players active in this Level. More...
 
unsigned int mMaxNumPlayers
 Maximum number of players allowed on this Level. More...
 

Detailed Description

This is a stand alone Level that will have varying jobs.

This class is tasked with the following:

  • drawing the scence and all objects in order
  • loading the background
  • keeping track of animations
  • moving objects
  • handling events
  • Todo:
    Storing Level specific Menus

Definition at line 32 of file Level.h.

Constructor & Destructor Documentation

Level::Level ( string  name,
Condition  winCond,
Behavior  loadBehave = NULL,
Behavior  updateBehave = NULL,
Behavior  endBehave = NULL,
Behavior  pBehave = NULL 
)

Level constructor.

Parameters
namename of the level
loadBehavethe Loading Behavior for this level (Run when loading).
updateBehavethe Updating Behavior for this level (Run every loop).
endBehavethe Unloading Behavior for this level (when leaving level).
pBehaveThe Paused Behavior (defaultly pauses the updates of the level and runs this)
winCondFunction thateturns a boolean telling the level that it shuold unload.

Set behavior

Definition at line 10 of file Level.cpp.

Level::~Level ( )

Definition at line 20 of file Level.cpp.

Member Function Documentation

void Level::addObject ( WorldObject o)

add a WorldObject to the list of objects

Parameters
oWorldObject to add

Definition at line 233 of file Level.cpp.

+ Here is the caller graph for this function:

void Level::addParticleSystem ( ParticleSystem sp)

add a ParticleSystem to the list of sprites

Parameters
spParticleSystem to add
bool Level::addPlayer ( Player p)

Adds a Player to the game if the number of players in the current level is not exceeded.

Parameters
pPlayer to add
Returns
If addition was successful

Definition at line 313 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Level::clearData ( )
protected

This will clear the data and make this level as if new.

Todo:
stop and delete sound

Definition at line 219 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Level::DrawCollisions ( )
protected

Draws all CollisionObject data.

Definition at line 57 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Level::DrawMenus ( )
protected

Draws all Menu elements on the screen.

Definition at line 50 of file Level.cpp.

+ Here is the caller graph for this function:

void Level::drawScene ( )

Draws everything that is set to draw on the screen.

Create a black background

Draw BG

Draw Menus (because they should draw if paused or otherwise)

Draw Boundary Data

Definition at line 27 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ParticleSystem * Level::findParticleSystem ( string  name)

gets the first ParticleSystem with the given name

Parameters
nameName of the ParticleSystem
Returns
Pointer to the requested ParticleSystem

Definition at line 276 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

vector< ParticleSystem * > Level::findParticleSystems ( string  name,
int  count = -1 
)

returns the first count ParticleSystems contained in this level

Parameters
nameName of the ParticleSystems to return
countnumber to return defaults to all
Returns
List of pointers to the requested ParticleSystem

Definition at line 285 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Sprite * Level::findSprite ( string  name)

gets the first sprite with the given name

Parameters
nameName of the sprite
Returns
Pointer to the requested Sprite

Definition at line 256 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

vector< Sprite * > Level::findSprites ( string  name,
int  count = -1 
)

returns the first count Sprites contained in this level

Parameters
nameName of the sprites to return
countnumber to return defaults to all
Returns
List of pointers to the requested sprite

Definition at line 265 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Background* Level::getBackground ( )
inline

gets the current level's name

Returns
Level's Background

Definition at line 136 of file Level.h.

+ Here is the caller graph for this function:

unsigned int Level::getMaxNumPlayers ( )

Returns the Maximum number of players a Level can contain.

Definition at line 301 of file Level.cpp.

+ Here is the caller graph for this function:

string Level::getName ( )
inline

returns the current level's name

Returns
Level's name

Definition at line 121 of file Level.h.

+ Here is the caller graph for this function:

unsigned int Level::getNumPlayers ( )

Returns the Player at a given index.

Definition at line 296 of file Level.cpp.

+ Here is the caller graph for this function:

Player * Level::getPlayer ( unsigned int  index)

Returns the Player at a given index.

Definition at line 309 of file Level.cpp.

+ Here is the caller graph for this function:

void Level::load ( )

Runs load action.

Todo:
Add menu (not sure what I meant by this)

Definition at line 196 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Level::LoadBG ( string  name)

Loads the Background.

Parameters
nameName of the background to load

Definition at line 67 of file Level.cpp.

+ Here is the call graph for this function:

void Level::postEvent ( SDL_Event  event)
virtual

Passes along SDL events.

Put level specific input here

Todo:
this should probably dissapear because Input will handle this in the future

Definition at line 72 of file Level.cpp.

void Level::removeAllParticleSystems ( string  name)

remove the ParticleSystem sp from the list of sprites

Parameters
nameParticleSystems to remove

Definition at line 249 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Level::removeAllSprites ( string  name)

remove the WorldObject sp from the list of sprites

Parameters
nameWorldObjects to remove

Definition at line 241 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Level::removeObject ( WorldObject o)

remove the WorldObject sp from the list of sprites

Parameters
oWorldObject to remove

Definition at line 237 of file Level.cpp.

+ Here is the caller graph for this function:

void Level::removeParticleSystem ( ParticleSystem sp)

remove the ParticleSystem sp from the list of sprites

Parameters
spParticleSystem to remove
bool Level::removePlayer ( Player p)

Removes the specified player p.

Parameters
pPlayer to remove
Returns
If removal was successful

Definition at line 322 of file Level.cpp.

int Level::removePlayers ( int  count)

Removes the specified player p.

Parameters
countnumber of Players to remove from the end of the list
Returns
the number of objects removed

Definition at line 332 of file Level.cpp.

+ Here is the caller graph for this function:

void Level::setBackground ( Background b)
inline

sets the current level's background and deletes the old one

Parameters
bBackground

Definition at line 127 of file Level.h.

+ Here is the caller graph for this function:

void Level::setMaxNumPlayers ( unsigned int  i)

Sets the Maximum number of players a Level can contain.

Definition at line 305 of file Level.cpp.

+ Here is the caller graph for this function:

void Level::unload ( )

Runs load action.

Definition at line 212 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Level::update ( )

Loop that runs every game frame that calculates movement, placement, etc.

Will handle all movement and dynamic triggers.

as well as obtains key strokes (limited by keyboard hardware)

Todo:
implement
Todo:
implement
Todo:
do collisions (do grid dropping for enemeies(maybe global scope?) collide ones in the same grid and then by name or all if you choose)
Todo:
pause/unpause
Todo:
loading screen

Definition at line 78 of file Level.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool Level::Loaded

Shows if the level has loaded or not (level changing)

Definition at line 171 of file Level.h.

Background* Level::mBackground
protected

Pointer to the current Background.

Definition at line 232 of file Level.h.

HUD Level::mHUD
protected

Display to draw on everything else.

Definition at line 244 of file Level.h.

Behavior Level::mInitialBehavior
protected

will be used to define the Load action of the level

Definition at line 247 of file Level.h.

Behavior Level::mMainBehavior
protected

will be used to define the update action of the level

Definition at line 249 of file Level.h.

unsigned int Level::mMaxNumPlayers
protected

Maximum number of players allowed on this Level.

Definition at line 264 of file Level.h.

vector<Menu> Level::mMenus
protected

Menus mMenus[0] will always be the pause menu.

Definition at line 258 of file Level.h.

string Level::mName
protected

Definition at line 230 of file Level.h.

vector<ParticleSystem*> Level::mParticleSystems
protected

Vector of all ParticleSystems on the level.

Definition at line 242 of file Level.h.

Behavior Level::mPauseBehavior
protected

Enacts a Pause menu or any set of menus based on what we have.

Definition at line 255 of file Level.h.

vector<Player*> Level::mPlayers
protected

All the players active in this Level.

Definition at line 261 of file Level.h.

vector<Sprite*> Level::mSprites
protected

Vector of all Sprites on the level.

Definition at line 236 of file Level.h.

Behavior Level::mUnloadBehavior
protected

will be used to define the end action of the level as it close

Definition at line 251 of file Level.h.

Condition Level::mWinCondition
protected

Conditions for the level to wait upon before exiting.

Definition at line 253 of file Level.h.

vector<WorldObject*> Level::mWorldObjects
protected

Vector of all objects on the level.

Definition at line 234 of file Level.h.

vector<WorldObject*> Level::ToAdd
protected

List of Sprites that should be added this game loop.

Definition at line 238 of file Level.h.

vector<WorldObject*> Level::ToRemove
protected

List of Sprites that should die after this game loop.

Definition at line 240 of file Level.h.


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