From 34356d9c0814ac4eed7f448f69a77a0a33a7d231 Mon Sep 17 00:00:00 2001 From: MatteoS Date: Sat, 8 Aug 2015 21:12:02 +0200 Subject: [PATCH] Implement 'hidden' game mod --- src/itdelatrisu/opsu/GameMod.java | 2 +- src/itdelatrisu/opsu/objects/Circle.java | 10 ++++- src/itdelatrisu/opsu/objects/Slider.java | 53 ++++++++++++++---------- src/itdelatrisu/opsu/states/Game.java | 12 +++++- 4 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/itdelatrisu/opsu/GameMod.java b/src/itdelatrisu/opsu/GameMod.java index e6adb54c..7b8059d2 100644 --- a/src/itdelatrisu/opsu/GameMod.java +++ b/src/itdelatrisu/opsu/GameMod.java @@ -48,7 +48,7 @@ public enum GameMod { "DoubleTime", "Zoooooooooom."), // NIGHTCORE (Category.HARD, 2, GameImage.MOD_NIGHTCORE, "NT", 64, Input.KEY_D, 1.12f, // "Nightcore", "uguuuuuuuu"), - HIDDEN (Category.HARD, 3, GameImage.MOD_HIDDEN, "HD", 8, Input.KEY_F, 1.06f, false, + HIDDEN (Category.HARD, 3, GameImage.MOD_HIDDEN, "HD", 8, Input.KEY_F, 1.06f, "Hidden", "Play with no approach circles and fading notes for a slight score advantage."), FLASHLIGHT (Category.HARD, 4, GameImage.MOD_FLASHLIGHT, "FL", 1024, Input.KEY_G, 1.12f, "Flashlight", "Restricted view area."), diff --git a/src/itdelatrisu/opsu/objects/Circle.java b/src/itdelatrisu/opsu/objects/Circle.java index 5bc1681c..a4e762c3 100644 --- a/src/itdelatrisu/opsu/objects/Circle.java +++ b/src/itdelatrisu/opsu/objects/Circle.java @@ -97,11 +97,17 @@ public class Circle implements GameObject { 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 (GameMod.HIDDEN.isActive()) { + float fadeOutScale = -(float)(timeDiff-game.getApproachTime())/game.getDecayTime(); + float fadeOutAlpha = Utils.clamp(1-fadeOutScale, 0, 1); + alpha = Math.min(alpha, fadeOutAlpha); + } + float oldAlpha = Utils.COLOR_WHITE_FADE.a; Utils.COLOR_WHITE_FADE.a = color.a = alpha; - if (timeDiff >= 0) + if (timeDiff >= 0 && !GameMod.HIDDEN.isActive()) GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color); GameImage.HITCIRCLE.getImage().drawCentered(x, y, color); boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber(); diff --git a/src/itdelatrisu/opsu/objects/Slider.java b/src/itdelatrisu/opsu/objects/Slider.java index 2ba83c71..428c6ece 100644 --- a/src/itdelatrisu/opsu/objects/Slider.java +++ b/src/itdelatrisu/opsu/objects/Slider.java @@ -210,6 +210,11 @@ public class Slider implements GameObject { tick.drawCentered(c[0], c[1], Utils.COLOR_WHITE_FADE); } } + if (GameMod.HIDDEN.isActive()) { + float fadeOutScale = -(float)(timeDiff-game.getApproachTime())/game.getDecayTime(); + float fadeOutAlpha = Utils.clamp(1-fadeOutScale, 0, 1); + alpha = Math.min(alpha, fadeOutAlpha); + } if (sliderClickedInitial) ; // don't draw current combo number if already clicked else @@ -243,36 +248,38 @@ public class Slider implements GameObject { if (timeDiff >= 0) { // approach circle - GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color); + if(!GameMod.HIDDEN.isActive()) + GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color); } else { // Since update() might not have run before drawing during a replay, the // slider time may not have been calculated, which causes NAN numbers and flicker. if (sliderTime == 0) return; + + if(!GameMod.HIDDEN.isActive()){ + float[] c = curve.pointAt(getT(trackPosition, false)); + float[] c2 = curve.pointAt(getT(trackPosition, false) + 0.01f); - float[] c = curve.pointAt(getT(trackPosition, false)); - float[] c2 = curve.pointAt(getT(trackPosition, false) + 0.01f); + float t = getT(trackPosition, false); +// float dis = hitObject.getPixelLength() * HitObject.getXMultiplier() * (t - (int) t); +// Image sliderBallFrame = sliderBallImages[(int) (dis / (diameter * Math.PI) * 30) % sliderBallImages.length]; + Image sliderBallFrame = sliderBallImages[(int) (t * sliderTime * 60 / 1000) % sliderBallImages.length]; + float angle = (float) (Math.atan2(c2[1] - c[1], c2[0] - c[0]) * 180 / Math.PI); + sliderBallFrame.setRotation(angle); + sliderBallFrame.drawCentered(c[0], c[1]); - float t = getT(trackPosition, false); -// float dis = hitObject.getPixelLength() * HitObject.getXMultiplier() * (t - (int) t); -// Image sliderBallFrame = sliderBallImages[(int) (dis / (diameter * Math.PI) * 30) % sliderBallImages.length]; - Image sliderBallFrame = sliderBallImages[(int) (t * sliderTime * 60 / 1000) % sliderBallImages.length]; - float angle = (float) (Math.atan2(c2[1] - c[1], c2[0] - c[0]) * 180 / Math.PI); - sliderBallFrame.setRotation(angle); - sliderBallFrame.drawCentered(c[0], c[1]); - - // follow circle - if (followCircleActive) { - GameImage.SLIDER_FOLLOWCIRCLE.getImage().drawCentered(c[0], c[1]); - - // "flashlight" mod: dim the screen - if (GameMod.FLASHLIGHT.isActive()) { - float oldAlphaBlack = Utils.COLOR_BLACK_ALPHA.a; - Utils.COLOR_BLACK_ALPHA.a = 0.75f; - g.setColor(Utils.COLOR_BLACK_ALPHA); - g.fillRect(0, 0, containerWidth, containerHeight); - Utils.COLOR_BLACK_ALPHA.a = oldAlphaBlack; - } + // follow circle + if (followCircleActive) + GameImage.SLIDER_FOLLOWCIRCLE.getImage().drawCentered(c[0], c[1]); + + } + // "flashlight" mod: dim the screen + if (followCircleActive && GameMod.FLASHLIGHT.isActive()) { + float oldAlphaBlack = Utils.COLOR_BLACK_ALPHA.a; + Utils.COLOR_BLACK_ALPHA.a = 0.75f; + g.setColor(Utils.COLOR_BLACK_ALPHA); + g.fillRect(0, 0, containerWidth, containerHeight); + Utils.COLOR_BLACK_ALPHA.a = oldAlphaBlack; } } diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index bfc65705..ad6d04d3 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -117,6 +117,9 @@ public class Game extends BasicGameState { /** Hit object approach time, in milliseconds. */ private int approachTime; + /** Decay of elements in hidden mod, in milliseconds. */ + private int decayTime = 800; + /** Time offsets for obtaining each hit result (indexed by HIT_* constants). */ private int[] hitResultOffset; @@ -1329,7 +1332,8 @@ public class Game extends BasicGameState { gameObjects[stack.pop()].draw(g, trackPosition); // draw OsuHitObjectResult objects - data.drawHitResults(trackPosition); + if(!GameMod.HIDDEN.isActive()) + data.drawHitResults(trackPosition); } /** @@ -1515,6 +1519,12 @@ public class Game extends BasicGameState { */ public int getApproachTime() { return approachTime; } + + /** + * Returns the object decay time in hidden mod, in milliseconds. + */ + public int getDecayTime() { return decayTime; } + /** * Returns an array of hit result offset times, in milliseconds (indexed by GameData.HIT_* constants). */