Skip to content
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

fix: Clock runs game simulation too fast sometimes when limiting fps #2162

Merged
merged 6 commits into from
Dec 18, 2021

Conversation

eonarheim
Copy link
Member

@eonarheim eonarheim commented Dec 18, 2021

===:clipboard: PR Checklist :clipboard:===

  • 📌 issue exists in github for these changes
  • 🔬 existing tests still pass
  • 🙈 code conforms to the style guide
  • 📐 new tests written and passing / old tests updated with new scenario(s)
  • 📄 changelog entry added (or not needed)

==================

This PR fixes an unreleased issue where sometimes when constraining fps with the clock, the update loop would get out of phase and the elapsed time passed to the mainloop could be nearly double the fps. Ironically the clock loops were running correctly, the elapsed time passed to the simulation was wrong.

Changes:

  • Refactored the update to be a little easier to read
  • Shifts the update elapsed time to be in-phase with the fps, the loop still counts updates correctly to match fps

@eonarheim eonarheim added the work-in-progress A work in progress pull request, will not be merged until this is removed label Dec 18, 2021
@eonarheim eonarheim changed the title fix: Clock runs game simulation too fast sometimes when constraining fps fix: Clock runs game simulation too fast sometimes when limiting fps Dec 18, 2021
@eonarheim eonarheim removed the work-in-progress A work in progress pull request, will not be merged until this is removed label Dec 18, 2021
@eonarheim eonarheim merged commit da0895f into main Dec 18, 2021
@eonarheim eonarheim deleted the bugfix/clock-too-fast branch December 18, 2021 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant