Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -231,7 +231,7 @@ class Fighter {
|
|
231 |
}
|
232 |
|
233 |
updateMouseInput(deltaX, deltaY) {
|
234 |
-
const sensitivity = GAME_CONSTANTS.MOUSE_SENSITIVITY * 2.0
|
235 |
|
236 |
// λ§μ°μ€ XμΆ: μμ λ‘€(λ κ° κΈ°μΈμ΄κΈ°)λ§ μ‘°μ
|
237 |
this.targetRoll += deltaX * sensitivity;
|
@@ -241,7 +241,7 @@ class Fighter {
|
|
241 |
|
242 |
// κ°λ μ ν
|
243 |
const maxPitchAngle = Math.PI / 3; // 60λ
|
244 |
-
const maxRollAngle = Math.PI; //
|
245 |
|
246 |
this.targetPitch = Math.max(-maxPitchAngle, Math.min(maxPitchAngle, this.targetPitch));
|
247 |
this.targetRoll = Math.max(-maxRollAngle, Math.min(maxRollAngle, this.targetRoll));
|
@@ -269,7 +269,7 @@ class Fighter {
|
|
269 |
if (!this.mesh) return;
|
270 |
|
271 |
// λΆλλ¬μ΄ νμ 보κ°
|
272 |
-
const rotationSpeed = deltaTime * 3.0
|
273 |
this.rotation.x = THREE.MathUtils.lerp(this.rotation.x, this.targetPitch, rotationSpeed);
|
274 |
this.rotation.z = THREE.MathUtils.lerp(this.rotation.z, this.targetRoll, rotationSpeed);
|
275 |
|
@@ -278,7 +278,7 @@ class Fighter {
|
|
278 |
if (Math.abs(this.rotation.z) > 0.1) {
|
279 |
const bankAngle = this.rotation.z;
|
280 |
// λ κ°κ° κΈ°μΈμ΄μ§ λλ§ μ ν (νμ€μ μΈ λΉν)
|
281 |
-
bankTurnRate = Math.sin(bankAngle) * deltaTime * 0.
|
282 |
this.targetYaw += bankTurnRate;
|
283 |
}
|
284 |
|
@@ -295,16 +295,16 @@ class Fighter {
|
|
295 |
const pitchDegrees = Math.abs(pitchAngle) * (180 / Math.PI);
|
296 |
|
297 |
// κΈ°μκ° μλ₯Ό ν₯νκ³ μμ κ²½μ° λΉ λ₯Έ μλ κ°μ
|
298 |
-
if (pitchAngle < -0.1) { //
|
299 |
const climbFactor = Math.abs(pitchAngle) / (Math.PI / 2); // 90λ κΈ°μ€
|
300 |
if (pitchDegrees > 30) { // 30λ μ΄μμΌ λ κΈκ²©ν κ°μ
|
301 |
targetSpeed *= Math.max(0, 1 - climbFactor * 1.5); // μ΅λ 150% κ°μ (0ktκΉμ§)
|
302 |
} else {
|
303 |
targetSpeed *= (1 - climbFactor * 0.3); // μ μμ μΈ κ°μ
|
304 |
}
|
305 |
-
} else if (pitchAngle > 0.1) { // κΈ°μκ° μλλ‘ (νκ°)
|
306 |
const diveFactor = pitchAngle / (Math.PI / 3);
|
307 |
-
targetSpeed *= (1 + diveFactor * 0.
|
308 |
}
|
309 |
|
310 |
// Over-G μν μ²λ¦¬
|
@@ -329,18 +329,35 @@ class Fighter {
|
|
329 |
this.overGTimer = 0; // Over-G μνκ° μλλ©΄ νμ΄λ¨Έ 리μ
|
330 |
}
|
331 |
|
332 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
if (this.stallWarning) {
|
334 |
-
// μ€ν¨
|
335 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
} else {
|
|
|
337 |
this.speed = THREE.MathUtils.lerp(this.speed, targetSpeed, deltaTime * 0.5);
|
338 |
}
|
339 |
|
340 |
-
// μ€ν¨ κ²½κ³ : 300kt μ΄νμμ μ€ν¨ μν
|
341 |
-
const speedKnots = this.speed * 1.94384; // m/s to knots
|
342 |
-
this.stallWarning = speedKnots < GAME_CONSTANTS.STALL_SPEED;
|
343 |
-
|
344 |
// μ€ν¨ μνμμμ 물리 ν¨κ³Ό
|
345 |
if (this.stallWarning) {
|
346 |
// λ°λ₯μΌλ‘ μΆλ½νλ©° κ°μλοΏ½οΏ½οΏ½ λΉ λ₯΄κ² λΆμ
|
@@ -363,9 +380,9 @@ class Fighter {
|
|
363 |
// μ μ λΉν μ
|
364 |
this.velocity = noseDirection.multiplyScalar(this.speed);
|
365 |
} else {
|
366 |
-
// μ€ν¨ μμλ μ€λ ₯μ΄
|
367 |
-
this.velocity.x = noseDirection.x * this.speed * 0.
|
368 |
-
this.velocity.z = noseDirection.z * this.speed * 0.
|
369 |
// y μλλ μμμ μ€λ ₯μΌλ‘ μ²λ¦¬λ¨
|
370 |
}
|
371 |
|
|
|
231 |
}
|
232 |
|
233 |
updateMouseInput(deltaX, deltaY) {
|
234 |
+
const sensitivity = GAME_CONSTANTS.MOUSE_SENSITIVITY * 1.0; // κ°λ 50% κ°μ (2.0 -> 1.0)
|
235 |
|
236 |
// λ§μ°μ€ XμΆ: μμ λ‘€(λ κ° κΈ°μΈμ΄κΈ°)λ§ μ‘°μ
|
237 |
this.targetRoll += deltaX * sensitivity;
|
|
|
241 |
|
242 |
// κ°λ μ ν
|
243 |
const maxPitchAngle = Math.PI / 3; // 60λ
|
244 |
+
const maxRollAngle = Math.PI * 0.75; // 135λλ‘ μ ν
|
245 |
|
246 |
this.targetPitch = Math.max(-maxPitchAngle, Math.min(maxPitchAngle, this.targetPitch));
|
247 |
this.targetRoll = Math.max(-maxRollAngle, Math.min(maxRollAngle, this.targetRoll));
|
|
|
269 |
if (!this.mesh) return;
|
270 |
|
271 |
// λΆλλ¬μ΄ νμ 보κ°
|
272 |
+
const rotationSpeed = deltaTime * 2.0; // νμ μλλ κ°μ (3.0 -> 2.0)
|
273 |
this.rotation.x = THREE.MathUtils.lerp(this.rotation.x, this.targetPitch, rotationSpeed);
|
274 |
this.rotation.z = THREE.MathUtils.lerp(this.rotation.z, this.targetRoll, rotationSpeed);
|
275 |
|
|
|
278 |
if (Math.abs(this.rotation.z) > 0.1) {
|
279 |
const bankAngle = this.rotation.z;
|
280 |
// λ κ°κ° κΈ°μΈμ΄μ§ λλ§ μ ν (νμ€μ μΈ λΉν)
|
281 |
+
bankTurnRate = Math.sin(bankAngle) * deltaTime * 0.3; // μ νμ¨ μΆκ° κ°μ (0.5 -> 0.3)
|
282 |
this.targetYaw += bankTurnRate;
|
283 |
}
|
284 |
|
|
|
295 |
const pitchDegrees = Math.abs(pitchAngle) * (180 / Math.PI);
|
296 |
|
297 |
// κΈ°μκ° μλ₯Ό ν₯νκ³ μμ κ²½μ° λΉ λ₯Έ μλ κ°μ
|
298 |
+
if (pitchAngle < -0.1 && !this.stallWarning) { // μ€ν¨μ΄ μλ λλ§ μμΉμΌλ‘ μΈν κ°μ
|
299 |
const climbFactor = Math.abs(pitchAngle) / (Math.PI / 2); // 90λ κΈ°μ€
|
300 |
if (pitchDegrees > 30) { // 30λ μ΄μμΌ λ κΈκ²©ν κ°μ
|
301 |
targetSpeed *= Math.max(0, 1 - climbFactor * 1.5); // μ΅λ 150% κ°μ (0ktκΉμ§)
|
302 |
} else {
|
303 |
targetSpeed *= (1 - climbFactor * 0.3); // μ μμ μΈ κ°μ
|
304 |
}
|
305 |
+
} else if (pitchAngle > 0.1) { // κΈ°μκ° μλλ‘ (νκ°) - μ€ν¨ μνμμλ μ μ©
|
306 |
const diveFactor = pitchAngle / (Math.PI / 3);
|
307 |
+
targetSpeed *= (1 + diveFactor * 0.4); // νκ° μ κ°μ μ¦κ° (0.2 -> 0.4)
|
308 |
}
|
309 |
|
310 |
// Over-G μν μ²λ¦¬
|
|
|
329 |
this.overGTimer = 0; // Over-G μνκ° μλλ©΄ νμ΄λ¨Έ 리μ
|
330 |
}
|
331 |
|
332 |
+
// μ€ν¨ κ²½κ³ : 300kt μ΄νμμ μ€ν¨ μν
|
333 |
+
const speedKnots = this.speed * 1.94384; // m/s to knots
|
334 |
+
const wasStalling = this.stallWarning;
|
335 |
+
this.stallWarning = speedKnots < GAME_CONSTANTS.STALL_SPEED;
|
336 |
+
|
337 |
+
// μ€ν¨ νμΆ μ‘°κ±΄: Wν€λ₯Ό λλ₯΄κ³ μκ³ , κΈ°μκ° μλλ₯Ό ν₯νκ³ μμ λ
|
338 |
+
if (this.stallWarning && this.throttle > 0.8 && pitchAngle > 0.2) {
|
339 |
+
// λ€μ΄λΉ μ€μ μλκ° ν볡λλ©΄ μ€ν¨ νμΆ
|
340 |
+
if (speedKnots > GAME_CONSTANTS.STALL_SPEED + 50) { // 350kt μ΄μ
|
341 |
+
this.stallWarning = false;
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
// μλ λ³ν μ μ©
|
346 |
if (this.stallWarning) {
|
347 |
+
// μ€ν¨ μνμμμ μλ λ³ν
|
348 |
+
if (pitchAngle > 0.1) { // κΈ°μκ° μλλ₯Ό ν₯ν λ
|
349 |
+
// λ€μ΄λΉμΌλ‘ μΈν μλ μ¦κ°
|
350 |
+
const diveSpeedGain = Math.min(pitchAngle * 300, 200); // μ΅λ 200m/s μ¦κ°
|
351 |
+
this.speed = Math.min(maxSpeed, this.speed + diveSpeedGain * deltaTime);
|
352 |
+
} else {
|
353 |
+
// κΈ°μκ° μλ₯Ό ν₯νκ±°λ μνμΌ λλ μλ κ°μ
|
354 |
+
this.speed = Math.max(0, this.speed - deltaTime * 100);
|
355 |
+
}
|
356 |
} else {
|
357 |
+
// μ μ λΉν μ μλ λ³ν
|
358 |
this.speed = THREE.MathUtils.lerp(this.speed, targetSpeed, deltaTime * 0.5);
|
359 |
}
|
360 |
|
|
|
|
|
|
|
|
|
361 |
// μ€ν¨ μνμμμ 물리 ν¨κ³Ό
|
362 |
if (this.stallWarning) {
|
363 |
// λ°λ₯μΌλ‘ μΆλ½νλ©° κ°μλοΏ½οΏ½οΏ½ λΉ λ₯΄κ² λΆμ
|
|
|
380 |
// μ μ λΉν μ
|
381 |
this.velocity = noseDirection.multiplyScalar(this.speed);
|
382 |
} else {
|
383 |
+
// μ€ν¨ μμλ μ€λ ₯μ΄ μ£Όλμ μ΄μ§λ§ λ€μ΄λΉ μλλ λ°μ
|
384 |
+
this.velocity.x = noseDirection.x * this.speed * 0.5; // μ λ°© μλ μ¦κ°
|
385 |
+
this.velocity.z = noseDirection.z * this.speed * 0.5;
|
386 |
// y μλλ μμμ μ€λ ₯μΌλ‘ μ²λ¦¬λ¨
|
387 |
}
|
388 |
|