Spaces:
Running
Running
cutechicken
commited on
Commit
โข
d7b0f1e
1
Parent(s):
4a23b1d
Update game.js
Browse files
game.js
CHANGED
@@ -83,19 +83,18 @@ class TankPlayer {
|
|
83 |
return null;
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
86 |
const bulletGeometry = new THREE.SphereGeometry(0.2);
|
87 |
const bulletMaterial = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
|
88 |
const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
const direction = new THREE.Vector3(0, 0, 1);
|
96 |
-
direction.applyQuaternion(this.turretGroup.quaternion);
|
97 |
-
direction.applyQuaternion(this.body.quaternion);
|
98 |
-
bullet.velocity = direction.multiplyScalar(2);
|
99 |
|
100 |
scene.add(bullet);
|
101 |
this.bullets.push(bullet);
|
@@ -106,8 +105,8 @@ class TankPlayer {
|
|
106 |
document.getElementById('ammo').textContent = `${this.ammo}/10`;
|
107 |
|
108 |
// ์ฐ๊ธฐ ๋ฐ ๋ถ๊ฝ ํจ๊ณผ ์์ฑ
|
109 |
-
this.createSmokeEffect(scene,
|
110 |
-
this.createMuzzleFlashEffect(scene,
|
111 |
|
112 |
// ๋ฐ์ฌ ์๋ฆฌ ์ฌ์
|
113 |
this.playRandomFireSound();
|
@@ -115,18 +114,17 @@ class TankPlayer {
|
|
115 |
return bullet;
|
116 |
}
|
117 |
|
118 |
-
|
119 |
-
createMuzzleFlashEffect(scene, position) {
|
120 |
// ๋น ํจ๊ณผ
|
121 |
const flashLight = new THREE.PointLight(0xffaa00, 2, 10);
|
122 |
-
flashLight.position.copy(
|
123 |
scene.add(flashLight);
|
124 |
|
125 |
// ๋ถ๊ฝ ๊ตฌ์ฒด
|
126 |
const flashGeometry = new THREE.SphereGeometry(0.3, 16, 16);
|
127 |
const flashMaterial = new THREE.MeshBasicMaterial({ color: 0xffaa00 });
|
128 |
const flashMesh = new THREE.Mesh(flashGeometry, flashMaterial);
|
129 |
-
flashMesh.position.copy(
|
130 |
scene.add(flashMesh);
|
131 |
|
132 |
// ๋ถ๊ฝ ํจ๊ณผ ์
๋ฐ์ดํธ
|
@@ -146,6 +144,7 @@ class TankPlayer {
|
|
146 |
}
|
147 |
|
148 |
|
|
|
149 |
// ์ฐ๊ธฐ ํจ๊ณผ ์์ฑ ๋ฉ์๋
|
150 |
createSmokeEffect(scene, position) {
|
151 |
const particleCount = 10;
|
|
|
83 |
return null;
|
84 |
}
|
85 |
|
86 |
+
// ํฌ์ ๋ ์ขํ ๊ณ์ฐ
|
87 |
+
const barrelEndOffset = new THREE.Vector3(0, 0, 2); // ํฌ์ ๋ ์คํ์
(Z ์ถ)
|
88 |
+
const barrelEndPosition = this.turret.localToWorld(barrelEndOffset.clone());
|
89 |
+
|
90 |
const bulletGeometry = new THREE.SphereGeometry(0.2);
|
91 |
const bulletMaterial = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
|
92 |
const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
|
93 |
|
94 |
+
bullet.position.copy(barrelEndPosition); // ํฌ์ ๋์์ ๋ฐ์ฌ
|
95 |
+
bullet.velocity = new THREE.Vector3(0, 0, 1)
|
96 |
+
.applyQuaternion(this.turret.quaternion)
|
97 |
+
.multiplyScalar(2);
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
scene.add(bullet);
|
100 |
this.bullets.push(bullet);
|
|
|
105 |
document.getElementById('ammo').textContent = `${this.ammo}/10`;
|
106 |
|
107 |
// ์ฐ๊ธฐ ๋ฐ ๋ถ๊ฝ ํจ๊ณผ ์์ฑ
|
108 |
+
this.createSmokeEffect(scene, barrelEndPosition);
|
109 |
+
this.createMuzzleFlashEffect(scene, barrelEndPosition);
|
110 |
|
111 |
// ๋ฐ์ฌ ์๋ฆฌ ์ฌ์
|
112 |
this.playRandomFireSound();
|
|
|
114 |
return bullet;
|
115 |
}
|
116 |
|
117 |
+
createMuzzleFlashEffect(scene, position) {
|
|
|
118 |
// ๋น ํจ๊ณผ
|
119 |
const flashLight = new THREE.PointLight(0xffaa00, 2, 10);
|
120 |
+
flashLight.position.copy(position); // ํฌ์ ๋ ์์น์์ ๋ถ๊ฝ ์์ฑ
|
121 |
scene.add(flashLight);
|
122 |
|
123 |
// ๋ถ๊ฝ ๊ตฌ์ฒด
|
124 |
const flashGeometry = new THREE.SphereGeometry(0.3, 16, 16);
|
125 |
const flashMaterial = new THREE.MeshBasicMaterial({ color: 0xffaa00 });
|
126 |
const flashMesh = new THREE.Mesh(flashGeometry, flashMaterial);
|
127 |
+
flashMesh.position.copy(position);
|
128 |
scene.add(flashMesh);
|
129 |
|
130 |
// ๋ถ๊ฝ ํจ๊ณผ ์
๋ฐ์ดํธ
|
|
|
144 |
}
|
145 |
|
146 |
|
147 |
+
|
148 |
// ์ฐ๊ธฐ ํจ๊ณผ ์์ฑ ๋ฉ์๋
|
149 |
createSmokeEffect(scene, position) {
|
150 |
const particleCount = 10;
|