Game Development Reference
In-Depth Information
game where the character can jump, as in Super Mario Bros . You're playing the
game, and Mario is jumping at a constant speed. Suddenly, the frame rate drops
low and you notice that Mario can jump much further. The reason this happens is
that the percent error in numeric integration gets higher with a lower frame rate, so
the jump arc becomes more exaggerated. This is demonstrated with the jumping
character in Figure 7.15 . This means a player on a slower machine will be able to
jump further than a player on fast machine.
Figure 7.15 Different jump arcs caused by different sized time steps.
For this reason, any game that uses physics to calculate the position should not use
a variable time step for physics calculations. It's certainly possible to code a game
where the physics is running at a different time step than the rest of the game, but
that's a little bit more advanced. For now, you could instead utilize the frame rate
limiting approach outlined in Chapter 1 , Game Programming Overview .
Calculating the Force
Numeric integration will allow us to go from acceleration to velocity, and then
velocity to position. But in order to compute the acceleration, we need force and
mass. There are multiple types of forces to consider. Some forces, such as grav-
ity, are constantly applied to an object. Other forces may instead be impulses , or
forces applied for a single frame.
Search WWH ::




Custom Search