Game Development Reference
In-Depth Information
hoop and background. The spin reduces the rebound angle and makes it more likely that the
ball will bounce into the basket.
Determining If a Shot Is Good
One element that is important to a basketball simulation is a way to determine whether a shot
is good. One way to accomplish this objective is by the knowledge that if a shot is good, the
center of the basketball must travel through the hoop. Consider the schematic shown in
Figure 7-20. The radius of the hoop is approximately 0.23 m , and the radius of the ball is about
0.12 m . Therefore, the center of the basketball doesn't have to travel right through the center of
the hoop, but can be 0.11 m away in any direction. Actually, the margin of error is larger than
0.11 m because glancing impacts with the hoop will cause the ball to fall through the hoop.
Figure 7-20. For a shot to be good, it must travel through the hoop.
Modeling Backboard Impacts
Another important element of basketball simulations is to model impacts that might occur
between the ball and backboard. The simplest way to model this situation is to assume a friction-
less collision between the ball and backboard. If the x-coordinate direction is down the length
of the court (perpendicular to the backboard), then the y- and x-components of the ball velocity
would be unchanged by the collision. The post-collision velocity in the x-direction would be
equal to the opposite of the pre-collision velocity multiplied by a coefficient of restitution.
v
′ =−
ev
(7.57)
x
x
The coefficient of restitution for a basketball is about 0.75. Equation (7.57) does not take
into account the effects of spin, which might change the post-collision velocities in all three
directions.
A Free-Throw Game
Let's use what we know about the flight of a basketball to develop a game that simulates a
player taking a free throw. A screen shot from the Free-Throw Game is shown in Figure 7-21.
The player is assumed to be facing directly at the basket, so the motion of the basketball is
restricted to the x-z plane. The user selects the initial velocity and angle of the ball. When the
Fire button is pressed, the shot is taken and the result printed on the screen.
Search WWH ::




Custom Search