delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/09/07:02:30

Message-ID: <D1FB30BBA491D1118E6D006097BCAE39247C4E@Probe-nt-2a.Probe.co.uk>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
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

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019