Well I would do it with a while loop running the game then a while loop outside for rendering
Code:
#define FPS_WANTED 100
int NewTime, LastTime
while GameRunning == true
{
while (NewTime < LastTime + (1000/FPS_WANTED))
{
NewTime = getTime in milliseconds or something
Do all the other stuff with no max speed
}
DoRenderFuction()
lastTime = getTime
}
if I haven't missed something then you should only reach the render function once every 1/100 of a second = 100FPS (max)
if you're doing it in C++ then you might need to add a if function checking seconds and adding 1000 to NewTime if needed since the sys/time.h loops the "under 1sec" measure, might want to devide it as well since it's goes +1 every 1/1 000 000 sec = milliseconds (easier to work with)
EDIT:
Post above might be better, but then again you can just turn my example around and put the render in the second loop and switch it around a bit.
Bookmarks