Subtle fade in effect for circles and sliders. (#9)

Also resize the "skip" button on hover. (follow-up 33f5df0)

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2014-12-24 02:45:43 -05:00
parent 068a844e1f
commit cc84d4a3e4
5 changed files with 35 additions and 14 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>itdelatrisu</groupId> <groupId>itdelatrisu</groupId>
<artifactId>opsu</artifactId> <artifactId>opsu</artifactId>
<version>0.3.2</version> <version>0.3.3</version>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>

View File

@ -63,7 +63,8 @@ public class Utils {
COLOR_BLUE_OBJECT = new Color(46, 136, 248), COLOR_BLUE_OBJECT = new Color(46, 136, 248),
COLOR_RED_OBJECT = new Color(243, 48, 77), COLOR_RED_OBJECT = new Color(243, 48, 77),
COLOR_ORANGE_OBJECT = new Color(255, 200, 32), COLOR_ORANGE_OBJECT = new Color(255, 200, 32),
COLOR_YELLOW_ALPHA = new Color(255, 255, 0, 0.4f); COLOR_YELLOW_ALPHA = new Color(255, 255, 0, 0.4f),
COLOR_WHITE_FADE = new Color(255, 255, 255, 1f);
/** /**
* The default map colors, used when a map does not provide custom colors. * The default map colors, used when a map does not provide custom colors.

View File

@ -100,8 +100,13 @@ public class Circle {
float x = hitObject.getX(), y = hitObject.getY(); float x = hitObject.getX(), y = hitObject.getY();
float approachScale = 1 + (timeDiff * 2f / game.getApproachTime()); float approachScale = 1 + (timeDiff * 2f / game.getApproachTime());
Utils.drawCentered(GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale), x, y, color); Utils.drawCentered(GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale), x, y, color);
Utils.drawCentered(GameImage.HITCIRCLE_OVERLAY.getImage(), x, y, Color.white); float alpha = (approachScale > 3.3f) ? 0f : 1f - (approachScale - 1f) / 2.7f;
color.a = alpha;
Utils.COLOR_WHITE_FADE.a = alpha;
Utils.drawCentered(GameImage.HITCIRCLE_OVERLAY.getImage(), x, y, Utils.COLOR_WHITE_FADE);
Utils.drawCentered(GameImage.HITCIRCLE.getImage(), x, y, color); Utils.drawCentered(GameImage.HITCIRCLE.getImage(), x, y, color);
color.a = 1f;
Utils.COLOR_WHITE_FADE.a = 1f;
score.drawSymbolNumber(hitObject.getComboNumber(), x, y, score.drawSymbolNumber(hitObject.getComboNumber(), x, y,
GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight()); GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight());
} }

View File

@ -263,7 +263,7 @@ public class Slider {
// draw overlay and hit circle // draw overlay and hit circle
for (int i = curveX.length - 1; i >= 0; i--) for (int i = curveX.length - 1; i >= 0; i--)
Utils.drawCentered(hitCircleOverlay, curveX[i], curveY[i], Color.white); Utils.drawCentered(hitCircleOverlay, curveX[i], curveY[i], Utils.COLOR_WHITE_FADE);
for (int i = curveX.length - 1; i >= 0; i--) for (int i = curveX.length - 1; i >= 0; i--)
Utils.drawCentered(hitCircle, curveX[i], curveY[i], color); Utils.drawCentered(hitCircle, curveX[i], curveY[i], color);
} }
@ -345,27 +345,33 @@ public class Slider {
float[] sliderX = hitObject.getSliderX(), sliderY = hitObject.getSliderY(); float[] sliderX = hitObject.getSliderX(), sliderY = hitObject.getSliderY();
int timeDiff = hitObject.getTime() - trackPosition; int timeDiff = hitObject.getTime() - trackPosition;
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage(); float approachScale = (timeDiff >= 0) ? 1 + (timeDiff * 2f / game.getApproachTime()) : 1f;
Image hitCircle = GameImage.HITCIRCLE.getImage(); float alpha = (approachScale > 3.3f) ? 0f : 1f - (approachScale - 1f) / 2.7f;
color.a = alpha;
Utils.COLOR_WHITE_FADE.a = alpha;
// bezier // bezier
bezier.draw(); bezier.draw();
// ticks // ticks
if (currentObject && ticksT != null) { if (currentObject && ticksT != null) {
Image tick = GameImage.SLIDER_TICK.getImage();
for (int i = 0; i < ticksT.length; i++) { for (int i = 0; i < ticksT.length; i++) {
float[] c = bezier.pointAt(ticksT[i]); float[] c = bezier.pointAt(ticksT[i]);
GameImage.SLIDER_TICK.getImage().drawCentered(c[0], c[1]); tick.drawCentered(c[0], c[1]);
} }
} }
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
Image hitCircle = GameImage.HITCIRCLE.getImage();
// end circle // end circle
int lastIndex = sliderX.length - 1; int lastIndex = sliderX.length - 1;
Utils.drawCentered(hitCircleOverlay, sliderX[lastIndex], sliderY[lastIndex], Color.white); Utils.drawCentered(hitCircleOverlay, sliderX[lastIndex], sliderY[lastIndex], Utils.COLOR_WHITE_FADE);
Utils.drawCentered(hitCircle, sliderX[lastIndex], sliderY[lastIndex], color); Utils.drawCentered(hitCircle, sliderX[lastIndex], sliderY[lastIndex], color);
// start circle // start circle
Utils.drawCentered(hitCircleOverlay, x, y, Color.white); Utils.drawCentered(hitCircleOverlay, x, y, Utils.COLOR_WHITE_FADE);
Utils.drawCentered(hitCircle, x, y, color); Utils.drawCentered(hitCircle, x, y, color);
if (sliderClicked) if (sliderClicked)
; // don't draw current combo number if already clicked ; // don't draw current combo number if already clicked
@ -373,9 +379,13 @@ public class Slider {
score.drawSymbolNumber(hitObject.getComboNumber(), x, y, score.drawSymbolNumber(hitObject.getComboNumber(), x, y,
hitCircle.getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight()); hitCircle.getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight());
color.a = 1f;
Utils.COLOR_WHITE_FADE.a = 1f;
// repeats // repeats
if (hitObject.getRepeatCount() - 1 > currentRepeats) { if (hitObject.getRepeatCount() - 1 > currentRepeats) {
Image arrow = GameImage.REVERSEARROW.getImage(); Image arrow = GameImage.REVERSEARROW.getImage();
arrow.setAlpha(alpha);
if (currentRepeats % 2 == 0) { // last circle if (currentRepeats % 2 == 0) { // last circle
arrow.setRotation(bezier.getEndAngle()); arrow.setRotation(bezier.getEndAngle());
arrow.drawCentered(sliderX[lastIndex], sliderY[lastIndex]); arrow.drawCentered(sliderX[lastIndex], sliderY[lastIndex]);
@ -383,11 +393,11 @@ public class Slider {
arrow.setRotation(bezier.getStartAngle()); arrow.setRotation(bezier.getStartAngle());
arrow.drawCentered(x, y); arrow.drawCentered(x, y);
} }
arrow.setAlpha(1f);
} }
if (timeDiff >= 0) { if (timeDiff >= 0) {
// approach circle // approach circle
float approachScale = 1 + (timeDiff * 2f / game.getApproachTime());
Utils.drawCentered(GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale), x, y, color); Utils.drawCentered(GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale), x, y, color);
} else { } else {
float[] c = bezier.pointAt(getT(trackPosition, false)); float[] c = bezier.pointAt(getT(trackPosition, false));

View File

@ -424,6 +424,8 @@ public class Game extends BasicGameState {
public void update(GameContainer container, StateBasedGame game, int delta) public void update(GameContainer container, StateBasedGame game, int delta)
throws SlickException { throws SlickException {
Utils.updateCursor(delta); Utils.updateCursor(delta);
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
skipButton.hoverUpdate(delta, mouseX, mouseY);
if (isLeadIn()) { // stop updating during song lead-in if (isLeadIn()) { // stop updating during song lead-in
leadInTime -= delta; leadInTime -= delta;
@ -521,8 +523,8 @@ public class Game extends BasicGameState {
// pause game if focus lost // pause game if focus lost
if (!container.hasFocus() && !GameMod.AUTO.isActive()) { if (!container.hasFocus() && !GameMod.AUTO.isActive()) {
if (pauseTime < 0) { if (pauseTime < 0) {
pausedMouseX = input.getMouseX(); pausedMouseX = mouseX;
pausedMouseY = input.getMouseY(); pausedMouseY = mouseY;
pausePulse = 0f; pausePulse = 0f;
} }
if (MusicController.isPlaying() || isLeadIn()) if (MusicController.isPlaying() || isLeadIn())
@ -563,9 +565,9 @@ public class Game extends BasicGameState {
if (hitObject.isCircle()) if (hitObject.isCircle())
done = circles.get(objectIndex).update(overlap); done = circles.get(objectIndex).update(overlap);
else if (hitObject.isSlider()) else if (hitObject.isSlider())
done = sliders.get(objectIndex).update(overlap, delta, input.getMouseX(), input.getMouseY()); done = sliders.get(objectIndex).update(overlap, delta, mouseX, mouseY);
else if (hitObject.isSpinner()) else if (hitObject.isSpinner())
done = spinners.get(objectIndex).update(overlap, delta, input.getMouseX(), input.getMouseY()); done = spinners.get(objectIndex).update(overlap, delta, mouseX, mouseY);
// increment object index? // increment object index?
if (done) if (done)
@ -789,6 +791,8 @@ public class Game extends BasicGameState {
leadInTime = osu.audioLeadIn + approachTime; leadInTime = osu.audioLeadIn + approachTime;
restart = RESTART_FALSE; restart = RESTART_FALSE;
} }
skipButton.setScale(1f);
} }
// @Override // @Override
@ -842,6 +846,7 @@ public class Game extends BasicGameState {
skipButton = new GUIMenuButton(skip, skipButton = new GUIMenuButton(skip,
width - (skip.getWidth() / 2f), width - (skip.getWidth() / 2f),
height - (skip.getHeight() / 2f)); height - (skip.getHeight() / 2f));
skipButton.setHoverDir(GUIMenuButton.Expand.UP_LEFT);
// countdown // countdown
float countdownHeight = height / 3f; float countdownHeight = height / 3f;