set robot on the map
This commit is contained in:
		
							parent
							
								
									3d686c7770
								
							
						
					
					
						commit
						f639fa3d63
					
				@ -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.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user