diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/SettingsController.java | 6 | ||||
-rw-r--r-- | src/main/SoundController.java | 22 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/main/SettingsController.java b/src/main/SettingsController.java index b7b2cb9..3304dd4 100644 --- a/src/main/SettingsController.java +++ b/src/main/SettingsController.java @@ -19,6 +19,9 @@ public class SettingsController read();
}
+ /**
+ * reads json data from settings.json
+ */
public void read()
{
JSONParser jsonParser = new JSONParser(); //parser to read the file
@@ -37,6 +40,9 @@ public class SettingsController }
}
+ /**
+ * writes json data to settings.json
+ */
public void write()
{
FileWriter fileWriter;
diff --git a/src/main/SoundController.java b/src/main/SoundController.java index c8e6c8a..8f255da 100644 --- a/src/main/SoundController.java +++ b/src/main/SoundController.java @@ -6,6 +6,7 @@ import java.util.HashMap; import gui.Driver; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; +import javafx.util.Duration; public class SoundController { @@ -14,6 +15,9 @@ public class SoundController private HashMap<String,MediaPlayer> effects = new HashMap<>(); private File mainMenuSong = new File("src/assets/fairyfountain.wav"); + /** + * creates a new sound controller and starts playing the main menu music + */ public SoundController() { effects.put("hit", new MediaPlayer(new Media(new File("src/assets/hit.wav").toURI().toString()))); @@ -26,6 +30,10 @@ public class SoundController playMenuSong(); } + /** + * plays the song that is passed in. + * @param songFile: the song + */ public void playSong(File songFile) { if (songMediaPlayer != null) @@ -38,6 +46,9 @@ public class SoundController songMediaPlayer.play(); } + /** + * plays the main menu song + */ public void playMenuSong() { playSong(mainMenuSong); @@ -45,6 +56,9 @@ public class SoundController songMediaPlayer.play(); } + /** + * stops the currently playing song + */ public void endSong() { if (songMediaPlayer != null) @@ -53,9 +67,15 @@ public class SoundController } } + /** + * plays a sound effect + * for the volume slider to take affect each mediaplayer needs to be pre loaded. + * this rewinds and played the proper mediaplayer for the sound + * @param preset: a string of the name of the sound. possible sounds assigned in the constructor + */ public void playSfx(String preset) { - effects.get(preset).stop(); + effects.get(preset).seek(new Duration(0)); effects.get(preset).play(); } }
\ No newline at end of file |