From 5f6768b6a7c954d47ef97809f688df83664e85bc Mon Sep 17 00:00:00 2001 From: Guillaume Pasquet <guillaume.pasquet@eggplant.io> Date: Mon, 11 Nov 2019 19:47:50 +0100 Subject: Better corridors, stairs --- src/main.rs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/main.rs') 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); -- cgit v1.2.3