Xref: news2.mv.net comp.os.msdos.djgpp:8638 From: gt4558a AT acmey DOT gatech DOT edu (Rubicant) Newsgroups: comp.os.msdos.djgpp Subject: Re: Best use of timers. Date: 8 Sep 1996 07:13:15 GMT Organization: Georgia Institute of Technology Lines: 33 Message-ID: <50trmb$t23@catapult.gatech.edu> References: <01bb9b3f$0a4109a0$LocalHost AT apache DOT d51 DOT lilly DOT com> NNTP-Posting-Host: acmey-prism.gatech.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Mark Fleig (markfleig AT worldnet DOT att DOT net) wrote: : Just getting started with DJGPP/Allegro/etcblahblah. So I know how to : create timers, and I know how to use them safely... I just don't know what : to use them for. : Could someone give me an overview of the best use for timers in a standard : game program. I imagine it's used to do all of the hard work and draw the : buffers, but only blit when the timer hits a particular tick. Am I close. : thanks, : -fleig Well, they work particularly well for making your game speed machine-independant. They aren't really used for the drawing (although they could be) so much as they are for everything that goes on while you aren't drawing. For example, suppose you wanted your game to run a 35 tics per second, regardless of machine. Now, also suppose that your game is pretty expensive rendering-wise. You can make sure that the game runs at the correct speed by makeing a variable called e.g. NumUpdates that is set to a timer that tics 35 times per second. This timer function would basically say NumUpdates++. Then, in your game loop, after your rendering, you check the value of NumUpdates. You then update the world that many times and reset NumUpdates. Of course, there any many other uses of timers, but this is by far the most important one. If you want to see an actual example of this, the demo game that comes with allegro has a good example of how this is done. Hope this helps. -- -- Rubicant --