From 0d69521986425d577bc2bff6967f044f9977c3d2 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Thu, 16 Jan 2020 13:04:05 +0400 Subject: [PATCH] Make score grow to the left instead of right Draw high score heading --- core/src/com/me/pacman/state/PlayState.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/com/me/pacman/state/PlayState.java b/core/src/com/me/pacman/state/PlayState.java index 9ea998d..fc673be 100644 --- a/core/src/com/me/pacman/state/PlayState.java +++ b/core/src/com/me/pacman/state/PlayState.java @@ -256,9 +256,18 @@ public class PlayState extends LevelState { @Override public void render() { - // Draw score + game.fontRenderer.setColor(Color.WHITE); - game.fontRenderer.draw(game.batch, "" + score, 5 * 8, 34 * 8); + game.fontRenderer.draw(game.batch, "1up", 3 * 8, 35 * 8); + + // Draw score + // Determine x position based on score size. + int scoreTileX = 5 - (score > 0 ? (int) Math.log10(score) - 1 : 0); + game.fontRenderer.draw(game.batch, score > 0 ? "" + score : "00", scoreTileX * 8, 34 * 8); + + // Draw high score + game.fontRenderer.draw(game.batch, "high score", 9 * 8, 35 * 8); + game.fontRenderer.draw(game.batch, "10000", 12 * 8, 34 * 8); // Draw remaining lives for (int i = 0; i < lives; i++) {