#include volatile long speed_counter = 0; void increment_speed_counter() // A function to increment the speed counter { speed_counter++; } END_OF_FUNCTION(increment_speed_counter); int main() { allegro_init(); install_keyboard(); install_timer(); 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(32); set_gfx_mode(GFX_AUTODETECT_WINDOWED , 800 , 600 , 0 , 0); BITMAP *tank = NULL; BITMAP *buffer = NULL; buffer = create_bitmap(800,600); tank = load_bitmap("tank2.bmp",NULL); int tank_X = 0; int tank_Y = 0; while(!key[KEY_ESC])//If the user hits escape, quit the program { while(speed_counter > 0) { if(key[KEY_RIGHT]) { tank_X++; } else if(key[KEY_LEFT]) { tank_X--; } else if(key[KEY_UP]) { tank_Y--; } else if(key[KEY_DOWN]) { tank_Y++; } speed_counter--; } // speed counter loop draw_sprite(buffer, tank, tank_X, tank_Y); blit(buffer, screen, 0,0,0,0,800,600); clear_bitmap(buffer); } destroy_bitmap(tank); destroy_bitmap(buffer); return 0; } END_OF_MAIN()