aboutsummaryrefslogtreecommitdiff
path: root/src/main/SoundController.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2023-06-05 21:53:17 -0400
committersowgro <tpoke.ferrari@gmail.com>2023-06-05 21:53:17 -0400
commit229bd77d401beb005edfca1b3ce387e150ddd21d (patch)
tree220d4de5d1921829089c6b8b32fa221fdfe9c2a0 /src/main/SoundController.java
parent1709842a9ac8521f18296a79286a6361aa64bcc1 (diff)
downloadNPEhero-229bd77d401beb005edfca1b3ce387e150ddd21d.tar.gz
NPEhero-229bd77d401beb005edfca1b3ce387e150ddd21d.tar.bz2
NPEhero-229bd77d401beb005edfca1b3ce387e150ddd21d.zip
add level priority, fix sfx volume, fix settings file reading
Diffstat (limited to '')
-rw-r--r--src/main/SoundController.java28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/main/SoundController.java b/src/main/SoundController.java
index b3c6d23..c8e6c8a 100644
--- a/src/main/SoundController.java
+++ b/src/main/SoundController.java
@@ -11,15 +11,18 @@ public class SoundController
{
public MediaPlayer songMediaPlayer;
public MediaPlayer sfxMediaPlayer;
- private HashMap<String,File> presets = new HashMap<>();
+ private HashMap<String,MediaPlayer> effects = new HashMap<>();
private File mainMenuSong = new File("src/assets/fairyfountain.wav");
public SoundController()
{
- presets.put("forward", new File("src/assets/MenuForward.wav"));
- presets.put("backward", new File("src/assets/MenuBackward.wav"));
- presets.put("hit", new File("src/assets/Hitsound.wav"));
- presets.put("miss", new File("src/assets/Miss.wav"));
+ effects.put("hit", new MediaPlayer(new Media(new File("src/assets/hit.wav").toURI().toString())));
+ effects.put("miss", new MediaPlayer(new Media(new File("src/assets/miss.wav").toURI().toString())));
+ effects.put("forward", new MediaPlayer(new Media(new File("src/assets/forward.wav").toURI().toString())));
+ effects.put("backward", new MediaPlayer(new Media(new File("src/assets/backward.wav").toURI().toString())));
+ effects.forEach((key,value) -> {
+ value.volumeProperty().bind(Driver.settingsController.effectsVol);
+ });
playMenuSong();
}
@@ -50,20 +53,9 @@ public class SoundController
}
}
- public void playSfx(File sfxFile)
- {
- if (sfxMediaPlayer != null)
- {
- sfxMediaPlayer.stop();
- }
- Media sound = new Media(sfxFile.toURI().toString());
- sfxMediaPlayer = new MediaPlayer(sound);
- sfxMediaPlayer.volumeProperty().bind(Driver.settingsController.effectsVol); //not working yet
- sfxMediaPlayer.play();
- }
-
public void playSfx(String preset)
{
- playSfx(presets.get(preset));
+ effects.get(preset).stop();
+ effects.get(preset).play();
}
} \ No newline at end of file