Browse Source

Merge branch 'main' of https://gitlab.cs.hs-fulda.de/fdai7012/pacmayham

remotes/origin/menu
fdai2751 11 months ago
committed by Bertrand Goune
parent
commit
399f4cb58e
  1. 6
      src/main/java/pacmanGame/GameManager.java
  2. 21
      src/main/java/pacmanGame/Player.java

6
src/main/java/pacmanGame/GameManager.java

@ -28,6 +28,12 @@ public class GameManager {
if(inputChar == 27) { if(inputChar == 27) {
//todo: escape key pauses game //todo: escape key pauses game
} }
else if (inputChar == 'w' || inputChar == 's' || inputChar == 'd' || inputChar == 'a') {
player.processInput(inputChar);
}
else { else {
System.out.println("Unprocessed Input: " + inputChar + " (" + (int)inputChar + ")"); System.out.println("Unprocessed Input: " + inputChar + " (" + (int)inputChar + ")");
} }

21
src/main/java/pacmanGame/Player.java

@ -18,4 +18,25 @@ public class Player {
position = newPosition; position = newPosition;
} }
} }
public void processInput(char inputchar) {
if(inputchar == 'w') {
direction = new Vector2(0,1);
}
else if(inputchar == 's') {
direction = new Vector2(0,-1);
}
else if(inputchar == 'd') {
direction = new Vector2(1,0);
}
else if(inputchar == 'a') {
direction = new Vector2(-1,0);
}
}
} }
Loading…
Cancel
Save