cutechicken commited on
Commit
c70fefd
Β·
verified Β·
1 Parent(s): 9328e0c

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +51 -48
index.html CHANGED
@@ -671,7 +671,7 @@ function buyTank(tankImg, cost, tankId) {
671
  lastShot = now;
672
  }
673
  }
674
- function updateGame() {
675
  if(gameOver) return;
676
  if(!isCountingDown) {
677
  // ν”Œλ ˆμ΄μ–΄ μ›€μ§μž„
@@ -709,58 +709,62 @@ function buyTank(tankImg, cost, tankId) {
709
  // λͺ¨λ“  지원 μœ λ‹› μ—…λ°μ΄νŠΈ (BF109와 JU87 λͺ¨λ‘ 처리)
710
  supportUnits = supportUnits.filter(unit => unit.update());
711
 
 
712
  enemies.forEach(enemy => enemy.update());
713
- if(!isCountingDown) {
714
- bullets = bullets.filter(bullet => {
715
- bullet.x += Math.cos(bullet.angle) * bullet.speed;
716
- bullet.y += Math.sin(bullet.angle) * bullet.speed;
717
- if(!bullet.isEnemy) {
718
- enemies = enemies.filter(enemy => {
719
- const dist = Math.hypot(bullet.x - enemy.x, bullet.y - enemy.y);
720
- if(dist < 30) {
721
- let damage = currentWeapon === 'cannon' ? 250 : 50; // κ³ μ • λ°λ―Έμ§€λ‘œ λ³€κ²½
722
- enemy.health -= damage;
723
- if(enemy.health <= 0) {
724
- spawnHealthItem(enemy.x, enemy.y);
725
- gold += 100;
726
- // 죽음 μ΄νŽ™νŠΈμ™€ μ‚¬μš΄λ“œ μΆ”κ°€
727
- effects.push(new Effect(enemy.x, enemy.y, 1000, 'death'));
728
- deathSound.cloneNode().play();
729
- return false;
730
- }
731
- if(player.health <= 0) {
732
- gameOver = true;
733
- restartBtn.style.display = 'block';
734
- effects.push(new Effect(player.x, player.y, 1000, 'death'));
735
- deathSound.cloneNode().play();
736
- }
737
- return true;
738
- }
739
- return true;
740
- });
741
- } else {
742
- const dist = Math.hypot(bullet.x - player.x, bullet.y - player.y);
743
- if(dist < 30) {
744
- player.health -= bullet.damage || 100;
745
- if(player.health <= 0) {
746
- gameOver = true;
747
- restartBtn.style.display = 'block';
748
- }
749
  return false;
750
  }
751
- }
752
- return bullet.x >= 0 && bullet.x <= canvas.width &&
753
- bullet.y >= 0 && bullet.y <= canvas.height;
754
- });
755
- items = items.filter(item => {
756
- const dist = Math.hypot(item.x - player.x, item.y - player.y);
757
- if(dist < 30) {
758
- player.health = Math.min(player.health + 200, player.maxHealth);
759
- return false;
760
  }
761
  return true;
762
  });
763
- if(enemies.length === 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
764
  if (!isBossStage) {
765
  if(currentRound < 10) {
766
  nextRoundBtn.style.display = 'block';
@@ -778,7 +782,6 @@ function buyTank(tankImg, cost, tankId) {
778
  }
779
  }
780
  }
781
- enemies.forEach(enemy => enemy.update());
782
  }
783
  function spawnHealthItem(x, y) {
784
  items.push({x, y});
 
671
  lastShot = now;
672
  }
673
  }
674
+ function updateGame() {
675
  if(gameOver) return;
676
  if(!isCountingDown) {
677
  // ν”Œλ ˆμ΄μ–΄ μ›€μ§μž„
 
709
  // λͺ¨λ“  지원 μœ λ‹› μ—…λ°μ΄νŠΈ (BF109와 JU87 λͺ¨λ‘ 처리)
710
  supportUnits = supportUnits.filter(unit => unit.update());
711
 
712
+ // 적 μ—…λ°μ΄νŠΈ - ν•œ 번만 μ‹€ν–‰
713
  enemies.forEach(enemy => enemy.update());
714
+
715
+ if(!isCountingDown) {
716
+ bullets = bullets.filter(bullet => {
717
+ bullet.x += Math.cos(bullet.angle) * bullet.speed;
718
+ bullet.y += Math.sin(bullet.angle) * bullet.speed;
719
+ if(!bullet.isEnemy) {
720
+ enemies = enemies.filter(enemy => {
721
+ const dist = Math.hypot(bullet.x - enemy.x, bullet.y - enemy.y);
722
+ if(dist < 30) {
723
+ let damage = currentWeapon === 'cannon' ? 250 : 50; // κ³ μ • λ°λ―Έμ§€λ‘œ λ³€κ²½
724
+ enemy.health -= damage;
725
+ if(enemy.health <= 0) {
726
+ spawnHealthItem(enemy.x, enemy.y);
727
+ gold += 100;
728
+ // 죽음 μ΄νŽ™νŠΈμ™€ μ‚¬μš΄λ“œ μΆ”κ°€
729
+ effects.push(new Effect(enemy.x, enemy.y, 1000, 'death'));
730
+ deathSound.cloneNode().play();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
731
  return false;
732
  }
733
+ if(player.health <= 0) {
734
+ gameOver = true;
735
+ restartBtn.style.display = 'block';
736
+ effects.push(new Effect(player.x, player.y, 1000, 'death'));
737
+ deathSound.cloneNode().play();
738
+ }
739
+ return true;
 
 
740
  }
741
  return true;
742
  });
743
+ } else {
744
+ const dist = Math.hypot(bullet.x - player.x, bullet.y - player.y);
745
+ if(dist < 30) {
746
+ player.health -= bullet.damage || 100;
747
+ if(player.health <= 0) {
748
+ gameOver = true;
749
+ restartBtn.style.display = 'block';
750
+ }
751
+ return false;
752
+ }
753
+ }
754
+ return bullet.x >= 0 && bullet.x <= canvas.width &&
755
+ bullet.y >= 0 && bullet.y <= canvas.height;
756
+ });
757
+
758
+ items = items.filter(item => {
759
+ const dist = Math.hypot(item.x - player.x, item.y - player.y);
760
+ if(dist < 30) {
761
+ player.health = Math.min(player.health + 200, player.maxHealth);
762
+ return false;
763
+ }
764
+ return true;
765
+ });
766
+
767
+ if(enemies.length === 0) {
768
  if (!isBossStage) {
769
  if(currentRound < 10) {
770
  nextRoundBtn.style.display = 'block';
 
782
  }
783
  }
784
  }
 
785
  }
786
  function spawnHealthItem(x, y) {
787
  items.push({x, y});