Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -106,9 +106,9 @@ class TankPlayer {
|
|
| 106 |
update(mouseX, mouseY, scene) {
|
| 107 |
if (!this.body || !this.turretGroup) return;
|
| 108 |
|
| 109 |
-
//
|
| 110 |
this.turretGroup.rotation.y = mouseX;
|
| 111 |
-
this.turretRotation = mouseX
|
| 112 |
|
| 113 |
// ํ๋ ์ด์ด ์ด์ ์
๋ฐ์ดํธ
|
| 114 |
for (let i = this.bullets.length - 1; i >= 0; i--) {
|
|
@@ -526,6 +526,7 @@ async addDesertDecorations() {
|
|
| 526 |
|
| 527 |
const direction = new THREE.Vector3();
|
| 528 |
|
|
|
|
| 529 |
if (this.keys.forward) direction.z += 1;
|
| 530 |
if (this.keys.backward) direction.z -= 1;
|
| 531 |
if (this.keys.left) this.tank.rotate(-1);
|
|
@@ -540,12 +541,10 @@ async addDesertDecorations() {
|
|
| 540 |
// ํฑํฌ ์์น ๊ฐ์ ธ์ค๊ธฐ
|
| 541 |
const tankPos = this.tank.getPosition();
|
| 542 |
|
| 543 |
-
//
|
| 544 |
const cameraDistance = 30;
|
| 545 |
const cameraHeight = 15;
|
| 546 |
-
|
| 547 |
-
// ๋ง์ฐ์ค X ๊ฐ์ ์นด๋ฉ๋ผ ๊ฐ๋๋ก ์ฌ์ฉ
|
| 548 |
-
const cameraAngle = this.mouse.x + Math.PI;
|
| 549 |
|
| 550 |
const cameraX = tankPos.x + Math.sin(cameraAngle) * cameraDistance;
|
| 551 |
const cameraZ = tankPos.z + Math.cos(cameraAngle) * cameraDistance;
|
|
@@ -564,6 +563,7 @@ async addDesertDecorations() {
|
|
| 564 |
);
|
| 565 |
this.camera.lookAt(lookAtPoint);
|
| 566 |
}
|
|
|
|
| 567 |
//this.camera.lookAt(lookAtPoint);
|
| 568 |
|
| 569 |
|
|
|
|
| 106 |
update(mouseX, mouseY, scene) {
|
| 107 |
if (!this.body || !this.turretGroup) return;
|
| 108 |
|
| 109 |
+
// ํฌํ์ ์ ๋ ํ์ (์ฐจ์ฒด ํ์ ๊ณผ ๋
๋ฆฝ์ )
|
| 110 |
this.turretGroup.rotation.y = mouseX;
|
| 111 |
+
this.turretRotation = mouseX; // ์ฐจ์ฒด ํ์ ์ ๋ํ์ง ์์
|
| 112 |
|
| 113 |
// ํ๋ ์ด์ด ์ด์ ์
๋ฐ์ดํธ
|
| 114 |
for (let i = this.bullets.length - 1; i >= 0; i--) {
|
|
|
|
| 526 |
|
| 527 |
const direction = new THREE.Vector3();
|
| 528 |
|
| 529 |
+
// ์ฐจ์ฒด ์ด๋๊ณผ ํ์ ์ ์ ์ง
|
| 530 |
if (this.keys.forward) direction.z += 1;
|
| 531 |
if (this.keys.backward) direction.z -= 1;
|
| 532 |
if (this.keys.left) this.tank.rotate(-1);
|
|
|
|
| 541 |
// ํฑํฌ ์์น ๊ฐ์ ธ์ค๊ธฐ
|
| 542 |
const tankPos = this.tank.getPosition();
|
| 543 |
|
| 544 |
+
// ์นด๋ฉ๋ผ๋ ๋ง์ฐ์ค X ํ์ ์๋ง ๋ฐ๋ผ๊ฐ
|
| 545 |
const cameraDistance = 30;
|
| 546 |
const cameraHeight = 15;
|
| 547 |
+
const cameraAngle = this.mouse.x + Math.PI; // ํญ์ ํฌํ์ ๋ค์ชฝ์ ์์น
|
|
|
|
|
|
|
| 548 |
|
| 549 |
const cameraX = tankPos.x + Math.sin(cameraAngle) * cameraDistance;
|
| 550 |
const cameraZ = tankPos.z + Math.cos(cameraAngle) * cameraDistance;
|
|
|
|
| 563 |
);
|
| 564 |
this.camera.lookAt(lookAtPoint);
|
| 565 |
}
|
| 566 |
+
|
| 567 |
//this.camera.lookAt(lookAtPoint);
|
| 568 |
|
| 569 |
|