Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -234,20 +234,30 @@ class Fighter {
|
|
234 |
}
|
235 |
|
236 |
updateMouseInput(deltaX, deltaY) {
|
237 |
-
const sensitivity = GAME_CONSTANTS.MOUSE_SENSITIVITY * 1.0;
|
238 |
-
|
239 |
-
// λ§μ°μ€ XμΆ: μμ λ‘€(λ κ° κΈ°μΈμ΄κΈ°)λ§ μ‘°μ
|
240 |
-
this.targetRoll += deltaX * sensitivity;
|
241 |
|
242 |
// λ§μ°μ€ YμΆ: νΌμΉ(κΈ°μ μν)
|
243 |
this.targetPitch -= deltaY * sensitivity;
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
// κ°λ μ ν
|
246 |
const maxPitchAngle = Math.PI / 3; // 60λ
|
247 |
-
const maxRollAngle = Math.PI * 0.
|
248 |
|
249 |
this.targetPitch = Math.max(-maxPitchAngle, Math.min(maxPitchAngle, this.targetPitch));
|
250 |
-
|
|
|
|
|
|
|
|
|
|
|
251 |
}
|
252 |
|
253 |
updateControls(keys, deltaTime) {
|
@@ -259,12 +269,12 @@ class Fighter {
|
|
259 |
this.throttle = Math.max(0.1, this.throttle - deltaTime * 0.5); // μ²μ²ν κ°μ
|
260 |
}
|
261 |
|
262 |
-
// A/D:
|
263 |
if (keys.a) {
|
264 |
-
this.targetYaw -= deltaTime * 0.
|
265 |
}
|
266 |
if (keys.d) {
|
267 |
-
this.targetYaw += deltaTime * 0.
|
268 |
}
|
269 |
}
|
270 |
|
@@ -272,22 +282,27 @@ class Fighter {
|
|
272 |
if (!this.mesh) return;
|
273 |
|
274 |
// λΆλλ¬μ΄ νμ 보κ°
|
275 |
-
const rotationSpeed = deltaTime * 2.0;
|
276 |
this.rotation.x = THREE.MathUtils.lerp(this.rotation.x, this.targetPitch, rotationSpeed);
|
277 |
-
this.rotation.
|
278 |
|
279 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
let bankTurnRate = 0;
|
281 |
-
if (Math.abs(this.rotation.z) > 0.
|
282 |
const bankAngle = this.rotation.z;
|
283 |
-
|
284 |
-
bankTurnRate = Math.sin(bankAngle) * deltaTime * 0.3; // μ νμ¨ μΆκ° κ°μ (0.5 -> 0.3)
|
285 |
this.targetYaw += bankTurnRate;
|
286 |
}
|
287 |
|
288 |
-
// μ νμ μ μ©
|
289 |
-
this.rotation.y = THREE.MathUtils.lerp(this.rotation.y, this.targetYaw, rotationSpeed);
|
290 |
-
|
291 |
// νμ€μ μΈ μλ κ³μ°
|
292 |
const minSpeed = 0; // μ΅μ μλ 0kt
|
293 |
const maxSpeed = 600; // μ΅λ μλ 600kt
|
|
|
234 |
}
|
235 |
|
236 |
updateMouseInput(deltaX, deltaY) {
|
237 |
+
const sensitivity = GAME_CONSTANTS.MOUSE_SENSITIVITY * 1.0;
|
|
|
|
|
|
|
238 |
|
239 |
// λ§μ°μ€ YμΆ: νΌμΉ(κΈ°μ μν)
|
240 |
this.targetPitch -= deltaY * sensitivity;
|
241 |
|
242 |
+
// λ§μ°μ€ XμΆ: μ(Yaw) - λͺΈμ²΄λ₯Ό μ’μ°λ‘ νμ
|
243 |
+
this.targetYaw += deltaX * sensitivity * 0.8; // μ νμ κ°λ μ‘°μ
|
244 |
+
|
245 |
+
// μ νμ μ λ°λ₯Έ μλ λ‘€ (λ±
ν¬ ν΄)
|
246 |
+
// μ’μ°λ‘ νμ ν λ μμ°μ€λ½κ² λ κ°κ° κΈ°μΈμ΄μ§
|
247 |
+
const yawRate = deltaX * sensitivity * 0.8;
|
248 |
+
this.targetRoll = -yawRate * 15; // μ νμ λμ λΉλ‘νμ¬ λ‘€ λ°μ
|
249 |
+
|
250 |
// κ°λ μ ν
|
251 |
const maxPitchAngle = Math.PI / 3; // 60λ
|
252 |
+
const maxRollAngle = Math.PI * 0.5; // 90λλ‘ μ ν (μλ λ‘€)
|
253 |
|
254 |
this.targetPitch = Math.max(-maxPitchAngle, Math.min(maxPitchAngle, this.targetPitch));
|
255 |
+
|
256 |
+
// μλ λ‘€μ μ νλ λ²μ λ΄μμλ§ μλ
|
257 |
+
if (Math.abs(this.targetRoll) < maxRollAngle) {
|
258 |
+
// λ‘€ κ°λ μ ν μ μ©
|
259 |
+
this.targetRoll = Math.max(-maxRollAngle, Math.min(maxRollAngle, this.targetRoll));
|
260 |
+
}
|
261 |
}
|
262 |
|
263 |
updateControls(keys, deltaTime) {
|
|
|
269 |
this.throttle = Math.max(0.1, this.throttle - deltaTime * 0.5); // μ²μ²ν κ°μ
|
270 |
}
|
271 |
|
272 |
+
// A/D: 보쑰 μ μ μ΄ (λ¬λ) - μ νμ μ¬μ©
|
273 |
if (keys.a) {
|
274 |
+
this.targetYaw -= deltaTime * 0.4; // κ°μλ λ¬λ ν¨κ³Ό
|
275 |
}
|
276 |
if (keys.d) {
|
277 |
+
this.targetYaw += deltaTime * 0.4; // κ°μλ λ¬λ ν¨κ³Ό
|
278 |
}
|
279 |
}
|
280 |
|
|
|
282 |
if (!this.mesh) return;
|
283 |
|
284 |
// λΆλλ¬μ΄ νμ 보κ°
|
285 |
+
const rotationSpeed = deltaTime * 2.0;
|
286 |
this.rotation.x = THREE.MathUtils.lerp(this.rotation.x, this.targetPitch, rotationSpeed);
|
287 |
+
this.rotation.y = THREE.MathUtils.lerp(this.rotation.y, this.targetYaw, rotationSpeed);
|
288 |
|
289 |
+
// λ‘€ μλ λ³΅κ· μμ€ν
|
290 |
+
if (Math.abs(this.targetYaw - this.rotation.y) < 0.05) {
|
291 |
+
// μ νμ μ΄ κ±°μ μμ λ λ‘€μ 0μΌλ‘ 볡κ·
|
292 |
+
this.targetRoll *= 0.95;
|
293 |
+
}
|
294 |
+
|
295 |
+
this.rotation.z = THREE.MathUtils.lerp(this.rotation.z, this.targetRoll, rotationSpeed * 1.5); // λ‘€μ λ λΉ λ₯΄κ² λ°μ
|
296 |
+
|
297 |
+
// μμ¬λ μ€νμΌ: μ νμ μ΄ μ£Όλμ , λ‘€μ 보쑰μ
|
298 |
+
// λ‘€μ λ°λ₯Έ μΆκ° μ νμ μ μ κ±°νκ±°λ μ΅μν
|
299 |
let bankTurnRate = 0;
|
300 |
+
if (Math.abs(this.rotation.z) > 0.3) { // λ‘€μ΄ μΆ©λΆν ν΄ λλ§
|
301 |
const bankAngle = this.rotation.z;
|
302 |
+
bankTurnRate = Math.sin(bankAngle) * deltaTime * 0.1; // λ§€μ° μμ μ νμ¨
|
|
|
303 |
this.targetYaw += bankTurnRate;
|
304 |
}
|
305 |
|
|
|
|
|
|
|
306 |
// νμ€μ μΈ μλ κ³μ°
|
307 |
const minSpeed = 0; // μ΅μ μλ 0kt
|
308 |
const maxSpeed = 600; // μ΅λ μλ 600kt
|