Make score grow to the left instead of right

Draw high score heading
This commit is contained in:
Matt Low 2020-01-16 13:04:05 +04:00
parent 5c227e53d1
commit 0d69521986

View File

@ -256,9 +256,18 @@ public class PlayState extends LevelState {
@Override @Override
public void render() { public void render() {
// Draw score
game.fontRenderer.setColor(Color.WHITE); 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 // Draw remaining lives
for (int i = 0; i < lives; i++) { for (int i = 0; i < lives; i++) {