cutechicken commited on
Commit
f67994b
·
verified ·
1 Parent(s): 1ec6ab1

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +22 -7
index.html CHANGED
@@ -255,7 +255,7 @@
255
  return Date.now() - this.startTime > this.duration;
256
  }
257
  }
258
- class SupportUnit {
259
  constructor(yPosition) {
260
  this.x = 0;
261
  this.y = yPosition;
@@ -267,14 +267,25 @@
267
  this.img = new Image();
268
  this.img.src = 'bf109.png';
269
  this.hasPlayedSound = false; // 첫 등장 소리용
 
270
  }
271
 
272
  update() {
273
  // 이동
274
  this.x += this.speed;
 
 
 
 
 
 
 
 
 
 
275
  // 발사 (1초에 5발)
276
  const now = Date.now();
277
- if (now - this.lastShot > 200) {
278
  this.shoot();
279
  this.lastShot = now;
280
  }
@@ -282,15 +293,19 @@
282
  }
283
 
284
  shoot() {
285
- // 최초 등장시 bf109mg.ogg 재생
286
- if (!this.hasPlayedSound && !isCountingDown) {
287
- new Audio('bf109mg.ogg').play();
 
 
288
  this.hasPlayedSound = true;
289
  }
290
 
291
- // 발사시 bf109mgse.ogg 재생 (카운트다운 중이 아닐 때만)
292
  if (!isCountingDown) {
293
- new Audio('bf109mgse.ogg').play();
 
 
294
  }
295
 
296
  bullets.push({
 
255
  return Date.now() - this.startTime > this.duration;
256
  }
257
  }
258
+ class SupportUnit {
259
  constructor(yPosition) {
260
  this.x = 0;
261
  this.y = yPosition;
 
267
  this.img = new Image();
268
  this.img.src = 'bf109.png';
269
  this.hasPlayedSound = false; // 첫 등장 소리용
270
+ this.mgSound = null; // 기관총 소리 객체
271
  }
272
 
273
  update() {
274
  // 이동
275
  this.x += this.speed;
276
+
277
+ // 카운트다운 중이면 소리 정지 및 초기화
278
+ if (isCountingDown) {
279
+ if (this.mgSound) {
280
+ this.mgSound.pause();
281
+ this.mgSound.currentTime = 0;
282
+ }
283
+ this.hasPlayedSound = false;
284
+ }
285
+
286
  // 발사 (1초에 5발)
287
  const now = Date.now();
288
+ if (now - this.lastShot > 200 && !isCountingDown) {
289
  this.shoot();
290
  this.lastShot = now;
291
  }
 
293
  }
294
 
295
  shoot() {
296
+ // 최초 등장시에만 bf109mg.ogg 재생
297
+ if (!this.hasPlayedSound) {
298
+ const firstSound = new Audio('bf109mg.ogg');
299
+ firstSound.volume = 0.5;
300
+ firstSound.play();
301
  this.hasPlayedSound = true;
302
  }
303
 
304
+ // 발사할 때마다 새로운 bf109mgse.ogg 재생
305
  if (!isCountingDown) {
306
+ const shootSound = new Audio('bf109mgse.ogg');
307
+ shootSound.volume = 0.3; // 볼륨 낮춤
308
+ shootSound.play();
309
  }
310
 
311
  bullets.push({