324 7. The Game Loop and Real-Time Simulation
void setPaused(bool isPaused)
{
m_isPaused = isPaused;
}
bool isPaused() const
{
return m_isPaused;
}
void setTimeScale(F32 scale)
{
m_timeScale = scale;
}
F32 getTimeScale() const
{
return m_timeScale;
}
void singleStep()
{
if (m_isPaused)
{
// Add one ideal frame interval; don’t forget
// to scale it by our current time scale!
U64 dtScaledCycles = secondsToCycles(
( 1.0f/30.0f) * m_timeScale);
m_timeCycles += dtScaledCycles;
}
}
};
7.6 Multiprocessor Game Loops
Now that we’ve investigated basic single-threaded game loops and learned
some of the ways in which time is commonly measured and manipulated
in a game engine, let’s turn our att ention to some more complex kinds of
game loops. In this section, we’ll explore how game loops have evolved to
take advantage of modern multiprocessor hardware. In the following sec-
tion, we’ll see how networked multiplayer games typically structure their
game loops.
In 2004, microprocessor manufacturers industry-wide encountered a
problem with heat dissipation that prevented them from producing faster