Game Development Reference
In-Depth Information
// Game Over Screen
if (m_GameState == GameState.GameOverScreen)
{
// Update Game Over Screen Here
m_GameOverBillBoard.DrawObject(m_Camera, m_PointLight);
}
//////////////////////////// Draw Objects
m_ArenaObjectsSet.RenderArenaObjects(m_Camera, m_PointLight,false);
m_TankFleet.RenderTankFleet(m_Camera, m_PointLight,false);
////////////////////////// Update and Draw Grid
m_Grid.DrawGrid(m_Camera);
// Player's Pyramid
m_Pyramid.DrawObject(m_Camera, m_PointLight);
// Player's Weapon
m_Weapon.RenderWeapon(m_Camera, m_PointLight, false);
///////////////////////// HUD
// Render HUD
m_HUD.RenderHUD(m_Camera, m_PointLight);
}
The CalculateFrameUpdateElapsedTime() function calculates the elapsed time since the last frame
update and stores this value in m_ElapsedTime . (See Listing 10-50.)
Listing 10-50. Calculating the Elapsed Time for the Frame Update
void CalculateFrameUpdateElapsedTime()
{
long Oldtime;
// Elapsed Time Since Last in this function
if (!m_TimeInit)
{
m_ElapsedTime = 0;
m_CurrentTime = System.currentTimeMillis();
m_TimeInit = true;
}
else
{
Oldtime = m_CurrentTime;
m_CurrentTime = System.currentTimeMillis();
m_ElapsedTime = m_CurrentTime - Oldtime;
}
}
The FrameMove() function updates the game by calling UpdateScene() and, if needed, the
ProcessCameraMove() function. The purpose of this function is to update the game at a constant and
smooth frame rate as close to a rate of one game update every k_SecondsPerTick as possible.
(See Listing 10-51.)
Search WWH ::




Custom Search