cutechicken commited on
Commit
084e8ed
ยท
verified ยท
1 Parent(s): 7072ffa

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +98 -54
index.html CHANGED
@@ -135,6 +135,8 @@
135
  </div>
136
  <button id="bossButton" class="button">Fight Boss!</button>
137
  <div id="winMessage" class="button" style="font-size: 72px; background: none;">You Win!</div>
 
 
138
 
139
 
140
  <script>
@@ -436,35 +438,57 @@
436
  return true;
437
  }
438
  }
439
-
440
- class Enemy {
441
- constructor(isBoss = false) {
442
- this.x = Math.random() * canvas.width;
443
- this.y = Math.random() * canvas.height;
444
- this.health = isBoss ? 15000 : 1000;
445
- this.maxHealth = this.health;
446
- this.speed = isBoss ? 1 : 2;
447
- this.lastShot = 0;
448
- this.shootInterval = isBoss ? 1000 : 1000;
449
- this.angle = 0;
450
- this.width = 100;
451
- this.height = 45;
452
- this.moveTimer = 0;
453
- this.moveInterval = Math.random() * 2000 + 1000;
454
- this.moveAngle = Math.random() * Math.PI * 2;
455
- this.isBoss = isBoss;
456
 
457
- if (isBoss) {
458
- this.enemyImg = new Image();
459
- this.enemyImg.src = 'boss.png';
460
- } else if (currentRound >= 7) {
461
- this.enemyImg = new Image();
462
  this.enemyImg.src = 'enemy3.png';
463
  } else if (currentRound >= 4) {
464
- this.enemyImg = new Image();
465
  this.enemyImg.src = 'enemy2.png';
 
 
466
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  }
 
 
468
  update() {
469
  if(isCountingDown) return;
470
  const now = Date.now();
@@ -567,9 +591,10 @@ function buyTank(tankImg, cost, tankId) {
567
  lastJU87Spawn = Date.now(); // ๊ตฌ๋งค ์ฆ‰์‹œ ์Šคํฐ ํƒ€์ด๋จธ ์ดˆ๊ธฐํ™”
568
  }
569
  }
570
- function initRound() {
571
  enemies = [];
572
- for(let i = 0; i < 1 * currentRound; i++) {
 
573
  enemies.push(new Enemy());
574
  }
575
  player.health = player.maxHealth;
@@ -578,6 +603,11 @@ function buyTank(tankImg, cost, tankId) {
578
  supportUnits = [];
579
  lastSupportSpawn = 0;
580
 
 
 
 
 
 
581
  // ์นด์šดํŠธ๋‹ค์šด ์‹œ์ž‘
582
  startCountdown();
583
 
@@ -589,17 +619,19 @@ function buyTank(tankImg, cost, tankId) {
589
  }
590
  }, 3000); // 3์ดˆ ํ›„์— ์Šคํฐ
591
  }
592
- function startBossStage() {
593
- isBossStage = true;
594
- enemies = [];
595
- enemies.push(new Enemy(true));
596
- player.health = player.maxHealth;
597
- bullets = [];
598
- items = [];
599
- document.getElementById('bossButton').style.display = 'none';
600
- bgm.src = 'BGM.ogg'; // ๋ณด์Šค์ „ BGM์œผ๋กœ ๋ณ€๊ฒฝ
601
- startCountdown();
602
- }
 
 
603
  canvas.addEventListener('mousemove', (e) => {
604
  player.angle = Math.atan2(e.clientY - player.y, e.clientX - player.x);
605
  });
@@ -732,24 +764,27 @@ function buyTank(tankImg, cost, tankId) {
732
  }
733
  return true;
734
  });
735
- if(enemies.length === 0) {
736
- if (!isBossStage) {
737
- if(currentRound < 10) {
738
- nextRoundBtn.style.display = 'block';
739
- showShop();
740
- } else {
741
- document.getElementById('bossButton').style.display = 'block';
742
- }
743
- } else {
744
- gameOver = true;
745
- document.getElementById('winMessage').style.display = 'block';
746
- restartBtn.style.display = 'block';
747
- bgm.pause(); // ํ˜„์žฌ BGM ์ •์ง€
748
- const victorySound = new Audio('victory.ogg'); // ์Šน๋ฆฌ ์‚ฌ์šด๋“œ ์ƒ์„ฑ
749
- victorySound.play(); // ์Šน๋ฆฌ ์‚ฌ์šด๋“œ ์žฌ์ƒ
750
- }
751
- }
752
- }
 
 
 
753
  enemies.forEach(enemy => enemy.update());
754
  }
755
  function spawnHealthItem(x, y) {
@@ -861,6 +896,15 @@ nextRoundBtn.addEventListener('click', () => {
861
 
862
  bossButton.addEventListener('click', startBossStage);
863
 
 
 
 
 
 
 
 
 
 
864
  restartBtn.addEventListener('click', () => {
865
  currentRound = 1;
866
  gameOver = false;
 
135
  </div>
136
  <button id="bossButton" class="button">Fight Boss!</button>
137
  <div id="winMessage" class="button" style="font-size: 72px; background: none;">You Win!</div>
138
+ <button id="nextStage" class="button">Next Stage</button>
139
+
140
 
141
 
142
  <script>
 
438
  return true;
439
  }
440
  }
441
+
442
+ class Enemy {
443
+ constructor(isBoss = false) {
444
+ this.x = Math.random() * canvas.width;
445
+ this.y = Math.random() * canvas.height;
446
+ this.health = this.getHealth(isBoss);
447
+ this.maxHealth = this.health;
448
+ this.speed = isBoss ? 1 : 2;
449
+ this.lastShot = 0;
450
+ this.shootInterval = isBoss ? 1000 : 1000;
451
+ this.angle = 0;
452
+ this.width = 100;
453
+ this.height = 45;
454
+ this.moveTimer = 0;
455
+ this.moveInterval = Math.random() * 2000 + 1000;
456
+ this.moveAngle = Math.random() * Math.PI * 2;
457
+ this.isBoss = isBoss;
458
 
459
+ this.enemyImg = new Image();
460
+ if (isBoss) {
461
+ this.enemyImg.src = currentStage === 1 ? 'boss.png' : 'enemyukboss.png';
462
+ } else if (currentStage === 1) {
463
+ if (currentRound >= 7) {
464
  this.enemyImg.src = 'enemy3.png';
465
  } else if (currentRound >= 4) {
 
466
  this.enemyImg.src = 'enemy2.png';
467
+ } else {
468
+ this.enemyImg.src = 'enemy.png';
469
  }
470
+ } else { // ์Šคํ…Œ์ด์ง€ 2
471
+ if (currentRound >= 7) {
472
+ this.enemyImg.src = 'enemyuk3.png';
473
+ } else if (currentRound >= 4) {
474
+ this.enemyImg.src = 'enemyuk2.png';
475
+ } else {
476
+ this.enemyImg.src = 'enemyuk1.png';
477
+ }
478
+ }
479
+ }
480
+
481
+ getHealth(isBoss) {
482
+ if (isBoss) return 15000;
483
+ if (currentStage === 1) {
484
+ return 1000; // ์Šคํ…Œ์ด์ง€ 1์€ ๊ธฐ์กด๊ณผ ๋™์ผ
485
+ } else { // ์Šคํ…Œ์ด์ง€ 2
486
+ if (currentRound >= 7) return 2000;
487
+ if (currentRound >= 4) return 1500;
488
+ return 1000;
489
  }
490
+ }
491
+
492
  update() {
493
  if(isCountingDown) return;
494
  const now = Date.now();
 
591
  lastJU87Spawn = Date.now(); // ๊ตฌ๋งค ์ฆ‰์‹œ ์Šคํฐ ํƒ€์ด๋จธ ์ดˆ๊ธฐํ™”
592
  }
593
  }
594
+ function initRound() {
595
  enemies = [];
596
+ let enemyCount = currentStage === 1 ? currentRound : (2 + currentRound); // 2์Šคํ…Œ์ด์ง€๋Š” 3๊ฐœ๋ถ€ํ„ฐ ์‹œ์ž‘
597
+ for(let i = 0; i < enemyCount; i++) {
598
  enemies.push(new Enemy());
599
  }
600
  player.health = player.maxHealth;
 
603
  supportUnits = [];
604
  lastSupportSpawn = 0;
605
 
606
+ if (currentStage === 2) {
607
+ backgroundImg.src = 'city2.png';
608
+ bgm.src = 'BGM3.ogg';
609
+ }
610
+
611
  // ์นด์šดํŠธ๋‹ค์šด ์‹œ์ž‘
612
  startCountdown();
613
 
 
619
  }
620
  }, 3000); // 3์ดˆ ํ›„์— ์Šคํฐ
621
  }
622
+ function startBossStage() {
623
+ isBossStage = true;
624
+ enemies = [];
625
+ enemies.push(new Enemy(true));
626
+ player.health = player.maxHealth;
627
+ bullets = [];
628
+ items = [];
629
+ document.getElementById('bossButton').style.display = 'none';
630
+ if (currentStage === 1) {
631
+ bgm.src = 'BGM.ogg';
632
+ }
633
+ startCountdown();
634
+ }
635
  canvas.addEventListener('mousemove', (e) => {
636
  player.angle = Math.atan2(e.clientY - player.y, e.clientX - player.x);
637
  });
 
764
  }
765
  return true;
766
  });
767
+ if(enemies.length === 0) {
768
+ if (!isBossStage) {
769
+ if(currentRound < 10) {
770
+ nextRoundBtn.style.display = 'block';
771
+ showShop();
772
+ } else {
773
+ document.getElementById('bossButton').style.display = 'block';
774
+ }
775
+ } else {
776
+ if (currentStage === 1) { // 1์Šคํ…Œ์ด์ง€ ๋ณด์Šค ์ฒ˜์น˜
777
+ document.getElementById('nextStage').style.display = 'block';
778
+ } else { // 2์Šคํ…Œ์ด์ง€ ๋ณด์Šค ์ฒ˜์น˜
779
+ gameOver = true;
780
+ document.getElementById('winMessage').style.display = 'block';
781
+ restartBtn.style.display = 'block';
782
+ bgm.pause(); // ํ˜„์žฌ BGM ์ •์ง€
783
+ const victorySound = new Audio('victory.ogg');
784
+ victorySound.play();
785
+ }
786
+ }
787
+ }
788
  enemies.forEach(enemy => enemy.update());
789
  }
790
  function spawnHealthItem(x, y) {
 
896
 
897
  bossButton.addEventListener('click', startBossStage);
898
 
899
+ // ๋‹ค์Œ ์Šคํ…Œ์ด์ง€ ๋ฒ„ํŠผ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ
900
+ document.getElementById('nextStage').addEventListener('click', () => {
901
+ currentStage++;
902
+ currentRound = 1;
903
+ isBossStage = false;
904
+ document.getElementById('nextStage').style.display = 'none';
905
+ initRound();
906
+ });
907
+
908
  restartBtn.addEventListener('click', () => {
909
  currentRound = 1;
910
  gameOver = false;