Game Development Reference
In-Depth Information
A Car Simulator
Let's take what we've learned about modeling the physics of cars and develop a car simulator.
The GUI display for the car simulator is shown in Figure 8-8. At the top of the simulator is a
display area that shows a picture of the car. Above the car are two rectangular markers. When
the simulator runs, the car location remains fixed on the screen, and the markers move from
left to right to simulate the forward motion of the car. The speed at which the markers move is
proportional to the speed of the car.
On the left-hand side of the GUI are three radio buttons that determine whether the car is
accelerating, cruising at a constant velocity, or slowing down by braking. The radio buttons are
mutually exclusive, so only one may be selected. Below the radio buttons are five buttons. The
Start button starts or resumes the simulation. The Shift Up and Shift Down buttons cause the
car to shift gears up or down. The Stop button stops the car, shifts the car into first gear, and
lowers the engine turnover rate to 1000 rpm . The Reset button does the same things as the Stop
button, but it also resets the distance and time values to zero.
Figure 8-8. Car Simulator screen shot
On the right-hand side of the display are text fields that show the current velocity and
engine turnover rate of the car as well as what gear the car is currently in. Also included are text
fields that display the distance the car has traveled and the total elapsed time of the simulation.
At the bottom of the display is a text field used to present warning messages. If the engine turn-
over rate exceeds the redline rpm value, a message to that effect is shown in the text field. If the
engine turnover rate exceeds 8000 rpm , you've “blown” the engine and the simulation will
stop, as shown in Figure 8-9.
Search WWH ::




Custom Search