Skip to main content
gamedev.net
🔒 Locked

Allegro Timer Function?

Started by Serendipity Nov 13, 2008 at 9:11 AM 0 replies 1.1k views
Original Post
Serendipity
Serendipity
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:
#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();

Thanks for any help.
Serendipity
Serendipity
I just thought I'd refresh in case someone had an answer. I'd also be happy with a finger in the right direction

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.