Add score class

This commit is contained in:
Victor 2014-01-15 14:28:36 +02:00
parent 8ff66abc0a
commit c744305fbb

View File

@ -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();
}
}