-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyboardListener.java
28 lines (25 loc) · 1016 Bytes
/
KeyboardListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class KeyboardListener extends KeyAdapter{
public void KeyPressed(KeyEvent e){
switch(e.getKeyCode()){
case 39:
if(ThreadsController.directionSnake!=2)
ThreadsController.directionSnake=1;
break;
case 38:
if(ThreadsController.directionSnake!=4)
ThreadsController.directionSnake=3;
break;
case 37:
if(ThreadsController.directionSnake!=1)
ThreadsController.directionSnake=3;
break;
case 40:
if(ThreadsController.directionSnake!=3)
ThreadsController.directionSnake=2;
break;
default: break;
}
}
}