diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs index 24a4bcb..7da68ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,19 +16,23 @@ use std::io; use std::convert::TryFrom; use world::{World, GameWorld, TileType}; -fn draw_block(window: &Window, block: &TileType) { - let repr = match block { +fn tile_to_str(tile: &TileType) -> &str { + match tile { TileType::Floor => ".", TileType::Wall => "█", - TileType::Corridor => "#", - TileType::Empty => " " - }; + TileType::Empty => " ", + TileType::StairsDown => ">", + TileType::StairsUp => "<", + _ => "?" + } +} - window.printw(repr); +fn draw_block(window: &Window, block: &TileType) { + window.printw(tile_to_str(block)); } fn render_world(window: &Window, world: &World) { - let grid = world.to_tilegrid(); + let grid = world.to_tilegrid().unwrap(); for (linenum, line) in grid.raw_data().iter().enumerate() { for block in line.iter() { @@ -39,24 +43,18 @@ fn render_world(window: &Window, world: &World) { } fn debug_world(world: &World) { - let grid = world.to_tilegrid(); + let grid = world.to_tilegrid().unwrap(); - for (line) in grid.raw_data().iter() { + for line in grid.raw_data().iter() { for block in line.iter() { - print!("{}", match block { - TileType::Floor => ".", - TileType::Wall => "█", - TileType::Corridor => "#", - TileType::Empty => " ", - _ => "?" - }); + print!("{}", tile_to_str(block)); } print!("\n"); } } fn main() { - let mut world = World::new(24); + let mut world = World::new(80, 24); world.generate(); debug_world(&world); |