Spaces:
Running
Running
cutechicken
commited on
Update game.js
Browse files
game.js
CHANGED
@@ -105,10 +105,8 @@ class TankPlayer {
|
|
105 |
update(mouseX, mouseY, scene) {
|
106 |
if (!this.body || !this.turretGroup) return;
|
107 |
|
108 |
-
// ํฌํ ํ์
|
109 |
-
|
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
|
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,
|