64 lines
1.9 KiB
Java
64 lines
1.9 KiB
Java
package cicaprojekt;
|
|
|
|
import java.awt.*;
|
|
import java.awt.event.KeyAdapter;
|
|
import java.awt.event.KeyEvent;
|
|
|
|
public class Control {
|
|
private Game game;
|
|
|
|
public class KeyHandler extends KeyAdapter{
|
|
@Override
|
|
public void keyTyped(KeyEvent e) {
|
|
char c = e.getKeyChar();
|
|
c = Character.toUpperCase(c);
|
|
switch(c) {
|
|
case 'W' :
|
|
game.moveONeill(Direction.NORTH);
|
|
break;
|
|
case 'A' :
|
|
game.moveONeill(Direction.WEST);
|
|
break;
|
|
case 'S' :
|
|
game.moveONeill(Direction.SOUTH);
|
|
break;
|
|
case 'D' :
|
|
game.moveONeill(Direction.EAST);
|
|
break;
|
|
case 'I' :
|
|
game.moveJaffa(Direction.NORTH);
|
|
break;
|
|
case 'J' :
|
|
game.moveJaffa(Direction.WEST);
|
|
break;
|
|
case 'K' :
|
|
game.moveJaffa(Direction.SOUTH);
|
|
break;
|
|
case 'L' :
|
|
game.moveJaffa(Direction.EAST);
|
|
break;
|
|
case 'Q' :
|
|
game.boxONeill();
|
|
break;
|
|
case 'U' :
|
|
game.boxJaffa();
|
|
break;
|
|
case 'E' :
|
|
game.shootStargate(Color.YELLOW);
|
|
break;
|
|
case 'R' :
|
|
game.shootStargate(Color.BLUE);
|
|
break;
|
|
case 'O' :
|
|
game.shootStargate(Color.RED);
|
|
break;
|
|
case 'P' :
|
|
game.shootStargate(Color.GREEN);
|
|
break;
|
|
}
|
|
game.updateDisplay();
|
|
|
|
}
|
|
}
|
|
}
|