|
Game speed |
Don Freeman
Member #5,110
October 2004
|
Ok...I've read the FAQ and some examples of how to do this...but I still can't find anything that shows what I need. I want to be able to set a 'speed limit', if you will, for fast computers. I am going to design the logic / render loops so they are optimized for the target computer...but I don't want the faster computers to run faster than the target. In the unused time slice, I would like to yeild to the OS. So, my question is...how do I implement this into my game? I would like something like:
Edit...corrected the code. -- |
Rick
Member #3,572
June 2003
|
Normally:
On very fast computers the logic wouldn't run more than once each time it enters the while loop, which would be the timers time 60 BPS if the norm I think, but on slow computers it could get into an infinit loop. That is why we have iLogicCounter. If we get into a situation where logic() runs for a long time and iLogic keeps getting ++ before it hits iLogic--, then the iLogicCounter will make sure we only do this 5 times before breaking out and showing to the user what we did. ======================================================== |
Elverion
Member #6,239
September 2005
|
Heres a "better" main loop to consider... It uses the timer (speed_counter is the variable for that), and avoids some wasted processing for faster computers. It could still use some minor tweeks, though (Check Rick's post, for example).
-- |
Kitty Cat
Member #2,815
October 2002
|
Elverion, your bLogicUpdate variable is rather useless there. Since you wait with rest(1) until you have logic to do, bLogicUpdate will always be true before it gets checked. As well, yield_timeslice is unneeded since you rest when you're caught up (and if you yield when you're not caught up, you're just wasting time and causing lost frames). -- |
Tobias Dammers
Member #2,604
August 2002
|
I don't know about the rest of you huys, but I haven't managed to produce smooth animation using allegro timers yet, unless I lock in on the physical screen refresh rate (or a multiple of that). --- |
|