cutechicken commited on
Commit
87ee926
ยท
verified ยท
1 Parent(s): 994b03f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +53 -39
index.html CHANGED
@@ -210,33 +210,35 @@
210
  health: 1000,
211
  maxHealth: 1000
212
  };
213
- function startCountdown() {
214
- isCountingDown = true;
215
- countdownTime = 3;
216
- countdownEl.style.display = 'block';
217
- countdownEl.textContent = countdownTime;
218
- bgm.pause();
219
-
220
- // ๋ชจ๋“  ์ง€์› ์œ ๋‹›์˜ ์†Œ๋ฆฌ ์ƒํƒœ ์ดˆ๊ธฐํ™”
221
- supportUnits.forEach(unit => {
222
- if (unit instanceof SupportUnit) {
223
- unit.hasPlayedSound = false;
224
- }
225
- });
226
-
227
- countSound.play();
228
- const countInterval = setInterval(() => {
229
- countdownTime--;
230
- if(countdownTime <= 0) {
231
- clearInterval(countInterval);
232
- countdownEl.style.display = 'none';
233
- isCountingDown = false;
234
- bgm.play();
235
- }
236
- countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
237
- }, 1000);
238
- }
239
-
 
 
240
  class Effect {
241
  constructor(x, y, duration, type, angle = 0, parent = null) {
242
  this.x = x;
@@ -263,7 +265,7 @@
263
  return Date.now() - this.startTime > this.duration;
264
  }
265
  }
266
- class SupportUnit {
267
  constructor(yPosition) {
268
  this.x = 0;
269
  this.y = yPosition;
@@ -274,10 +276,19 @@
274
  this.angle = 0; // ํ•ญ์ƒ ์˜ค๋ฅธ์ชฝ์„ ํ–ฅํ•จ
275
  this.img = new Image();
276
  this.img.src = 'bf109.png';
277
- this.hasPlayedSound = false; // ์†Œ๋ฆฌ ์žฌ์ƒ ์—ฌ๋ถ€ ์ถ”๊ฐ€
 
278
  }
279
 
280
  update() {
 
 
 
 
 
 
 
 
281
  // ์ด๋™
282
  this.x += this.speed;
283
  // ๋ฐœ์‚ฌ (1์ดˆ์— 5๋ฐœ)
@@ -290,9 +301,10 @@
290
  }
291
 
292
  shoot() {
293
- // ์นด์šดํŠธ๋‹ค์šด ์ค‘์ด ์•„๋‹ˆ๊ณ  ์†Œ๋ฆฌ๋ฅผ ์•„์ง ์žฌ์ƒํ•˜์ง€ ์•Š์•˜์„ ๋•Œ๋งŒ ์žฌ์ƒ
294
  if (!isCountingDown && !this.hasPlayedSound) {
295
- new Audio('bf109mg.ogg').play();
 
296
  this.hasPlayedSound = true;
297
  }
298
 
@@ -566,16 +578,18 @@ function buyTank(tankImg, cost, tankId) {
566
  supportUnits = [];
567
  lastSupportSpawn = 0;
568
 
569
- // ์นด์šดํŠธ๋‹ค์šด ์‹œ์ž‘
570
  startCountdown();
571
 
572
- // ์นด์šดํŠธ๋‹ค์šด์ด ๋๋‚˜๋ฉด JU87 ์Šคํฐ
573
- setTimeout(() => {
574
- if (hasJU87) {
575
- supportUnits.push(new JU87());
576
- lastJU87Spawn = Date.now();
577
- }
578
- }, 3000); // 3์ดˆ ํ›„์— ์Šคํฐ
 
 
 
579
  }
580
  function startBossStage() {
581
  isBossStage = true;
 
210
  health: 1000,
211
  maxHealth: 1000
212
  };
213
+ function startCountdown() {
214
+ isCountingDown = true;
215
+ countdownTime = 3;
216
+ countdownEl.style.display = 'block';
217
+ countdownEl.textContent = countdownTime;
218
+ bgm.pause();
219
+
220
+ // ๋ชจ๋“  ์ง€์› ์œ ๋‹›์˜ ์†Œ๋ฆฌ๋ฅผ ์ฆ‰์‹œ ์ •์ง€
221
+ supportUnits.forEach(unit => {
222
+ if (unit instanceof SupportUnit && unit.mgSound) {
223
+ unit.mgSound.pause();
224
+ unit.mgSound.currentTime = 0;
225
+ unit.mgSound = null;
226
+ unit.hasPlayedSound = false;
227
+ }
228
+ });
229
+
230
+ countSound.play();
231
+ const countInterval = setInterval(() => {
232
+ countdownTime--;
233
+ if(countdownTime <= 0) {
234
+ clearInterval(countInterval);
235
+ countdownEl.style.display = 'none';
236
+ isCountingDown = false;
237
+ bgm.play();
238
+ }
239
+ countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
240
+ }, 1000);
241
+ }
242
  class Effect {
243
  constructor(x, y, duration, type, angle = 0, parent = null) {
244
  this.x = x;
 
265
  return Date.now() - this.startTime > this.duration;
266
  }
267
  }
268
+ class SupportUnit {
269
  constructor(yPosition) {
270
  this.x = 0;
271
  this.y = yPosition;
 
276
  this.angle = 0; // ํ•ญ์ƒ ์˜ค๋ฅธ์ชฝ์„ ํ–ฅํ•จ
277
  this.img = new Image();
278
  this.img.src = 'bf109.png';
279
+ this.hasPlayedSound = false;
280
+ this.mgSound = null; // ์˜ค๋””์˜ค ๊ฐ์ฒด ์ €์žฅ
281
  }
282
 
283
  update() {
284
+ // ์นด์šดํŠธ๋‹ค์šด ์ƒํƒœ๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด ์†Œ๋ฆฌ ์ •์ง€
285
+ if (isCountingDown && this.mgSound) {
286
+ this.mgSound.pause();
287
+ this.mgSound.currentTime = 0;
288
+ this.hasPlayedSound = false;
289
+ this.mgSound = null; // ๊ฐ์ฒด ์ œ๊ฑฐ
290
+ }
291
+
292
  // ์ด๋™
293
  this.x += this.speed;
294
  // ๋ฐœ์‚ฌ (1์ดˆ์— 5๋ฐœ)
 
301
  }
302
 
303
  shoot() {
304
+ // ์นด์šดํŠธ๋‹ค์šด ์ค‘์ด ์•„๋‹ ๋•Œ๋งŒ ์†Œ๋ฆฌ ์žฌ์ƒ
305
  if (!isCountingDown && !this.hasPlayedSound) {
306
+ this.mgSound = new Audio('bf109mg.ogg');
307
+ this.mgSound.play();
308
  this.hasPlayedSound = true;
309
  }
310
 
 
578
  supportUnits = [];
579
  lastSupportSpawn = 0;
580
 
 
581
  startCountdown();
582
 
583
+ // setTimeout ๋Œ€์‹  setInterval ์‚ฌ์šฉ
584
+ if (hasJU87) {
585
+ const spawnInterval = setInterval(() => {
586
+ if (!isCountingDown) {
587
+ supportUnits.push(new JU87());
588
+ lastJU87Spawn = Date.now();
589
+ clearInterval(spawnInterval);
590
+ }
591
+ }, 100); // 100ms๋งˆ๋‹ค ์ฒดํฌ
592
+ }
593
  }
594
  function startBossStage() {
595
  isBossStage = true;