-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sleep() missing in loop example "play catch up"? #370
Comments
while (lag >= MS_PER_UPDATE) /// ensures a certain time (MS_PER_UPDATE) has passed, and sleep isn't required |
I still don't quite get it. Here's an example with some numbers:
In the first cycle there's no In the second cycle In the third cycle there will even be 3 calls ( |
since render is not called when catching up. The Displayed objects will work correctly. its covered in. https://gameprogrammingpatterns.com/game-loop.html and more detail in here |
I try to wrap my head around the final code example on the page on game loops:
In the text it says:
I fail to see any fixed time step here. How often
update()
is called is only limited by how fast the underlying machine is. So a faster machine will give more updates than a slower machine. This throws us back to non-deterministic behavior as described a chapter before.It also doesn't match with the diagram, where there's a clock above the
update()
box:According to this image I would expect a call to
sleep()
in the inner loop. Could it be missing?The text was updated successfully, but these errors were encountered: