From e9f00ec16feba6aa27849a963c5b9a3782465052 Mon Sep 17 00:00:00 2001 From: Romain Murphy Date: Wed, 7 May 2025 16:19:00 +0200 Subject: [PATCH] change sound effect --- OOP_2B1_Project/src/backend/Game.java | 5 ++++- OOP_2B1_Project/src/windowInterface/MyInterface.java | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/OOP_2B1_Project/src/backend/Game.java b/OOP_2B1_Project/src/backend/Game.java index f239dfd..be2e4d9 100644 --- a/OOP_2B1_Project/src/backend/Game.java +++ b/OOP_2B1_Project/src/backend/Game.java @@ -11,7 +11,7 @@ public class Game extends Thread { private int LINE_NUM = 8; private int loopDelay = 250; boolean[] activationAIFlags; - + private SoundEffect soundEffect = new SoundEffect(); public Game(MyInterface mjfParam) { mjf = mjfParam; board = new Board(COL_NUM, LINE_NUM); @@ -120,6 +120,9 @@ public class Game extends Thread { public void toggleAI(boolean isWhite) { // System.out.println(isWhite); this.activationAIFlags[isWhite?1:0] = !this.activationAIFlags[isWhite?1:0]; + if (this.activationAIFlags[isWhite?1:0]) { + soundEffect.aiSound(); + } } public void setTurnNumber(int turnNumber) { diff --git a/OOP_2B1_Project/src/windowInterface/MyInterface.java b/OOP_2B1_Project/src/windowInterface/MyInterface.java index e661bdb..349ba00 100644 --- a/OOP_2B1_Project/src/windowInterface/MyInterface.java +++ b/OOP_2B1_Project/src/windowInterface/MyInterface.java @@ -1,5 +1,5 @@ package windowInterface; -import backend.SoundEffect; + import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridLayout; @@ -44,7 +44,6 @@ public class MyInterface extends JFrame { private JLabel actionLabel; private JCheckBox chckbxBlackAI; private JCheckBox chckbxWhiteAI; - private SoundEffect soundEffect = new SoundEffect(); /** * Create the frame. @@ -195,7 +194,6 @@ public class MyInterface extends JFrame { } else { game.toggleAI(isWhite); } - soundEffect.aiSound(); } public void clicLoadFileButton() {