Make music pitch and speed go down on fail (like in osu!)
This commit is contained in:
@@ -237,6 +237,15 @@ public class MusicController {
|
||||
player.fade(duration, 0f, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fades out the pitch (and speed) of the track.
|
||||
* @param duration the pitch fade time (in ms)
|
||||
*/
|
||||
public static void pitchFadeOut(int duration) {
|
||||
if (isPlaying())
|
||||
player.pitchFade(duration, 0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the position in the current track, in milliseconds.
|
||||
* If no track is loaded, 0 will be returned.
|
||||
@@ -316,7 +325,7 @@ public class MusicController {
|
||||
* @param pitch the new pitch
|
||||
*/
|
||||
public static void setPitch(float pitch) {
|
||||
SoundStore.get().setMusicPitch(pitch);
|
||||
player.setPitch(pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,4 +473,4 @@ public class MusicController {
|
||||
ErrorHandler.error("Failed to destroy OpenAL.", e, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.newdawn.slick.state.transition.FadeOutTransition;
|
||||
*/
|
||||
public class GamePauseMenu extends BasicGameState {
|
||||
/** Music fade-out time, in milliseconds. */
|
||||
private static final int FADEOUT_TIME = 1000;
|
||||
private static final int FADEOUT_TIME = 2000;
|
||||
|
||||
/** Track position when the pause menu was loaded (for FADEOUT_TIME). */
|
||||
private long pauseStartTime;
|
||||
@@ -207,6 +207,7 @@ public class GamePauseMenu extends BasicGameState {
|
||||
pauseStartTime = System.currentTimeMillis();
|
||||
if (gameState.getRestart() == Game.Restart.LOSE) {
|
||||
MusicController.fadeOut(FADEOUT_TIME);
|
||||
MusicController.pitchFadeOut(FADEOUT_TIME);
|
||||
SoundController.playSound(SoundEffect.FAIL);
|
||||
} else
|
||||
MusicController.pause();
|
||||
|
||||
Reference in New Issue
Block a user