cutechicken commited on
Commit
07fd491
Β·
verified Β·
1 Parent(s): 5a1b7a2

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +33 -18
game.js CHANGED
@@ -234,20 +234,30 @@ class Fighter {
234
  }
235
 
236
  updateMouseInput(deltaX, deltaY) {
237
- const sensitivity = GAME_CONSTANTS.MOUSE_SENSITIVITY * 1.0; // 감도 50% κ°μ†Œ (2.0 -> 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.75; // 135λ„λ‘œ μ œν•œ
248
 
249
  this.targetPitch = Math.max(-maxPitchAngle, Math.min(maxPitchAngle, this.targetPitch));
250
- this.targetRoll = Math.max(-maxRollAngle, Math.min(maxRollAngle, this.targetRoll));
 
 
 
 
 
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.8;
265
  }
266
  if (keys.d) {
267
- this.targetYaw += deltaTime * 0.8;
268
  }
269
  }
270
 
@@ -272,22 +282,27 @@ class Fighter {
272
  if (!this.mesh) return;
273
 
274
  // λΆ€λ“œλŸ¬μš΄ νšŒμ „ 보간
275
- const rotationSpeed = deltaTime * 2.0; // νšŒμ „ 속도도 κ°μ†Œ (3.0 -> 2.0)
276
  this.rotation.x = THREE.MathUtils.lerp(this.rotation.x, this.targetPitch, rotationSpeed);
277
- this.rotation.z = THREE.MathUtils.lerp(this.rotation.z, this.targetRoll, rotationSpeed);
278
 
279
- // ν˜„μ‹€μ μΈ λΉ„ν–‰ 물리: 둀에 λ”°λ₯Έ μžμ—°μŠ€λŸ¬μš΄ μ„ νšŒ
 
 
 
 
 
 
 
 
 
280
  let bankTurnRate = 0;
281
- if (Math.abs(this.rotation.z) > 0.1) {
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