rendered paste body#include <allegro.h>
#include <stdlib.h>
#include "datfile.h"
/* globale variabelen */
BITMAP *buffer = NULL;
volatile long speed_counter = 0;
/* functie prototypes */
void increment_speed_counter();
int main()
{
allegro_init();
install_keyboard();
install_timer();
install_mouse();
show_os_cursor(2);
buffer = create_bitmap(800, 600);
LOCK_VARIABLE(speed_counter); //Used to set the timer - which regulates the game's
LOCK_FUNCTION(increment_speed_counter);//speed.
install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));
set_color_depth(24);
set_gfx_mode(GFX_AUTODETECT_WINDOWED , 800 , 600 , 0 , 0);
show_os_cursor(MOUSE_CURSOR_ARROW);
DATAFILE *my_datafile = NULL;
my_datafile = load_datafile("datfile.dat");
// Check that the datafile was created correctly
if(my_datafile == NULL)
{
set_gfx_mode(GFX_TEXT,0,0,0,0);
allegro_message("Could not load datafile!");
exit(EXIT_FAILURE);
}
int nf = 0, nt = 0;
while(!key[KEY_ESC])//If the user hits escape, quit the program
{
while(speed_counter > 0)
{
nt++;
speed_counter--;
} // speed counter loop
draw_sprite(buffer, (BITMAP*)my_datafile[SILLY_BITMAP].dat, 0, 0);
textprintf_ex(buffer, font, 0, 0, -1, 0, "%f", (float) nf * 60 / nt);
blit(buffer, screen, 0, 0, 0, 0, 800, 600);//Blit the buffer
nf++;
clear(buffer);//Clear the buffer
}
destroy_bitmap(buffer);
unload_datafile(my_datafile);
return 0;
}
// functie definities
void increment_speed_counter()
{
speed_counter++;
}