Original Post
Hi all, I'm following a book on game programming, and I have a question about one of the functions. I think it's a standard C function, however, it may also be an allegro function. The function is rest(int). My question is what exactly does the function do. I think it delays the time between the drawing the next element in my while loop but I'm not sure. Here's the full code: Thanks for any help.
#include<conio.h>
#include<stdlib.h>
#include "allegro.h"
void main(void)
{
int x, y, radiusx, radiusy;
int red, green, blue, color;
//initialize everything
allegro_init();
install_keyboard();
install_timer;
srand(time(NULL));
//initialize video mod
int ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
if (ret != 0)
{
allegro_message(allegro_error);
return;
}//end if
//display screen resolution
textprintf(screen, font, 0, 0, 15,
"Ellipse Program - %d x %d - Press ESC to exit",
SCREEN_W, SCREEN_H);
//wait for keypress
while (!key[KEY_ESC])
{
//set a random location
x = 30 + rand() % (SCREEN_W - 60);
y = 30 + rand() % (SCREEN_H - 60);
radiusx = rand() % 30;
radiusy = rand() % 30;
//set a random color
red = rand() % 255;
green = rand() % 255;
blue = rand() % 255;
color = makecol(red, green, blue);
//dras the ellipse
ellipse(x, y, radiusx, radiusy, color);
rest(25);
}//end while
//end program
allegro_exit();
}//end main
END_OF_MAIN();