feat: add skip_first_dt flag to prevent timer jump on new puzzle start

This commit is contained in:
epic-64 2025-11-19 00:00:00 +01:00
parent f6d1b8b6f6
commit 7be94e225a
2 changed files with 16 additions and 0 deletions

View File

@ -42,6 +42,14 @@ The game should run fine in any terminal. If you want retro CRT effects, here ar
- Windows: Windows Terminal (enable experimental "retro mode")
- Linux: Rio (with CRT shader), Cool Retro Term
## Resource Conscious
In most game-states, the game will sleep until your next input, resulting in 0% CPU usage while idle.
![sc9.png](docs/sc9.png)
Only during an active puzzle (timer running), the game runs at ~30 FPS, which results in some CPU usage.
![sc8.png](docs/sc8.png)
## Build/Run from source
You may be inclined to not run binaries from the internet, and want to build from source instead.

View File

@ -542,6 +542,7 @@ pub struct BinaryNumbersPuzzle {
guess_result: Option<GuessResult>,
last_points_awarded: u32,
stats_snapshot: Option<StatsSnapshot>,
skip_first_dt: bool, // Skip first dt to prevent timer jump when starting new puzzle
}
impl BinaryNumbersPuzzle {
@ -585,6 +586,7 @@ impl BinaryNumbersPuzzle {
guess_result,
last_points_awarded,
stats_snapshot: None,
skip_first_dt: true, // Skip first dt to prevent timer jump
}
}
@ -608,6 +610,12 @@ impl BinaryNumbersPuzzle {
return;
}
// Skip first dt to prevent timer jump when starting new puzzle
if self.skip_first_dt {
self.skip_first_dt = false;
return;
}
self.time_left = (self.time_left - dt).max(0.0);
if self.time_left <= 0.0 {