Browse Source

added game restart key

remotes/origin/player
fdai7910 11 months ago
parent
commit
9b36ee55f4
  1. 6
      src/main/java/pacmanGame/GameManager.java
  2. 3
      src/main/java/pacmanGame/Player.java

6
src/main/java/pacmanGame/GameManager.java

@ -9,12 +9,14 @@ public class GameManager {
public int score = 0;
public boolean ghostIsEdible = false;
public int timeStopPillEffect;
public int moveSpeed = 5;
public GameManager() {
setupGame();
}
public void setupGame(){
time = 0;
map = new Map(Map.mapClassic,this);
visualizer = new VisualizerPlainText(this);
player = new Player(this);
@ -27,7 +29,7 @@ public class GameManager {
public void Update() {
visualizer.Update();
if(time%5 == 0) {
if(time%moveSpeed == 0) {
player.Move();
}
if(time == 300) {
@ -61,7 +63,7 @@ public class GameManager {
if(inputChar == 27) {
//todo: escape key pauses game
}
else if (inputChar == 'w' || inputChar == 's' || inputChar == 'd' || inputChar == 'a') {
else if (inputChar == 'w' || inputChar == 's' || inputChar == 'd' || inputChar == 'a' || inputChar == 'r') {
player.processInput(inputChar);
}
else {

3
src/main/java/pacmanGame/Player.java

@ -48,6 +48,9 @@ public class Player {
else if(inputchar == 'a') {
checkInput(new Vector2(-1,0));
}
else if(inputchar == 'r') {
gameManager.setupGame();
}
}

Loading…
Cancel
Save