Spaces:
Running
Running
cutechicken
commited on
Update index.html
Browse files- index.html +37 -17
index.html
CHANGED
@@ -242,6 +242,11 @@
|
|
242 |
let bgm = new Audio('title.ogg');
|
243 |
const countSound = new Audio('count.ogg');
|
244 |
const deathSound = new Audio('death.ogg');
|
|
|
|
|
|
|
|
|
|
|
245 |
bgm.loop = true;
|
246 |
enemyFireSound.volume = 0.5;
|
247 |
|
@@ -956,7 +961,14 @@ function updateGame() {
|
|
956 |
|
957 |
fireBullet();
|
958 |
}
|
959 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
960 |
// BF109 κ΄λ ¨ μ½λ
|
961 |
if (hasBF109 && !isCountingDown) {
|
962 |
const now = Date.now();
|
@@ -1008,22 +1020,30 @@ function updateGame() {
|
|
1008 |
bullet.y += Math.sin(bullet.angle) * bullet.speed;
|
1009 |
|
1010 |
if(!bullet.isEnemy) {
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1027 |
} else {
|
1028 |
// μμ μ΄ μ΄λ €μμ§ μμ λλ§ νλ μ΄μ΄ λ°λ―Έμ§ μ²λ¦¬
|
1029 |
if (!document.getElementById('shop').style.display ||
|
|
|
242 |
let bgm = new Audio('title.ogg');
|
243 |
const countSound = new Audio('count.ogg');
|
244 |
const deathSound = new Audio('death.ogg');
|
245 |
+
let currentHitSound = null;
|
246 |
+
let currentReloadSound = null;
|
247 |
+
const hitSounds = Array.from({length: 6}, (_, i) => new Audio(`hit${i+1}.ogg`));
|
248 |
+
const reloadSounds = [new Audio('reload1.ogg'), new Audio('reload2.ogg')];
|
249 |
+
const escapeSound = new Audio('escape.ogg');
|
250 |
bgm.loop = true;
|
251 |
enemyFireSound.volume = 0.5;
|
252 |
|
|
|
961 |
|
962 |
fireBullet();
|
963 |
}
|
964 |
+
// ν
μ€νΈμ€, μλλ©΄ μμ
|
965 |
+
if(player.health <= 0) {
|
966 |
+
gameOver = true;
|
967 |
+
restartBtn.style.display = 'block';
|
968 |
+
effects.push(new Effect(player.x, player.y, 1000, 'death'));
|
969 |
+
deathSound.cloneNode().play();
|
970 |
+
escapeSound.play(); // μ¬λ§ μ escape.ogg μ¬μ
|
971 |
+
}
|
972 |
// BF109 κ΄λ ¨ μ½λ
|
973 |
if (hasBF109 && !isCountingDown) {
|
974 |
const now = Date.now();
|
|
|
1020 |
bullet.y += Math.sin(bullet.angle) * bullet.speed;
|
1021 |
|
1022 |
if(!bullet.isEnemy) {
|
1023 |
+
enemies = enemies.filter(enemy => {
|
1024 |
+
const dist = Math.hypot(bullet.x - enemy.x, bullet.y - enemy.y);
|
1025 |
+
if(dist < 30) {
|
1026 |
+
let damage = currentWeapon === 'cannon' ? 250 : 50;
|
1027 |
+
enemy.health -= damage;
|
1028 |
+
if(enemy.health <= 0) {
|
1029 |
+
spawnHealthItem(enemy.x, enemy.y);
|
1030 |
+
gold += 100;
|
1031 |
+
effects.push(new Effect(enemy.x, enemy.y, 1000, 'death'));
|
1032 |
+
deathSound.cloneNode().play();
|
1033 |
+
|
1034 |
+
// ννΈ μ¬μ΄λ μ¬μ μΆκ°
|
1035 |
+
if (!currentHitSound || currentHitSound.ended) {
|
1036 |
+
currentHitSound = hitSounds[Math.floor(Math.random() * hitSounds.length)];
|
1037 |
+
currentHitSound.volume = 1.0;
|
1038 |
+
currentHitSound.play();
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
return false;
|
1042 |
+
}
|
1043 |
+
return true;
|
1044 |
+
}
|
1045 |
+
return true;
|
1046 |
+
});
|
1047 |
} else {
|
1048 |
// μμ μ΄ μ΄λ €μμ§ μμ λλ§ νλ μ΄μ΄ λ°λ―Έμ§ μ²λ¦¬
|
1049 |
if (!document.getElementById('shop').style.display ||
|