Game Development Reference
In-Depth Information
{
VChangeState(BGS_LoadingGameEnvironment);
}
break;
case BGS_Running:
m_pProcessManager->UpdateProcesses(deltaMilliseconds);
// update the physics
if(m_pPhysics && !m_bProxy)
{
m_pPhysics->VOnUpdate(elapsedTime);
m_pPhysics->VSyncVisibleScene();
}
break;
default:
GCC_ERROR(“Unrecognized state.”);
}
// update all game views
for (GameViewList::iterator it = m_gameViews.begin();
it != m_gameViews.end(); ++it)
{
(*it)->VOnUpdate(deltaMilliseconds);
}
// update game actors
for (ActorMap::const_iterator it = m_actors.begin();
it != m_actors.end(); ++it)
{
it->second->Update(deltaMilliseconds);
}
}
The function begins by updating the lifetime of the object. Then it processes the
game state in a big switch statement. Any logic that needs to happen every frame
while in a specific state can happen here. For example, the Process Manager and
physics system are only updated during the BGS_Running state. After that, the
views are all updated, followed by all the actors. The views and actors must all be
updated regardless of what state the game is in.
State processing often needs to occur when one state transitions to a new state. This
logic is placed into the VChangeState() function.
Search WWH ::




Custom Search