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++) { for(int i = 0; i < ghosts.length; i++) {
ghosts[i] = new Ghost(this); ghosts[i] = new Ghost(this);
} }
} }
public void Update() { public void Update() {
visualizer.Update(); visualizer.Update();
if(time%5 == 0) { if(time%5 == 0) {
@ -31,23 +31,19 @@ public class GameManager {
time++; time++;
} }
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
} }
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);
} }
else { else {
System.out.println("Unprocessed Input: " + inputChar + " (" + (int)inputChar + ")"); System.out.println("Unprocessed Input: " + inputChar + " (" + (int)inputChar + ")");
} }
} }
public boolean GostPlayerColisionTest()
{
public boolean GhostPlayerColisionTest() {
for(int i = 0; i < ghosts.length; i++) { for(int i = 0; i < ghosts.length; i++) {
@ -57,14 +53,10 @@ public class GameManager {
{ {
return true; return true;
} }
} }
} }
} }
return false; return false;
} }
} }

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

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

Loading…
Cancel
Save