|
@ -7,7 +7,8 @@ public class GameManager { |
|
|
public Visualizer visualizer; |
|
|
public Visualizer visualizer; |
|
|
public Player player; |
|
|
public Player player; |
|
|
public int score = 0; |
|
|
public int score = 0; |
|
|
public Boolean ghostIsEdible = false; |
|
|
|
|
|
|
|
|
public boolean ghostIsEdible = false; |
|
|
|
|
|
public boolean isPaused; |
|
|
|
|
|
|
|
|
public GameManager() { |
|
|
public GameManager() { |
|
|
setupGame(); |
|
|
setupGame(); |
|
@ -22,6 +23,8 @@ public class GameManager { |
|
|
for(int i = 0; i < ghosts.length; i++) { |
|
|
for(int i = 0; i < ghosts.length; i++) { |
|
|
ghosts[i] = new Ghost(this); |
|
|
ghosts[i] = new Ghost(this); |
|
|
} |
|
|
} |
|
|
|
|
|
isPaused = false; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void Update() { |
|
|
public void Update() { |
|
@ -47,8 +50,8 @@ public class GameManager { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void ProcessInput(char inputChar) { |
|
|
public void ProcessInput(char inputChar) { |
|
|
if(inputChar == 27) { |
|
|
|
|
|
//todo: escape key pauses game |
|
|
|
|
|
|
|
|
if(inputChar == 27) {// 27 = ESC |
|
|
|
|
|
TogglePause(); |
|
|
} |
|
|
} |
|
|
else if (inputChar == 'w' || inputChar == 's' || inputChar == 'd' || inputChar == 'a') { |
|
|
else if (inputChar == 'w' || inputChar == 's' || inputChar == 'd' || inputChar == 'a') { |
|
|
player.processInput(inputChar); |
|
|
player.processInput(inputChar); |
|
@ -85,4 +88,18 @@ public class GameManager { |
|
|
ghostIsEdible = false; |
|
|
ghostIsEdible = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
public void Pause() { |
|
|
|
|
|
isPaused = true; |
|
|
|
|
|
} |
|
|
|
|
|
public void Unpause() { |
|
|
|
|
|
isPaused = false; |
|
|
|
|
|
} |
|
|
|
|
|
public void TogglePause() { |
|
|
|
|
|
if(isPaused) { |
|
|
|
|
|
Unpause(); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
Pause(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |