• Advertisement
Sign in to follow this  

Allegro Timer Function?

This topic is 3388 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 "allegro.h"

void main(void)
    int x, y, radiusx, radiusy;
    int red, green, blue, color;
    //initialize everything
    //initialize video mod
    int ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
    if (ret != 0)
    }//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);
    }//end while
    //end program
}//end main

Thanks for any help.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement