Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -470,16 +470,7 @@ class Fighter {
|
|
470 |
this.stallEscapeProgress = 0; // ์คํจ ์ง์
์ ์งํ๋ ์ด๊ธฐํ
|
471 |
}
|
472 |
|
473 |
-
//
|
474 |
-
if (this.stallWarning && this.escapeKeyPressed && pitchAngle > 0.2 && speedKnots > GAME_CONSTANTS.STALL_SPEED + 50) {
|
475 |
-
// Fํค๋ฅผ ๋๋ฅด๊ณ ์๊ณ ์กฐ๊ฑด์ด ๋ง์ผ๋ฉด ์งํ๋ ์ฆ๊ฐ
|
476 |
-
this.stallEscapeProgress += deltaTime;
|
477 |
-
|
478 |
-
// 2์ด ์ด์ Fํค๋ฅผ ๋๋ฅด๊ณ ์์ผ๋ฉด ์คํจ ํ์ถ
|
479 |
-
if (this.stallEscapeProgress >= 2.0) {
|
480 |
-
this.stallWarning = false;
|
481 |
-
this.stallEscapeProgress = 0;
|
482 |
-
}
|
483 |
} else if (this.stallWarning && !this.escapeKeyPressed) {
|
484 |
// Fํค๋ฅผ ๋์ผ๋ฉด ์งํ๋ ๊ฐ์
|
485 |
this.stallEscapeProgress = Math.max(0, this.stallEscapeProgress - deltaTime * 2);
|
@@ -591,8 +582,117 @@ class Fighter {
|
|
591 |
if (this.warningAudios.normal && !this.warningAudios.normal.paused) {
|
592 |
this.warningAudios.normal.volume = 0.3 + this.throttle * 0.4; // 0.3~0.7
|
593 |
}
|
594 |
-
}
|
595 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
596 |
this.stallEscapeProgress = Math.max(0, this.stallEscapeProgress - deltaTime * 2);
|
597 |
}
|
598 |
|
@@ -1206,6 +1306,12 @@ class Game {
|
|
1206 |
this.keys = { w: false, a: false, s: false, d: false, f: false };
|
1207 |
this.isStarted = false;
|
1208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1209 |
this.setupScene();
|
1210 |
this.setupEventListeners();
|
1211 |
this.preloadGame();
|
@@ -1501,14 +1607,14 @@ class Game {
|
|
1501 |
}
|
1502 |
|
1503 |
getTerrainHeightAt(x, z) {
|
1504 |
-
if (!this.terrainGeometry) return 0;
|
1505 |
|
1506 |
// ์งํ ์ขํ๋ฅผ ์ ๊ทํ
|
1507 |
const normalizedX = (x + GAME_CONSTANTS.MAP_SIZE / 2) / GAME_CONSTANTS.MAP_SIZE;
|
1508 |
const normalizedZ = (z + GAME_CONSTANTS.MAP_SIZE / 2) / GAME_CONSTANTS.MAP_SIZE;
|
1509 |
|
1510 |
// ๊ฐ์ฅ ๊ฐ๊น์ด ๋ฒํ
์ค ์ธ๋ฑ์ค ์ฐพ๊ธฐ
|
1511 |
-
const segments =
|
1512 |
const gridX = Math.floor(normalizedX * (segments - 1));
|
1513 |
const gridZ = Math.floor(normalizedZ * (segments - 1));
|
1514 |
|
|
|
470 |
this.stallEscapeProgress = 0; // ์คํจ ์ง์
์ ์งํ๋ ์ด๊ธฐํ
|
471 |
}
|
472 |
|
473 |
+
// Uncaught SyntaxError ํด๊ฒฐ์ ์ํด ํจ์ ๋ ๋ถ๋ถ ์์
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
} else if (this.stallWarning && !this.escapeKeyPressed) {
|
475 |
// Fํค๋ฅผ ๋์ผ๋ฉด ์งํ๋ ๊ฐ์
|
476 |
this.stallEscapeProgress = Math.max(0, this.stallEscapeProgress - deltaTime * 2);
|
|
|
582 |
if (this.warningAudios.normal && !this.warningAudios.normal.paused) {
|
583 |
this.warningAudios.normal.volume = 0.3 + this.throttle * 0.4; // 0.3~0.7
|
584 |
}
|
585 |
+
} Fํค๋ฅผ ๋์ผ๋ฉด ์งํ๋ ๊ฐ์
|
586 |
+
this.stallEscapeProgress = Math.max(0, this.stallEscapeProgress - deltaTime * 2);
|
587 |
+
}
|
588 |
+
|
589 |
+
// ์๋ ๋ณํ ์ ์ฉ
|
590 |
+
if (this.stallWarning) {
|
591 |
+
// ์คํจ ์ํ์์์ ์๋ ๋ณํ
|
592 |
+
if (pitchAngle > 0.1) { // ๊ธฐ์๊ฐ ์๋๋ฅผ ํฅํ ๋
|
593 |
+
// ๋ค์ด๋น์ผ๋ก ์ธํ ์๋ ์ฆ๊ฐ
|
594 |
+
const diveSpeedGain = Math.min(pitchAngle * 300, 200); // ์ต๋ 200m/s ์ฆ๊ฐ
|
595 |
+
this.speed = Math.min(maxSpeed, this.speed + diveSpeedGain * deltaTime);
|
596 |
+
} else {
|
597 |
+
// ๊ธฐ์๊ฐ ์๋ฅผ ํฅํ๊ฑฐ๋ ์ํ์ผ ๋๋ ์๋ ๊ฐ์
|
598 |
+
this.speed = Math.max(0, this.speed - deltaTime * 100);
|
599 |
+
}
|
600 |
+
} else {
|
601 |
+
// ์ ์ ๋นํ ์ ์๋ ๋ณํ
|
602 |
+
this.speed = THREE.MathUtils.lerp(this.speed, targetSpeed, deltaTime * 0.5);
|
603 |
+
}
|
604 |
+
|
605 |
+
// ์คํจ ์ํ์์์ ๋ฌผ๋ฆฌ ํจ๊ณผ
|
606 |
+
if (this.stallWarning) {
|
607 |
+
// ๋ฐ๋ฅ์ผ๋ก ์ถ๋ฝํ๋ฉฐ ๊ฐ์๋๊ฐ ๋น ๋ฅด๊ฒ ๋ถ์
|
608 |
+
this.targetPitch = Math.min(Math.PI / 2.5, this.targetPitch + deltaTime * 2.5); // ๊ธฐ์๊ฐ ๋ ๊ทน๋จ์ ์ผ๋ก ์๋๋ก (72๋๊น์ง)
|
609 |
+
|
610 |
+
// ์กฐ์ข
๋ถ๋ฅ ์ํ - ๋ ์ฌํ ํ๋ค๋ฆผ
|
611 |
+
this.rotation.x += (Math.random() - 0.5) * deltaTime * 0.8;
|
612 |
+
this.rotation.z += (Math.random() - 0.5) * deltaTime * 0.8;
|
613 |
+
|
614 |
+
// ์ค๋ ฅ์ ์ํ ๊ฐ์
|
615 |
+
const gravityAcceleration = GAME_CONSTANTS.GRAVITY * deltaTime * 3.0; // 3๋ฐฐ ์ค๋ ฅ
|
616 |
+
this.velocity.y -= gravityAcceleration;
|
617 |
+
}
|
618 |
+
|
619 |
+
// ์๋ ๋ฒกํฐ ๊ณ์ฐ
|
620 |
+
const noseDirection = new THREE.Vector3(0, 0, 1);
|
621 |
+
noseDirection.applyEuler(this.rotation);
|
622 |
+
|
623 |
+
if (!this.stallWarning) {
|
624 |
+
// ์ ์ ๋นํ ์
|
625 |
+
this.velocity = noseDirection.multiplyScalar(this.speed);
|
626 |
+
} else {
|
627 |
+
// ์คํจ ์์๋ ์ค๋ ฅ์ด ์ฃผ๋์ ์ด์ง๋ง ๋ค์ด๋น ์๋๋ ๋ฐ์
|
628 |
+
this.velocity.x = noseDirection.x * this.speed * 0.5; // ์ ๋ฐฉ ์๋ ์ฆ๊ฐ
|
629 |
+
this.velocity.z = noseDirection.z * this.speed * 0.5;
|
630 |
+
// y ์๋๋ ์์์ ์ค๋ ฅ์ผ๋ก ์ฒ๋ฆฌ๋จ
|
631 |
+
}
|
632 |
+
|
633 |
+
// ์ ์ ๋นํ ์ ์ค๋ ฅ ํจ๊ณผ
|
634 |
+
if (!this.stallWarning) {
|
635 |
+
const gravityEffect = GAME_CONSTANTS.GRAVITY * deltaTime * 0.15;
|
636 |
+
this.velocity.y -= gravityEffect;
|
637 |
+
|
638 |
+
// ์๋ ฅ ํจ๊ณผ (์๋์ ๋น๋ก)
|
639 |
+
const liftFactor = (this.speed / maxSpeed) * 0.8;
|
640 |
+
const lift = gravityEffect * liftFactor;
|
641 |
+
this.velocity.y += lift;
|
642 |
+
}
|
643 |
+
|
644 |
+
// ์์น ์
๋ฐ์ดํธ
|
645 |
+
this.position.add(this.velocity.clone().multiplyScalar(deltaTime));
|
646 |
+
|
647 |
+
// ์งํ ์ถฉ๋ ๊ฐ์ง (Game ํด๋์ค์์ ์ฒ๋ฆฌํ๋๋ก ์์ )
|
648 |
+
|
649 |
+
// ์ง๋ฉด ์ถฉ๋
|
650 |
+
if (this.position.y <= GAME_CONSTANTS.MIN_ALTITUDE) {
|
651 |
+
this.position.y = GAME_CONSTANTS.MIN_ALTITUDE;
|
652 |
+
this.health = 0;
|
653 |
+
return;
|
654 |
+
}
|
655 |
+
|
656 |
+
// ์ต๋ ๊ณ ๋ ์ ํ
|
657 |
+
if (this.position.y > GAME_CONSTANTS.MAX_ALTITUDE) {
|
658 |
+
this.position.y = GAME_CONSTANTS.MAX_ALTITUDE;
|
659 |
+
this.altitudeWarning = true;
|
660 |
+
if (this.velocity.y > 0) this.velocity.y = 0;
|
661 |
+
} else {
|
662 |
+
this.altitudeWarning = false;
|
663 |
+
}
|
664 |
+
|
665 |
+
// ๋งต ๊ฒฝ๊ณ ์ฒ๋ฆฌ
|
666 |
+
const mapLimit = GAME_CONSTANTS.MAP_SIZE / 2;
|
667 |
+
if (this.position.x > mapLimit) this.position.x = -mapLimit;
|
668 |
+
if (this.position.x < -mapLimit) this.position.x = mapLimit;
|
669 |
+
if (this.position.z > mapLimit) this.position.z = -mapLimit;
|
670 |
+
if (this.position.z < -mapLimit) this.position.z = mapLimit;
|
671 |
+
|
672 |
+
// ๋ฉ์ ์์น ๋ฐ ํ์ ์
๋ฐ์ดํธ
|
673 |
+
this.mesh.position.copy(this.position);
|
674 |
+
this.mesh.rotation.x = this.rotation.x;
|
675 |
+
this.mesh.rotation.y = this.rotation.y + 3 * Math.PI / 2;
|
676 |
+
this.mesh.rotation.z = this.rotation.z;
|
677 |
+
|
678 |
+
// ๊ฒฝ๊ณ ๊น๋นก์ ํ์ด๋จธ
|
679 |
+
this.warningBlinkTimer += deltaTime;
|
680 |
+
if (this.warningBlinkTimer >= 1.0) {
|
681 |
+
this.warningBlinkTimer = 0;
|
682 |
+
this.warningBlinkState = !this.warningBlinkState;
|
683 |
+
}
|
684 |
+
|
685 |
+
// ๊ณ ๋ ๊ณ์ฐ
|
686 |
+
this.altitude = this.position.y;
|
687 |
+
|
688 |
+
// ๊ฒฝ๊ณ ์ ์
๋ฐ์ดํธ (์์ง ์๋ฆฌ๋ ๊ณ์ ์ ์ง)
|
689 |
+
this.updateWarningAudios();
|
690 |
+
|
691 |
+
// ์์ง ์๋ฆฌ ๋ณผ๋ฅจ์ ์ค๋กํ์ ์ฐ๋
|
692 |
+
if (this.warningAudios.normal && !this.warningAudios.normal.paused) {
|
693 |
+
this.warningAudios.normal.volume = 0.3 + this.throttle * 0.4; // 0.3~0.7
|
694 |
+
}
|
695 |
+
} Fํค๋ฅผ ๋์ผ๋ฉด ์งํ๋ ๊ฐ์
|
696 |
this.stallEscapeProgress = Math.max(0, this.stallEscapeProgress - deltaTime * 2);
|
697 |
}
|
698 |
|
|
|
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();
|
|
|
1607 |
}
|
1608 |
|
1609 |
getTerrainHeightAt(x, z) {
|
1610 |
+
if (!this.terrainGeometry || !this.heightMap) return 0;
|
1611 |
|
1612 |
// ์งํ ์ขํ๋ฅผ ์ ๊ทํ
|
1613 |
const normalizedX = (x + GAME_CONSTANTS.MAP_SIZE / 2) / GAME_CONSTANTS.MAP_SIZE;
|
1614 |
const normalizedZ = (z + GAME_CONSTANTS.MAP_SIZE / 2) / GAME_CONSTANTS.MAP_SIZE;
|
1615 |
|
1616 |
// ๊ฐ์ฅ ๊ฐ๊น์ด ๋ฒํ
์ค ์ธ๋ฑ์ค ์ฐพ๊ธฐ
|
1617 |
+
const segments = this.terrainSegments || 100; // terrainSegments๊ฐ ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ ์ฌ์ฉ
|
1618 |
const gridX = Math.floor(normalizedX * (segments - 1));
|
1619 |
const gridZ = Math.floor(normalizedZ * (segments - 1));
|
1620 |
|