• Create Account

### #ActualFirestryke31

Posted 14 August 2012 - 08:40 AM

totalTime = 0;

{

startUpdate = timestamp();

while(totalTime >= UPDATE_STEP)

{

Update(); // Simulates exactly UPDATE_STEP amount of time each call

}

Render(); // Renders the latest tick

totalTime += timestamp() - startUpdate;

}

This way at 200 FPS you only update the simulation every X frames, but at 20 FPS you update multiple times a frame as needed. Animations are smoother as you're taking snapshots of a guaranteed smooth stepping, and it's easier to ensure physics are accurate as they're no longer framerate-dependant.

### #1Firestryke31

Posted 14 August 2012 - 08:40 AM