From efe0f640d891f527fa5fb398bb9c1387b43828a7 Mon Sep 17 00:00:00 2001 From: Cheese581 <51549948+Cheese581@users.noreply.github.com> Date: Sat, 18 May 2024 15:22:24 -0400 Subject: [PATCH] RHuipfyhr AAAAAAAAAAAAAAAAAAA --- .../cornell/gdiac/rabbeat/GameController.java | 11 ++++++++++- .../cornell/gdiac/rabbeat/SoundController.java | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/core/src/edu/cornell/gdiac/rabbeat/GameController.java b/core/src/edu/cornell/gdiac/rabbeat/GameController.java index 42f8a71c..8844436b 100644 --- a/core/src/edu/cornell/gdiac/rabbeat/GameController.java +++ b/core/src/edu/cornell/gdiac/rabbeat/GameController.java @@ -537,6 +537,13 @@ public void gatherAssets(AssetDirectory directory) { * @param directory Reference to global asset manager. */ public void setSoundtrack(AssetDirectory directory) { + soundController.USE_INSTANT_SWITCH = false; + if (synthSoundtrack != null) { + synthSoundtrack.dispose(); + } + if (jazzSoundtrack != null) { + jazzSoundtrack.dispose(); + } synthSoundtrack = directory.getEntry( objectController.defaultConstants.get("music").get(getCurrentLevel()) .getString("synth"), Music.class); @@ -688,6 +695,7 @@ public void initialize() { worldHeight = DEFAULT_HEIGHT * objectController.levelBackground.getRegionHeight() / getCanvas().getHeight(); world.setContactListener(this); + //soundController.pauseMusic(); soundController.resetMusic(); soundController.playMusic(genre); syncController.initializeSync(); @@ -951,6 +959,7 @@ public void beginContact(Contact contact) { if ((bd1 == objectController.player && bd2 == objectController.goalDoor) || (bd1 == objectController.goalDoor && bd2 == objectController.player)) { setComplete(true); + soundController.USE_INSTANT_SWITCH = true; } // Bullet and Bee Collision checks @@ -1489,6 +1498,7 @@ public void pause () { */ public void resume () { soundController.setGlobalMusicVolumeImmediate(musicVolume / 10f); + soundController.setGlobalSFXVolume(SFXVolume / 10f); // soundController.resumeMusic(); @@ -1618,7 +1628,6 @@ public int getNumberOfLevels () { /** Called when the game screen needs to be exited out of */ public void exitScreen ( int exitCode){ - soundController.pauseMusic(); listener.exitScreen(this, exitCode); } diff --git a/core/src/edu/cornell/gdiac/rabbeat/SoundController.java b/core/src/edu/cornell/gdiac/rabbeat/SoundController.java index 5e24e70e..3276a2a5 100644 --- a/core/src/edu/cornell/gdiac/rabbeat/SoundController.java +++ b/core/src/edu/cornell/gdiac/rabbeat/SoundController.java @@ -28,7 +28,7 @@ public class SoundController { * Set this to true to make genre switches instantaneous / in one frame. * Set this to false to make genre switches gradual / over several frames. */ - private static final boolean USE_INSTANT_SWITCH = false; + public static boolean USE_INSTANT_SWITCH = false; /** What percentage of volume should be kept when pausing. * A value of 0.4 means the track will be 40% as loud as it normally would be. @@ -57,6 +57,8 @@ public SoundController() { public void playMusic() { synthTrack.setLooping(true); jazzTrack.setLooping(true); + currentlyUpdating = false; + currentUpdateFrame = 0; synthTrack.play(); jazzTrack.play(); } @@ -103,6 +105,19 @@ public void setGlobalMusicVolumeImmediate(float vol, boolean paused) { jazzTrack.setVolume(vol * (paused ? PAUSE_VOL : 1)); synthTrack.setVolume(0); } + if (synthTrack.getVolume() > 1) { + synthTrack.setVolume(1); + } + if (jazzTrack.getVolume() > 1) { + jazzTrack.setVolume(1); + } + + if (synthTrack.getVolume() < 0) { + synthTrack.setVolume(0); + } + if (jazzTrack.getVolume() < 0) { + jazzTrack.setVolume(0); + } } public void resetMusic() { @@ -113,7 +128,6 @@ public void resetMusic() { currentlyUpdating = false; currentUpdateFrame = 0; } - public void pauseMusic() { /*savedJazzVolume = jazzTrack.getVolume(); savedSynthVolume = synthTrack.getVolume();