134
|
1 package alice.test.topology.aquarium;
|
92
|
2
|
|
3 import java.awt.event.KeyEvent;
|
|
4 import java.awt.event.KeyListener;
|
|
5
|
|
6 public class KeyInputCodeSegment implements KeyListener{
|
|
7 int KeyCode = 0;
|
98
|
8 SendLocation cs;
|
|
9 String key;
|
|
10
|
|
11 public void setKey(){
|
|
12
|
|
13 }
|
|
14
|
92
|
15 @Override
|
|
16 public void keyPressed(KeyEvent event) {
|
|
17 KeyCode = event.getKeyCode();
|
105
|
18 //System.out.println("getKey" +KeyCode);
|
92
|
19 switch(KeyCode)
|
|
20 {
|
|
21 case 37:
|
97
|
22 cs = new SendLocation(-0.1f,0.0f);
|
105
|
23 cs.position.setKey("local", "fish");
|
92
|
24 break;
|
|
25 case 39:
|
97
|
26 cs = new SendLocation(0.1f,0.0f);
|
105
|
27 cs.position.setKey("local", "fish");
|
97
|
28 break;
|
|
29 case 40:
|
|
30 cs = new SendLocation(0.0f,-0.1f);
|
105
|
31 cs.position.setKey("local", "fish");
|
97
|
32 break;
|
|
33 case 38:
|
|
34 cs = new SendLocation(0.0f,0.1f);
|
105
|
35 cs.position.setKey("local", "fish");
|
92
|
36 break;
|
|
37 }
|
|
38 }
|
|
39
|
|
40 @Override
|
|
41 public void keyReleased(KeyEvent arg0) {
|
|
42
|
|
43 }
|
|
44
|
|
45 @Override
|
|
46 public void keyTyped(KeyEvent arg0) {
|
|
47
|
|
48 }
|
|
49
|
|
50 }
|