From 07f782df6df192a60443dc687d871be193478f46 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Thu, 20 Nov 2025 12:30:22 -0500 Subject: dungeon: add chest tile --- dungeon/src/map.rs | 13 ++++--------- graphics/src/render.rs | 5 +++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/dungeon/src/map.rs b/dungeon/src/map.rs index 7403e31..9aa513f 100644 --- a/dungeon/src/map.rs +++ b/dungeon/src/map.rs @@ -2,8 +2,6 @@ //! including the current `Floor`, and map `Tile`. use rand::Rng; -use strum::IntoEnumIterator; -use strum_macros::EnumIter; use std::{ cell::RefCell, @@ -11,7 +9,7 @@ use std::{ hash::{DefaultHasher, Hash, Hasher}, }; -use crate::{pos::Pos, rng::DungeonRng}; +use crate::{entity::Item, pos::Pos, rng::DungeonRng}; /// `MAP_SIZE` is the size of the size of the dungeon grid. pub const MAP_SIZE: u16 = 48; @@ -24,7 +22,7 @@ pub const TILE_COUNT: usize = MAP_SIZE_USIZE * MAP_SIZE_USIZE; /// The `Tile` enum represents what is (or is not) at /// any given spot in the dungeon grid. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, EnumIter)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum Tile { /// `Wall` represents an impassible wall Wall, @@ -34,13 +32,9 @@ pub enum Tile { Hallway, /// `Stairs` represents stairs to another floor Stairs, + Chest(Item), } impl Tile { - /// Returns a list of all possible tiles - pub fn values() -> impl Iterator { - Self::iter() - } - /// Returns if the tile is a wall #[must_use] pub const fn is_wall(self) -> bool { @@ -66,6 +60,7 @@ impl Display for Tile { Self::Room => '.', Self::Hallway => ',', Self::Stairs => '>', + Self::Chest(_) => 'C', }; f.write_char(char) } diff --git a/graphics/src/render.rs b/graphics/src/render.rs index 89f9dc3..613763c 100644 --- a/graphics/src/render.rs +++ b/graphics/src/render.rs @@ -114,7 +114,7 @@ const ATLAS_FLOOR_EXT3: (u16, u16) = (2, 2); const ATLAS_FLOOR_EXT4: (u16, u16) = (3, 2); // Misc atlas.bmp textures -//const ATLAS_ERROR: (u16, u16) = (3, 3); +const ATLAS_ERROR: (u16, u16) = (3, 3); /// Full source rec for any texture const FULL_SOURCE_REC: Rectangle = rect! { @@ -400,7 +400,7 @@ impl Renderer { Tile::Wall => ATLAS_WALL_SIDE, Tile::Room | Tile::Hallway => ATLAS_FLOOR, Tile::Stairs => ATLAS_STAIR, - //_ => ATLAS_ERROR, + Tile::Chest(_) => ATLAS_ERROR, }; rt.draw_atlas( &self.textures.atlas, @@ -453,6 +453,7 @@ impl Renderer { Tile::Room => Color::GRAY, Tile::Hallway => Color::GRAY, Tile::Stairs => Color::WHITE, + Tile::Chest(_) => Color::BLUE, }; rt.draw_pixel(x.into(), y.into(), color); } -- cgit v1.2.3-freya