Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
Issue #3 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
JupiterRider committed Nov 22, 2020
1 parent 3484099 commit 86fea33
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions core/src/main/java/com/github/jupiterrider/getintospace/Hud.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,35 @@
public class Hud {

private BitmapFont bitmapFont;
private float time = 0f;
private float currentScore = 0f;
private float lastScore = 0f;
private float bestScore = 0f;

public Hud() {
bitmapFont = new BitmapFont();
}

public void draw(Batch batch, float delta) {
time += delta;
String strTime = "Survived: " + String.valueOf((long) time) + "sec";
currentScore += delta;
String strFps = "FPS: " + String.valueOf(Gdx.graphics.getFramesPerSecond());
bitmapFont.draw(batch, strFps + "\r\n" + strTime, 0f, Gdx.graphics.getHeight());
String strCurrentScore = "Current score: " + String.valueOf((long) currentScore) + "sec";
String strLastScore = "Last score: " + String.valueOf((long) lastScore) + "sec";
String strBestScore = "Best score: " + String.valueOf((long) bestScore) + "sec";

String text = strFps + "\r\n" + strCurrentScore + "\r\n" + strLastScore + "\r\n" + strBestScore;
bitmapFont.draw(batch, text, 0f, Gdx.graphics.getHeight());
}

public void reset() {
time = 0f;
lastScore = currentScore;

if (lastScore > bestScore) {
bestScore = lastScore;
}

currentScore = 0f;
}

public void dispose() {
bitmapFont.dispose();
}
Expand Down

0 comments on commit 86fea33

Please sign in to comment.