Minor changes: fading game bg dim, initial flashlight radius fix.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-03-24 01:03:58 -04:00
parent a6ece307ff
commit 18e57fdb96
2 changed files with 22 additions and 12 deletions

View File

@ -236,6 +236,14 @@ public class Game extends BasicGameState {
throws SlickException { throws SlickException {
int width = container.getWidth(); int width = container.getWidth();
int height = container.getHeight(); 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); g.setBackground(Color.black);
// "flashlight" mod: initialize offscreen graphics // "flashlight" mod: initialize offscreen graphics
@ -246,6 +254,12 @@ public class Game extends BasicGameState {
// background // background
float dimLevel = Options.getBackgroundDim(); 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)) { if (Options.isDefaultPlayfieldForced() || !osu.drawBG(width, height, dimLevel, false)) {
Image playfield = GameImage.PLAYFIELD.getImage(); Image playfield = GameImage.PLAYFIELD.getImage();
playfield.setAlpha(dimLevel); playfield.setAlpha(dimLevel);
@ -256,14 +270,6 @@ public class Game extends BasicGameState {
if (GameMod.FLASHLIGHT.isActive()) if (GameMod.FLASHLIGHT.isActive())
Graphics.setCurrent(g); 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 // "auto" and "autopilot" mods: move cursor automatically
// TODO: this should really be in update(), not render() // TODO: this should really be in update(), not render()
autoMouseX = width / 2; autoMouseX = width / 2;
@ -280,7 +286,7 @@ public class Game extends BasicGameState {
timeDiff = firstObjectTime - trackPosition; timeDiff = firstObjectTime - trackPosition;
if (timeDiff < approachTime) { if (timeDiff < approachTime) {
float[] xy = hitObjects[0].getPointAt(trackPosition); 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) { } else if (objectIndex < osu.objects.length) {
// normal object // normal object
@ -1236,6 +1242,7 @@ public class Game extends BasicGameState {
autoMouseX = 0; autoMouseX = 0;
autoMouseY = 0; autoMouseY = 0;
autoMousePressed = false; autoMousePressed = false;
flashlightRadius = container.getHeight() * 2 / 3;
System.gc(); System.gc();
} }

View File

@ -63,6 +63,9 @@ public class MainMenu extends BasicGameState {
/** Idle time, in milliseconds, before returning the logo to its original position. */ /** Idle time, in milliseconds, before returning the logo to its original position. */
private static final short MOVE_DELAY = 5000; 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. */ /** Logo button that reveals other buttons on click. */
private MenuButton logo; private MenuButton logo;
@ -319,10 +322,10 @@ public class MainMenu extends BasicGameState {
MusicController.toggleTrackDimmed(0.33f); MusicController.toggleTrackDimmed(0.33f);
// fade in background // fade in background
if (bgAlpha < 0.9f) { if (bgAlpha < BG_MAX_ALPHA) {
bgAlpha += delta / 1000f; bgAlpha += delta / 1000f;
if (bgAlpha > 0.9f) if (bgAlpha > BG_MAX_ALPHA)
bgAlpha = 0.9f; bgAlpha = BG_MAX_ALPHA;
} }
// buttons // buttons