|
|
@ -9,8 +9,12 @@ public class GameManager { |
|
|
|
public int score = 0; |
|
|
|
public boolean ghostIsEdible = false; |
|
|
|
public boolean isPaused; |
|
|
|
public int livesRemaining; |
|
|
|
public int failedAttempts; |
|
|
|
|
|
|
|
public GameManager() { |
|
|
|
livesRemaining = 3; |
|
|
|
failedAttempts = 0; |
|
|
|
setupGame(); |
|
|
|
} |
|
|
|
|
|
|
@ -24,14 +28,26 @@ public class GameManager { |
|
|
|
ghosts[i] = new Ghost(this); |
|
|
|
} |
|
|
|
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(); |
|
|
|
} |
|
|
|