Update index.html
Browse files- index.html +25 -47
index.html
CHANGED
@@ -835,69 +835,47 @@ const defaultPlayerStats = {
|
|
835 |
//3μ€ν
μ΄μ§ λ¨Έμ€ν±
|
836 |
class P51 {
|
837 |
constructor(x) {
|
838 |
-
this.x = x;
|
839 |
-
this.y = 0;
|
840 |
-
this.speed = 3;
|
841 |
-
this.width = 100;
|
842 |
-
this.height = 100;
|
843 |
-
this.
|
844 |
-
this.
|
845 |
this.img = new Image();
|
846 |
-
this.img.src = 'p51.png';
|
847 |
}
|
848 |
|
849 |
-
|
850 |
-
|
851 |
-
// μμ μ΄ μ΄λ €μμΌλ©΄ ννμ ν¬ννμ§ μμ
|
852 |
-
if (document.getElementById('shop').style.display === 'block') return;
|
853 |
-
|
854 |
-
// νλ° μ리 μ¬μ
|
855 |
-
const bombSound = new Audio('bomb2.ogg');
|
856 |
-
bombSound.volume = 0.5;
|
857 |
-
bombSound.play();
|
858 |
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
this.y,
|
863 |
-
500,
|
864 |
-
'bomb',
|
865 |
-
0
|
866 |
-
));
|
867 |
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
// μκ΅° μ λ λ°λ―Έμ§ 체ν¬
|
878 |
-
allyUnits.forEach(ally => {
|
879 |
-
const distToAlly = Math.hypot(this.x - ally.x, this.y - ally.y);
|
880 |
-
if (distToAlly < blastRadius) {
|
881 |
-
ally.health -= 400;
|
882 |
-
}
|
883 |
});
|
884 |
}
|
885 |
|
886 |
-
// P51 μ
λ°μ΄νΈ λ©μλ
|
887 |
update() {
|
888 |
if (isCountingDown) return true;
|
889 |
|
890 |
-
// μλλ‘ μ΄λ
|
891 |
this.y += this.speed;
|
892 |
|
893 |
-
// νν ν¬ν νμ΄λ° 체ν¬
|
894 |
const now = Date.now();
|
895 |
-
if (now - this.
|
896 |
-
this.
|
897 |
-
this.
|
898 |
}
|
899 |
|
900 |
-
// νλ©΄ νλ¨μ λλ¬νλμ§ μ²΄ν¬
|
901 |
return this.y < canvas.height;
|
902 |
}
|
903 |
}
|
|
|
835 |
//3μ€ν
μ΄μ§ λ¨Έμ€ν±
|
836 |
class P51 {
|
837 |
constructor(x) {
|
838 |
+
this.x = x;
|
839 |
+
this.y = 0;
|
840 |
+
this.speed = 3;
|
841 |
+
this.width = 100;
|
842 |
+
this.height = 100;
|
843 |
+
this.lastShot = 0;
|
844 |
+
this.fireRate = 200;
|
845 |
this.img = new Image();
|
846 |
+
this.img.src = 'p51.png';
|
847 |
}
|
848 |
|
849 |
+
shoot() {
|
850 |
+
if (isCountingDown || document.getElementById('shop').style.display === 'block') return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
851 |
|
852 |
+
const mgSound = new Audio('firemg.ogg');
|
853 |
+
mgSound.volume = 0.5;
|
854 |
+
mgSound.play();
|
|
|
|
|
|
|
|
|
|
|
855 |
|
856 |
+
bullets.push({
|
857 |
+
x: this.x,
|
858 |
+
y: this.y,
|
859 |
+
angle: Math.PI / 2, // Shooting downward
|
860 |
+
speed: 10,
|
861 |
+
isEnemy: true,
|
862 |
+
damage: 100,
|
863 |
+
size: 2,
|
864 |
+
isP51Bullet: true
|
|
|
|
|
|
|
|
|
|
|
|
|
865 |
});
|
866 |
}
|
867 |
|
|
|
868 |
update() {
|
869 |
if (isCountingDown) return true;
|
870 |
|
|
|
871 |
this.y += this.speed;
|
872 |
|
|
|
873 |
const now = Date.now();
|
874 |
+
if (now - this.lastShot > this.fireRate) {
|
875 |
+
this.shoot();
|
876 |
+
this.lastShot = now;
|
877 |
}
|
878 |
|
|
|
879 |
return this.y < canvas.height;
|
880 |
}
|
881 |
}
|