diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 544b401..7f11a92 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -31,10 +31,10 @@ public class GameManager { player.Move(); } if(time == 300) { - spawnCherry(); + spawnFruit(); } if (time == 600) { - destroyCherry(); + destroyFruit(); } if(ghostIsEdible) { if(time == timeStopPillEffect) @@ -43,13 +43,19 @@ public class GameManager { time++; } - public void spawnCherry() { - map.GetCell(map.playerSpawn).type = "cherry"; + public void spawnFruit() { + map.GetCell(map.playerSpawn).type = randomFruit(); } - public void destroyCherry() { + public void destroyFruit() { map.GetCell(map.playerSpawn).type = "empty"; } + + public String randomFruit() { + String fruitTypes[] = {"cherry"}; + int randomNumber = (int) (Math. random() * fruitTypes.length); + return fruitTypes[randomNumber]; + } public void ProcessInput(char inputChar) { if(inputChar == 27) {