Correct circle and slider fade in.
Match osu! behaviour. Fadein time is static and doesn't scale with approach rate. Circles, numbers, arrows and ticks alpha is the same.
This commit is contained in:
parent
16ec6c5e23
commit
87667c5dab
|
@ -444,13 +444,13 @@ public class GameData {
|
|||
* @param y the center y coordinate
|
||||
* @param scale the scale to apply
|
||||
*/
|
||||
public void drawSymbolNumber(int n, float x, float y, float scale) {
|
||||
public void drawSymbolNumber(int n, float x, float y, float scale, Color color) {
|
||||
int length = (int) (Math.log10(n) + 1);
|
||||
float digitWidth = getDefaultSymbolImage(0).getWidth() * scale;
|
||||
float cx = x + ((length - 1) * (digitWidth / 2));
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
getDefaultSymbolImage(n % 10).getScaledCopy(scale).drawCentered(cx, y);
|
||||
getDefaultSymbolImage(n % 10).getScaledCopy(scale).drawCentered(cx, y, color);
|
||||
cx -= digitWidth;
|
||||
n /= 10;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,9 @@ import org.newdawn.slick.Graphics;
|
|||
* Data type representing a circle object.
|
||||
*/
|
||||
public class Circle implements HitObject {
|
||||
/** The amount of time, in milliseconds, to fade in the circle. */
|
||||
private static final int FADE_IN_TIME = 375;
|
||||
|
||||
/** The associated OsuHitObject. */
|
||||
private OsuHitObject hitObject;
|
||||
|
||||
|
@ -85,26 +88,22 @@ public class Circle implements HitObject {
|
|||
@Override
|
||||
public void draw(Graphics g, int trackPosition) {
|
||||
int timeDiff = hitObject.getTime() - trackPosition;
|
||||
float scale = timeDiff / (float) game.getApproachTime();
|
||||
float fadeinScale = (timeDiff - game.getApproachTime() + FADE_IN_TIME) / (float) FADE_IN_TIME;
|
||||
float approachScale = 1 + scale * 3;
|
||||
float alpha = Utils.clamp(1 - fadeinScale, 0, 1);
|
||||
|
||||
if (timeDiff >= 0) {
|
||||
float oldAlpha = color.a;
|
||||
float scale = timeDiff / (float)game.getApproachTime();
|
||||
float oldAlpha = Utils.COLOR_WHITE_FADE.a;
|
||||
Utils.COLOR_WHITE_FADE.a = color.a = alpha;
|
||||
|
||||
float approachScale = 1 + scale * 3;
|
||||
color.a = 1 - scale;
|
||||
if(timeDiff >= 0 )
|
||||
GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color);
|
||||
GameImage.HITCIRCLE.getImage().drawCentered(x, y, color);
|
||||
GameImage.HITCIRCLE_OVERLAY.getImage().drawCentered(x, y, Utils.COLOR_WHITE_FADE);
|
||||
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
||||
GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), Utils.COLOR_WHITE_FADE);
|
||||
|
||||
float alpha = Utils.clamp((1 - scale) * 2, 0, 1);
|
||||
color.a = alpha;
|
||||
Utils.COLOR_WHITE_FADE.a = alpha;
|
||||
GameImage.HITCIRCLE.getImage().drawCentered(x, y, color);
|
||||
GameImage.HITCIRCLE_OVERLAY.getImage().drawCentered(x, y, Utils.COLOR_WHITE_FADE);
|
||||
|
||||
color.a = oldAlpha;
|
||||
Utils.COLOR_WHITE_FADE.a = 1f;
|
||||
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
||||
GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight());
|
||||
}
|
||||
Utils.COLOR_WHITE_FADE.a = oldAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,6 +47,9 @@ public class Slider implements HitObject {
|
|||
/** Rate at which slider ticks are placed. */
|
||||
private static float sliderTickRate = 1.0f;
|
||||
|
||||
/** The amount of time, in milliseconds, to fade in the slider. */
|
||||
private static final int FADE_IN_TIME = 375;
|
||||
|
||||
/** The associated OsuHitObject. */
|
||||
private OsuHitObject hitObject;
|
||||
|
||||
|
@ -152,29 +155,27 @@ public class Slider implements HitObject {
|
|||
public void draw(Graphics g, int trackPosition) {
|
||||
int timeDiff = hitObject.getTime() - trackPosition;
|
||||
float scale = timeDiff / (float) game.getApproachTime();
|
||||
float fadeinScale = (timeDiff - game.getApproachTime() + FADE_IN_TIME) / (float) FADE_IN_TIME;
|
||||
float approachScale = 1 + scale * 3;
|
||||
float alpha = Utils.clamp(1 - scale, 0, 1);
|
||||
float alpha = Utils.clamp(1 - fadeinScale, 0, 1);
|
||||
|
||||
float oldAlpha = color.a;
|
||||
color.a = alpha;
|
||||
Utils.COLOR_WHITE_FADE.a = alpha;
|
||||
float oldAlpha = Utils.COLOR_WHITE_FADE.a;
|
||||
Utils.COLOR_WHITE_FADE.a = color.a = alpha;
|
||||
|
||||
// curve
|
||||
curve.draw();
|
||||
|
||||
// ticks
|
||||
if (timeDiff < 0 && ticksT != null) {
|
||||
if (ticksT != null) {
|
||||
Image tick = GameImage.SLIDER_TICK.getImage();
|
||||
for (int i = 0; i < ticksT.length; i++) {
|
||||
float[] c = curve.pointAt(ticksT[i]);
|
||||
tick.drawCentered(c[0], c[1]);
|
||||
tick.drawCentered(c[0], c[1], Utils.COLOR_WHITE_FADE);
|
||||
}
|
||||
}
|
||||
|
||||
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
|
||||
Image hitCircle = GameImage.HITCIRCLE.getImage();
|
||||
color.a = alpha;
|
||||
Utils.COLOR_WHITE_FADE.a = 1f;
|
||||
|
||||
// end circle
|
||||
float[] endPos = curve.pointAt(1);
|
||||
|
@ -188,9 +189,7 @@ public class Slider implements HitObject {
|
|||
; // don't draw current combo number if already clicked
|
||||
else
|
||||
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
||||
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight());
|
||||
|
||||
color.a = oldAlpha;
|
||||
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), Utils.COLOR_WHITE_FADE);
|
||||
|
||||
// repeats
|
||||
for (int tcurRepeat = currentRepeats; tcurRepeat <= currentRepeats + 1; tcurRepeat++) {
|
||||
|
@ -217,7 +216,6 @@ public class Slider implements HitObject {
|
|||
|
||||
if (timeDiff >= 0) {
|
||||
// approach circle
|
||||
color.a = 1 - scale;
|
||||
GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color);
|
||||
} else {
|
||||
// Since update() might not have run before drawing during a replay, the
|
||||
|
@ -250,6 +248,8 @@ public class Slider implements HitObject {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Utils.COLOR_WHITE_FADE.a = oldAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -168,7 +168,7 @@ public class Spinner implements HitObject {
|
|||
GameImage.SPINNER_CLEAR.getImage().drawCentered(width / 2, height / 4);
|
||||
int extraRotations = (int) (rotations - rotationsNeeded);
|
||||
if (extraRotations > 0)
|
||||
data.drawSymbolNumber(extraRotations * 1000, width / 2, height * 2 / 3, 1.0f);
|
||||
data.drawSymbolNumber(extraRotations * 1000, width / 2, height * 2 / 3, 1.0f, Color.white);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user