Browse Source

added randomFruit function to GameManager

remotes/origin/player
fdai7910 11 months ago
parent
commit
8c8bf20c02
  1. 16
      src/main/java/pacmanGame/GameManager.java

16
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) {

Loading…
Cancel
Save