Beginning of the source code

Will explain the source code in fragments.

Program begins in Listing 1.

Listing 1 declares and initializes several global variables.

Purpose of most variables explained by the comments.

Will explain purpose of the others later.

Listing 1. Beginning of the source code.

#include <allegro.h>

int width = 220;//width of box
int height = 440;//height of box
int radius = 5;//radius of ball

int x = 110;//initial position of ball
int y = 220;//initial position of ball

int tempX;
int tempY;

//Keep track of direction of motion here.
//0= northwest 1 = southwest, 2 = northeast,
//3 = southeast
int dir;