cutechicken commited on
Commit
590c2f2
ยท
verified ยท
1 Parent(s): ad7f1aa

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +10 -1
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 = {