Mail Archives: djgpp/1998/04/09/07:02:30
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.
- Raw text -