Game Development Reference
In-Depth Information
data and the approximation shown in Figure 9-8 represents the maximum, full-throttle accel-
eration of the boat. If the engines weren't at full throttle, the acceleration experienced at a
given boat velocity would be less.
Speedboat Simulator
Let's use the estimated acceleration profile for the Fountain Lightning to develop a boat simu-
lator program. The GUI for the simulator, shown in Figure 9-9, looks very similar to the Car
Simulator GUI we developed in Chapter 8. The Boat Simulator computes and displays values
of velocity and distance of a powerboat as a function of elapsed time. On the left-hand side of
the GUI are three radio button components that allow the user to specify whether the boat is
accelerating, cruising at constant speed, or decelerating. Below the radio buttons are three
buttons that start, stop, or reset the simulation. A Timer object is used to slow the action down,
so the velocity and distance values are updated in approximately real-time.
A drawing panel at the top of the GUI shows the powerboat. As with the Car Simulator
from Chapter 8, a rectangular marker is used to simulate the forward motion of the boat. The
powerboat cartoon stays in a fixed location on the screen, and the marker moves from right-to-
left with a velocity proportional to the velocity of the boat. The Boat Simulator also models the
planing action of the powerboat. When the boat reaches the velocity at which planing begins,
the boat cartoon will tilt upwards.
Figure 9-9. Boat Simulator GUI
Two classes will be written that will represent boats. The first, named Powerboat , will model
a generic powerboat and will define the fields and methods common to all powerboats. The
second class, FountainLightning , will define the data specific to the Fountain 35' Lightning
speedboat.
We'll start by discussing the Powerboat class. Since the curve fit expression shown in
Equation (9.26) is used to compute the acceleration as a function of the current velocity of the
boat, there is no need to calculate the aerodynamic or hydrodynamic drag terms. The Powerboat
Search WWH ::




Custom Search