diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-11 16:34:10 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-11 16:34:10 +0200 |
| commit | db03808fc52d47f136bb0726fd6ba4ab6a690c12 (patch) | |
| tree | 804a5418eab14d64665f67df08d66a0ed435d47f /src/game.rs | |
| parent | merge enemy AI (diff) | |
| parent | add floor transition: Space on exit descends to next depth (diff) | |
| download | dungeon-db03808fc52d47f136bb0726fd6ba4ab6a690c12.tar.gz dungeon-db03808fc52d47f136bb0726fd6ba4ab6a690c12.zip | |
merge floor transition
Diffstat (limited to 'src/game.rs')
| -rw-r--r-- | src/game.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/game.rs b/src/game.rs index 992023e..1c13dd4 100644 --- a/src/game.rs +++ b/src/game.rs | |||
| @@ -1585,10 +1585,32 @@ impl Game { | |||
| 1585 | 1585 | ||
| 1586 | // ---- misc ------------------------------------------------------------- | 1586 | // ---- misc ------------------------------------------------------------- |
| 1587 | 1587 | ||
| 1588 | pub fn check_win(&self) -> bool { | 1588 | /// True when the player is standing on the exit staircase. |
| 1589 | pub fn on_exit(&self) -> bool { | ||
| 1589 | self.maze.is_exit(self.player.x, self.player.y) | 1590 | self.maze.is_exit(self.player.x, self.player.y) |
| 1590 | } | 1591 | } |
| 1591 | 1592 | ||
| 1593 | /// Descend to the next dungeon depth. Generates a new maze, places the | ||
| 1594 | /// player in a starting room facing east. All stats, inventory, and | ||
| 1595 | /// weapon carry over. | ||
| 1596 | pub fn descend(&mut self) { | ||
| 1597 | self.depth += 1; | ||
| 1598 | let mut rng = rand::rng(); | ||
| 1599 | let (maze, (start_x, start_y)) = Maze::generate(self.depth, &mut rng); | ||
| 1600 | self.maze = maze; | ||
| 1601 | self.player = Player::new(start_x, start_y, 0.0); // facing east | ||
| 1602 | self.wall_texture = crate::texture::generate_wall_texture(&mut rng); | ||
| 1603 | self.floor_texture = crate::texture::generate_floor_texture(&mut rng); | ||
| 1604 | self.exit_texture = crate::texture::generate_exit_texture(&mut rng); | ||
| 1605 | self.state = GameState::WaitingForInput; | ||
| 1606 | self.moving = false; | ||
| 1607 | self.turning = false; | ||
| 1608 | self.attacking = false; | ||
| 1609 | self.enemy_moves.clear(); | ||
| 1610 | self.acted_this_turn.clear(); | ||
| 1611 | self.set_message(&format!("You descend to depth {}...", self.depth)); | ||
| 1612 | } | ||
| 1613 | |||
| 1592 | /// Whole heartbeats elapsed (displayed in HUD). | 1614 | /// Whole heartbeats elapsed (displayed in HUD). |
| 1593 | pub fn heartbeats(&self) -> usize { | 1615 | pub fn heartbeats(&self) -> usize { |
| 1594 | self.heartbeat_count as usize | 1616 | self.heartbeat_count as usize |
