Spaces:
Running
Running
cutechicken
commited on
Commit
β’
590c2f2
1
Parent(s):
ad7f1aa
Update game.js
Browse files
game.js
CHANGED
@@ -139,11 +139,19 @@ class TankPlayer {
|
|
139 |
}
|
140 |
this.lastShootTime = currentTime;
|
141 |
|
142 |
-
// λ°μ¬μ ν¨κ³Ό
|
143 |
const sounds = ['sounds/mbtfire1.ogg', 'sounds/mbtfire2.ogg', 'sounds/mbtfire3.ogg', 'sounds/mbtfire4.ogg'];
|
144 |
const randomSound = sounds[Math.floor(Math.random() * sounds.length)];
|
145 |
const audio = new Audio(randomSound);
|
146 |
audio.volume = 0.5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
audio.play();
|
148 |
|
149 |
// λ°μ¬ μ΄ννΈ
|
@@ -638,6 +646,7 @@ class Game {
|
|
638 |
this.lastTime = performance.now();
|
639 |
this.gameTimer = null;
|
640 |
this.animationFrameId = null;
|
|
|
641 |
|
642 |
this.mouse = { x: 0, y: 0 };
|
643 |
this.keys = {
|
|
|
139 |
}
|
140 |
this.lastShootTime = currentTime;
|
141 |
|
142 |
+
// λ°μ¬μ ν¨κ³Ό (ν λ²λ§ μ¬μ)
|
143 |
const sounds = ['sounds/mbtfire1.ogg', 'sounds/mbtfire2.ogg', 'sounds/mbtfire3.ogg', 'sounds/mbtfire4.ogg'];
|
144 |
const randomSound = sounds[Math.floor(Math.random() * sounds.length)];
|
145 |
const audio = new Audio(randomSound);
|
146 |
audio.volume = 0.5;
|
147 |
+
|
148 |
+
// μ΄μ μ€λμ€ μΈμ€ν΄μ€κ° μλ€λ©΄ μ€μ§
|
149 |
+
if (this.lastAudio) {
|
150 |
+
this.lastAudio.pause();
|
151 |
+
this.lastAudio.currentTime = 0;
|
152 |
+
}
|
153 |
+
|
154 |
+
this.lastAudio = audio;
|
155 |
audio.play();
|
156 |
|
157 |
// λ°μ¬ μ΄ννΈ
|
|
|
646 |
this.lastTime = performance.now();
|
647 |
this.gameTimer = null;
|
648 |
this.animationFrameId = null;
|
649 |
+
this.lastAudio = null; // λ§μ§λ§ λ°μ¬μ μΆμ μ μν μμ± μΆκ°
|
650 |
|
651 |
this.mouse = { x: 0, y: 0 };
|
652 |
this.keys = {
|