From f639fa3d63e485205afdad55af828b3d612a1482 Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta <6977238-fiplox@users.noreply.gitlab.com> Date: Tue, 20 Oct 2020 13:57:23 +0200 Subject: [PATCH] set robot on the map --- src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.rs b/src/main.rs index 0300cd7..df4cbd6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,15 @@ impl World { fn create_map(&mut self) { self.map = vec!['.'; (self.x * self.y) as usize]; } + /// Set robot on the map. + fn set_robot(&mut self, r: Robot) { + self.map[(r.p.x * r.p.y) as usize] = match r.o { + Orientation::N => '⬆', + Orientation::S => '⬇', + Orientation::E => '➡', + Orientation::W => '⬅', + } + } } /// Struct to store robot position.