Skip to content
Snippets Groups Projects
Commit 787760b5 authored by bosskkev's avatar bosskkev
Browse files

unmute and demute

parent 33f4823d
No related branches found
No related tags found
No related merge requests found
Pipeline #25297 passed
......@@ -212,5 +212,9 @@ public class Kernel {
return physicEngine.isCollision;
}
public void muteSoundEngine(){
soundEngine.mute();
}
}
......@@ -19,6 +19,7 @@ public class SoundEngine implements Engine {
public SoundEngine() {
}
public void playMusic(String location){
if(isMuted) return;
try {
File musicPath = new File(location);
if (musicPath.exists()) {
......@@ -58,13 +59,10 @@ public class SoundEngine implements Engine {
soundMap.put(soundPath, isPlaying);
}
public void muteSoundEngine(){
isMuted = true;
public void mute(){
isMuted = !isMuted;
}
public void unmuteSoundEngine(){
isMuted = false;
}
@Override
......
......@@ -46,7 +46,7 @@ public class PongApp {
components.add(pongBall);
Kernel kernel = new Kernel("Pong", width, height, components);
//kernel.playSound("src/main/resources/Sound/minecraft.wav");
kernel.playSound("src/main/resources/Sound/minecraft.wav");
kernel.addSound("src/main/resources/Sound/hit_racket.wav", kernel.isItACollision());
JButton button = new JButton("Restart");
JButton button2 = new JButton("Mute");
......@@ -65,7 +65,7 @@ public class PongApp {
}
});
button2.addActionListener(e -> SoundEngine.stopMusic());
button2.addActionListener(e -> kernel.muteSoundEngine());
kernel.addButton(button); // Add a button to restart the game
kernel.addButton(button2); // Add a button to mute the game
//kernel.addLabel(muteLabel); // Add a button to mute the game
......
......@@ -4,6 +4,9 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
* Test class for the CartesianVector class.
*/
class CartesianVectorTest {
@Test
public void testAdd() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment