Animated the score display.
Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
f195ffb861
commit
0b471fa1cc
|
@ -159,6 +159,11 @@ public class GameScore {
|
|||
*/
|
||||
private long score;
|
||||
|
||||
/**
|
||||
* Displayed game score (for animation, slightly behind score).
|
||||
*/
|
||||
private long scoreDisplay;
|
||||
|
||||
/**
|
||||
* Current health bar percentage.
|
||||
*/
|
||||
|
@ -249,6 +254,7 @@ public class GameScore {
|
|||
*/
|
||||
public void clear() {
|
||||
score = 0;
|
||||
scoreDisplay = 0;
|
||||
health = 100f;
|
||||
hitResultCount = new int[HIT_MAX];
|
||||
hitResultList = new LinkedList<OsuHitObjectResult>();
|
||||
|
@ -432,7 +438,7 @@ public class GameScore {
|
|||
*/
|
||||
public void drawGameElements(Graphics g, int mapLength, boolean breakPeriod, boolean firstObject) {
|
||||
// score
|
||||
drawSymbolString(String.format("%08d", score),
|
||||
drawSymbolString(String.format("%08d", scoreDisplay),
|
||||
width - 2, 0, 1.0f, true);
|
||||
|
||||
// score percentage
|
||||
|
@ -670,8 +676,21 @@ public class GameScore {
|
|||
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.
|
||||
* @param delta the delta interval since the last call
|
||||
*/
|
||||
public void updateComboBurst(int delta) {
|
||||
if (comboBurstIndex > -1 && Options.isComboBurstEnabled()) {
|
||||
|
|
|
@ -498,6 +498,8 @@ public class Game extends BasicGameState {
|
|||
return;
|
||||
}
|
||||
|
||||
score.updateScoreDisplay(delta);
|
||||
|
||||
// map complete!
|
||||
if (objectIndex >= osu.objects.length) {
|
||||
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);
|
||||
}
|
||||
|
||||
score.updateComboBurst(delta);
|
||||
|
||||
// drain health
|
||||
score.changeHealth(delta / -200f);
|
||||
if (!score.isAlive()) {
|
||||
|
@ -566,8 +570,6 @@ public class Game extends BasicGameState {
|
|||
game.enterState(Opsu.STATE_GAMEPAUSEMENU);
|
||||
}
|
||||
|
||||
score.updateComboBurst(delta);
|
||||
|
||||
// update objects (loop in unlikely event of any skipped indexes)
|
||||
while (objectIndex < osu.objects.length && trackPosition > osu.objects[objectIndex].time) {
|
||||
OsuHitObject hitObject = osu.objects[objectIndex];
|
||||
|
|
Loading…
Reference in New Issue
Block a user