Add score class
This commit is contained in:
parent
8ff66abc0a
commit
c744305fbb
33
src/com/annimon/influencexxii/Score.java
Normal file
33
src/com/annimon/influencexxii/Score.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user