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(
|