Game Development Reference
In-Depth Information
process. If you have game-specific logic systems in C++, this is how you would com-
municate with them.
The game states are handled by two functions: VOnUpdate() and VChangeState() .
VOnUpdate() is the heart of the game logic. This function is responsible for proces-
sing the game state, updating all objects, and performing any per-frame operations the
game logic needs to perform. Here is the VOnUpdate() function defined in
BaseGameLogic :
void BaseGameLogic::VOnUpdate(float time, float elapsedTime)
{
int deltaMilliseconds = int(elapsedTime * 1000.0f);
m_Lifetime += elapsedTime;
switch(m_State)
{
case BGS_Initializing:
// If we get to here we
re ready to attach players
VChangeState(BGS_MainMenu);
break;
'
case BGS_MainMenu:
break;
case BGS_LoadingGameEnvironment:
if (!g_pApp->VLoadGame())
{
GCC_ERROR(
The game failed to load.
);
g_pApp->AbortGame();
}
break;
case BGS_WaitingForPlayersToLoadEnvironment:
if (m_ExpectedPlayers + m_ExpectedRemotePlayers <= m_HumanGamesLoaded)
{
VChangeState(BGS_SpawningPlayersActors);
break;
}
case BGS_SpawningPlayersActors:
VChangeState(BGS_Running);
break;
case BGS_WaitingForPlayers:
if (m_ExpectedPlayers + m_ExpectedRemotePlayers ==
m_HumanPlayersAttached )
Search WWH ::




Custom Search