I came across the blog post Understanding GameTime, and after lots of reading on fixed time steps in game loops this is the approach I would like to take. In summary, this is the logic from the post:
- Set the desired time spent in Update + Draw as 1/60 of a second (fixed 60 fps).
If time elapsed since last Update + Draw is exactly 1/60 of a second:
- Call Update
- Call Draw
- Tick (Game loops.)
If time elapsed since last Update + Draw takes less than 1/60 of a second:
- Call Update
- Call Draw
- Look at the Clock (Time left over? Wait.)
- Tick (Game loops.)
If time elapsed since last Update + Draw takes more than 1/60 of a second?
- Call Update (Until we catch up.)
- Call Draw
- Tick (Game loops.)
I guess the two parts I'm having trouble understanding is in #3, how would the waiting be accomplished since thread sleeps are often not accurate enough, and what does it mean in #4 to call update until we catch up? Catch up to what since the time elapsed is already greater than our target 60 fps?