|
|
@ -10,8 +10,12 @@ public class GameManager { |
|
|
|
public boolean ghostIsEdible = false; |
|
|
|
public boolean isPaused; |
|
|
|
public final int ghostCount = 10; |
|
|
|
public int livesRemaining; |
|
|
|
public int failedAttempts; |
|
|
|
|
|
|
|
public GameManager() { |
|
|
|
livesRemaining = 3; |
|
|
|
failedAttempts = 0; |
|
|
|
setupGame(); |
|
|
|
} |
|
|
|
|
|
|
@ -27,13 +31,27 @@ public class GameManager { |
|
|
|
for (int i = 0; i < ghosts.length; i++) { |
|
|
|
ghosts[i].spawn(); |
|
|
|
} |
|
|
|
isPaused = false; |
|
|
|
} |
|
|
|
|
|
|
|
public void handleGhostCollision() { |
|
|
|
livesRemaining--; // Reduziere verbleibende leben um 1 |
|
|
|
failedAttempts++; // Erh he die Anzahl der Fehlversuche |
|
|
|
if(livesRemaining <= 0) { |
|
|
|
gameOver(); //wenn Keine Leben mehr brig sind. |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void gameOver() { |
|
|
|
System.out.println("Das Spiel ist vorbei! Pech!!"); |
|
|
|
} |
|
|
|
public void Update() { |
|
|
|
if(!isPaused) { |
|
|
|
visualizer.Update(); |
|
|
|
if(time%5 == 0) { |
|
|
|
player.Move(); |
|
|
|
} |
|
|
|
} |
|
|
|
if(time == 300) { |
|
|
|
spawnCherry(); |
|
|
|
} |
|
|
|