Add wall without collision

This commit is contained in:
Paul Brinkmeier 2025-11-30 01:50:21 +01:00
parent 57a442c5e2
commit c7194cf2bc

View File

@ -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<Tile> {
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("");
},
}
}
}