diff --git a/cicaprojekt/Control.java b/cicaprojekt/Control.java new file mode 100644 index 0000000..8a5a34e --- /dev/null +++ b/cicaprojekt/Control.java @@ -0,0 +1,50 @@ +package cicaprojekt; + +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; + } + game.updateDisplay(); + + } + } +} diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index 0193d0f..49c66d8 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -45,4 +45,23 @@ public class Game { public void stopGame(GameoverCause cause) { } + + public void moveONeill(Direction direction) { + oneill.move(direction); + } + + public void moveJaffa(Direction direction) { + jaffa.move(direction); + } + + public void boxONeill() { + + } + + public void boxJaffa() { + + } + + public void updateDisplay() { + } }