From c744305fbbd99656a1852dda25af57abf4d5828a Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 15 Jan 2014 14:28:36 +0200 Subject: [PATCH] Add score class --- src/com/annimon/influencexxii/Score.java | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/com/annimon/influencexxii/Score.java diff --git a/src/com/annimon/influencexxii/Score.java b/src/com/annimon/influencexxii/Score.java new file mode 100644 index 0000000..6d92972 --- /dev/null +++ b/src/com/annimon/influencexxii/Score.java @@ -0,0 +1,33 @@ +package com.annimon.influencexxii; + +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; + +/** + * Score logic class + * @author aNNiMON + */ +public class Score { + + private static int killCount = 0; + private static int hiscore = 0; + + public static void reset() { + killCount = 0; + } + + public static void add() { + killCount++; + if (killCount > hiscore) { + hiscore = killCount; + } + } + + public static void draw(SpriteBatch batch, BitmapFont font) { + String text = "Score: " + killCount + " Hiscore: " + hiscore; + final float height = font.getCapHeight() + 2; + batch.begin(); + font.draw(batch, text, 10, height); + batch.end(); + } +} \ No newline at end of file