cutechicken commited on
Commit
254f9c3
Β·
verified Β·
1 Parent(s): 575f8cb

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +13 -7
game.js CHANGED
@@ -109,13 +109,18 @@ update(mouseX, mouseY, scene) {
109
  // ν¬νƒ‘μ˜ ν˜„μž¬ νšŒμ „κ°λ„
110
  const currentRotation = this.turretGroup.rotation.y;
111
 
112
- // λͺ©ν‘œ νšŒμ „κ°λ„ (차체 νšŒμ „ κ³ λ €)
113
- const targetRotation = mouseX;
114
 
115
- // λΆ€λ“œλŸ¬μš΄ νšŒμ „μ„ μœ„ν•œ 보간
116
- const rotationSpeed = 0.1;
117
- const newRotation = currentRotation + (targetRotation - currentRotation) * rotationSpeed;
118
 
 
 
 
 
 
 
119
  this.turretGroup.rotation.y = newRotation;
120
  this.turretRotation = newRotation + this.body.rotation.y; // 전체 νšŒμ „κ° μ €μž₯
121
 
@@ -490,11 +495,12 @@ async addDesertDecorations() {
490
  }
491
  });
492
 
493
- document.addEventListener('mousemove', (event) => {
494
  if (this.isLoading || this.isGameOver || !document.pointerLockElement) return;
495
 
496
  const movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
497
- this.mouse.x += movementX * 0.002; // λˆ„μ  νšŒμ „λŸ‰μœΌλ‘œ λ³€κ²½
 
498
  this.mouse.y = 0; // Y좕은 μ‚¬μš©ν•˜μ§€ μ•ŠμŒ
499
 
500
  // 각도 μ •κ·œν™” (-Ο€ ~ Ο€)
 
109
  // ν¬νƒ‘μ˜ ν˜„μž¬ νšŒμ „κ°λ„
110
  const currentRotation = this.turretGroup.rotation.y;
111
 
112
+ // 마우슀 μ΄λ™λŸ‰μ„ νšŒμ „ λͺ©ν‘œλŸ‰μœΌλ‘œ λ³€ν™˜
113
+ const rotationTarget = mouseX * 0.05; // νšŒμ „ 속도 κ°μ†Œ
114
 
115
+ // ν˜„μž¬ 각도와 λͺ©ν‘œ κ°λ„μ˜ 차이 계산
116
+ let angleDiff = rotationTarget;
 
117
 
118
+ // 각도 차이가 νŠΉμ • μž„κ³„κ°’λ³΄λ‹€ μž‘μœΌλ©΄ 천천히 νšŒμ „
119
+ const maxRotationSpeed = 0.03; // μ΅œλŒ€ νšŒμ „ 속도
120
+ const rotationAmount = Math.sign(angleDiff) * Math.min(Math.abs(angleDiff), maxRotationSpeed);
121
+
122
+ // μƒˆλ‘œμš΄ νšŒμ „κ° 계산 및 적용
123
+ const newRotation = currentRotation + rotationAmount;
124
  this.turretGroup.rotation.y = newRotation;
125
  this.turretRotation = newRotation + this.body.rotation.y; // 전체 νšŒμ „κ° μ €μž₯
126
 
 
495
  }
496
  });
497
 
498
+ document.addEventListener('mousemove', (event) => {
499
  if (this.isLoading || this.isGameOver || !document.pointerLockElement) return;
500
 
501
  const movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
502
+ // 마우슀 μ΄λ™λŸ‰μ„ 더 μž‘μ€ κ°’μœΌλ‘œ μ‘°μ •
503
+ this.mouse.x = movementX * 0.001; // 감도 κ°μ†Œ
504
  this.mouse.y = 0; // Y좕은 μ‚¬μš©ν•˜μ§€ μ•ŠμŒ
505
 
506
  // 각도 μ •κ·œν™” (-Ο€ ~ Ο€)