Message-ID: From: Shawn Hargreaves To: djgpp AT delorie DOT com Subject: Re: demo.c allegro question Date: Thu, 9 Apr 1998 12:00:19 +0100 MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk leger_v AT bluewin DOT ch writes: > There is a loop that I don't understand : > while(game_time > 0 ) { > move_everyone(); > game_time--; > } > draw_screen(); This is one of the most frequent FAQ's on the Allegro mailing list, so you can almost certainly find something useful in the archives on http://www.talula.demon.co.uk/allegro/maillist.html This code works by installing a timer callback to update the game_time variable at a fixed rate. It can then check the value of this variable to know when the game state must be updated, which lets it run at a constant speed on any machine. > The timer is set with a frequency of 6400/SCREEN_W That isn't important: the calculation based on the screen size is just so that it will run faster in higher resolution modes. You would never do that in a real game, because it is unlikely that you would support so many different resolutions (typically a game just chooses one mode, or perhaps supports two but scales the graphics accordingly). Shawn Hargreaves.