Game Development Reference
In-Depth Information
The actionPerformed method called by the Timer is exactly the same as the version in the
original Golf Game. Because the projectile trajectory classes have been created sequentially
using a common data structure, no changes need to be made to this method. Play around with
the Golf Game version 2 by adjusting the variables that influence drag. As always, if for some
reason the entire GUI is not displayed, pressing the Reset button will redraw the display.
Drag effects make a big difference when it comes to the flight of a golf ball as the Golf Game
version 2 can demonstrate. Figure 5-9 shows two trajectories that use the same initial velocities,
mass, density, and area values. The first trajectory uses a drag coefficient of 0.25, which is a
typical value for a golf ball. For the second trajectory, drag effects are turned off by setting the
drag coefficient value to zero. Without drag, the golf ball travels 221 m . When drag is included
in the simulation, the same golf ball only travels 126 m . Clearly when it comes to projectiles
such as golf balls, drag must be included in the model.
Figure 5-9. The effect of drag on the flight of a golf ball
Also notice in Figure 5-9 that when drag effects are included, the shape of the trajectory is
not a perfect parabola. Instead, the downward part of the trajectory is steeper because drag is
slowing the golf ball down.
Summary: Adding Drag to the Projectile Trajectory Model
In this section, we have added a key element to the projectile trajectory model—aerodynamic
drag force. Drag is the resistance a fluid such as air exerts on an object traveling through it.
Drag is an important effect for many projectile simulations. We saw the effect drag has on the
flight of a golf ball in this section. Drag will also be important when modeling such things as
bullets, cannonballs, and baseballs. The inclusion of drag effects complicates the projectile
Search WWH ::




Custom Search