Spaces:
Running
Running
cutechicken
commited on
Update index.html
Browse files- index.html +51 -48
index.html
CHANGED
@@ -671,7 +671,7 @@ function buyTank(tankImg, cost, tankId) {
|
|
671 |
lastShot = now;
|
672 |
}
|
673 |
}
|
674 |
-
|
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 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
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 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
player.health = Math.min(player.health + 200, player.maxHealth);
|
759 |
-
return false;
|
760 |
}
|
761 |
return true;
|
762 |
});
|
763 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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});
|