Browse Source

refactoring: formating of GameManager

remotes/origin/menu
fdai7910 11 months ago
parent
commit
20d88f3075
  1. 14
      src/main/java/pacmanGame/GameManager.java
  2. 4
      src/test/java/pacmanTests/GameManagerTest.java

14
src/main/java/pacmanGame/GameManager.java

@ -21,8 +21,8 @@ public class GameManager {
for(int i = 0; i < ghosts.length; i++) {
ghosts[i] = new Ghost(this);
}
}
public void Update() {
visualizer.Update();
if(time%5 == 0) {
@ -31,23 +31,19 @@ public class GameManager {
time++;
}
public void ProcessInput(char inputChar) {
if(inputChar == 27) {
//todo: escape key pauses game
}
else if (inputChar == 'w' || inputChar == 's' || inputChar == 'd' || inputChar == 'a') {
player.processInput(inputChar);
}
else {
System.out.println("Unprocessed Input: " + inputChar + " (" + (int)inputChar + ")");
}
}
public boolean GostPlayerColisionTest()
{
public boolean GhostPlayerColisionTest() {
for(int i = 0; i < ghosts.length; i++) {
@ -57,14 +53,10 @@ public class GameManager {
{
return true;
}
}
}
}
return false;
}
}

4
src/test/java/pacmanTests/GameManagerTest.java

@ -54,7 +54,7 @@ class GameManagerTest {
GameManager gameManager = new GameManager();
gameManager.player.position = gameManager.ghosts[0].position.Clone();
//act
boolean colision = gameManager.GostPlayerColisionTest();
boolean colision = gameManager.GhostPlayerColisionTest();
boolean expected = true;
// assert
@ -69,7 +69,7 @@ class GameManagerTest {
gameManager.player.position = new Vector2(2,3);
gameManager.ghosts[0].position = new Vector2(4,5);
//act
boolean colision = gameManager.GostPlayerColisionTest();
boolean colision = gameManager.GhostPlayerColisionTest();
boolean expected = false;
// assert

Loading…
Cancel
Save