The animation loop
When the user presses the Esc key:
- The loop in Listing 3 terminates
- Causing the main function to return
- Causing the program to terminate.
During each iteration of the loop in Listing
3:
- The function named moveBall is called once
- To attempt to move the green ball shown in
Figure 1
- By an incremental amount in the direction specified by the value of the
variable dir.
(I say attempt because the ball won't always move if it has collided with
one of the walls.)