Consider the case where:
- The current direction of motion is northwest
- The ball collides with the top wall, and
- The new direction of motion is either northwest or northeast.
This could be a problem
Motion to the northwest or northeast would cause the ball to penetrate the
However, in this case (see Listing 4):
- The ball will simply pause at the wall
- Until the same code is executed in a future iteration of the animation
- To send the ball off in a southwest or southeast direction.