pub fn key_pressed(&mut self, key: Key) {
        match key {
            Key::Up => self.snake.new_direction(Direction::UP),
            Key::Down => self.snake.new_direction(Direction::DOWN),
            Key::Left => self.snake.new_direction(Direction::LEFT),
            Key::Right => self.snake.new_direction(Direction::RIGHT),
            _ => (),
        };
    }
/// Detect key press and convert them to directions
Detect key press and convert them to directions
Detect key press and convert them to directions
pub fn key_pressed(&mut self, key: Key) {
        match key {
            Key::Up => self.snake.new_direction(Direction::UP),
            Key::Down => self.snake.new_direction(Direction::DOWN),
            Key::Left => self.snake.new_direction(Direction::LEFT),
            Key::Right => self.snake.new_direction(Direction::RIGHT),
            _ => (),
        };
    }
pub fn key_pressed ( & mut self , key : Key ) { match key { Key :: Up => self . snake . new_direction ( Direction :: UP ) , Key :: Down => self . snake . new_direction ( Direction :: DOWN ) , Key :: Left => self . snake . new_direction ( Direction :: LEFT ) , Key :: Right => self . snake . new_direction ( Direction :: RIGHT ) , _ => ( ) , } ; }
Detect key press and convert them to directions
Detect key press and convert them to directions
&mut self
key
Key
&mut self
key
Key