Well, I'm assuming you only want the code for using a timer so here goes...
This program is going to show you how to draw to the screen and when to draw to the screen next by using a timer.
Code:
#include <allegro.h>
void setup();
void redraw();
void update_counter();
int counter = 0;
int x, y;
BITMAP *bmp;
BITMAP *buffer;
int main()
{
setup();
redraw();
counter = 0; //setting the counter to 0 because it has been running
while(!keypressed()) /*this loop is SUPPOSED TO run until a key is pressed
however there is constant updating which is preventing
this from happening so the program won't terminate
until you a special windows key command, such as
ctrl+alt+del or alt+tab*/
{
if(counter == 180) //this is going to happen every 3 seconds
{
redraw();
counter = 0;
}
}
// allegro_exit();
return 0;
}
END_OF_MAIN();
void setup()
{
allegro_init();
install_timer(); //this must be called before any other timer functions are called
install_int_ex( update_counter, BPS_TO_TIMER(60)); //this is the "actual" timer function
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 800, 600, 0, 0);
bmp = load_bitmap("name_of_bmp.bmp", NULL);
buffer = create_bitmap(SCREEN_W, SCREEN_H);
}
void update_counter()
{
counter++;
}
void redraw()
{
clear_bitmap(buffer); //clearing the buffer to not leave any trails
blit(bmp, buffer, 0, 0, x, y, SCREEN_W, SCREEN_H); //blitting the image to the buffer
blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); //blitting the buffer to the screen
if(x < SCREEN_W - 100)
{
x += 10;
}
if(y < SCREEN_H - 100)
{
y += 5;
}
}
The program is going to draw your bitmap to the screen then every 3 seconds it is going to redraw the image to the screen and after every redraw it is going to move the image over 10 pixels to the right and 5 pixels down until each of them reach their limit
Hope that helps you out and now I have another tutorial to add to my site.
EDIT: had a few things wrong w/ the program so I fixed them