Spaces:
Running
Running
cutechicken
commited on
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 = {
|