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 = new JFrame("PacmaaaAAAYYYHAAAaaam");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 665);
frame.setSize(500, 685);
textArea = new JTextArea("..."); textArea = new JTextArea("...");
textArea.setEditable(false); textArea.setEditable(false);

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

@ -3,7 +3,7 @@ package pacmanGame;
import java.util.HashMap; import java.util.HashMap;
public class VisualizerPlainText implements Visualizer { public class VisualizerPlainText implements Visualizer {
public boolean showScore = true;
private String output; private String output;
public final GameManager gameManager; public final GameManager gameManager;
@ -28,6 +28,9 @@ public class VisualizerPlainText implements Visualizer {
@Override @Override
public void Update() { public void Update() {
output = ""; output = "";
if(showScore) {
output = "score: " + gameManager.score + "\n";
}
Map map = gameManager.map; Map map = gameManager.map;
for(int y = 0; y < map.size.y; y++) { 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 gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager); gameManager.map = new Map(mapTest, gameManager);
VisualizerPlainText vpt = new VisualizerPlainText(gameManager); VisualizerPlainText vpt = new VisualizerPlainText(gameManager);
vpt.showScore = false;
String expected = "" String expected = ""
+ "[]. []\n" + "[]. []\n"
+ " . \n" + " . \n"
@ -46,6 +46,7 @@ class VisualizerPlainTextTest {
GameManager gameManager = new GameManager(); GameManager gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager); gameManager.map = new Map(mapTest, gameManager);
VisualizerPlainText vpt = new VisualizerPlainText(gameManager); VisualizerPlainText vpt = new VisualizerPlainText(gameManager);
vpt.showScore = false;
gameManager.ghosts[0].position = new Vector2(1, 1); gameManager.ghosts[0].position = new Vector2(1, 1);

Loading…
Cancel
Save