// main.cpp #include "main.h" 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); // set graphics mode set_color_depth(24); set_gfx_mode(GFX_AUTODETECT_WINDOWED , 800 , 600 , 0 , 0); // set game speed 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 os cursor as mouse show_os_cursor(MOUSE_CURSOR_ARROW); BITMAP *buffer = NULL; // create a buffer bitmap and a datafil buffer = create_bitmap(800, 600); DATAFILE *my_datafile = NULL; my_datafile = load_datafile("datfile.dat"); unit my_units[5]; // 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) { my_units[0].is_selected(); nt++; speed_counter--; } draw_sprite(buffer, (BITMAP*)my_datafile[SILLY_BITMAP].dat, 0, 0); textprintf_ex(buffer, font, 0, 0, -1, 0, "hallo"); // 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++; }END_OF_FUNCTION(increment_speed_counter);