diff --git a/src/level.rs b/src/level.rs index 18d4c95..b5853e0 100644 --- a/src/level.rs +++ b/src/level.rs @@ -15,26 +15,28 @@ pub struct Level { } impl Level { + const ROOM_HEIGHT: usize = 6; + const ROOM_WIDTH: usize = 7; + fn draw_room(row: usize, col: usize, s: &mut [[LevelElement; LEVEL_HEIGHT]; LEVEL_WIDTH]) { + for r in 0..Level::ROOM_HEIGHT { + for c in 0..Level::ROOM_WIDTH { + if c == Level::ROOM_WIDTH - 1 || r == Level::ROOM_HEIGHT - 1 { + s[col * Level::ROOM_WIDTH + c][row * Level::ROOM_HEIGHT + r] = LevelElement::Wall; + } + } + } + } pub fn new() -> Level { let mut s = [[LevelElement::Floor; LEVEL_HEIGHT]; LEVEL_WIDTH]; + Level::draw_room(0, 0, &mut s); + Level::draw_room(1, 1, &mut s); for i in 0..LEVEL_WIDTH { s[i][0] = LevelElement::Wall; - s[i][LEVEL_HEIGHT-1] = LevelElement::Wall; } for i in 0..LEVEL_HEIGHT { s[0][i] = LevelElement::Wall; - s[LEVEL_WIDTH-1][i] = LevelElement::Wall; } - s[10][10] = LevelElement::Wall; - s[11][10] = LevelElement::Wall; - s[10][11] = LevelElement::Wall; - s[11][11] = LevelElement::Wall; - s[1][20] = LevelElement::Wall; - s[20][1] = LevelElement::Wall; - s[20][LEVEL_HEIGHT-2] = LevelElement::Wall; - s[LEVEL_WIDTH-2][20] = LevelElement::Wall; - s[4][4] = LevelElement::StairDown; - s[45][20] = LevelElement::StairUp; + Level { structure: s } diff --git a/src/main.rs b/src/main.rs index 7b01e1d..85e9915 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,11 +62,13 @@ fn main() -> Result<()> { height: 25, }; frame.render_widget( - Paragraph::new(format!("{}\nHealth: {}/{}\n{}", + Paragraph::new(format!("{}\nHealth: {}/{}\n{}/{}/{}", g.player.get_name(), g.player.get_life(), g.player.get_max_life(), - g.player.get_position().get_x())) + g.player.get_position().get_level(), + g.player.get_position().get_x(), + g.player.get_position().get_y())) .white() .on_blue(), stats_area,