cutechicken commited on
Commit
a3ac463
Β·
verified Β·
1 Parent(s): aeb079a

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +41 -21
game.js CHANGED
@@ -730,6 +730,8 @@ class EnemyFighter {
730
  this.speed = 600; // 600kt둜 μ‹œμž‘ (500-750kt λ²”μœ„)
731
  this.velocity = new THREE.Vector3(0, 0, 0);
732
  this.health = GAME_CONSTANTS.MAX_HEALTH;
 
 
733
 
734
  // AI μƒνƒœ
735
  this.aiState = 'patrol'; // patrol, combat, evade
@@ -848,8 +850,11 @@ class EnemyFighter {
848
  // λͺ©ν‘œλ₯Ό ν–₯ν•΄ λΆ€λ“œλŸ½κ²Œ νšŒμ „
849
  this.smoothTurnToTarget(this.targetPosition, deltaTime);
850
 
851
- // 속도 μœ μ§€ (500-750kt)
852
- this.speed = THREE.MathUtils.clamp(this.speed, 257, 386); // m/s λ³€ν™˜
 
 
 
853
  }
854
 
855
  executeCombat(playerPosition, deltaTime) {
@@ -889,7 +894,7 @@ class EnemyFighter {
889
  smoothTurnToTarget(targetPos, deltaTime) {
890
  // νƒ€κ²Ÿ λ°©ν–₯ 계산
891
  const direction = targetPos.clone().sub(this.position);
892
- direction.y *= 0.3; // 수직 이동을 μ œν•œ
893
  direction.normalize();
894
 
895
  // 좩돌 νšŒν”Ό 벑터 적용
@@ -916,15 +921,16 @@ class EnemyFighter {
916
  }
917
 
918
  // Pitch νšŒμ „ (μ œν•œμ )
919
- const maxPitchRate = maxTurnRate * 0.5;
920
  if (Math.abs(pitchDiff) > maxPitchRate) {
921
  this.rotation.x += Math.sign(pitchDiff) * maxPitchRate;
922
  } else {
923
  this.rotation.x = targetPitch;
924
  }
925
 
926
- // Pitch μ œν•œ
927
- this.rotation.x = THREE.MathUtils.clamp(this.rotation.x, -Math.PI / 6, Math.PI / 6);
 
928
  }
929
 
930
  calculateAvoidance() {
@@ -960,20 +966,25 @@ class EnemyFighter {
960
  const forward = new THREE.Vector3(0, 0, 1);
961
  forward.applyEuler(this.rotation);
962
 
963
- // 속도 μœ μ§€ (500-750kt, m/s둜 λ³€ν™˜)
964
- this.speed = THREE.MathUtils.clamp(this.speed, 257, 386);
 
 
 
 
 
965
  this.velocity = forward.multiplyScalar(this.speed);
966
 
967
- // μœ„μΉ˜ μ—…λ°μ΄νŠΈ
968
  this.position.add(this.velocity.clone().multiplyScalar(deltaTime));
969
 
970
  // 고도 μ œν•œ
971
  if (this.position.y < 500) {
972
  this.position.y = 500;
973
- this.rotation.x = -0.1; // μ•½κ°„ μƒμŠΉ
974
  } else if (this.position.y > 8000) {
975
  this.position.y = 8000;
976
- this.rotation.x = 0.1; // μ•½κ°„ ν•˜κ°•
977
  }
978
 
979
  // λ§΅ 경계 처리
@@ -1017,8 +1028,8 @@ class EnemyFighter {
1017
  }
1018
 
1019
  shoot() {
1020
- // νƒ„ν™˜ 생성
1021
- const bulletGeometry = new THREE.CylinderGeometry(0.8, 0.8, 12, 8);
1022
  const bulletMaterial = new THREE.MeshBasicMaterial({
1023
  color: 0xff0000,
1024
  emissive: 0xff0000,
@@ -1026,19 +1037,22 @@ class EnemyFighter {
1026
  });
1027
  const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
1028
 
1029
- // 기수 λμ—μ„œ λ°œμ‚¬
1030
- const muzzleOffset = new THREE.Vector3(0, 0, 12);
1031
  muzzleOffset.applyEuler(this.rotation);
1032
  bullet.position.copy(this.position).add(muzzleOffset);
1033
 
1034
- // νƒ„ν™˜ νšŒμ „
1035
  bullet.rotation.copy(this.rotation);
1036
  bullet.rotateX(Math.PI / 2);
1037
 
1038
- // νƒ„ν™˜ 속도
 
 
 
1039
  const direction = new THREE.Vector3(0, 0, 1);
1040
  direction.applyEuler(this.rotation);
1041
- bullet.velocity = direction.multiplyScalar(1200);
1042
 
1043
  this.scene.add(bullet);
1044
  this.bullets.push(bullet);
@@ -1072,8 +1086,9 @@ class EnemyFighter {
1072
  continue;
1073
  }
1074
 
1075
- // 거리 μ œν•œ
1076
- if (bullet.position.distanceTo(this.position) > 5000) {
 
1077
  this.scene.remove(bullet);
1078
  this.bullets.splice(i, 1);
1079
  }
@@ -1089,9 +1104,14 @@ class EnemyFighter {
1089
 
1090
  selectNewPatrolTarget() {
1091
  const mapLimit = GAME_CONSTANTS.MAP_SIZE / 2 * 0.7;
 
 
 
 
 
1092
  this.targetPosition = new THREE.Vector3(
1093
  (Math.random() - 0.5) * 2 * mapLimit,
1094
- 2000 + Math.random() * 2000, // 2000-4000m 고도
1095
  (Math.random() - 0.5) * 2 * mapLimit
1096
  );
1097
  }
 
730
  this.speed = 600; // 600kt둜 μ‹œμž‘ (500-750kt λ²”μœ„)
731
  this.velocity = new THREE.Vector3(0, 0, 0);
732
  this.health = GAME_CONSTANTS.MAX_HEALTH;
733
+ this.minSpeed = 257; // 500kt in m/s
734
+ this.maxSpeed = 386; // 750kt in m/s
735
 
736
  // AI μƒνƒœ
737
  this.aiState = 'patrol'; // patrol, combat, evade
 
850
  // λͺ©ν‘œλ₯Ό ν–₯ν•΄ λΆ€λ“œλŸ½κ²Œ νšŒμ „
851
  this.smoothTurnToTarget(this.targetPosition, deltaTime);
852
 
853
+ // 속도 μœ μ§€ (500-750kt) - 항상 μ΅œμ†Œ 속도 이상 μœ μ§€
854
+ if (this.speed < this.minSpeed) {
855
+ this.speed = this.minSpeed;
856
+ }
857
+ this.speed = THREE.MathUtils.clamp(this.speed, this.minSpeed, this.maxSpeed);
858
  }
859
 
860
  executeCombat(playerPosition, deltaTime) {
 
894
  smoothTurnToTarget(targetPos, deltaTime) {
895
  // νƒ€κ²Ÿ λ°©ν–₯ 계산
896
  const direction = targetPos.clone().sub(this.position);
897
+ direction.y *= 0.5; // 수직 이동을 덜 μ œν•œμ μœΌλ‘œ
898
  direction.normalize();
899
 
900
  // 좩돌 νšŒν”Ό 벑터 적용
 
921
  }
922
 
923
  // Pitch νšŒμ „ (μ œν•œμ )
924
+ const maxPitchRate = maxTurnRate * 0.7; // ν”ΌμΉ˜λŠ” 쑰금 더 λΉ λ₯΄κ²Œ
925
  if (Math.abs(pitchDiff) > maxPitchRate) {
926
  this.rotation.x += Math.sign(pitchDiff) * maxPitchRate;
927
  } else {
928
  this.rotation.x = targetPitch;
929
  }
930
 
931
+ // Pitch μ œν•œ (Β±40도)
932
+ const maxPitchAngle = Math.PI * 40 / 180; // 40도λ₯Ό λΌλ””μ•ˆμœΌλ‘œ
933
+ this.rotation.x = THREE.MathUtils.clamp(this.rotation.x, -maxPitchAngle, maxPitchAngle);
934
  }
935
 
936
  calculateAvoidance() {
 
966
  const forward = new THREE.Vector3(0, 0, 1);
967
  forward.applyEuler(this.rotation);
968
 
969
+ // 속도 μœ μ§€ (500-750kt, m/s둜 λ³€ν™˜) - κ°•μ œλ‘œ μ΅œμ†Œ 속도 μœ μ§€
970
+ if (this.speed < this.minSpeed) {
971
+ this.speed = this.minSpeed;
972
+ }
973
+ this.speed = THREE.MathUtils.clamp(this.speed, this.minSpeed, this.maxSpeed);
974
+
975
+ // 속도 벑터 생성 - 항상 μ „μ§„
976
  this.velocity = forward.multiplyScalar(this.speed);
977
 
978
+ // μœ„μΉ˜ μ—…λ°μ΄νŠΈ - 항상 이동
979
  this.position.add(this.velocity.clone().multiplyScalar(deltaTime));
980
 
981
  // 고도 μ œν•œ
982
  if (this.position.y < 500) {
983
  this.position.y = 500;
984
+ this.rotation.x = -0.2; // μƒμŠΉ
985
  } else if (this.position.y > 8000) {
986
  this.position.y = 8000;
987
+ this.rotation.x = 0.2; // ν•˜κ°•
988
  }
989
 
990
  // λ§΅ 경계 처리
 
1028
  }
1029
 
1030
  shoot() {
1031
+ // νƒ„ν™˜ 생성 (ν”Œλ ˆμ΄μ–΄μ™€ λ™μΌν•œ 크기)
1032
+ const bulletGeometry = new THREE.CylinderGeometry(1.0, 1.0, 16, 8);
1033
  const bulletMaterial = new THREE.MeshBasicMaterial({
1034
  color: 0xff0000,
1035
  emissive: 0xff0000,
 
1037
  });
1038
  const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
1039
 
1040
+ // 기수 λμ—μ„œ λ°œμ‚¬ (ν”Œλ ˆμ΄μ–΄μ™€ λ™μΌν•˜κ²Œ 더 μ•žμͺ½μ—μ„œ)
1041
+ const muzzleOffset = new THREE.Vector3(0, 0, 10);
1042
  muzzleOffset.applyEuler(this.rotation);
1043
  bullet.position.copy(this.position).add(muzzleOffset);
1044
 
1045
+ // νƒ„ν™˜μ„ λ°œμ‚¬ λ°©ν–₯으둜 νšŒμ „
1046
  bullet.rotation.copy(this.rotation);
1047
  bullet.rotateX(Math.PI / 2);
1048
 
1049
+ // νƒ„ν™˜ 초기 μœ„μΉ˜ μ €μž₯
1050
+ bullet.startPosition = bullet.position.clone();
1051
+
1052
+ // νƒ„ν™˜ 속도 (ν”Œλ ˆμ΄μ–΄μ™€ λ™μΌν•˜κ²Œ 1500)
1053
  const direction = new THREE.Vector3(0, 0, 1);
1054
  direction.applyEuler(this.rotation);
1055
+ bullet.velocity = direction.multiplyScalar(1500);
1056
 
1057
  this.scene.add(bullet);
1058
  this.bullets.push(bullet);
 
1086
  continue;
1087
  }
1088
 
1089
+ // 거리 μ œν•œ (ν”Œλ ˆμ΄μ–΄μ™€ λ™μΌν•˜κ²Œ 6000m)
1090
+ if (bullet.position.distanceTo(bullet.startPosition) > 6000 ||
1091
+ bullet.position.y > GAME_CONSTANTS.MAX_ALTITUDE + 500) {
1092
  this.scene.remove(bullet);
1093
  this.bullets.splice(i, 1);
1094
  }
 
1104
 
1105
  selectNewPatrolTarget() {
1106
  const mapLimit = GAME_CONSTANTS.MAP_SIZE / 2 * 0.7;
1107
+
1108
+ // 더 λ‹€μ–‘ν•œ 고도 선택
1109
+ const minAltitude = 1000;
1110
+ const maxAltitude = 6000;
1111
+
1112
  this.targetPosition = new THREE.Vector3(
1113
  (Math.random() - 0.5) * 2 * mapLimit,
1114
+ minAltitude + Math.random() * (maxAltitude - minAltitude),
1115
  (Math.random() - 0.5) * 2 * mapLimit
1116
  );
1117
  }