From a2fdc351e591bf339edb62fd73700b1fe015c5e1 Mon Sep 17 00:00:00 2001 From: fdai7012 Date: Wed, 7 Feb 2024 23:56:45 +0100 Subject: [PATCH] Implemented player animation to vptu --- .../pacmanGame/VisualizerPlainTextUltra.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/pacmanGame/VisualizerPlainTextUltra.java b/src/main/java/pacmanGame/VisualizerPlainTextUltra.java index 2db5054..b28f00d 100644 --- a/src/main/java/pacmanGame/VisualizerPlainTextUltra.java +++ b/src/main/java/pacmanGame/VisualizerPlainTextUltra.java @@ -5,6 +5,8 @@ import java.util.HashMap; public class VisualizerPlainTextUltra implements Visualizer { public boolean showScore = true; + + public final int playerAnimationTime = 2; private String output; @@ -155,8 +157,28 @@ public class VisualizerPlainTextUltra implements Visualizer { } if(containsPlayer) { + if((gameManager.time / playerAnimationTime) % 2 == 0) { + int directionIndex = 0; + + if(gameManager.player.direction.equals(new Vector2(0, 1))) { + directionIndex = 0; + } + else if(gameManager.player.direction.equals(new Vector2(0, -1))) { + directionIndex = 1; + } + else if(gameManager.player.direction.equals(new Vector2(-1, 0))) { + directionIndex = 2; + } + else if(gameManager.player.direction.equals(new Vector2(1, 0))) { + directionIndex = 3; + } + + lineBuffer = AttachToBuffer(lineBuffer, playerAltSprites[directionIndex]); + } + else { lineBuffer = AttachToBuffer(lineBuffer, playerSprite); } + } else if(containsGhosts) { lineBuffer = AttachToBuffer(lineBuffer, ghostSprites[ghostIndex]); }