diff --git a/core/src/sagittarius/SagittariusGame.java b/core/src/sagittarius/SagittariusGame.java index 001fdc1..10480e6 100644 --- a/core/src/sagittarius/SagittariusGame.java +++ b/core/src/sagittarius/SagittariusGame.java @@ -1,8 +1,11 @@ package sagittarius; import com.badlogic.gdx.Game; +import com.badlogic.gdx.Gdx; import com.kotcrab.vis.ui.VisUI; - +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.files.*; import sagittarius.view.*; public class SagittariusGame extends Game { @@ -10,7 +13,7 @@ public class SagittariusGame extends Game { // Constants public static float G = 100; public static boolean debugMode = true; - + public static Music music; private static Game game; public SagittariusGame() { @@ -27,6 +30,14 @@ 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.play(); + + // Default volume + music.setVolume(0.3f); + VisUI.load(); game.setScreen(new SettingsScreen()); } diff --git a/core/src/sagittarius/view/SettingsScreen.java b/core/src/sagittarius/view/SettingsScreen.java index 7691124..675c536 100644 --- a/core/src/sagittarius/view/SettingsScreen.java +++ b/core/src/sagittarius/view/SettingsScreen.java @@ -13,13 +13,14 @@ import com.kotcrab.vis.ui.widget.VisTextButton; import com.kotcrab.vis.ui.widget.spinner.SimpleFloatSpinnerModel; import com.kotcrab.vis.ui.widget.spinner.Spinner; + import sagittarius.SagittariusGame; public class SettingsScreen extends BaseScreen { @Override public void initialize() { - + Gdx.input.setInputProcessor(uiStage); // Table creation @@ -34,6 +35,12 @@ public class SettingsScreen extends BaseScreen { VisCheckBox debugModeBox = new VisCheckBox("debug mode"); debugModeBox.setChecked(SagittariusGame.debugMode); + + + // Change volume of the music + Spinner musicVolume= new Spinner("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3)); + + // save button VisTextButton saveButton = new VisTextButton("Save"); saveButton.addListener(new ActorGestureListener() { @@ -42,6 +49,7 @@ public class SettingsScreen extends BaseScreen { super.tap(event, x, y, count, button); SagittariusGame.G = Float.parseFloat(gConstField.getTextField().getText()); + SagittariusGame.music.setVolume(Float.parseFloat(musicVolume.getTextField().getText())); SagittariusGame.debugMode = debugModeBox.isChecked(); } @@ -60,6 +68,8 @@ public class SettingsScreen extends BaseScreen { // Table structure table.add(gConstField).width(250); table.row(); + table.add(musicVolume).width(250); + table.row(); table.add(debugModeBox).align(Align.left); table.row(); table.add(saveButton).width(250);