From c7194cf2bc7a8f2fabfa5bcdfa20e82870d0cec3 Mon Sep 17 00:00:00 2001 From: Paul Brinkmeier Date: Sun, 30 Nov 2025 01:50:21 +0100 Subject: [PATCH] Add wall without collision --- src/game.rs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/game.rs b/src/game.rs index 7d04bde..ede73a1 100644 --- a/src/game.rs +++ b/src/game.rs @@ -55,7 +55,7 @@ impl Room { impl GameModel { pub fn new() -> Self { Self { - player_pos: P2::new(0, 0), + player_pos: P2::new(1, 1), room: Room { size: V2::new(20, 10), }, @@ -87,7 +87,23 @@ impl GameModel { } fn render_tiles(&self) -> Grid { - let mut tiles = Grid::from_fn(self.room.size.x, self.room.size.y, |_x, _y| Tile::Floor); + let w = self.room.size.x; + let h = self.room.size.y; + let mut tiles = Grid::from_fn(w, h, |x, y| { + let is_vertical_boundary = [0, w - 1].contains(&x); + let is_horizontal_boundary = [0, h - 1].contains(&y); + let is_corner = is_vertical_boundary && is_horizontal_boundary; + + if is_corner { + Tile::Corner + } else if is_vertical_boundary { + Tile::VerticalWall + } else if is_horizontal_boundary { + Tile::HorizontalWall + } else { + Tile::Floor + } + }); tiles .get_mut(P2::new(1, 1)) @@ -124,6 +140,9 @@ enum Tile { Amphora, Frog, Water, + Corner, + VerticalWall, + HorizontalWall, } impl Tile { @@ -150,6 +169,15 @@ impl Tile { .set_bg(Color::Blue) .set_fg(Color::White); } + Tile::Corner => { + cell.set_symbol("♦"); + } + Tile::VerticalWall => { + cell.set_symbol("║"); + }, + Tile::HorizontalWall => { + cell.set_symbol("═"); + }, } } }