Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -111,9 +111,8 @@ update(mouseX, mouseY, scene) {
|
|
111 |
// ๊ฐ๋๋ฅผ 0~2ฯ ๋ฒ์๋ก ์ ๊ทํ
|
112 |
if (angle < 0) angle += Math.PI * 2;
|
113 |
|
114 |
-
|
115 |
-
this.
|
116 |
-
this.turretRotation = angle + Math.PI;
|
117 |
|
118 |
// ํ๋ ์ด์ด ์ด์ ์
๋ฐ์ดํธ
|
119 |
for (let i = this.bullets.length - 1; i >= 0; i--) {
|
@@ -530,20 +529,13 @@ async addDesertDecorations() {
|
|
530 |
|
531 |
const direction = new THREE.Vector3();
|
532 |
|
533 |
-
// ์ด๋ ๋ฐฉํฅ ๊ณ์ฐ
|
534 |
if (this.keys.forward) direction.z += 1;
|
535 |
if (this.keys.backward) direction.z -= 1;
|
536 |
-
if (this.keys.left)
|
537 |
-
if (this.keys.right)
|
538 |
|
539 |
if (direction.length() > 0) {
|
540 |
direction.normalize();
|
541 |
-
|
542 |
-
// ํฑํฌ ํ์
|
543 |
-
if (this.keys.left) this.tank.rotate(-1);
|
544 |
-
if (this.keys.right) this.tank.rotate(1);
|
545 |
-
|
546 |
-
// ์ด๋ ๋ฐฉํฅ์ ํฑํฌ์ ํ์ ์ ๋ง์ถฐ ์กฐ์
|
547 |
direction.applyEuler(this.tank.body.rotation);
|
548 |
this.tank.move(direction);
|
549 |
}
|
@@ -551,14 +543,15 @@ async addDesertDecorations() {
|
|
551 |
// ํฑํฌ ์์น ๊ฐ์ ธ์ค๊ธฐ
|
552 |
const tankPos = this.tank.getPosition();
|
553 |
|
554 |
-
// ์นด๋ฉ๋ผ ์์น ๊ณ์ฐ
|
555 |
const cameraDistance = 30;
|
556 |
const cameraHeight = 15;
|
557 |
-
const fixedCameraAngle = Math.PI; // ์นด๋ฉ๋ผ๋ ํญ์ ๋จ์ชฝ(ฯ)์ ํฅํ๋๋ก ์ค์
|
558 |
|
559 |
-
//
|
560 |
-
const
|
561 |
-
|
|
|
|
|
562 |
|
563 |
// ์นด๋ฉ๋ผ ์์น ๋ฐ ์์ ์ค์
|
564 |
this.camera.position.set(
|
|
|
111 |
// ๊ฐ๋๋ฅผ 0~2ฯ ๋ฒ์๋ก ์ ๊ทํ
|
112 |
if (angle < 0) angle += Math.PI * 2;
|
113 |
|
114 |
+
this.turretGroup.rotation.y = angle;
|
115 |
+
this.turretRotation = angle;
|
|
|
116 |
|
117 |
// ํ๋ ์ด์ด ์ด์ ์
๋ฐ์ดํธ
|
118 |
for (let i = this.bullets.length - 1; i >= 0; i--) {
|
|
|
529 |
|
530 |
const direction = new THREE.Vector3();
|
531 |
|
|
|
532 |
if (this.keys.forward) direction.z += 1;
|
533 |
if (this.keys.backward) direction.z -= 1;
|
534 |
+
if (this.keys.left) this.tank.rotate(-1);
|
535 |
+
if (this.keys.right) this.tank.rotate(1);
|
536 |
|
537 |
if (direction.length() > 0) {
|
538 |
direction.normalize();
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
direction.applyEuler(this.tank.body.rotation);
|
540 |
this.tank.move(direction);
|
541 |
}
|
|
|
543 |
// ํฑํฌ ์์น ๊ฐ์ ธ์ค๊ธฐ
|
544 |
const tankPos = this.tank.getPosition();
|
545 |
|
546 |
+
// ์นด๋ฉ๋ผ ์์น ๊ณ์ฐ
|
547 |
const cameraDistance = 30;
|
548 |
const cameraHeight = 15;
|
|
|
549 |
|
550 |
+
// ํฌํ์ ํ์ฌ ํ์ ๊ฐ๋์์ 180๋๋ฅผ ๋ํด ํญ์ ํฌํ์ ๋ค์ ์์นํ๋๋ก ํจ
|
551 |
+
const cameraAngle = this.tank.turretRotation + Math.PI;
|
552 |
+
|
553 |
+
const cameraX = tankPos.x + Math.sin(cameraAngle) * cameraDistance;
|
554 |
+
const cameraZ = tankPos.z + Math.cos(cameraAngle) * cameraDistance;
|
555 |
|
556 |
// ์นด๋ฉ๋ผ ์์น ๋ฐ ์์ ์ค์
|
557 |
this.camera.position.set(
|