To: djgpp AT delorie DOT com Subject: Re: Allegro game timing. Message-ID: <19970128.160056.2063.7.chambersb@juno.com> References: From: chambersb AT juno DOT com (Benjamin D Chambers) Date: Tue, 28 Jan 1997 19:00:00 EST On Tue, 28 Jan 1997 16:30:08 -0600 (CST) Andrew Deren writes: >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;} Here's the problem. Don't use mod - it's a divide, taking a different part of the result. And since you're using different values to mod by, there's no way to save on the computations. Instead, try keeping a running tally for each task, and resetting it to zero when appropriate. Believe me, multiple mods being removed will increase the speed by an incredible amount. For instance, use if (timer_1==0) {do some stuff; timer_1=6;} if (timer_2==0) {do some other stuff; timer_2=11;} And have them all being decremented in your interrupt. ...Chambers