From c0f0a92a76ace76af9e390db0c2198d6cfe526d6 Mon Sep 17 00:00:00 2001 From: EliasCubz Date: Sun, 1 Nov 2020 15:49:02 +0100 Subject: [PATCH] declaration of display grid --- src/main.rs | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9fee27b..3c1f9f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -198,19 +198,26 @@ fn open_file(filename: &str) -> io::Result { Ok(content) } -fn display_grid(h: HashMap<>, ){ - for (i=0;j - match robot_pool[id-1].o { - "N" => println!("fleche du haut"), - "E" => println!("fleche a droite"), - "W" => println!("fleche a gauche"), - "S" => println!("fleche en bas"), - +fn display_grid( + w: &world::World, + robot_pool: &Vec, + h: &HashMap, +) { + for i in (0..w.y).rev() { + + print!(" "); + for j in 0..w.x { + print!("{} ", i); + match h.get(Position{ x: j, y: i }) { + some(id) => match robot_pool[(id - 1) as usize].o { + robot::Orientation::N => print!("↑"), + robot::Orientation::E => print!("→"), + robot::Orientation::S => print!("↓"), + robot::Orientation::W => print!("←"), + None => print!("."), }, - None => println!("."), - + } + println!() } } }