Browse Source

Merge branch 'menu'

remotes/origin/visualizer
fdai2751 11 months ago
parent
commit
fad5780a76
  1. 16
      src/main/java/pacmanGame/GameManager.java
  2. 13
      src/main/java/pacmanGame/VisualizerPlainText.java

16
src/main/java/pacmanGame/GameManager.java

@ -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();
}

13
src/main/java/pacmanGame/VisualizerPlainText.java

@ -38,6 +38,18 @@ public class VisualizerPlainText implements Visualizer {
for(int y = 0; y < map.size.y; y++) {
for(int x = 0; x < map.size.x; x++) {
Cell cell = map.GetCell(new Vector2(x, map.size.y - 1 - y));
if(gameManager.isPaused && 5 < y && y <= 10){
if(x == 0) {
if(y == 8){
output += "Game Paused!";
}
else {
output += "";
}
}
}
else {
boolean containsGhosts = false;
boolean containsPlayer = false;
for( int i = 0; i < gameManager.ghosts.length; i++) {
@ -63,6 +75,7 @@ public class VisualizerPlainText implements Visualizer {
System.out.println("unknown type" + cell.type);
}
}
}
output += "\n";
}
}

Loading…
Cancel
Save