From 1e57b563280582c9bd1c385d4b44458d66885b8b Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 11 Jul 2026 14:01:49 +0200 Subject: end game screen, fix occlusion --- src/game.rs | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'src/game.rs') diff --git a/src/game.rs b/src/game.rs index a17526b..f66ca40 100644 --- a/src/game.rs +++ b/src/game.rs @@ -544,7 +544,11 @@ fn place_entities( } // --- hallucinated pickups --- - let fake_count = if depth >= 3 { rng.random_range(1..=2) } else { 0 }; + let fake_count = if depth >= 3 { + rng.random_range(1..=2) + } else { + 0 + }; for _ in 0..fake_count { if next >= candidates.len() { break; @@ -673,6 +677,9 @@ pub struct Game { // ---- controls overlay ---- pub show_controls: bool, + + // ---- death screen ---- + pub death_frames: u32, } fn smoothstep(t: f64) -> f64 { @@ -724,6 +731,7 @@ impl Game { flash_color: 0, flash_alpha: 0.0, show_controls: true, + death_frames: 0, } } @@ -802,10 +810,11 @@ impl Game { if done { self.state = GameState::ResolvingTurn; self.resolve_turn(); - self.state = GameState::WaitingForInput; + if self.state != GameState::GameOver { + self.state = GameState::WaitingForInput; + } return true; } - false } GameState::AnimatingEnemies => { @@ -814,14 +823,22 @@ impl Game { self.enemy_anim_t = 0.0; self.state = GameState::ResolvingTurn; self.resolve_turn(); - self.state = GameState::WaitingForInput; + if self.state != GameState::GameOver { + self.state = GameState::WaitingForInput; + } return true; } - false } - _ => false, + _ => {} + } + + // Count frames since death so the death screen has a minimum display time. + if self.state == GameState::GameOver { + self.death_frames += 1; } + + false } /// Attempt to walk one tile in grid direction (dx, dy). @@ -1160,7 +1177,9 @@ impl Game { fn advance_turn(&mut self) { self.state = GameState::ResolvingTurn; self.resolve_turn(); - self.state = GameState::WaitingForInput; + if self.state != GameState::GameOver { + self.state = GameState::WaitingForInput; + } } /// Apply all per-turn effects (weakness, heartbeat, HP drain, message decay). @@ -1248,4 +1267,9 @@ impl Game { pub fn weakness_factor(&self) -> f64 { (self.weakness as f64 / MAX_WEAKNESS as f64) * 2.0 } + + /// Compute the final score. + pub fn score(&self) -> u64 { + (self.kills * 100) + (self.depth.pow(2) * 50) + (self.weapon_base_damage as u64 * 500) + } } -- cgit v1.2.3