diff --git a/core/assets/sounds/HMO-MercuryCity.mp3 b/core/assets/sounds/HMO-MercuryCity.mp3 new file mode 100644 index 0000000..b24d22f Binary files /dev/null and b/core/assets/sounds/HMO-MercuryCity.mp3 differ diff --git a/core/assets/sounds/Metre - Concentric.mp3 b/core/assets/sounds/Metre - Concentric.mp3 new file mode 100644 index 0000000..c362ab4 Binary files /dev/null and b/core/assets/sounds/Metre - Concentric.mp3 differ diff --git a/core/assets/sounds/bensound-house.mp3 b/core/assets/sounds/bensound-house.mp3 new file mode 100644 index 0000000..d0192f0 Binary files /dev/null and b/core/assets/sounds/bensound-house.mp3 differ diff --git a/core/src/sagittarius/SagittariusGame.java b/core/src/sagittarius/SagittariusGame.java index d3f1580..175ca40 100644 --- a/core/src/sagittarius/SagittariusGame.java +++ b/core/src/sagittarius/SagittariusGame.java @@ -12,6 +12,8 @@ public class SagittariusGame extends Game { public static float G = 100; public static boolean debugMode = true; public static Music music; + public static boolean disableMusic= false; + public static float musicVolume= 0.5f; public static boolean disableSounds = false; public static float soundsVolume = 0.5f; private static Game game; @@ -31,14 +33,6 @@ public class SagittariusGame extends Game { @Override public void create() { - // A welcome music is played - music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3")); - music.setLooping(true); - music.play(); - - // Default volume - music.setVolume(0.3f); - // We load the VisUI library VisUI.load(); diff --git a/core/src/sagittarius/view/BaseScreen.java b/core/src/sagittarius/view/BaseScreen.java index f5eac65..d62e97a 100644 --- a/core/src/sagittarius/view/BaseScreen.java +++ b/core/src/sagittarius/view/BaseScreen.java @@ -4,6 +4,8 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL30; import com.badlogic.gdx.scenes.scene2d.Stage; +import sagittarius.SagittariusGame; + import com.badlogic.gdx.Screen; public abstract class BaseScreen implements Screen { @@ -42,6 +44,8 @@ public abstract class BaseScreen implements Screen { } @Override public void dispose() { + + SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3")); uiStage.dispose(); mainStage.dispose(); } diff --git a/core/src/sagittarius/view/GameScreen.java b/core/src/sagittarius/view/GameScreen.java index 8e317b6..6954da1 100644 --- a/core/src/sagittarius/view/GameScreen.java +++ b/core/src/sagittarius/view/GameScreen.java @@ -48,6 +48,13 @@ public class GameScreen extends BaseScreen implements InputProcessor { @Override public void initialize() { + if (SagittariusGame.music.isPlaying()){ + SagittariusGame.music.stop(); + SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/HMO-MercuryCity.mp3")); + SagittariusGame.music.setLooping(true); + SagittariusGame.music.play(); + } + Gdx.input.setInputProcessor(this); // arrows diff --git a/core/src/sagittarius/view/SettingsScreen.java b/core/src/sagittarius/view/SettingsScreen.java index ebb867e..b373568 100644 --- a/core/src/sagittarius/view/SettingsScreen.java +++ b/core/src/sagittarius/view/SettingsScreen.java @@ -18,6 +18,11 @@ public class SettingsScreen extends BaseScreen { @Override public void initialize() { + SagittariusGame.music.stop(); + SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Metre - Concentric.mp3")); + SagittariusGame.music.setLooping(true); + SagittariusGame.music.play(); + Gdx.input.setInputProcessor(uiStage); // Table creation @@ -35,7 +40,8 @@ public class SettingsScreen extends BaseScreen { // disable music checkbox VisCheckBox disableMusic = new VisCheckBox("disable music"); - + disableMusic.setChecked(SagittariusGame.disableMusic); + // Change volume of the music Spinner musicVolume= new Spinner("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3)); @@ -58,6 +64,14 @@ public class SettingsScreen extends BaseScreen { SagittariusGame.soundsVolume = Float.parseFloat(musicVolume.getTextField().getText()); SagittariusGame.debugMode = debugModeBox.isChecked(); + // Deactivate music or not + if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()){ + SagittariusGame.music.stop(); + } + + else if (!disableMusic.isChecked() && ! SagittariusGame.music.isPlaying()){ + SagittariusGame.music.play(); + } } }); diff --git a/core/src/sagittarius/view/StartScreen.java b/core/src/sagittarius/view/StartScreen.java index 9732c8f..83f5344 100644 --- a/core/src/sagittarius/view/StartScreen.java +++ b/core/src/sagittarius/view/StartScreen.java @@ -14,6 +14,23 @@ public class StartScreen extends BaseScreen { @Override public void initialize() { + // A welcome music is played + if (!SagittariusGame.disableMusic){ + if ( SagittariusGame.music != null ){ + SagittariusGame.music.stop(); + SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3")); + SagittariusGame.music.setLooping(true); + SagittariusGame.music.play(); + } + + else { + SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3")); + SagittariusGame.music.setLooping(true); + SagittariusGame.music.play(); + } + + } + Gdx.input.setInputProcessor(uiStage); // Table creation