- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
public void keyPressed(final KeyEvent event) {
final int keys[] = { KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT, KeyEvent.VK_SPACE };
final int dir[][] = { { 0, -1 }, { 0, 1 }, { -1, 0 }, { 1, 0 }, { 0, 0 } };
for (int i = 0; i < 5; i++) {
if (event.getKeyCode() == keys[i]) {
man.s.move(dir[i][0], dir[i][1]);
}
}
}
gegMOPO4 24.01.2011 23:11 # 0
Lure Of Chaos 24.01.2011 23:28 # +1
gegMOPO4 24.01.2011 23:43 # 0
tir 25.01.2011 13:45 # 0
и с точки зрения ООП не особо красиво