diff options
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)); |