Spaces:
Running
Running
cutechicken
commited on
Commit
β’
79d8666
1
Parent(s):
15a66ff
Update game.js
Browse files
game.js
CHANGED
@@ -104,25 +104,31 @@ class TankPlayer {
|
|
104 |
|
105 |
// TankPlayer ν΄λμ€ λ΄λΆ
|
106 |
update(mouseX, mouseY, scene) {
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
|
128 |
|
|
|
104 |
|
105 |
// TankPlayer ν΄λμ€ λ΄λΆ
|
106 |
update(mouseX, mouseY, scene) {
|
107 |
+
if (!this.body || !this.turretGroup) return;
|
108 |
+
|
109 |
+
// ν¬νμ΄ λ°λΌλ³΄λ μ λ λ°©ν₯ κ³μ°
|
110 |
+
const absoluteTurretRotation = mouseX;
|
111 |
+
|
112 |
+
// 차체 νμ μ μμνλ ν¬ν νμ κ³μ°
|
113 |
+
// μ°¨μ²΄κ° νμ νλ©΄ κ·Έλ§νΌ λ°λλ‘ νμ νμ¬ μ λ λ°©ν₯ μ μ§
|
114 |
+
this.turretGroup.rotation.y = absoluteTurretRotation - this.body.rotation.y;
|
115 |
+
|
116 |
+
// μ 체 νμ κ°μ μ λ λ°©ν₯ κ·Έλλ‘ μ μ§
|
117 |
+
this.turretRotation = absoluteTurretRotation;
|
118 |
+
|
119 |
+
// νλ μ΄μ΄ μ΄μ μ
λ°μ΄νΈ
|
120 |
+
for (let i = this.bullets.length - 1; i >= 0; i--) {
|
121 |
+
const bullet = this.bullets[i];
|
122 |
+
bullet.position.add(bullet.velocity);
|
123 |
+
|
124 |
+
if (
|
125 |
+
Math.abs(bullet.position.x) > MAP_SIZE / 2 ||
|
126 |
+
Math.abs(bullet.position.z) > MAP_SIZE / 2
|
127 |
+
) {
|
128 |
+
scene.remove(bullet);
|
129 |
+
this.bullets.splice(i, 1);
|
130 |
+
}
|
131 |
+
}
|
132 |
}
|
133 |
|
134 |
|