limiting frames per second
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?
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]
{
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]
''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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement