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

Timer fix #63

Merged
merged 2 commits into from
Nov 12, 2023
Merged

Timer fix #63

merged 2 commits into from
Nov 12, 2023

Conversation

Mia75owo
Copy link
Contributor

This fixes a bug in the game speed calculation (see commit messages).

Steps to reproduce the bug:
Start the game (compiled in debug mode) and enter the command

maxfps 10

into the console.

I also changed the mechanic, which splits the physic calculations into multiple steps,
when the game runs with a low framerate. The game speed is now even between
these steps.
Please let me know if there is a good reason for the chunks to not be even.

Changed the split mechanic into even chunks:
When the SpeedFaktor reaches the threshold (0.3), it is split:
0.4 was split into (1) 0.3 and (2) 0.1
Now it is split into two even steps.
The TimerClass had a local `SpeedFaktor` variable, which is used by the sync function.
This leads to a desync between the local and the global variable and can cause the game
speed to be calculated wrong.

Example:
The game speeds up when it runs with a low framerate (the speed factor is changed
to have more accurate calculations, but the sync function still uses the "old" variable)
This can be easily repuduced by starting the game in debug mode and typing
```
maxfps 10
```
in the console to limit the framerate.
@drfiemost drfiemost added the bug label Nov 12, 2023
@drfiemost drfiemost self-assigned this Nov 12, 2023
@drfiemost
Copy link
Member

Didn't dig deep in the changes but I can see the vast improvement in 10 FPS mode and no regression in full FPS.

As a further step I think it would be possible to move SpeedFaktor and its logic into the Timer class, all those global vars are quite annoying.

@drfiemost drfiemost merged commit 379e4bc into HurricanGame:master Nov 12, 2023
6 checks passed
@Mia75owo Mia75owo deleted the timer-fix branch November 12, 2023 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants