Animated the score display.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2014-07-03 02:03:56 -04:00
parent f195ffb861
commit 0b471fa1cc
2 changed files with 24 additions and 3 deletions

View File

@ -159,6 +159,11 @@ public class GameScore {
*/ */
private long score; private long score;
/**
* Displayed game score (for animation, slightly behind score).
*/
private long scoreDisplay;
/** /**
* Current health bar percentage. * Current health bar percentage.
*/ */
@ -249,6 +254,7 @@ public class GameScore {
*/ */
public void clear() { public void clear() {
score = 0; score = 0;
scoreDisplay = 0;
health = 100f; health = 100f;
hitResultCount = new int[HIT_MAX]; hitResultCount = new int[HIT_MAX];
hitResultList = new LinkedList<OsuHitObjectResult>(); hitResultList = new LinkedList<OsuHitObjectResult>();
@ -432,7 +438,7 @@ public class GameScore {
*/ */
public void drawGameElements(Graphics g, int mapLength, boolean breakPeriod, boolean firstObject) { public void drawGameElements(Graphics g, int mapLength, boolean breakPeriod, boolean firstObject) {
// score // score
drawSymbolString(String.format("%08d", score), drawSymbolString(String.format("%08d", scoreDisplay),
width - 2, 0, 1.0f, true); width - 2, 0, 1.0f, true);
// score percentage // score percentage
@ -670,8 +676,21 @@ public class GameScore {
return GRADE_D; return GRADE_D;
} }
/**
* Updates the score display based on a delta value.
* @param delta the delta interval since the last call
*/
public void updateScoreDisplay(int delta) {
if (scoreDisplay < score) {
scoreDisplay += (score - scoreDisplay) * delta / 50 + 1;
if (scoreDisplay > score)
scoreDisplay = score;
}
}
/** /**
* Updates combo burst data based on a delta value. * Updates combo burst data based on a delta value.
* @param delta the delta interval since the last call
*/ */
public void updateComboBurst(int delta) { public void updateComboBurst(int delta) {
if (comboBurstIndex > -1 && Options.isComboBurstEnabled()) { if (comboBurstIndex > -1 && Options.isComboBurstEnabled()) {

View File

@ -498,6 +498,8 @@ public class Game extends BasicGameState {
return; return;
} }
score.updateScoreDisplay(delta);
// map complete! // map complete!
if (objectIndex >= osu.objects.length) { if (objectIndex >= osu.objects.length) {
game.enterState(Opsu.STATE_GAMERANKING, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAMERANKING, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
@ -558,6 +560,8 @@ public class Game extends BasicGameState {
game.enterState(Opsu.STATE_GAMEPAUSEMENU); game.enterState(Opsu.STATE_GAMEPAUSEMENU);
} }
score.updateComboBurst(delta);
// drain health // drain health
score.changeHealth(delta / -200f); score.changeHealth(delta / -200f);
if (!score.isAlive()) { if (!score.isAlive()) {
@ -566,8 +570,6 @@ public class Game extends BasicGameState {
game.enterState(Opsu.STATE_GAMEPAUSEMENU); game.enterState(Opsu.STATE_GAMEPAUSEMENU);
} }
score.updateComboBurst(delta);
// update objects (loop in unlikely event of any skipped indexes) // update objects (loop in unlikely event of any skipped indexes)
while (objectIndex < osu.objects.length && trackPosition > osu.objects[objectIndex].time) { while (objectIndex < osu.objects.length && trackPosition > osu.objects[objectIndex].time) {
OsuHitObject hitObject = osu.objects[objectIndex]; OsuHitObject hitObject = osu.objects[objectIndex];