Added 3 more sounds. Added function calls to test sounds, some still untested

This commit is contained in:
Joshua 2024-12-15 18:55:45 +01:00
parent f5a0f8c9fe
commit 626ae041e5
7 changed files with 10 additions and 5 deletions

BIN
Sound/hit.mp3 Normal file

Binary file not shown.

BIN
Sound/plop.mp3 Normal file

Binary file not shown.

BIN
Sound/shipdestroyed.mp3 Normal file

Binary file not shown.

View File

@ -102,6 +102,7 @@ public class BoardDisplay extends JPanel {
} else if (SwingUtilities.isLeftMouseButton(e)) {
Point o = new Point(x, y);
handleFieldClick(o);
SoundHandler.playSound("plop");
}
}
});
@ -222,13 +223,16 @@ public class BoardDisplay extends JPanel {
switch (hit.getType()) {
case HIT:
fields[i][j].setBackground(Color.ORANGE);
SoundHandler.playSound("hit");
break;
case SUNK:
case VICTORY:
SoundHandler.playSound("destroyed");
fields[i][j].setBackground(Color.RED);
break;
case MISS:
if (this.enemyBoard) {
SoundHandler.playSound("miss");
fields[i][j].setBackground(Color.BLUE);
} else {
fields[i][j].setBackground(Color.CYAN);

View File

@ -7,8 +7,8 @@ public class HalloSchiffeVersenken {
System.out.println("HelloSchiffeVersenekn");
System.out.println("sound");
SoundHandler.playSound("hit");
//System.out.println("sound");
//SoundHandler.playSound("hit");
Thread.sleep(10000);

View File

@ -8,8 +8,6 @@ import java.net.InetSocketAddress;
/**
* Das JoinGame Panel dient zum setzten des Ports/IP-Adresse.
* Anschließend kann das Verbinden Panel gezeigt werden.
* 51525
* ssh.lgc.sh
*/
public class JoinGame extends JPanel {
// Grafiken

View File

@ -16,7 +16,10 @@ public class SoundHandler {
// Wenn fehler beim erstellen von .jar mit sound hier gucken
private static HashMap<String, String> sounds = new HashMap<String, String>(Map.of(
"hit", "./Sound/water-drip.mp3"
"miss", "./Sound/water-drip.mp3",
"hit", "./Sound/hit.mp3",
"destroyed", "./Sound/hit.mp3",
"plop", "./Sound/plop.mp3"
));
public static void playSound(String soundName) {