delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/28/17:41:42

Date: Tue, 28 Jan 1997 16:30:08 -0600 (CST)
From: Andrew Deren <aderen AT eecs DOT uic DOT edu>
To: djgpp <djgpp AT delorie DOT com>
Subject: Allegro game timing.
Message-ID: <Pine.SUN.3.95.970128162301.26911C-100000@ernie.eecs.uic.edu>
MIME-Version: 1.0

Can anyone help me with setting up timers in Allegro so that my game
events respond to the timer. So far I was using an old method I used with
BC++:

.
.
rest(10);
my_timer++;
//i want some event to occur every 6th irritation
if (my_timer % 6 == 0) {do some stuff;}
//other stuff every 11th
if (my_timer % 11 == 0) {some other stuff;}
.
.
However this worked fine if the program did not do a lot of computing, but
now I got a program that does a lot of computing and this makes slow
computers run the program at different times, which is really not how the
game should work.
Is there some way in Allegro that I can achieve the same thing, I tried
similar thing setting timer to 10ms, and then using timer%6, but this
failed in some cases because the timer var is being updated by an
interrupt and the program was missing some irritations of timer%6.
Can anyone help me with setting the program to respond to timer.
Thanks in advance!!!

- Raw text -


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