diff --git a/bin/de/bricked/resources/sounds/destroy_brick.mp3 b/bin/de/bricked/resources/sounds/destroy_brick.mp3 deleted file mode 100644 index 188f9704a00f3421a37a438580cd8c0c7af71903..0000000000000000000000000000000000000000 Binary files a/bin/de/bricked/resources/sounds/destroy_brick.mp3 and /dev/null differ diff --git a/bin/de/bricked/resources/sounds/destroy_brick.wav b/bin/de/bricked/resources/sounds/destroy_brick.wav new file mode 100644 index 0000000000000000000000000000000000000000..59cc7da0dc99466bce481c2fceca90b1af20bdb6 Binary files /dev/null and b/bin/de/bricked/resources/sounds/destroy_brick.wav differ diff --git a/bin/de/bricked/resources/sounds/finished_level.mp3 b/bin/de/bricked/resources/sounds/finished_level.mp3 deleted file mode 100644 index 7b190396ae0060beca3709f697a1c4f8cb7c1003..0000000000000000000000000000000000000000 Binary files a/bin/de/bricked/resources/sounds/finished_level.mp3 and /dev/null differ diff --git a/bin/de/bricked/resources/sounds/finished_level.wav b/bin/de/bricked/resources/sounds/finished_level.wav new file mode 100644 index 0000000000000000000000000000000000000000..4a5fa028b6e2da883faca1e6c2e07e93d4656375 Binary files /dev/null and b/bin/de/bricked/resources/sounds/finished_level.wav differ diff --git a/bin/de/bricked/resources/sounds/game_over.mp3 b/bin/de/bricked/resources/sounds/game_over.mp3 deleted file mode 100644 index 80148d9cdd4ee2bb79d38b46b8f2e332682a2dbd..0000000000000000000000000000000000000000 Binary files a/bin/de/bricked/resources/sounds/game_over.mp3 and /dev/null differ diff --git a/bin/de/bricked/resources/sounds/game_over.wav b/bin/de/bricked/resources/sounds/game_over.wav new file mode 100644 index 0000000000000000000000000000000000000000..4b5007c5812fc41a28b6467509fffdcc5786a02c Binary files /dev/null and b/bin/de/bricked/resources/sounds/game_over.wav differ diff --git a/bin/de/bricked/resources/sounds/hit_brick.mp3 b/bin/de/bricked/resources/sounds/hit_brick.mp3 deleted file mode 100644 index 80dae7bf515d60865328b6fd9e6e59ddd97fb25f..0000000000000000000000000000000000000000 Binary files a/bin/de/bricked/resources/sounds/hit_brick.mp3 and /dev/null differ diff --git a/bin/de/bricked/resources/sounds/hit_brick.wav b/bin/de/bricked/resources/sounds/hit_brick.wav new file mode 100644 index 0000000000000000000000000000000000000000..b0fc1d251bdf03a8007bdb8784a2bdfe4f85f72e Binary files /dev/null and b/bin/de/bricked/resources/sounds/hit_brick.wav differ diff --git a/bin/de/bricked/resources/sounds/hit_paddle.mp3 b/bin/de/bricked/resources/sounds/hit_paddle.mp3 deleted file mode 100644 index d57dd2687c1d7614940b655e80a357add37c0107..0000000000000000000000000000000000000000 Binary files a/bin/de/bricked/resources/sounds/hit_paddle.mp3 and /dev/null differ diff --git a/bin/de/bricked/resources/sounds/hit_paddle.wav b/bin/de/bricked/resources/sounds/hit_paddle.wav new file mode 100644 index 0000000000000000000000000000000000000000..a1b047deaf395c676b398d22a64aaa1122dfc58f Binary files /dev/null and b/bin/de/bricked/resources/sounds/hit_paddle.wav differ diff --git a/bin/de/bricked/resources/sounds/hit_wall.mp3 b/bin/de/bricked/resources/sounds/hit_wall.mp3 deleted file mode 100644 index 89e45f6bc237c7d5f3714d315e6b81346bcc4653..0000000000000000000000000000000000000000 Binary files a/bin/de/bricked/resources/sounds/hit_wall.mp3 and /dev/null differ diff --git a/bin/de/bricked/resources/sounds/hit_wall.wav b/bin/de/bricked/resources/sounds/hit_wall.wav new file mode 100644 index 0000000000000000000000000000000000000000..b040a4191e67f2a03344493c6b3923f85d0f2cbd Binary files /dev/null and b/bin/de/bricked/resources/sounds/hit_wall.wav differ diff --git a/bin/de/bricked/resources/sounds/life_lost.mp3 b/bin/de/bricked/resources/sounds/life_lost.mp3 deleted file mode 100644 index 9ae1796065f2db2cf15377e42aacd97cfd590350..0000000000000000000000000000000000000000 Binary files a/bin/de/bricked/resources/sounds/life_lost.mp3 and /dev/null differ diff --git a/bin/de/bricked/resources/sounds/life_lost.wav b/bin/de/bricked/resources/sounds/life_lost.wav new file mode 100644 index 0000000000000000000000000000000000000000..dabc3615f1f22429e487d397dab39d98d73bd034 Binary files /dev/null and b/bin/de/bricked/resources/sounds/life_lost.wav differ diff --git a/bin/de/bricked/resources/sounds/tnt.mp3 b/bin/de/bricked/resources/sounds/tnt.mp3 deleted file mode 100644 index 308c229c4fb80b2cceb8d98b78fe03ab06f35fba..0000000000000000000000000000000000000000 Binary files a/bin/de/bricked/resources/sounds/tnt.mp3 and /dev/null differ diff --git a/bin/de/bricked/resources/sounds/tnt.wav b/bin/de/bricked/resources/sounds/tnt.wav new file mode 100644 index 0000000000000000000000000000000000000000..581b5f56fe2a20303119d1292140c9c383410a21 Binary files /dev/null and b/bin/de/bricked/resources/sounds/tnt.wav differ diff --git a/bin/de/bricked/resources/sounds/unlocked.mp3 b/bin/de/bricked/resources/sounds/unlocked.mp3 deleted file mode 100644 index fc3562c1d3c1a4cb3d58a2cffb2ff444197972d1..0000000000000000000000000000000000000000 Binary files a/bin/de/bricked/resources/sounds/unlocked.mp3 and /dev/null differ diff --git a/bin/de/bricked/resources/sounds/unlocked.wav b/bin/de/bricked/resources/sounds/unlocked.wav new file mode 100644 index 0000000000000000000000000000000000000000..065a5ea5d8a3e3702d95c654d5fa5ddcbc0d6a83 Binary files /dev/null and b/bin/de/bricked/resources/sounds/unlocked.wav differ diff --git a/lib/TinySound.jar b/lib/TinySound.jar new file mode 100644 index 0000000000000000000000000000000000000000..64ca033f246d9f2ff8a1581eb5108527ddd8c82a Binary files /dev/null and b/lib/TinySound.jar differ diff --git a/lib/jorbis-0.0.17.jar b/lib/jorbis-0.0.17.jar new file mode 100644 index 0000000000000000000000000000000000000000..d3de17562e25380623c34e6d14b9b92177617cc0 Binary files /dev/null and b/lib/jorbis-0.0.17.jar differ diff --git a/lib/tritonus_share.jar b/lib/tritonus_share.jar new file mode 100644 index 0000000000000000000000000000000000000000..d21ba89ad75ad7ce561c1d21c42034ae5c677d6b Binary files /dev/null and b/lib/tritonus_share.jar differ diff --git a/lib/vorbisspi1.0.3.jar b/lib/vorbisspi1.0.3.jar new file mode 100644 index 0000000000000000000000000000000000000000..cd65017665e93baaac718888dfb407ff090fbea6 Binary files /dev/null and b/lib/vorbisspi1.0.3.jar differ diff --git a/src/de/bricked/game/board/Board.java b/src/de/bricked/game/board/Board.java index 2474070ac7927baf93eb52cf67509a5b169cdef0..e684131b7a0c3ac32e02f05086718e38112cc6f1 100644 --- a/src/de/bricked/game/board/Board.java +++ b/src/de/bricked/game/board/Board.java @@ -179,22 +179,22 @@ public class Board } bricks.get(row).set(col, new Brick(BrickType.TNT)); - destroyBrick(row, col, false); + destroyBrick(row, col, false, false); break; case NO_COLLISION: - destroyBrick(row, col, true); + destroyBrick(row, col, true, true); break; default: - destroyBrick(row, col, false); + destroyBrick(row, col, false, true); break; } return points; } - public void destroyBrick(int row, int col, boolean instantDestroy) + public void destroyBrick(int row, int col, boolean instantDestroy, boolean playDestroySound) { Brick hittedBrick = bricks.get(row).get(col); @@ -215,7 +215,10 @@ public class Board } else { - game.getSoundHandler().play(SoundType.DESTROY_BRICK); + if(playDestroySound) + { + game.getSoundHandler().play(SoundType.DESTROY_BRICK); + } } if(hittedBrick.getPowerUp() != null) @@ -253,7 +256,7 @@ public class Board { if(k >= 0 && k < WIDTH) { - destroyBrick(i, k, true); + destroyBrick(i, k, true, true); } } } diff --git a/src/de/bricked/game/sound/SoundHandler.java b/src/de/bricked/game/sound/SoundHandler.java index f37a3593ea8b97c88a120a47551b29d4d200e6a7..34419b33f5468dcacfdfb70e750be64ad73398b4 100644 --- a/src/de/bricked/game/sound/SoundHandler.java +++ b/src/de/bricked/game/sound/SoundHandler.java @@ -2,12 +2,12 @@ package de.bricked.game.sound; import java.net.MalformedURLException; import java.net.URISyntaxException; +import java.net.URL; import java.util.HashMap; import de.bricked.game.Config; -import javafx.scene.media.Media; -import javafx.scene.media.MediaPlayer; -import javafx.scene.media.MediaPlayer.Status; +import kuusisto.tinysound.Sound; +import kuusisto.tinysound.TinySound; import logger.LogLevel; import logger.Logger; @@ -15,29 +15,30 @@ public class SoundHandler { private double volume; private boolean muted; - private HashMap<SoundType, MediaPlayer> mediaPlayers; + private HashMap<SoundType, Sound> mediaPlayers; + private int tntCounter; + + static + { + TinySound.init(); + } public SoundHandler(double volume, boolean muted) { this.volume = volume; this.muted = muted; + this.tntCounter = 0; - mediaPlayers = new HashMap<>(); + mediaPlayers = new HashMap<>(); for(SoundType currentType : SoundType.values()) { try { - String path = SoundHandler.class.getResource(Config.JAR_SOUND_SAVEDIR + currentType.getFileName() + ".mp3").toURI().toURL().toString(); - Media sound = new Media(path); - MediaPlayer mediaPlayer = new MediaPlayer(sound); - mediaPlayer.setVolume(volume); - mediaPlayer.setAutoPlay(false); - mediaPlayer.setOnEndOfMedia(()->{ - mediaPlayer.stop(); - }); - - mediaPlayers.put(currentType, mediaPlayer); + URL path = SoundHandler.class.getResource(Config.JAR_SOUND_SAVEDIR + currentType.getFileName() + ".wav").toURI().toURL(); + + Sound sound = TinySound.loadSound(path); + mediaPlayers.put(currentType, sound); } catch(MalformedURLException | URISyntaxException e) { @@ -47,17 +48,22 @@ public class SoundHandler } public void play(SoundType soundType) - { + { if(volume > 0 && !muted) - { - MediaPlayer player = mediaPlayers.get(soundType); + { + Sound player = mediaPlayers.get(soundType); + if(soundType.equals(SoundType.TNT)) + { + tntCounter++; + } + else + { + tntCounter = 0; + } - if(player != null) - { - if(!player.getStatus().equals(Status.PLAYING)) - { - player.play(); - } + if(player != null && tntCounter < 2) + { + player.play(volume); } } } @@ -81,4 +87,12 @@ public class SoundHandler { this.muted = muted; } + + public void stopAll() + { + for(Sound currentSound : mediaPlayers.values()) + { + currentSound.stop(); + } + } } \ No newline at end of file diff --git a/src/de/bricked/resources/sounds/destroy_brick.mp3 b/src/de/bricked/resources/sounds/destroy_brick.mp3 deleted file mode 100644 index 188f9704a00f3421a37a438580cd8c0c7af71903..0000000000000000000000000000000000000000 Binary files a/src/de/bricked/resources/sounds/destroy_brick.mp3 and /dev/null differ diff --git a/src/de/bricked/resources/sounds/destroy_brick.wav b/src/de/bricked/resources/sounds/destroy_brick.wav new file mode 100644 index 0000000000000000000000000000000000000000..59cc7da0dc99466bce481c2fceca90b1af20bdb6 Binary files /dev/null and b/src/de/bricked/resources/sounds/destroy_brick.wav differ diff --git a/src/de/bricked/resources/sounds/finished_level.mp3 b/src/de/bricked/resources/sounds/finished_level.mp3 deleted file mode 100644 index 7b190396ae0060beca3709f697a1c4f8cb7c1003..0000000000000000000000000000000000000000 Binary files a/src/de/bricked/resources/sounds/finished_level.mp3 and /dev/null differ diff --git a/src/de/bricked/resources/sounds/finished_level.wav b/src/de/bricked/resources/sounds/finished_level.wav new file mode 100644 index 0000000000000000000000000000000000000000..4a5fa028b6e2da883faca1e6c2e07e93d4656375 Binary files /dev/null and b/src/de/bricked/resources/sounds/finished_level.wav differ diff --git a/src/de/bricked/resources/sounds/game_over.mp3 b/src/de/bricked/resources/sounds/game_over.mp3 deleted file mode 100644 index 80148d9cdd4ee2bb79d38b46b8f2e332682a2dbd..0000000000000000000000000000000000000000 Binary files a/src/de/bricked/resources/sounds/game_over.mp3 and /dev/null differ diff --git a/src/de/bricked/resources/sounds/game_over.wav b/src/de/bricked/resources/sounds/game_over.wav new file mode 100644 index 0000000000000000000000000000000000000000..4b5007c5812fc41a28b6467509fffdcc5786a02c Binary files /dev/null and b/src/de/bricked/resources/sounds/game_over.wav differ diff --git a/src/de/bricked/resources/sounds/hit_brick.mp3 b/src/de/bricked/resources/sounds/hit_brick.mp3 deleted file mode 100644 index 80dae7bf515d60865328b6fd9e6e59ddd97fb25f..0000000000000000000000000000000000000000 Binary files a/src/de/bricked/resources/sounds/hit_brick.mp3 and /dev/null differ diff --git a/src/de/bricked/resources/sounds/hit_brick.wav b/src/de/bricked/resources/sounds/hit_brick.wav new file mode 100644 index 0000000000000000000000000000000000000000..b0fc1d251bdf03a8007bdb8784a2bdfe4f85f72e Binary files /dev/null and b/src/de/bricked/resources/sounds/hit_brick.wav differ diff --git a/src/de/bricked/resources/sounds/hit_paddle.mp3 b/src/de/bricked/resources/sounds/hit_paddle.mp3 deleted file mode 100644 index d57dd2687c1d7614940b655e80a357add37c0107..0000000000000000000000000000000000000000 Binary files a/src/de/bricked/resources/sounds/hit_paddle.mp3 and /dev/null differ diff --git a/src/de/bricked/resources/sounds/hit_paddle.wav b/src/de/bricked/resources/sounds/hit_paddle.wav new file mode 100644 index 0000000000000000000000000000000000000000..a1b047deaf395c676b398d22a64aaa1122dfc58f Binary files /dev/null and b/src/de/bricked/resources/sounds/hit_paddle.wav differ diff --git a/src/de/bricked/resources/sounds/hit_wall.mp3 b/src/de/bricked/resources/sounds/hit_wall.mp3 deleted file mode 100644 index 89e45f6bc237c7d5f3714d315e6b81346bcc4653..0000000000000000000000000000000000000000 Binary files a/src/de/bricked/resources/sounds/hit_wall.mp3 and /dev/null differ diff --git a/src/de/bricked/resources/sounds/hit_wall.wav b/src/de/bricked/resources/sounds/hit_wall.wav new file mode 100644 index 0000000000000000000000000000000000000000..b040a4191e67f2a03344493c6b3923f85d0f2cbd Binary files /dev/null and b/src/de/bricked/resources/sounds/hit_wall.wav differ diff --git a/src/de/bricked/resources/sounds/life_lost.mp3 b/src/de/bricked/resources/sounds/life_lost.mp3 deleted file mode 100644 index 9ae1796065f2db2cf15377e42aacd97cfd590350..0000000000000000000000000000000000000000 Binary files a/src/de/bricked/resources/sounds/life_lost.mp3 and /dev/null differ diff --git a/src/de/bricked/resources/sounds/life_lost.wav b/src/de/bricked/resources/sounds/life_lost.wav new file mode 100644 index 0000000000000000000000000000000000000000..dabc3615f1f22429e487d397dab39d98d73bd034 Binary files /dev/null and b/src/de/bricked/resources/sounds/life_lost.wav differ diff --git a/src/de/bricked/resources/sounds/tnt.mp3 b/src/de/bricked/resources/sounds/tnt.mp3 deleted file mode 100644 index 308c229c4fb80b2cceb8d98b78fe03ab06f35fba..0000000000000000000000000000000000000000 Binary files a/src/de/bricked/resources/sounds/tnt.mp3 and /dev/null differ diff --git a/src/de/bricked/resources/sounds/tnt.wav b/src/de/bricked/resources/sounds/tnt.wav new file mode 100644 index 0000000000000000000000000000000000000000..581b5f56fe2a20303119d1292140c9c383410a21 Binary files /dev/null and b/src/de/bricked/resources/sounds/tnt.wav differ diff --git a/src/de/bricked/resources/sounds/unlocked.mp3 b/src/de/bricked/resources/sounds/unlocked.mp3 deleted file mode 100644 index fc3562c1d3c1a4cb3d58a2cffb2ff444197972d1..0000000000000000000000000000000000000000 Binary files a/src/de/bricked/resources/sounds/unlocked.mp3 and /dev/null differ diff --git a/src/de/bricked/resources/sounds/unlocked.wav b/src/de/bricked/resources/sounds/unlocked.wav new file mode 100644 index 0000000000000000000000000000000000000000..065a5ea5d8a3e3702d95c654d5fa5ddcbc0d6a83 Binary files /dev/null and b/src/de/bricked/resources/sounds/unlocked.wav differ diff --git a/src/de/bricked/ui/Controller.java b/src/de/bricked/ui/Controller.java index 5e578dba8eb5349c3a41fbc0fe3f2eb7453e4857..71e276a999eeb91f00867fea931463f07be8fb79 100644 --- a/src/de/bricked/ui/Controller.java +++ b/src/de/bricked/ui/Controller.java @@ -7,6 +7,7 @@ import java.util.ResourceBundle; import de.bricked.commandLine.CommandLine; import de.bricked.commandLine.commands.CommandBundle; import de.bricked.game.Game; +import javafx.application.Platform; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -20,6 +21,8 @@ import javafx.scene.input.KeyEvent; import javafx.scene.layout.AnchorPane; import javafx.stage.Modality; import javafx.stage.Stage; +import javafx.stage.WindowEvent; +import kuusisto.tinysound.TinySound; import logger.LogLevel; import logger.Logger; @@ -58,6 +61,17 @@ public class Controller } }); + stage.setOnCloseRequest(new EventHandler<WindowEvent>() + { + @Override + public void handle(WindowEvent event) + { + TinySound.shutdown(); + Platform.exit(); + System.exit(0); + } + }); + mainPane.setStyle("-fx-base: " + bundle.getString("color.background") + ";"); buttonLevelSelect.setStyle("-fx-base: " + bundle.getString("color.button")); buttonSettings.setStyle("-fx-base: " + bundle.getString("color.button")); diff --git a/src/de/bricked/ui/LevelController.java b/src/de/bricked/ui/LevelController.java index f2d2d082bd8119af07eb865adf43790236f5aba0..22b92950a92d939525cb3dcca6f26eea96459e2d 100644 --- a/src/de/bricked/ui/LevelController.java +++ b/src/de/bricked/ui/LevelController.java @@ -63,6 +63,7 @@ import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.stage.WindowEvent; import javafx.util.Duration; +import kuusisto.tinysound.TinySound; import logger.LogLevel; import logger.Logger; import tools.Worker; @@ -287,6 +288,8 @@ public class LevelController { timer.stop(); } + + TinySound.shutdown(); Worker.shutdown(); Platform.exit(); System.exit(0); @@ -1045,7 +1048,9 @@ public class LevelController game.resetPointsSinceLastMultiplicatorReset(); game.setBoard(null); game.setLevelController(null); - game.setMovingPowerUps(new ArrayList<>()); + game.setMovingPowerUps(new ArrayList<>()); + + game.getSoundHandler().stopAll(); anchorPaneGame.requestFocus(); } diff --git a/src/de/bricked/ui/LevelPackSelectController.java b/src/de/bricked/ui/LevelPackSelectController.java index 56a96a17fd85132a26006219cf3aee879a2dfb3c..75dc7998873883f706ab54a734fbf55f09d2868a 100644 --- a/src/de/bricked/ui/LevelPackSelectController.java +++ b/src/de/bricked/ui/LevelPackSelectController.java @@ -28,6 +28,7 @@ import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.WindowEvent; import javafx.util.Callback; +import kuusisto.tinysound.TinySound; import logger.LogLevel; import logger.Logger; @@ -103,7 +104,9 @@ public class LevelPackSelectController { // TODO achievementhandling + TinySound.shutdown(); Platform.exit(); + System.exit(0); } }); diff --git a/src/de/bricked/ui/LevelSelectController.java b/src/de/bricked/ui/LevelSelectController.java index f266af1c9e0f619bbc300881b6424ff550d7cf1d..f29cb7c240f9ec8bc3c681180cbde7ee0a3e8688 100644 --- a/src/de/bricked/ui/LevelSelectController.java +++ b/src/de/bricked/ui/LevelSelectController.java @@ -30,6 +30,7 @@ import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.WindowEvent; import javafx.util.Callback; +import kuusisto.tinysound.TinySound; import logger.LogLevel; import logger.Logger; @@ -87,7 +88,9 @@ public class LevelSelectController { // TODO achievementhandling + TinySound.shutdown(); Platform.exit(); + System.exit(0); } });