Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

ps
Class CGame

boost::noncopyable
   |
   +--CGame

   in Game.h
   in Game.cpp

class CGame
extends boost::noncopyable

The container that holds the rules, resources and attributes of the game. The CGame object is responsible for creating a game that is defined by a set of attributes provided. The CGame object is also responsible for maintaining the relations between CPlayer and CWorld, CSimulation and CWorld.


Inner Classes, Typedefs, and Enums
enum CGame::EOG
          enumerated values for game status.
 
Field Summary
private bool m_GameStarted
          the game has been initialized and ready for use if true.
private CGameView* m_GameView
          pointer to the CGameView object representing the view into the game world.
private uint m_NumPlayers
          number of players operating on the game world(not including gaia).
 bool m_Paused
          the game is paused and no updates will be performed if true.
private std::vector< CPlayer* > m_Players
          STL vectors of pointers to all CPlayer objects(including gaia) operating on the game world.
private CPlayer* m_pLocalPlayer
          pointer to the local CPlayer object operating on the game world.
private float m_SimRate
          scale multiplier for simulation rate.
private CSimulation* m_Simulation
          pointer to the CSimulation object operating on the game world.
private double m_Time
          total elapsed game time in seconds.
private CWorld* m_World
          pointer to the CWorld object representing the game world.
 
Constructor Summary
CGame()
          Constructor
~CGame()
          Destructor
 
Method Summary
 void EndGame()
          End of game console message creation.
 inline CPlayer* GetLocalPlayer()
          Get pointer to the local player object.
 inline uint GetNumPlayers() const
          Get m_NumPlayers.
 CPlayer* GetPlayer( uint idx )
          Get the player object from the players list at the provided index.
 inline std::vector< CPlayer* >* GetPlayers()
          Get a reference to the m_Players vector.
 inline float GetSimRate() const
          Get the simulation scale multiplier.
 inline CSimulation* GetSimulation()
          Get the pointer to the simulation object.
 inline double GetTime() const
          Get the current game elapsed time.
 inline CGameView* GetView()
          Get the pointer to the game view object.
 inline CWorld* GetWorld()
          Get the pointer to the game world object.
 inline bool IsGameStarted() const
          Get m_GameStarted.
 PSRETURN ReallyStartGame()
          Game initialization has been completed.
private PSRETURN RegisterInit( CGameAttributes* pAttribs )
          Initializes the game with the set of attributes provided.
 inline void SetLocalPlayer( CPlayer* pLocalPlayer )
          Change the pointer to the local player object.
 inline void SetSimRate( float simRate )
          Set the simulation scale multiplier.
 PSRETURN StartGame( CGameAttributes* pGameAttributes )
          Prepare to start the game.
 bool Update( double deltaTime, bool doInterpolate = true )
          Periodic heartbeat that controls the process.
 void UpdateGameStatus()
          
 

Field Detail

m_GameStarted

private bool m_GameStarted;
the game has been initialized and ready for use if true.

m_GameView

private CGameView* m_GameView;
pointer to the CGameView object representing the view into the game world.

m_NumPlayers

private uint m_NumPlayers;
number of players operating on the game world(not including gaia).

m_Paused

public bool m_Paused;
the game is paused and no updates will be performed if true.

m_Players

private std::vector< CPlayer* > m_Players;
STL vectors of pointers to all CPlayer objects(including gaia) operating on the game world.

m_pLocalPlayer

private CPlayer* m_pLocalPlayer;
pointer to the local CPlayer object operating on the game world.

m_SimRate

private float m_SimRate;
scale multiplier for simulation rate.

m_Simulation

private CSimulation* m_Simulation;
pointer to the CSimulation object operating on the game world.

m_Time

private double m_Time;
total elapsed game time in seconds.

m_World

private CWorld* m_World;
pointer to the CWorld object representing the game world.


Constructor Detail

CGame

public CGame();
Constructor

~CGame

public ~CGame();
Destructor


Method Detail

EndGame

public void EndGame();
End of game console message creation.

GetLocalPlayer

public inline CPlayer* GetLocalPlayer();
Get pointer to the local player object.
Returns:
CPlayer * the value of m_pLocalPlayer.

GetNumPlayers

public inline uint GetNumPlayers() const;
Get m_NumPlayers.
Returns:
PS_uint the value of m_NumPlayers.

GetPlayer

public CPlayer* GetPlayer( uint idx );
Get the player object from the players list at the provided index.
Parameters:
PS_uint - idx sequential position in the list.
Returns:
CPlayer * pointer to player requested.

GetPlayers

public inline std::vector< CPlayer* >* GetPlayers();
Get a reference to the m_Players vector.
Returns:
std::vector * reference to m_Players.

GetSimRate

public inline float GetSimRate() const;
Get the simulation scale multiplier.
Returns:
float value of m_SimRate.

GetSimulation

public inline CSimulation* GetSimulation();
Get the pointer to the simulation object.
Returns:
CSimulation * the value of m_Simulation.

GetTime

public inline double GetTime() const;
Get the current game elapsed time.
Returns:
double value of m_Time.

GetView

public inline CGameView* GetView();
Get the pointer to the game view object.
Returns:
CGameView * the value of m_GameView.

GetWorld

public inline CWorld* GetWorld();
Get the pointer to the game world object.
Returns:
CWorld * the value of m_World.

IsGameStarted

public inline bool IsGameStarted() const;
Get m_GameStarted.
Returns:
bool the value of m_GameStarted.

ReallyStartGame

public PSRETURN ReallyStartGame();
Game initialization has been completed. Set game started flag and start the session.
Returns:
PSRETURN 0

RegisterInit

private PSRETURN RegisterInit( CGameAttributes* pAttribs );
Initializes the game with the set of attributes provided. Makes calls to initialize the game view, world, and simulation objects. Calls are made to facilitate progress reporting of the initialization.
Parameters:
CGameAttributes - * pAttribs pointer to the game attribute values
Returns:
PSRETURN 0

SetLocalPlayer

public inline void SetLocalPlayer( CPlayer* pLocalPlayer );
Change the pointer to the local player object.
Parameters:
CPlayer - * pLocalPlayer pointer to a valid player object.

SetSimRate

public inline void SetSimRate( float simRate );
Set the simulation scale multiplier.
Parameters:
float - simRate value to set m_SimRate to. Because m_SimRate is also used to scale TimeSinceLastFrame it must be clamped to 0.0f.

StartGame

public PSRETURN StartGame( CGameAttributes* pGameAttributes );
Prepare to start the game. Set up the players list then call RegisterInit that initializes the game and is used to report progress.
Parameters:
CGameAttributes - * pGameAttributes game attributes for initialization.
Returns:
PSRETURN 0 if successful, error information if not.

Update

public bool Update( double deltaTime, bool doInterpolate = true );
Periodic heartbeat that controls the process. Simulation update is called and game status update is called.
Parameters:
double - deltaTime elapsed time since last beat in seconds.
bool - doInterpolate perform interpolation if true.
Returns:
bool false if it can't keep up with the desired simulation rate indicating that you might want to render less frequently.

UpdateGameStatus

public void UpdateGameStatus();

 Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
Generated on September 04, 2007 at 18:13
CppDoc v2.4.0
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD