cutechicken commited on
Commit
0db636e
ยท
verified ยท
1 Parent(s): b231e62

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +52 -23
index.html CHANGED
@@ -304,6 +304,9 @@
304
  bullets = [];
305
  items = [];
306
  effects = [];
 
 
 
307
 
308
  bgm.loop = true;
309
  bgm.play().catch(err => console.error("Error playing game music:", err));
@@ -312,25 +315,33 @@
312
  initRound();
313
  gameLoop();
314
  }
315
- function startCountdown() {
316
- isCountingDown = true;
317
- countdownTime = 3;
318
- countdownEl.style.display = 'block';
319
- countdownEl.textContent = countdownTime;
320
- bgm.pause();
321
- countSound.play();
 
 
 
 
 
 
 
 
322
 
323
- const countInterval = setInterval(() => {
324
- countdownTime--;
325
- if(countdownTime <= 0) {
326
- clearInterval(countInterval);
327
- countdownEl.style.display = 'none';
328
- isCountingDown = false;
329
- bgm.play();
330
- }
331
- countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
332
- }, 1000);
333
  }
 
 
 
334
 
335
  function initRound() {
336
  console.log(`Initializing round ${currentRound}`);
@@ -605,6 +616,9 @@ const defaultPlayerStats = {
605
  }
606
 
607
  shoot() {
 
 
 
608
  const mgSound = new Audio('firemg.ogg');
609
  mgSound.volume = 0.5;
610
  mgSound.play();
@@ -622,10 +636,13 @@ const defaultPlayerStats = {
622
  }
623
 
624
  update() {
 
 
 
625
  this.x -= this.speed;
626
 
627
  const now = Date.now();
628
- if (now - this.lastShot > 200) { // 1์ดˆ์— 5๋ฐœ
629
  this.shoot();
630
  this.lastShot = now;
631
  }
@@ -659,9 +676,17 @@ const defaultPlayerStats = {
659
  }
660
 
661
  function spawnSpitfires() {
662
- if (currentStage === 2 && !isCountingDown) {
 
663
  const now = Date.now();
664
- if (now - lastSpitfireSpawn > 15000) { // 15์ดˆ๋งˆ๋‹ค
 
 
 
 
 
 
 
665
  const positions = [
666
  canvas.height * 0.2,
667
  canvas.height * 0.5,
@@ -675,15 +700,19 @@ function spawnSpitfires() {
675
 
676
  // 2์ดˆ ํ›„ ์Šคํ•ํŒŒ์ด์–ด ์ƒ์„ฑ
677
  setTimeout(() => {
678
- positions.forEach(y => {
679
- spitfires.push(new Spitfire(y));
680
- });
 
 
 
681
  }, 2000);
682
 
683
  lastSpitfireSpawn = now;
684
  }
685
  }
686
  }
 
687
 
688
  class SupportUnit {
689
  constructor(yPosition) {
 
304
  bullets = [];
305
  items = [];
306
  effects = [];
307
+ spitfires = []; // ์Šคํ•ํŒŒ์ด์–ด ๋ฐฐ์—ด ์ดˆ๊ธฐํ™” ์ถ”๊ฐ€
308
+ warningLines = []; // ๊ฒฝ๊ณ ์„  ๋ฐฐ์—ด ์ดˆ๊ธฐํ™” ์ถ”๊ฐ€
309
+ lastSpitfireSpawn = Date.now(); // ์Šคํฐ ํƒ€์ด๋จธ ์ดˆ๊ธฐํ™”
310
 
311
  bgm.loop = true;
312
  bgm.play().catch(err => console.error("Error playing game music:", err));
 
315
  initRound();
316
  gameLoop();
317
  }
318
+ function startCountdown() {
319
+ isCountingDown = true;
320
+ countdownTime = 3;
321
+ countdownEl.style.display = 'block';
322
+ countdownEl.textContent = countdownTime;
323
+ bgm.pause();
324
+ countSound.play();
325
+
326
+ // ์Šคํ•ํŒŒ์ด์–ด ๊ด€๋ จ ์š”์†Œ ์ดˆ๊ธฐํ™”
327
+ spitfires = [];
328
+ warningLines = [];
329
+ lastSpitfireSpawn = 0; // 0์œผ๋กœ ์ดˆ๊ธฐํ™”ํ•˜์—ฌ ์ƒˆ ๋ผ์šด๋“œ ์‹œ์ž‘ ์‹œ ๋ฐ”๋กœ ์Šคํฐ๋˜๋„๋ก ํ•จ
330
+
331
+ // ์Šคํ•ํŒŒ์ด์–ด๊ฐ€ ๋ฐœ์‚ฌํ•œ ์ด์•Œ ์ œ๊ฑฐ
332
+ bullets = bullets.filter(bullet => !bullet.isSpitfireBullet);
333
 
334
+ const countInterval = setInterval(() => {
335
+ countdownTime--;
336
+ if(countdownTime <= 0) {
337
+ clearInterval(countInterval);
338
+ countdownEl.style.display = 'none';
339
+ isCountingDown = false;
340
+ bgm.play();
 
 
 
341
  }
342
+ countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
343
+ }, 1000);
344
+ }
345
 
346
  function initRound() {
347
  console.log(`Initializing round ${currentRound}`);
 
616
  }
617
 
618
  shoot() {
619
+ // ์นด์šดํŠธ๋‹ค์šด ์ค‘์—๋Š” ๋ฐœ์‚ฌํ•˜์ง€ ์•Š์Œ
620
+ if (isCountingDown) return;
621
+
622
  const mgSound = new Audio('firemg.ogg');
623
  mgSound.volume = 0.5;
624
  mgSound.play();
 
636
  }
637
 
638
  update() {
639
+ // ์นด์šดํŠธ๋‹ค์šด ์ค‘์ด๋ฉด false๋ฅผ ๋ฐ˜ํ™˜ํ•˜์—ฌ ์Šคํ•ํŒŒ์ด์–ด ์ œ๊ฑฐ
640
+ if (isCountingDown) return false;
641
+
642
  this.x -= this.speed;
643
 
644
  const now = Date.now();
645
+ if (now - this.lastShot > 200) {
646
  this.shoot();
647
  this.lastShot = now;
648
  }
 
676
  }
677
 
678
  function spawnSpitfires() {
679
+ // 2์Šคํ…Œ์ด์ง€์ด๊ณ , ์นด์šดํŠธ๋‹ค์šด ์ค‘์ด ์•„๋‹ˆ๊ณ , ๊ฒŒ์ž„์ด ์ง„ํ–‰ ์ค‘์ผ ๋•Œ๋งŒ
680
+ if (currentStage === 2 && !isCountingDown && !gameOver && gameStarted) {
681
  const now = Date.now();
682
+
683
+ // lastSpitfireSpawn์ด 0์ด๋ฉด ์ดˆ๊ธฐํ™”
684
+
685
+
686
+ // 15์ดˆ๋งˆ๋‹ค ์Šคํฐ
687
+ if (now - lastSpitfireSpawn > 15000) {
688
+ console.log('Spawning Spitfires...'); // ๋””๋ฒ„๊น…์šฉ ๋กœ๊ทธ
689
+
690
  const positions = [
691
  canvas.height * 0.2,
692
  canvas.height * 0.5,
 
700
 
701
  // 2์ดˆ ํ›„ ์Šคํ•ํŒŒ์ด์–ด ์ƒ์„ฑ
702
  setTimeout(() => {
703
+ if (!isCountingDown && !gameOver) {
704
+ positions.forEach(y => {
705
+ spitfires.push(new Spitfire(y));
706
+ });
707
+ console.log('Spitfires spawned:', spitfires.length); // ๋””๋ฒ„๊น…์šฉ ๋กœ๊ทธ
708
+ }
709
  }, 2000);
710
 
711
  lastSpitfireSpawn = now;
712
  }
713
  }
714
  }
715
+
716
 
717
  class SupportUnit {
718
  constructor(yPosition) {