GameEngine::BaseGame Class Reference

#include <BaseGame.h>

Inheritance diagram for GameEngine::BaseGame:

Inheritance graph
[legend]
Collaboration diagram for GameEngine::BaseGame:

Collaboration graph
[legend]
List of all members.

Detailed Description

Base class for games. Manages game states, loads game options etc This class is also responsible for passing events on to the game state which is currently active.

Definition at line 48 of file BaseGame.h.

Public Member Functions

 BaseGame (Real width, Real height, Real depth, GameApp &application)
virtual ~BaseGame ()
bool init ()
virtual void loadGame ()
virtual bool handleEvent (const Event &event)
virtual void onUpdate (const double dt)
virtual void changeState (GameState *state)
virtual void changeState (std::string stateName)
virtual void pushState (GameState *state)
virtual void popState ()
virtual GameStategetState (std::string stateName)=0
const RealgetWidth () const
const RealgetHeight () const
const RealgetDepth () const
boost::shared_ptr< HumanViewgetHumanView () const
Vector3wrapCoords (Vector3 &coords) const

Protected Attributes

GameAppmApplication
boost::shared_ptr< HumanViewmHumanView
GameStateStack mGameStatesStack
Real mWidth
Real mHeight
Real mDepth


Constructor & Destructor Documentation

GameEngine::BaseGame::BaseGame ( Real  width,
Real  height,
Real  depth,
GameApp application 
)

Constructor.

Creates a game world with a specified force of gravity, and of the specified dimensions. Note: Vector(0, -9.81, 0) is a good approximation for earths gravity.

Parameters:
width The width of the world
height The height of the world
depth The depth of the world
application The application that this game is part of

Definition at line 30 of file BaseGame.cpp.

GameEngine::BaseGame::~BaseGame (  )  [virtual]

Destructor

Definition at line 54 of file BaseGame.cpp.


Member Function Documentation

bool GameEngine::BaseGame::init (  ) 

Perform any basic initialisation tasks required before loading the game. E.g Register with EventManager to listen for events

Definition at line 37 of file BaseGame.cpp.

virtual void GameEngine::BaseGame::loadGame (  )  [inline, virtual]

Load game options, set initial state etc

Definition at line 76 of file BaseGame.h.

bool GameEngine::BaseGame::handleEvent ( const Event event  )  [virtual]

Handle any events which the game has registered to listen for. This function should pass on any relevent events to the game state which is currently active.

Parameters:
event The event to handle
Returns:
true if event is consumed, false otherwise

Implements GameEngine::IEventListener.

Definition at line 60 of file BaseGame.cpp.

void GameEngine::BaseGame::onUpdate ( const double  dt  )  [virtual]

Update the game, called after each frame is rendered

Parameters:
dt Time passed since last frame was rendered

Definition at line 85 of file BaseGame.cpp.

void GameEngine::BaseGame::changeState ( GameState state  )  [virtual]

Stops current state if one exists and start a new one

Parameters:
state The state to change to

Definition at line 91 of file BaseGame.cpp.

void GameEngine::BaseGame::changeState ( std::string  stateName  )  [virtual]

Stops current state if one exists and starts a new one

Parameters:
stateName The name of the state to change to

Definition at line 103 of file BaseGame.cpp.

void GameEngine::BaseGame::pushState ( GameState state  )  [virtual]

Pauses current state if one exists and starts a new one

Parameters:
state The state to push onto the stack

Definition at line 111 of file BaseGame.cpp.

void GameEngine::BaseGame::popState (  )  [virtual]

Stops current state and restarts previously paused state if one exits

Definition at line 121 of file BaseGame.cpp.

virtual GameState* GameEngine::BaseGame::getState ( std::string  stateName  )  [pure virtual]

Get a state by name

Parameters:
stateName The name of the state to retrieve

const Real& GameEngine::BaseGame::getWidth (  )  const [inline]

Get width of the game world (x axis)

Returns:
the width of the game world

Definition at line 124 of file BaseGame.h.

const Real& GameEngine::BaseGame::getHeight (  )  const [inline]

Get height of the game world (y axis)

Returns:
the height of the game world

Definition at line 129 of file BaseGame.h.

const Real& GameEngine::BaseGame::getDepth (  )  const [inline]

Get depth of the game world (z axis)

Returns:
the depth of the game world

Definition at line 134 of file BaseGame.h.

boost::shared_ptr<HumanView> GameEngine::BaseGame::getHumanView (  )  const [inline]

Get the human view (the GUI)

Returns:
the human view

Definition at line 141 of file BaseGame.h.

Vector3 & GameEngine::BaseGame::wrapCoords ( Vector3 coords  )  const

Keep a vector representing a position in space within the bounds of the current world size

Parameters:
coords A reference to the vector to be wrapped
Returns:
the wrapped vector

Definition at line 133 of file BaseGame.cpp.


Member Data Documentation

GameApp& GameEngine::BaseGame::mApplication [protected]

Definition at line 152 of file BaseGame.h.

boost::shared_ptr<HumanView> GameEngine::BaseGame::mHumanView [protected]

Definition at line 154 of file BaseGame.h.

GameStateStack GameEngine::BaseGame::mGameStatesStack [protected]

Definition at line 155 of file BaseGame.h.

Real GameEngine::BaseGame::mWidth [protected]

Definition at line 158 of file BaseGame.h.

Real GameEngine::BaseGame::mHeight [protected]

Definition at line 159 of file BaseGame.h.

Real GameEngine::BaseGame::mDepth [protected]

Definition at line 160 of file BaseGame.h.


The documentation for this class was generated from the following files:
Generated on Thu Apr 19 09:48:41 2007 for GameEngine by  doxygen 1.5.2