diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-19 22:20:56 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-19 22:20:56 -0500 |
| commit | f0e715fd3fad342c785a5b4a8637cedfaccb8731 (patch) | |
| tree | cb07fa591e78c4bac440a0a1e9f2ece461d045a0 /dungeon/src/lib.rs | |
| parent | nix: fix fenix flake and update lock (diff) | |
| download | DungeonCrawl-f0e715fd3fad342c785a5b4a8637cedfaccb8731.tar.gz DungeonCrawl-f0e715fd3fad342c785a5b4a8637cedfaccb8731.tar.bz2 DungeonCrawl-f0e715fd3fad342c785a5b4a8637cedfaccb8731.zip | |
dungeon: implement items
Diffstat (limited to 'dungeon/src/lib.rs')
| -rw-r--r-- | dungeon/src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/dungeon/src/lib.rs b/dungeon/src/lib.rs index 4e48b68..13ab397 100644 --- a/dungeon/src/lib.rs +++ b/dungeon/src/lib.rs @@ -10,6 +10,8 @@ pub mod player_input; pub mod pos; pub mod rng; +use std::time::Instant; + use rand::{Rng, SeedableRng, TryRngCore, rngs::OsRng}; use crate::{ @@ -119,6 +121,7 @@ impl Dungeon { UpdateResult::MessageUpdated(changed) } else { self.update_entities(player_input, delta_time); + self.update_player(); if self.floor.get(self.player.entity.pos) == Tile::Stairs { // we are moving to a new floor @@ -132,6 +135,15 @@ impl Dungeon { } } + fn update_player(&mut self) { + if let Some(timer) = self.player.potion_timer + && Instant::now() > timer + { + self.player.potion_timer = None; + self.player.entity.speed = self.player.entity.kind.initial_speed(); + } + } + fn spawn_enimies(&mut self) { // TODO: better entity spawning let zombie = Entity::zombie(self.floor.random_walkable_pos(&mut self.level_rng)); |