From 18e57fdb9649e43834215c810665fd5be397ca64 Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Tue, 24 Mar 2015 01:03:58 -0400 Subject: [PATCH] Minor changes: fading game bg dim, initial flashlight radius fix. Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/states/Game.java | 25 +++++++++++++++-------- src/itdelatrisu/opsu/states/MainMenu.java | 9 +++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index b1ab778c..bdfc72ca 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -236,6 +236,14 @@ public class Game extends BasicGameState { throws SlickException { int width = container.getWidth(); int height = container.getHeight(); + int trackPosition = MusicController.getPosition(); + if (pauseTime > -1) // returning from pause screen + trackPosition = pauseTime; + else if (deathTime > -1) // "Easy" mod: health bar increasing + trackPosition = deathTime; + int firstObjectTime = osu.objects[0].getTime(); + int timeDiff = firstObjectTime - trackPosition; + g.setBackground(Color.black); // "flashlight" mod: initialize offscreen graphics @@ -246,6 +254,12 @@ public class Game extends BasicGameState { // background float dimLevel = Options.getBackgroundDim(); + if (trackPosition < firstObjectTime) { + if (timeDiff < approachTime) + dimLevel += (1f - dimLevel) * ((float) timeDiff / Math.min(approachTime, firstObjectTime)); + else + dimLevel = 1f; + } if (Options.isDefaultPlayfieldForced() || !osu.drawBG(width, height, dimLevel, false)) { Image playfield = GameImage.PLAYFIELD.getImage(); playfield.setAlpha(dimLevel); @@ -256,14 +270,6 @@ public class Game extends BasicGameState { if (GameMod.FLASHLIGHT.isActive()) Graphics.setCurrent(g); - int trackPosition = MusicController.getPosition(); - if (pauseTime > -1) // returning from pause screen - trackPosition = pauseTime; - else if (deathTime > -1) // "Easy" mod: health bar increasing - trackPosition = deathTime; - int firstObjectTime = osu.objects[0].getTime(); - int timeDiff = firstObjectTime - trackPosition; - // "auto" and "autopilot" mods: move cursor automatically // TODO: this should really be in update(), not render() autoMouseX = width / 2; @@ -280,7 +286,7 @@ public class Game extends BasicGameState { timeDiff = firstObjectTime - trackPosition; if (timeDiff < approachTime) { float[] xy = hitObjects[0].getPointAt(trackPosition); - autoXY = getPointAt(autoMouseX, autoMouseY, xy[0], xy[1], 1f - ((float) timeDiff / approachTime)); + autoXY = getPointAt(autoMouseX, autoMouseY, xy[0], xy[1], 1f - ((float) timeDiff / Math.min(approachTime, firstObjectTime))); } } else if (objectIndex < osu.objects.length) { // normal object @@ -1236,6 +1242,7 @@ public class Game extends BasicGameState { autoMouseX = 0; autoMouseY = 0; autoMousePressed = false; + flashlightRadius = container.getHeight() * 2 / 3; System.gc(); } diff --git a/src/itdelatrisu/opsu/states/MainMenu.java b/src/itdelatrisu/opsu/states/MainMenu.java index b4534910..cc879207 100644 --- a/src/itdelatrisu/opsu/states/MainMenu.java +++ b/src/itdelatrisu/opsu/states/MainMenu.java @@ -63,6 +63,9 @@ public class MainMenu extends BasicGameState { /** Idle time, in milliseconds, before returning the logo to its original position. */ private static final short MOVE_DELAY = 5000; + /** Max alpha level of the menu background. */ + private static final float BG_MAX_ALPHA = 0.9f; + /** Logo button that reveals other buttons on click. */ private MenuButton logo; @@ -319,10 +322,10 @@ public class MainMenu extends BasicGameState { MusicController.toggleTrackDimmed(0.33f); // fade in background - if (bgAlpha < 0.9f) { + if (bgAlpha < BG_MAX_ALPHA) { bgAlpha += delta / 1000f; - if (bgAlpha > 0.9f) - bgAlpha = 0.9f; + if (bgAlpha > BG_MAX_ALPHA) + bgAlpha = BG_MAX_ALPHA; } // buttons