Browse Source

added score to plaintextvisualizer

remotes/origin/menu
fdai2751 11 months ago
parent
commit
9847527ba8
  1. 2
      src/main/java/pacmanGame/Program.java
  2. 5
      src/main/java/pacmanGame/VisualizerPlainText.java
  3. 3
      src/test/java/pacmanTests/VisualizerPlainTextTest.java

2
src/main/java/pacmanGame/Program.java

@ -52,7 +52,7 @@ public class Program {
frame = new JFrame("PacmaaaAAAYYYHAAAaaam");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 665);
frame.setSize(500, 685);
textArea = new JTextArea("...");
textArea.setEditable(false);

5
src/main/java/pacmanGame/VisualizerPlainText.java

@ -3,7 +3,7 @@ package pacmanGame;
import java.util.HashMap;
public class VisualizerPlainText implements Visualizer {
public boolean showScore = true;
private String output;
public final GameManager gameManager;
@ -28,6 +28,9 @@ public class VisualizerPlainText implements Visualizer {
@Override
public void Update() {
output = "";
if(showScore) {
output = "score: " + gameManager.score + "\n";
}
Map map = gameManager.map;
for(int y = 0; y < map.size.y; y++) {

3
src/test/java/pacmanTests/VisualizerPlainTextTest.java

@ -22,7 +22,7 @@ class VisualizerPlainTextTest {
GameManager gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager);
VisualizerPlainText vpt = new VisualizerPlainText(gameManager);
vpt.showScore = false;
String expected = ""
+ "[]. []\n"
+ " . \n"
@ -46,6 +46,7 @@ class VisualizerPlainTextTest {
GameManager gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager);
VisualizerPlainText vpt = new VisualizerPlainText(gameManager);
vpt.showScore = false;
gameManager.ghosts[0].position = new Vector2(1, 1);

Loading…
Cancel
Save