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

View File

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

View File

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

View File

@ -16,7 +16,10 @@ public class SoundHandler {
// Wenn fehler beim erstellen von .jar mit sound hier gucken // Wenn fehler beim erstellen von .jar mit sound hier gucken
private static HashMap<String, String> sounds = new HashMap<String, String>(Map.of( 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) { public static void playSound(String soundName) {