Game Development Reference
In-Depth Information
CHAPTER 8
■ ■ ■
Cars and Motorcycles
C
ar racing games are a lot of fun. You can drive high-powered vehicles that you couldn't
possibly afford in real life, and you can drive them into trees. Between the speed, the power,
and the spectacular fiery crashes, you can create a lot of exciting game scenarios using cars,
motorcycles, and other motorized vehicles. But it's important to get the physics right in a car or
motorcycle simulation. Your game should properly model, for example, whether a Nissan 350Z
can outrun a police cruiser.
In this chapter, we will explore the physics of cars and motorcycles, but the basic princi-
ples we will explore are equally applicable to other types of motorized vehicles. The focus will
be on the external physics of the vehicles—how they accelerate, how they brake, how they
travel around curves. We won't go into the physics of the internal workings of motor vehicles.
As a game programmer, you don't really need to know the physics of the internal combustion
engine or how disk brakes work.
Some of the topics we will cover in this chapter include the following:
•
A brief history of the automobile
•
The basic force diagram of a car
•
Engine torque and power: how to compute them from the engine turnover rate
•
Gears and gear shifting: how gears are used to increase the torque applied to the wheels
•
Rolling friction of car tires: what it is and how to calculate it
•
Computing the acceleration and velocity of a car
•
Braking: how brakes work and how to model braking in game programs
•
Wheel traction and how it can limit the acceleration of a car
•
Turning: how to compute turn radius and turn rate and how to model the effects of
high-speed turns
•
Motorcycles and how they turn
We'll also develop a car simulator that will model the performance and operation of a
sports car.
211