cutechicken commited on
Commit
1bd8588
ยท
verified ยท
1 Parent(s): 5eeb328

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +6 -7
game.js CHANGED
@@ -105,10 +105,8 @@ class TankPlayer {
105
  update(mouseX, mouseY, scene) {
106
  if (!this.body || !this.turretGroup) return;
107
 
108
- // ํฌํƒ‘ ํšŒ์ „ ๋ฐฉํ–ฅ ์„ค์ •
109
- const turretDirection = new THREE.Vector3(mouseX, 0, -mouseY).normalize();
110
- const angle = Math.atan2(turretDirection.x, turretDirection.z);
111
- this.turretGroup.rotation.y = angle;
112
 
113
  // ํ”Œ๋ ˆ์ด์–ด ์ด์•Œ ์ด๋™ ์ฒ˜๋ฆฌ
114
  for (let i = this.bullets.length - 1; i >= 0; i--) {
@@ -534,19 +532,20 @@ async addDesertDecorations() {
534
  this.tank.move(direction);
535
  }
536
 
537
- // ์นด๋ฉ”๋ผ ์œ„์น˜ ์—…๋ฐ์ดํŠธ
538
  const tankPos = this.tank.getPosition();
539
- const turretRotation = this.tank.turretGroup.rotation.y + this.tank.body.rotation.y;
540
  const cameraDistance = 30;
541
  const cameraHeight = 15;
542
 
 
543
  this.camera.position.set(
544
  tankPos.x - Math.sin(turretRotation) * cameraDistance,
545
  tankPos.y + cameraHeight,
546
  tankPos.z - Math.cos(turretRotation) * cameraDistance
547
  );
548
 
549
- // ์นด๋ฉ”๋ผ๊ฐ€ ํ•ญ์ƒ ํฌํƒ‘์˜ ์•ž ๋ฐฉํ–ฅ์„ ๋ฐ”๋ผ๋ณด๊ฒŒ ์„ค์ •
550
  const lookAtPoint = new THREE.Vector3(
551
  tankPos.x + Math.sin(turretRotation) * 10,
552
  tankPos.y + 5,
 
105
  update(mouseX, mouseY, scene) {
106
  if (!this.body || !this.turretGroup) return;
107
 
108
+ // ํฌํƒ‘ ํšŒ์ „ - ๋งˆ์šฐ์Šค ์ด๋™์— ๋”ฐ๋ผ ์ž์œ ๋กญ๊ฒŒ 360๋„ ํšŒ์ „
109
+ this.turretGroup.rotation.y += mouseX * 0.03;
 
 
110
 
111
  // ํ”Œ๋ ˆ์ด์–ด ์ด์•Œ ์ด๋™ ์ฒ˜๋ฆฌ
112
  for (let i = this.bullets.length - 1; i >= 0; i--) {
 
532
  this.tank.move(direction);
533
  }
534
 
535
+ // ์นด๋ฉ”๋ผ ์œ„์น˜ ์—…๋ฐ์ดํŠธ - ํฌํƒ‘ ํšŒ์ „๋งŒ ๋”ฐ๋ผ๊ฐ€๋„๋ก ์ˆ˜์ •
536
  const tankPos = this.tank.getPosition();
537
+ const turretRotation = this.tank.turretGroup.rotation.y;
538
  const cameraDistance = 30;
539
  const cameraHeight = 15;
540
 
541
+ // ์นด๋ฉ”๋ผ ์œ„์น˜๋ฅผ ํฌํƒ‘ ํšŒ์ „์— ๋งž์ถฐ ์„ค์ •
542
  this.camera.position.set(
543
  tankPos.x - Math.sin(turretRotation) * cameraDistance,
544
  tankPos.y + cameraHeight,
545
  tankPos.z - Math.cos(turretRotation) * cameraDistance
546
  );
547
 
548
+ // ์นด๋ฉ”๋ผ๊ฐ€ ํ•ญ์ƒ ํฌํƒ‘์„ ๋ฐ”๋ผ๋ณด๋„๋ก ์„ค์ •
549
  const lookAtPoint = new THREE.Vector3(
550
  tankPos.x + Math.sin(turretRotation) * 10,
551
  tankPos.y + 5,