The animation loop
Listing 5 calls the srand function and the rand function:
Listing 5. The animation loop.
//Seed the random number generator and set the initial
// direction based on a random number.
srand (time(NULL));
dir = rand() % 4;
//Loop until the user presses the Esc key.
while( !key[KEY_ESC]){
moveBall();
}//end while loop
return 0;
}//end main
END_OF_MAIN();
|