Game Class Reference

The core class of TFK:GE. More...

Inheritance diagram for Game:

Inheritance graph
[legend]
Collaboration diagram for Game:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Game ()
 ctor
virtual ~Game ()
 dtor
void run ()
 Main game loop.
void init (int argc, char **argv)
 Initialize TFK:GE.
virtual bool OnEvent (const irr::SEvent &e)
 Primary even handler.
WorldgetWorld () const
StategetState () const
void setState (State *s)
 set the active state
irr::IrrlichtDevice * getDevice () const
cAudio::IAudioManager * getAudioManager () const

Static Public Member Functions

static Gameinstance ()

Classes

class  State
 The main entry point to TFK:GE. More...


Detailed Description

The core class of TFK:GE.

The Game class is in charge of initializing the various subsystems (graphics, physics, sound, scripting) and the game components (level manager, weapons).

TFK:GE uses a very common state pattern. The Game object has a current State object to which all events are forwarded and which is also responsible for rendering.


Member Function Documentation

Game * Game::instance (  )  [static]

Returns:
Pointer to the global and unique Game instance

Referenced by Game::State::changeState(), and Player::update().

void Game::run (  ) 

Main game loop.

This function periodically updates the game by caling the update() method of the active state (if any)

See also:
Game::State::update()

References Game::State::update().

void Game::init ( int  argc,
char **  argv 
)

Initialize TFK:GE.

Parameters:
argc number of arguments, as passed to main()
argv argument data, as passed to main()
Creates Irrlicht device and initilize all Irrlicht components, then set up the OpenAL-based sound engine, then the Bullet-based physics engine and finally all other game components (specfic to TFK:GE)

Note:
This data is passed to alutInit() and any valid (platform dependent parameter alutInit() accepts can thus be passed to this method)

bool Game::OnEvent ( const irr::SEvent &  event  )  [virtual]

Primary even handler.

Returns:
true if the event has been processed, false otherwise
Parameters:
event Event to handle
Events are sent by Irrlicht and forwarded to the active state.

References Game::State::event().

World * Game::getWorld (  )  const

Returns:
pointer to the physics engine wrapper

Game::State * Game::getState (  )  const

Returns:
pointer to the active state
See also:
setState()

Referenced by Game::State::changeState().

void Game::setState ( Game::State s  ) 

set the active state

Parameters:
s state to activate
the old state is notified to Game::State::leave() and the new one to Game::State::enter()

See also:
getState()

References Game::State::enter(), and Game::State::leave().

Referenced by Game::State::changeState().

irr::IrrlichtDevice * Game::getDevice (  )  const

Returns:
point to the graphics device

cAudio::IAudioManager * Game::getAudioManager (  )  const

Returns:
pointer to the audio device

Referenced by Player::update().


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

Generated on Sat Jul 26 13:58:39 2008 for TFK:GE by  doxygen 1.5.5