From cc84d4a3e43da480c8834d12f06b6e5e052285c3 Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Wed, 24 Dec 2014 02:45:43 -0500 Subject: [PATCH] Subtle fade in effect for circles and sliders. (#9) Also resize the "skip" button on hover. (follow-up 33f5df0) Signed-off-by: Jeffrey Han --- pom.xml | 2 +- src/itdelatrisu/opsu/Utils.java | 3 ++- src/itdelatrisu/opsu/objects/Circle.java | 7 ++++++- src/itdelatrisu/opsu/objects/Slider.java | 24 +++++++++++++++++------- src/itdelatrisu/opsu/states/Game.java | 13 +++++++++---- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 060857a1..547ac53d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 itdelatrisu opsu - 0.3.2 + 0.3.3 src diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java index b7660c3c..949bd4b4 100644 --- a/src/itdelatrisu/opsu/Utils.java +++ b/src/itdelatrisu/opsu/Utils.java @@ -63,7 +63,8 @@ public class Utils { COLOR_BLUE_OBJECT = new Color(46, 136, 248), COLOR_RED_OBJECT = new Color(243, 48, 77), 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. diff --git a/src/itdelatrisu/opsu/objects/Circle.java b/src/itdelatrisu/opsu/objects/Circle.java index 11222a80..74dc36d2 100644 --- a/src/itdelatrisu/opsu/objects/Circle.java +++ b/src/itdelatrisu/opsu/objects/Circle.java @@ -100,8 +100,13 @@ public class Circle { float x = hitObject.getX(), y = hitObject.getY(); float approachScale = 1 + (timeDiff * 2f / game.getApproachTime()); 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); + color.a = 1f; + Utils.COLOR_WHITE_FADE.a = 1f; score.drawSymbolNumber(hitObject.getComboNumber(), x, y, GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight()); } diff --git a/src/itdelatrisu/opsu/objects/Slider.java b/src/itdelatrisu/opsu/objects/Slider.java index e51cc195..b8f861cb 100644 --- a/src/itdelatrisu/opsu/objects/Slider.java +++ b/src/itdelatrisu/opsu/objects/Slider.java @@ -263,7 +263,7 @@ public class Slider { // draw overlay and hit circle 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--) Utils.drawCentered(hitCircle, curveX[i], curveY[i], color); } @@ -345,27 +345,33 @@ public class Slider { float[] sliderX = hitObject.getSliderX(), sliderY = hitObject.getSliderY(); int timeDiff = hitObject.getTime() - trackPosition; - Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage(); - Image hitCircle = GameImage.HITCIRCLE.getImage(); + float approachScale = (timeDiff >= 0) ? 1 + (timeDiff * 2f / game.getApproachTime()) : 1f; + float alpha = (approachScale > 3.3f) ? 0f : 1f - (approachScale - 1f) / 2.7f; + color.a = alpha; + Utils.COLOR_WHITE_FADE.a = alpha; // bezier bezier.draw(); // ticks if (currentObject && ticksT != null) { + Image tick = GameImage.SLIDER_TICK.getImage(); for (int i = 0; i < ticksT.length; 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 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); // start circle - Utils.drawCentered(hitCircleOverlay, x, y, Color.white); + Utils.drawCentered(hitCircleOverlay, x, y, Utils.COLOR_WHITE_FADE); Utils.drawCentered(hitCircle, x, y, color); if (sliderClicked) ; // don't draw current combo number if already clicked @@ -373,9 +379,13 @@ public class Slider { score.drawSymbolNumber(hitObject.getComboNumber(), x, y, hitCircle.getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight()); + color.a = 1f; + Utils.COLOR_WHITE_FADE.a = 1f; + // repeats if (hitObject.getRepeatCount() - 1 > currentRepeats) { Image arrow = GameImage.REVERSEARROW.getImage(); + arrow.setAlpha(alpha); if (currentRepeats % 2 == 0) { // last circle arrow.setRotation(bezier.getEndAngle()); arrow.drawCentered(sliderX[lastIndex], sliderY[lastIndex]); @@ -383,11 +393,11 @@ public class Slider { arrow.setRotation(bezier.getStartAngle()); arrow.drawCentered(x, y); } + arrow.setAlpha(1f); } if (timeDiff >= 0) { // approach circle - float approachScale = 1 + (timeDiff * 2f / game.getApproachTime()); Utils.drawCentered(GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale), x, y, color); } else { float[] c = bezier.pointAt(getT(trackPosition, false)); diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index e8d4d03f..8ef0640f 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -424,6 +424,8 @@ public class Game extends BasicGameState { public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { Utils.updateCursor(delta); + int mouseX = input.getMouseX(), mouseY = input.getMouseY(); + skipButton.hoverUpdate(delta, mouseX, mouseY); if (isLeadIn()) { // stop updating during song lead-in leadInTime -= delta; @@ -521,8 +523,8 @@ public class Game extends BasicGameState { // pause game if focus lost if (!container.hasFocus() && !GameMod.AUTO.isActive()) { if (pauseTime < 0) { - pausedMouseX = input.getMouseX(); - pausedMouseY = input.getMouseY(); + pausedMouseX = mouseX; + pausedMouseY = mouseY; pausePulse = 0f; } if (MusicController.isPlaying() || isLeadIn()) @@ -563,9 +565,9 @@ public class Game extends BasicGameState { if (hitObject.isCircle()) done = circles.get(objectIndex).update(overlap); 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()) - done = spinners.get(objectIndex).update(overlap, delta, input.getMouseX(), input.getMouseY()); + done = spinners.get(objectIndex).update(overlap, delta, mouseX, mouseY); // increment object index? if (done) @@ -789,6 +791,8 @@ public class Game extends BasicGameState { leadInTime = osu.audioLeadIn + approachTime; restart = RESTART_FALSE; } + + skipButton.setScale(1f); } // @Override @@ -842,6 +846,7 @@ public class Game extends BasicGameState { skipButton = new GUIMenuButton(skip, width - (skip.getWidth() / 2f), height - (skip.getHeight() / 2f)); + skipButton.setHoverDir(GUIMenuButton.Expand.UP_LEFT); // countdown float countdownHeight = height / 3f;