limiting frames per second

Started by
2 comments, last by colinisinhere 20 years, 7 months ago
In some games like MoH:A, It limits the fps to a certain number so it wont overheat... well, i was wondering how i can achive that, i want my program to run anywhere under 150, how can this be done?
Advertisement
if(CurrentTime-LastTime >= LimitTime)
{
Render();
LastTime = CurrentTime;
}

where LimitTime is LengthOfSecondAccordingToTimer/MaxFPS.

You can do physics, ai, input, etc. outside this if. Otherwise this loop will likely occur hundreds of times without it ever doing anything.

[edited by - Erzengeldeslichtes on September 21, 2003 7:16:20 PM]
----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?
''overheat'' ?


I do it like this:

Have a counter that is incremented by the time between frames... When the counter hits a certain number (say 1/60) you carry out your actions and reset the timer.

I only use this for updates/renders, giving me spare ticks to do other things, like VMs and AIs
lol, i cant beleive i didnt think of this, lol, sorry

BrAiNfArT

This topic is closed to new replies.

Advertisement