From 95aad715b636c7e1326b2675668bd0fa12349cf5 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 17 Nov 2025 11:54:58 -0500 Subject: update min rust version to 1.88.0 --- Cargo.toml | 2 +- dungeon/src/entity.rs | 24 +++++++++--------------- graphics/src/render.rs | 2 +- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 61c916d..8b2140e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ authors = [ edition = "2024" license = "MIT" publish = false -rust-version = "1.87" +rust-version = "1.88" [workspace.dependencies] dungeon = { path = "dungeon" } diff --git a/dungeon/src/entity.rs b/dungeon/src/entity.rs index b14f815..3463618 100644 --- a/dungeon/src/entity.rs +++ b/dungeon/src/entity.rs @@ -42,15 +42,15 @@ pub enum Item { } /// The `EntityKind` represents what kind of entity this is. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, Default, PartialEq)] pub enum EntityKind { /// The main player + #[default] Player, Zombie(EnemyMoveState), /// An item (not in an inventory) on the floor of the dungeon Item(Item), } - impl EntityKind { /// Returns the move speed value for this type of entity in tiles/s pub const fn move_speed(&self) -> f32 { @@ -61,11 +61,6 @@ impl EntityKind { } } } -impl Default for EntityKind { - fn default() -> Self { - Self::Player - } -} /// The `EnemyMoveState` enum describes the state of an enemies movement, either Idle /// Roam, or Attack. Idle carries a `f32` value to remember time waited in idle. Both Roam @@ -108,14 +103,13 @@ impl EnemyMoveState { let dir = rng.random(); let dist = rng.random_range(MIN_ROAM_DIST..=MAX_ROAM_DIST); - if let Some(p) = starting_pos.step_by(dir, dist) { - if !floor.get(p).is_wall() { - if let Some(data) = astar::astar(starting_pos, p, floor) { - let mut path = data.0; - path.reverse(); - return Self::Roam(path); - } - } + if let Some(p) = starting_pos.step_by(dir, dist) + && !floor.get(p).is_wall() + && let Some(data) = astar::astar(starting_pos, p, floor) + { + let mut path = data.0; + path.reverse(); + return Self::Roam(path); } // Safety check diff --git a/graphics/src/render.rs b/graphics/src/render.rs index 1c10f57..a03d545 100644 --- a/graphics/src/render.rs +++ b/graphics/src/render.rs @@ -502,7 +502,7 @@ impl Renderer { Direction::East => (1, 0), Direction::West => (1, 1), }; - if self.timer.since_start().as_millis() / 250 % 2 == 0 { + if (self.timer.since_start().as_millis() / 250).is_multiple_of(2) { // entity animtion frame every 250 millis ax += 2; } -- cgit v1.2.3-freya