Merge branch 'set-robot' into 'master'

set robot on the map

See merge request mhart/DancingDroids!20
This commit is contained in:
Martin HART 2020-10-20 13:59:26 +02:00
commit bd9681ad86
1 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,15 @@ impl World {
fn create_map(&mut self) { fn create_map(&mut self) {
self.map = vec!['.'; (self.x * self.y) as usize]; 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. /// Struct to store robot position.