Browse Source

Fixed Error in Ghost Constructor

remotes/origin/menu
fdai7012 11 months ago
committed by Julian Wenzel
parent
commit
712f058eb8
  1. 10
      src/main/java/pacmanGame/GameManager.java
  2. 2
      src/main/java/pacmanGame/Ghost.java

10
src/main/java/pacmanGame/GameManager.java

@ -12,8 +12,8 @@ public class GameManager {
visualizer = new VisualizerPlainText(this); visualizer = new VisualizerPlainText(this);
player = new Player(this); player = new Player(this);
ghosts = new Ghost[4]; ghosts = new Ghost[4];
for(int i = 0; i< ghosts.length; i++) {
ghosts[i] = new Ghost();
for(int i = 0; i < ghosts.length; i++) {
ghosts[i] = new Ghost(this);
} }
} }
@ -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 + ")");
} }

2
src/main/java/pacmanGame/Ghost.java

@ -5,7 +5,7 @@ public class Ghost {
public final GameManager gameManager; public final GameManager gameManager;
public Ghost(GameManager gameManager) { public Ghost(GameManager gameManager) {
this.gameManager = new GameManager();
this.gameManager = gameManager;
} }
} }
Loading…
Cancel
Save