daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Aug 12th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package controller;
  2.  
  3. import javafx.scene.input.KeyCode;
  4. import javafx.scene.input.KeyEvent;
  5. import model.Snake;
  6. import view.Screen;
  7.  
  8.  
  9. public class InputController {
  10.  
  11.     Screen screen;
  12.     Snake snake;
  13.  
  14.  
  15.     public InputController(Screen screen, Snake snake){
  16.         this.screen = screen;
  17.         this.snake = snake;
  18.  
  19.     }
  20.  
  21.     public void changeSnakePath(){
  22.  
  23.       screen.getScene().setOnKeyPressed((KeyEvent event) -> {
  24.             KeyCode keyCode = event.getCode();
  25.             switch(keyCode){
  26.                 case A:
  27.                     //snake.setDirection(Direction.UP);
  28.                     System.out.println("elo");
  29.                     break;
  30.                 case B:
  31.                     // snake.setDirection(Direction.DOWN);
  32.                     break;
  33.                 case C:
  34.                     //  snake.setDirection(Direction.LEFT);
  35.                     break;
  36.                 case D:
  37.                     // snake.setDirection(Direction.RIGHT);
  38.                     break;
  39.             }
  40.               snake.move();
  41.  
  42.         });
  43.     }
  44. }
RAW Paste Data
Top