Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -76,7 +76,6 @@ class Fighter {
|
|
| 76 |
// ๊ฒฝ๊ณ ์์คํ
|
| 77 |
this.altitudeWarning = false;
|
| 78 |
this.stallWarning = false;
|
| 79 |
-
this.terrainWarning = false; // ์งํ ์ถฉ๋ ๊ฒฝ๊ณ ์ถ๊ฐ
|
| 80 |
this.warningBlinkTimer = 0;
|
| 81 |
this.warningBlinkState = false;
|
| 82 |
|
|
@@ -91,7 +90,6 @@ class Fighter {
|
|
| 91 |
pullup: null,
|
| 92 |
overg: null,
|
| 93 |
stall: null,
|
| 94 |
-
terrain: null, // ์งํ ์ถฉ๋ ๊ฒฝ๊ณ ์ ์ถ๊ฐ
|
| 95 |
normal: null // ์์ง ์๋ฆฌ
|
| 96 |
};
|
| 97 |
this.initializeWarningAudios();
|
|
@@ -111,10 +109,6 @@ class Fighter {
|
|
| 111 |
this.warningAudios.stall = new Audio('sounds/alert.ogg');
|
| 112 |
this.warningAudios.stall.volume = 0.75;
|
| 113 |
|
| 114 |
-
// ์งํ ์ถฉ๋ ๊ฒฝ๊ณ ์
|
| 115 |
-
this.warningAudios.terrain = new Audio('sounds/alert.ogg');
|
| 116 |
-
this.warningAudios.terrain.volume = 0.8;
|
| 117 |
-
|
| 118 |
// ์์ง ์๋ฆฌ ์ค์
|
| 119 |
this.warningAudios.normal = new Audio('sounds/normal.ogg');
|
| 120 |
this.warningAudios.normal.volume = 0.5;
|
|
@@ -151,9 +145,6 @@ class Fighter {
|
|
| 151 |
else if (this.altitude < 500) {
|
| 152 |
currentWarning = 'altitude';
|
| 153 |
}
|
| 154 |
-
else if (this.terrainWarning) {
|
| 155 |
-
currentWarning = 'terrain';
|
| 156 |
-
}
|
| 157 |
else if (this.overG) {
|
| 158 |
currentWarning = 'overg';
|
| 159 |
}
|
|
@@ -1306,12 +1297,6 @@ class Game {
|
|
| 1306 |
this.keys = { w: false, a: false, s: false, d: false, f: false };
|
| 1307 |
this.isStarted = false;
|
| 1308 |
|
| 1309 |
-
// ์งํ ๊ด๋ จ ์ด๊ธฐํ
|
| 1310 |
-
this.terrain = null;
|
| 1311 |
-
this.terrainGeometry = null;
|
| 1312 |
-
this.heightMap = null;
|
| 1313 |
-
this.terrainSegments = 100;
|
| 1314 |
-
|
| 1315 |
this.setupScene();
|
| 1316 |
this.setupEventListeners();
|
| 1317 |
this.preloadGame();
|
|
@@ -1442,17 +1427,18 @@ class Game {
|
|
| 1442 |
directionalLight.shadow.camera.bottom = -8000;
|
| 1443 |
this.scene.add(directionalLight);
|
| 1444 |
|
| 1445 |
-
//
|
| 1446 |
-
|
| 1447 |
-
|
| 1448 |
-
|
| 1449 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1450 |
|
| 1451 |
// ๊ฐ์ ๋ ๊ตฌ๋ฆ ์ถ๊ฐ
|
| 1452 |
this.addClouds();
|
| 1453 |
-
|
| 1454 |
-
// ๋๊ธฐ ํจ๊ณผ ์ถ๊ฐ
|
| 1455 |
-
this.addAtmosphericEffects();
|
| 1456 |
}
|
| 1457 |
|
| 1458 |
createProceduralTerrain() {
|
|
@@ -2279,10 +2265,6 @@ class Game {
|
|
| 2279 |
warningText += 'OVER-G! OVER-G!\n';
|
| 2280 |
}
|
| 2281 |
|
| 2282 |
-
if (this.fighter.terrainWarning) {
|
| 2283 |
-
warningText += 'TERRAIN! TERRAIN!\n';
|
| 2284 |
-
}
|
| 2285 |
-
|
| 2286 |
if (warningText) {
|
| 2287 |
warningContainer.innerHTML = warningText.replace(/\n/g, '<br>');
|
| 2288 |
document.body.appendChild(warningContainer);
|
|
@@ -2448,34 +2430,6 @@ class Game {
|
|
| 2448 |
});
|
| 2449 |
}
|
| 2450 |
|
| 2451 |
-
checkTerrainCollision() {
|
| 2452 |
-
if (!this.fighter || !this.terrain || !this.heightMap) return;
|
| 2453 |
-
|
| 2454 |
-
// ํ์ฌ ์ ํฌ๊ธฐ ์์น์์์ ์งํ ๋์ด ๊ณ์ฐ
|
| 2455 |
-
const terrainHeight = this.getTerrainHeightAt(this.fighter.position.x, this.fighter.position.z);
|
| 2456 |
-
|
| 2457 |
-
// ์งํ๊ณผ์ ๊ฑฐ๋ฆฌ ๊ณ์ฐ
|
| 2458 |
-
const clearanceHeight = this.fighter.position.y - terrainHeight;
|
| 2459 |
-
|
| 2460 |
-
// ์ถฉ๋ ๊ฒฝ๊ณ ๊ฑฐ๋ฆฌ ์ค์ (์๋์ ๋ฐ๋ผ ๋์ ์ผ๋ก ์กฐ์ )
|
| 2461 |
-
const warningDistance = 150 + this.fighter.speed * 0.1; // ๊ธฐ๋ณธ 150m + ์๋ ๋ณด์
|
| 2462 |
-
const criticalDistance = 50;
|
| 2463 |
-
|
| 2464 |
-
// ์งํ ์ถฉ๋ ๊ฒฝ๊ณ ํ์
|
| 2465 |
-
if (clearanceHeight < warningDistance) {
|
| 2466 |
-
this.fighter.terrainWarning = true;
|
| 2467 |
-
|
| 2468 |
-
// ์ค์ ์ถฉ๋ ํ์
|
| 2469 |
-
if (clearanceHeight < criticalDistance) {
|
| 2470 |
-
// ์ถฉ๋ ๋ฐ์
|
| 2471 |
-
this.fighter.health = 0;
|
| 2472 |
-
this.endGame(false, "TERRAIN COLLISION");
|
| 2473 |
-
}
|
| 2474 |
-
} else {
|
| 2475 |
-
this.fighter.terrainWarning = false;
|
| 2476 |
-
}
|
| 2477 |
-
}
|
| 2478 |
-
|
| 2479 |
checkCollisions() {
|
| 2480 |
// ํ๋ ์ด์ด ํํ vs ์ ๊ธฐ ์ถฉ๋
|
| 2481 |
for (let i = this.fighter.bullets.length - 1; i >= 0; i--) {
|
|
@@ -2685,9 +2639,6 @@ class Game {
|
|
| 2685 |
this.fighter.updatePhysics(deltaTime);
|
| 2686 |
this.fighter.updateBullets(this.scene, deltaTime);
|
| 2687 |
|
| 2688 |
-
// ์งํ ์ถฉ๋ ๊ฐ์ง
|
| 2689 |
-
this.checkTerrainCollision();
|
| 2690 |
-
|
| 2691 |
// ๋ง์ฐ์ค ๋๋ฆ ์ํ์ผ ๋ ์ฐ์ ๋ฐ์ฌ
|
| 2692 |
if (this.fighter.isMouseDown && this.isStarted) {
|
| 2693 |
const currentShootTime = Date.now();
|
|
|
|
| 76 |
// ๊ฒฝ๊ณ ์์คํ
|
| 77 |
this.altitudeWarning = false;
|
| 78 |
this.stallWarning = false;
|
|
|
|
| 79 |
this.warningBlinkTimer = 0;
|
| 80 |
this.warningBlinkState = false;
|
| 81 |
|
|
|
|
| 90 |
pullup: null,
|
| 91 |
overg: null,
|
| 92 |
stall: null,
|
|
|
|
| 93 |
normal: null // ์์ง ์๋ฆฌ
|
| 94 |
};
|
| 95 |
this.initializeWarningAudios();
|
|
|
|
| 109 |
this.warningAudios.stall = new Audio('sounds/alert.ogg');
|
| 110 |
this.warningAudios.stall.volume = 0.75;
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
// ์์ง ์๋ฆฌ ์ค์
|
| 113 |
this.warningAudios.normal = new Audio('sounds/normal.ogg');
|
| 114 |
this.warningAudios.normal.volume = 0.5;
|
|
|
|
| 145 |
else if (this.altitude < 500) {
|
| 146 |
currentWarning = 'altitude';
|
| 147 |
}
|
|
|
|
|
|
|
|
|
|
| 148 |
else if (this.overG) {
|
| 149 |
currentWarning = 'overg';
|
| 150 |
}
|
|
|
|
| 1297 |
this.keys = { w: false, a: false, s: false, d: false, f: false };
|
| 1298 |
this.isStarted = false;
|
| 1299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1300 |
this.setupScene();
|
| 1301 |
this.setupEventListeners();
|
| 1302 |
this.preloadGame();
|
|
|
|
| 1427 |
directionalLight.shadow.camera.bottom = -8000;
|
| 1428 |
this.scene.add(directionalLight);
|
| 1429 |
|
| 1430 |
+
// ๋จ์ํ ํํํ ๋ฐ๋ฅ
|
| 1431 |
+
const groundGeometry = new THREE.PlaneGeometry(GAME_CONSTANTS.MAP_SIZE, GAME_CONSTANTS.MAP_SIZE);
|
| 1432 |
+
const groundMaterial = new THREE.MeshLambertMaterial({
|
| 1433 |
+
color: 0x8FBC8F
|
| 1434 |
+
});
|
| 1435 |
+
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
|
| 1436 |
+
ground.rotation.x = -Math.PI / 2;
|
| 1437 |
+
ground.receiveShadow = true;
|
| 1438 |
+
this.scene.add(ground);
|
| 1439 |
|
| 1440 |
// ๊ฐ์ ๋ ๊ตฌ๋ฆ ์ถ๊ฐ
|
| 1441 |
this.addClouds();
|
|
|
|
|
|
|
|
|
|
| 1442 |
}
|
| 1443 |
|
| 1444 |
createProceduralTerrain() {
|
|
|
|
| 2265 |
warningText += 'OVER-G! OVER-G!\n';
|
| 2266 |
}
|
| 2267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2268 |
if (warningText) {
|
| 2269 |
warningContainer.innerHTML = warningText.replace(/\n/g, '<br>');
|
| 2270 |
document.body.appendChild(warningContainer);
|
|
|
|
| 2430 |
});
|
| 2431 |
}
|
| 2432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2433 |
checkCollisions() {
|
| 2434 |
// ํ๋ ์ด์ด ํํ vs ์ ๊ธฐ ์ถฉ๋
|
| 2435 |
for (let i = this.fighter.bullets.length - 1; i >= 0; i--) {
|
|
|
|
| 2639 |
this.fighter.updatePhysics(deltaTime);
|
| 2640 |
this.fighter.updateBullets(this.scene, deltaTime);
|
| 2641 |
|
|
|
|
|
|
|
|
|
|
| 2642 |
// ๋ง์ฐ์ค ๋๋ฆ ์ํ์ผ ๋ ์ฐ์ ๋ฐ์ฌ
|
| 2643 |
if (this.fighter.isMouseDown && this.isStarted) {
|
| 2644 |
const currentShootTime = Date.now();
|