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(); player.Move();
} }
if(time == 300) { if(time == 300) {
spawnCherry();
spawnFruit();
} }
if (time == 600) { if (time == 600) {
destroyCherry();
destroyFruit();
} }
if(ghostIsEdible) { if(ghostIsEdible) {
if(time == timeStopPillEffect) if(time == timeStopPillEffect)
@ -43,14 +43,20 @@ public class GameManager {
time++; 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"; 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) { public void ProcessInput(char inputChar) {
if(inputChar == 27) { if(inputChar == 27) {
//todo: escape key pauses game //todo: escape key pauses game

Loading…
Cancel
Save