From 176a0f52c5519a8b3becc0e82be49871d03e198b Mon Sep 17 00:00:00 2001 From: Alex Bethel Date: Sat, 18 Dec 2021 13:06:00 -0600 Subject: [PATCH] Extremely basic level drawing --- src/game.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/game.rs b/src/game.rs index 178863d..3bd691b 100644 --- a/src/game.rs +++ b/src/game.rs @@ -24,11 +24,12 @@ pub const LEVEL_SIZE: (usize, usize) = (80, 24); /// A single level of the dungeon. pub struct DungeonLevel { /// The tiles at every position in the level. - tiles: [[DungeonTile; LEVEL_SIZE.1]; LEVEL_SIZE.0], + tiles: [[DungeonTile; LEVEL_SIZE.0]; LEVEL_SIZE.1], } /// The smallest possible independent location in the dungeon, /// corresponding to a single character on the screen. +#[derive(Debug, Clone, Copy)] pub enum DungeonTile { Floor, Wall, @@ -39,11 +40,23 @@ impl DungeonLevel { /// Creates a new level in a branch that has the given /// configuration. pub fn new(cfg: &BranchConfig) -> Self { - todo!() + Self { + tiles: [[DungeonTile::Floor; LEVEL_SIZE.0]; LEVEL_SIZE.1], + } } /// Draws a level on the display window. pub fn draw(&self, win: &Window) { - todo!() + for (y, row) in self.tiles.iter().enumerate() { + win.mv(y as _, 0); + for tile in row { + win.addch(match tile { + DungeonTile::Floor => '.', + DungeonTile::Wall => ' ', + DungeonTile::Hallway => '#', + }); + } + } + win.mv(0, 0); } }