From: "Christopher Nelson" To: Subject: Re: Simple timer question... Date: Sun, 2 May 1999 07:45:15 -0600 Message-ID: <01be94a2$026d8fa0$LocalHost@thendren> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.71.1712.3 X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Reply-To: djgpp AT delorie DOT com >I'm about to start writing a game with DJGPP and Allegro. However, I >don't have much experience with either, so 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. >In QBasic (which I normally use), I'd do something like: > > time! = TIMER > [do stuff here] > WHILE time! + .1 > TIMER: WEND there is a simple and less simple answer. the simple answer is to use the delay() function in Allegro. it will eat processor cycles for the specified amount of time. the other, more efficient way, is to setup a timer callback with install_int(). then you can be processing stuff while waiting for the timer. e.g. volatile int time_to_draw=0; void my_handler( ... ) { time_to_draw=1; } then while you are waiting for time_to_draw to become 1, you can be doing other stuff ... calculating AI movements, stage loading stuff, all sorts of other interesting stuff. this way you're not wasting so many precious cycles. -={C}=-