Skip to content

Commit

Permalink
Animate the music icon in the song menu. (follow-up to c5cc43a)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
  • Loading branch information
itdelatrisu committed Sep 5, 2015
1 parent c5cc43a commit 5ff35d3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/itdelatrisu/opsu/states/SongMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ public SongNode(BeatmapSetNode node, int index) {
/** Timer for animations when a new song node is selected. */
private AnimatedValue songChangeTimer = new AnimatedValue(900, 0f, 1f, AnimationEquation.OUT_QUAD);

/** Timer for the music icon animation when a new song node is selected. */
private AnimatedValue musicIconBounceTimer = new AnimatedValue(350, 0f, 1f, AnimationEquation.LINEAR);

/**
* Beatmaps whose difficulties were recently computed (if flag is non-null).
* Unless the Boolean flag is null, then upon removal, the beatmap's objects will
Expand Down Expand Up @@ -401,8 +404,13 @@ public void render(GameContainer container, StateBasedGame game, Graphics g)
Image musicNote = GameImage.MENU_MUSICNOTE.getImage();
if (MusicController.isTrackLoading())
loader.draw(marginX, marginY);
else
musicNote.draw(marginX, marginY);
else {
float t = musicIconBounceTimer.getValue() * 2f;
if (t > 1)
t = 2f - t;
float musicNoteScale = 1f + 0.3f * t;
musicNote.getScaledCopy(musicNoteScale).drawCentered(marginX + musicNote.getWidth() / 2f, marginY + musicNote.getHeight() / 2f);
}
int iconWidth = musicNote.getWidth();

// song info text
Expand Down Expand Up @@ -585,8 +593,10 @@ public void update(GameContainer container, StateBasedGame game, int delta)
if (!focusNodeBeatmap.isBackgroundLoading())
bgAlpha.update(delta);

// song change timer
// song change timers
songChangeTimer.update(delta);
if (!MusicController.isTrackLoading())
musicIconBounceTimer.update(delta);
}

// star stream
Expand Down Expand Up @@ -1045,6 +1055,7 @@ public void enter(GameContainer container, StateBasedGame game)
songInfo = null;
bgAlpha.setTime(bgAlpha.getDuration());
songChangeTimer.setTime(songChangeTimer.getDuration());
musicIconBounceTimer.setTime(musicIconBounceTimer.getDuration());
starStream.clear();

// reset song stack
Expand Down Expand Up @@ -1248,6 +1259,7 @@ public BeatmapSetNode setFocus(BeatmapSetNode node, int beatmapIndex, boolean ch
hoverIndex = -1;
songInfo = null;
songChangeTimer.setTime(0);
musicIconBounceTimer.setTime(0);
BeatmapSetNode oldFocus = focusNode;

// expand node before focusing it
Expand Down

0 comments on commit 5ff35d3

Please # to comment.