Beginning of the program
The program code begins in Listing 1.
Listing 1. Beginning of the program named BouncingBall02.
#include <allegro.h> //Declare a pointer variable named buffer that can be // used to point to a BITMAP. This will be the main // memory buffer containing an image. BITMAP *buffer = NULL; BITMAP *smallBuffer = NULL; //Note that the size of the image was known before the // program was written, and that size is used below to // set the size of the box. int width = 324;//width of box int height = 330;//height of box int radius = 9;//radius of ball int x = 100;//initial position of ball int y = 200;//initial position of ball int tempX;//used to save the current location of the ball int tempY;//used to save the current location of the ball //Keep track of direction of motion here. //0= northwest 1 = southwest, 2 = northeast, //3 = southeast int dir;