delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/04/06:10:31

Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE30136623C@probe-2.acclaim-euro.net>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Simple timer question...
Date: Tue, 4 May 1999 11:10:09 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.0.1460.8)
Reply-To: djgpp AT delorie DOT com

Unigni writes:
> I was wondering how to get a timer in milliseconds, so that 
> each game loop would take 100 milliseconds -- NOT doing 
> stuff and *then* waiting 100 milliseconds.

Several people have already commented that you can use uclock()
for this, but if you are using Allegro, that isn't such a great
plan since Allegro will probably already be using its own
timer module (that is needed for things like mouse input and
MIDI playback, and can conflict with the libc time functions).
Using Allegro, you can either check the global retrace_count
variable, or install a timer callback function of your own.
The ex7 example program shows how to do this, and for examples
of using them to control game speed, look at the demo game
and the Allegro FAQ.


	Shawn Hargreaves.

- Raw text -


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