Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -2070,55 +2070,61 @@ class Game {
|
|
| 2070 |
}
|
| 2071 |
|
| 2072 |
checkCollisions() {
|
| 2073 |
-
|
| 2074 |
-
|
| 2075 |
-
|
| 2076 |
-
|
| 2077 |
-
|
| 2078 |
-
|
| 2079 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2080 |
|
| 2081 |
-
|
| 2082 |
-
|
| 2083 |
-
|
| 2084 |
-
|
| 2085 |
-
|
| 2086 |
-
|
| 2087 |
-
|
| 2088 |
-
// νν μ κ±°λ μ΄ννΈ μμ± νμ
|
| 2089 |
-
this.scene.remove(bullet);
|
| 2090 |
-
this.fighter.bullets.splice(i, 1);
|
| 2091 |
|
| 2092 |
-
|
| 2093 |
-
|
| 2094 |
-
|
| 2095 |
-
this.score += 100;
|
| 2096 |
-
}
|
| 2097 |
-
break;
|
| 2098 |
}
|
|
|
|
| 2099 |
}
|
| 2100 |
}
|
| 2101 |
-
|
| 2102 |
-
|
| 2103 |
-
|
| 2104 |
-
|
| 2105 |
-
|
| 2106 |
-
|
| 2107 |
-
|
| 2108 |
-
|
| 2109 |
-
|
| 2110 |
-
|
| 2111 |
-
|
| 2112 |
-
|
| 2113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2114 |
|
| 2115 |
-
|
| 2116 |
-
this.endGame(false);
|
| 2117 |
-
}
|
| 2118 |
}
|
| 2119 |
}
|
| 2120 |
-
}
|
| 2121 |
-
}
|
|
|
|
| 2122 |
|
| 2123 |
createHitEffect(position) {
|
| 2124 |
// νΌκ²© νν°ν΄ ν¨κ³Ό μμ±
|
|
@@ -2215,6 +2221,20 @@ class Game {
|
|
| 2215 |
}
|
| 2216 |
|
| 2217 |
createExplosionEffect(position) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2218 |
// λ©μΈ νλ° νλμ
|
| 2219 |
const explosionGeometry = new THREE.SphereGeometry(50, 16, 16);
|
| 2220 |
const explosionMaterial = new THREE.MeshBasicMaterial({
|
|
@@ -2296,15 +2316,6 @@ class Game {
|
|
| 2296 |
smoke.push(smokePuff);
|
| 2297 |
}
|
| 2298 |
|
| 2299 |
-
// νλ°μ μ¬μ - 150% μλ
|
| 2300 |
-
try {
|
| 2301 |
-
const explosionSound = new Audio('sounds/bang.ogg');
|
| 2302 |
-
explosionSound.volume = 1.0;
|
| 2303 |
-
explosionSound.play().catch(e => console.log('Explosion sound failed:', e));
|
| 2304 |
-
} catch (e) {
|
| 2305 |
-
console.log('Explosion sound error:', e);
|
| 2306 |
-
}
|
| 2307 |
-
|
| 2308 |
// μ λλ©μ΄μ
|
| 2309 |
const animateExplosion = () => {
|
| 2310 |
let allDead = true;
|
|
@@ -2462,10 +2473,15 @@ class Game {
|
|
| 2462 |
|
| 2463 |
this.checkCollisions();
|
| 2464 |
|
| 2465 |
-
|
| 2466 |
-
|
| 2467 |
-
|
| 2468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2469 |
|
| 2470 |
this.updateUI();
|
| 2471 |
this.updateRadar();
|
|
|
|
| 2070 |
}
|
| 2071 |
|
| 2072 |
checkCollisions() {
|
| 2073 |
+
// νλ μ΄μ΄ νν vs μ κΈ° μΆ©λ
|
| 2074 |
+
for (let i = this.fighter.bullets.length - 1; i >= 0; i--) {
|
| 2075 |
+
const bullet = this.fighter.bullets[i];
|
| 2076 |
+
|
| 2077 |
+
for (let j = this.enemies.length - 1; j >= 0; j--) {
|
| 2078 |
+
const enemy = this.enemies[j];
|
| 2079 |
+
if (!enemy.mesh || !enemy.isLoaded) continue;
|
| 2080 |
+
|
| 2081 |
+
const distance = bullet.position.distanceTo(enemy.position);
|
| 2082 |
+
if (distance < 90) {
|
| 2083 |
+
// ννΈ νμ μΆκ°
|
| 2084 |
+
this.showHitMarker(enemy.position);
|
| 2085 |
+
// νΌκ²© μ΄ννΈ μΆκ°
|
| 2086 |
+
this.createHitEffect(enemy.position);
|
| 2087 |
|
| 2088 |
+
// νν μ κ±°λ μ΄ννΈ μμ± νμ
|
| 2089 |
+
this.scene.remove(bullet);
|
| 2090 |
+
this.fighter.bullets.splice(i, 1);
|
| 2091 |
+
|
| 2092 |
+
if (enemy.takeDamage(GAME_CONSTANTS.BULLET_DAMAGE)) {
|
| 2093 |
+
// μ κΈ° νκ΄΄ μ νλ° ν¨κ³Ό μΆκ° - μμΉ νμΈ
|
| 2094 |
+
this.createExplosionEffect(enemy.position);
|
|
|
|
|
|
|
|
|
|
| 2095 |
|
| 2096 |
+
enemy.destroy();
|
| 2097 |
+
this.enemies.splice(j, 1);
|
| 2098 |
+
this.score += 100;
|
|
|
|
|
|
|
|
|
|
| 2099 |
}
|
| 2100 |
+
break;
|
| 2101 |
}
|
| 2102 |
}
|
| 2103 |
+
}
|
| 2104 |
+
|
| 2105 |
+
// μ νν vs νλ μ΄μ΄ μΆ©λ
|
| 2106 |
+
this.enemies.forEach(enemy => {
|
| 2107 |
+
for (let index = enemy.bullets.length - 1; index >= 0; index--) {
|
| 2108 |
+
const bullet = enemy.bullets[index];
|
| 2109 |
+
const distance = bullet.position.distanceTo(this.fighter.position);
|
| 2110 |
+
if (distance < 100) {
|
| 2111 |
+
// νλ μ΄μ΄ νΌκ²© μ΄ννΈ
|
| 2112 |
+
this.createHitEffect(this.fighter.position);
|
| 2113 |
+
|
| 2114 |
+
// νν μ κ±°
|
| 2115 |
+
this.scene.remove(bullet);
|
| 2116 |
+
enemy.bullets.splice(index, 1);
|
| 2117 |
+
|
| 2118 |
+
if (this.fighter.takeDamage(GAME_CONSTANTS.BULLET_DAMAGE)) {
|
| 2119 |
+
// νλ μ΄μ΄ νκ΄΄ μ νλ° ν¨κ³Ό μΆκ°
|
| 2120 |
+
this.createExplosionEffect(this.fighter.position);
|
| 2121 |
|
| 2122 |
+
this.endGame(false);
|
|
|
|
|
|
|
| 2123 |
}
|
| 2124 |
}
|
| 2125 |
+
}
|
| 2126 |
+
});
|
| 2127 |
+
}
|
| 2128 |
|
| 2129 |
createHitEffect(position) {
|
| 2130 |
// νΌκ²© νν°ν΄ ν¨κ³Ό μμ±
|
|
|
|
| 2221 |
}
|
| 2222 |
|
| 2223 |
createExplosionEffect(position) {
|
| 2224 |
+
// νλ°μμ κ°μ₯ λ¨Όμ μ¬μ (μκ°ν¨κ³Όλ³΄λ€ μ°μ )
|
| 2225 |
+
try {
|
| 2226 |
+
const explosionSound = new Audio('sounds/bang.ogg');
|
| 2227 |
+
explosionSound.volume = 1.0; // μ΅λ μλ
|
| 2228 |
+
|
| 2229 |
+
// μ¦μ μ¬μ μλ
|
| 2230 |
+
const playPromise = explosionSound.play();
|
| 2231 |
+
if (playPromise !== undefined) {
|
| 2232 |
+
playPromise.catch(e => console.log('Explosion sound failed:', e));
|
| 2233 |
+
}
|
| 2234 |
+
} catch (e) {
|
| 2235 |
+
console.log('Explosion sound error:', e);
|
| 2236 |
+
}
|
| 2237 |
+
|
| 2238 |
// λ©μΈ νλ° νλμ
|
| 2239 |
const explosionGeometry = new THREE.SphereGeometry(50, 16, 16);
|
| 2240 |
const explosionMaterial = new THREE.MeshBasicMaterial({
|
|
|
|
| 2316 |
smoke.push(smokePuff);
|
| 2317 |
}
|
| 2318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2319 |
// μ λλ©μ΄μ
|
| 2320 |
const animateExplosion = () => {
|
| 2321 |
let allDead = true;
|
|
|
|
| 2473 |
|
| 2474 |
this.checkCollisions();
|
| 2475 |
|
| 2476 |
+
if (this.fighter.health <= 0) {
|
| 2477 |
+
|
| 2478 |
+
if (this.fighter.position.y <= 0) {
|
| 2479 |
+
this.endGame(false, "GROUND COLLISION");
|
| 2480 |
+
} else {
|
| 2481 |
+
this.endGame(false);
|
| 2482 |
+
}
|
| 2483 |
+
return;
|
| 2484 |
+
}
|
| 2485 |
|
| 2486 |
this.updateUI();
|
| 2487 |
this.updateRadar();
|