Game Development Reference
In-Depth Information
The force of gravity will pull on the car down the ramp. The magnitude of the force is equal
to the mass of the car, m , the acceleration due to gravity, g , and the sine of the angle of the
ramp, q .
(1.2)
Fmgq
=
sin
Once again, Equation (1.2) is simple, and yet it accurately models the gravitational force
acting on the car. You could use Equation (1.2) to determine if the brakes could hold the car on
the ramp or to determine the speed of the car if it were to start moving down the ramp.
Now, it's true that some of the equations in the topic will be more complicated than
Equations (1.1) and (1.2), but as was mentioned before, 95% of the math in this topic is algebra
and trigonometry. What about the other 5%? There will be times in the topic when we will have
to make use of things called differential equations in our physics models. They may sound a bit
scary, but they are really just equations that are used in this topic to describe how quantities
such as velocity or position change over time. We'll provide you with a handy little program
that solves differential equations that you can make use of in your game programs.
So one thing that makes incorporating physics into your game programs easier than you
might have thought is that the mathematics for the most part isn't that complicated. Another
nice thing about physics is that in most cases you can make your physics models as simple or
as complicated as you like or need. For example, the flight of a projectile can be modeled using
a simple algebraic equation. If you want, you can add some complexity to the model by including
effects such as aerodynamic drag or spin, but these more complicated effects are simply added
to the base model. If the simple model is all you need, you can stick with it and leave out the
more complicated stuff.
When it comes to adding realistic physics to your games, you get a lot of bang for your
buck. Even including a simple physical model in your games will greatly enhance their realism
and believability.
Adding Physics Won't Affect Game Performance
Another reason some game programmers are reluctant to add physics-based realism to their
games is the perception that β€œall that complicated math will slow the game down.” That might
have been true in the dark days when computers boasted β€œ500 kilohertz performance,” but
modern computer processors are fast enough to zip through anything but the most compli-
cated physics models. Your games will spend a lot more time rendering than they will evaluating
whatever physics model you incorporate into them.
The sample games presented in this topic demonstrate that physics won't slow down game
performance. The car simulator presented in Chapter 8 uses a reasonably complex physics
model to simulate the acceleration and gear shifting capabilities of a sports car. The game ran
so quickly on a 1.6 GHz Pentium 4 PC (an older, fairly slow computer) that a timer had to be
built into the program to actually slow the game down. Otherwise, the user didn't have time to
shift gears before the maximum engine speed was reached. The same condition is true for the
flight simulator that will be presented in Chapter 10. The physics equations are computed so
quickly that the game has to be intentionally slowed down. The physics models in the car and
flight simulators would have to be made significantly more complicated for there to be any
effect on the execution of the games.
Search WWH ::




Custom Search