cutechicken commited on
Commit
d06efcc
ยท
verified ยท
1 Parent(s): 43a60cf

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +120 -14
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
- } //Fํ‚ค๋ฅผ ๋†“์œผ๋ฉด ์ง„ํ–‰๋„ ๊ฐ์†Œ
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 = Math.sqrt(this.terrainGeometry.attributes.position.count);
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