Game Development Reference
In-Depth Information
After the initial impact between the cue ball and the eight ball, the eight ball moves to
the left and impacts two more balls. These balls then shoot off diagonally. Most of the
energy from the eight ball is transferred to the two other balls, so the eight ball quickly
comes to rest while being kissed by the cue ball. The other two balls continue rolling
away diagonally (see Figure 19-4 ).
Figure 19-4. Elapsed time = 0.566s
In this example, we'll show you how to handle ball-ball collisions, ball-table collisions,
ball-table contact, aerodynamic drag on the ball, rolling resistance, friction between
balls at the time of impact, and friction between the balls and table.
Implementation
If you've read and studied the examples presented in Chapter 7 through Chapter 13 ,
then the implementation of this billiards example will be very familiar to you; we use
the same basic approach. During each simulation time step, we calculate all the forces
acting on each ball; integrate the equations of motion, updating each ball's position and
velocity; and then check for and deal with collisions.