diff options
author | Guillaume Pasquet <guillaume.pasquet@eggplant.io> | 2019-11-11 19:47:50 +0100 |
---|---|---|
committer | Guillaume Pasquet <guillaume.pasquet@eggplant.io> | 2019-11-11 19:47:50 +0100 |
commit | 5f6768b6a7c954d47ef97809f688df83664e85bc (patch) | |
tree | d528d73f788b5301d4ab552350306002220845c2 /src/main.rs | |
parent | 7af405bd91e110afae90ce5ccb2249231b4c9d31 (diff) |
Better corridors, stairs
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); |