cutechicken commited on
Commit
4f3870f
β€’
1 Parent(s): 7aaeb16

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +45 -25
game.js CHANGED
@@ -152,66 +152,86 @@ class TankPlayer {
152
  createMuzzleFlash(scene) {
153
  const flashGroup = new THREE.Group();
154
 
155
- // ν™”μ—Ό 생성
156
- const flameGeometry = new THREE.SphereGeometry(0.5, 8, 8);
157
  const flameMaterial = new THREE.MeshBasicMaterial({
158
  color: 0xffa500,
159
  transparent: true,
160
  opacity: 0.8
161
  });
162
  const flame = new THREE.Mesh(flameGeometry, flameMaterial);
163
- flame.scale.set(1.5, 1.5, 2);
164
  flashGroup.add(flame);
165
 
166
- // μ—°κΈ° 생성
167
- const smokeGeometry = new THREE.SphereGeometry(0.3, 8, 8);
168
  const smokeMaterial = new THREE.MeshBasicMaterial({
169
  color: 0x555555,
170
  transparent: true,
171
  opacity: 0.5
172
  });
173
- for (let i = 0; i < 3; i++) {
 
174
  const smoke = new THREE.Mesh(smokeGeometry, smokeMaterial);
175
  smoke.position.set(
176
- Math.random() * 0.5 - 0.25,
177
- Math.random() * 0.5 - 0.25,
178
- -0.5 - Math.random() * 0.5
179
  );
 
180
  flashGroup.add(smoke);
181
  }
182
 
183
- // 포탑 끝의 μ „μ—­ μ’Œν‘œ 계산
184
- const muzzlePosition = new THREE.Vector3(0, 0, 2); // 포탑 끝의 둜컬 μ’Œν‘œ (ν¬μ‹ μ˜ 끝)
185
- this.turret.localToWorld(muzzlePosition); // 둜컬 μ’Œν‘œλ₯Ό μ „μ—­ μ’Œν‘œλ‘œ λ³€ν™˜
 
 
 
 
 
 
 
186
 
187
  flashGroup.position.copy(muzzlePosition);
 
188
 
189
- // 씬에 μΆ”κ°€
190
  scene.add(flashGroup);
191
 
192
- // 일정 μ‹œκ°„ ν›„ 제거
193
  setTimeout(() => {
194
  scene.remove(flashGroup);
195
- }, 300); // 300ms μœ μ§€
196
  }
197
 
198
 
199
 
200
-
201
  createBullet(scene) {
202
- const bulletGeometry = new THREE.CylinderGeometry(0.1, 0.1, 1, 8);
 
203
  const bulletMaterial = new THREE.MeshBasicMaterial({ color: 0xffd700 });
204
  const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
205
 
206
- bullet.rotation.x = Math.PI / 2; // μˆ˜ν‰μœΌλ‘œ νšŒμ „
207
- const bulletOffset = new THREE.Vector3(0, 0.5, 2);
208
- bulletOffset.applyQuaternion(this.turretGroup.quaternion);
209
- bulletOffset.applyQuaternion(this.body.quaternion);
210
- bullet.position.copy(this.body.position).add(bulletOffset);
211
-
 
 
 
 
 
 
 
 
 
 
 
 
212
  const direction = new THREE.Vector3(0, 0, 1);
213
- direction.applyQuaternion(this.turretGroup.quaternion);
214
- direction.applyQuaternion(this.body.quaternion);
215
  bullet.velocity = direction.multiplyScalar(5);
216
 
217
  scene.add(bullet);
 
152
  createMuzzleFlash(scene) {
153
  const flashGroup = new THREE.Group();
154
 
155
+ // ν™”μ—Ό 크기 증가
156
+ const flameGeometry = new THREE.SphereGeometry(1.0, 8, 8);
157
  const flameMaterial = new THREE.MeshBasicMaterial({
158
  color: 0xffa500,
159
  transparent: true,
160
  opacity: 0.8
161
  });
162
  const flame = new THREE.Mesh(flameGeometry, flameMaterial);
163
+ flame.scale.set(2, 2, 3);
164
  flashGroup.add(flame);
165
 
166
+ // μ—°κΈ° 효과 크기 증가
167
+ const smokeGeometry = new THREE.SphereGeometry(0.8, 8, 8);
168
  const smokeMaterial = new THREE.MeshBasicMaterial({
169
  color: 0x555555,
170
  transparent: true,
171
  opacity: 0.5
172
  });
173
+
174
+ for (let i = 0; i < 5; i++) { // μ—°κΈ° νŒŒν‹°ν΄ 수 증가
175
  const smoke = new THREE.Mesh(smokeGeometry, smokeMaterial);
176
  smoke.position.set(
177
+ Math.random() * 1 - 0.5,
178
+ Math.random() * 1 - 0.5,
179
+ -1 - Math.random()
180
  );
181
+ smoke.scale.set(1.5, 1.5, 1.5);
182
  flashGroup.add(smoke);
183
  }
184
 
185
+ // 포ꡬ μœ„μΉ˜ 계산
186
+ const muzzleOffset = new THREE.Vector3(0, 0.5, 4);
187
+ const muzzlePosition = new THREE.Vector3();
188
+ const turretWorldQuaternion = new THREE.Quaternion();
189
+
190
+ this.turret.getWorldPosition(muzzlePosition);
191
+ this.turret.getWorldQuaternion(turretWorldQuaternion);
192
+
193
+ muzzleOffset.applyQuaternion(turretWorldQuaternion);
194
+ muzzlePosition.add(muzzleOffset);
195
 
196
  flashGroup.position.copy(muzzlePosition);
197
+ flashGroup.quaternion.copy(turretWorldQuaternion);
198
 
 
199
  scene.add(flashGroup);
200
 
201
+ // μ΄νŽ™νŠΈ 지속 μ‹œκ°„ 증가
202
  setTimeout(() => {
203
  scene.remove(flashGroup);
204
+ }, 500);
205
  }
206
 
207
 
208
 
 
209
  createBullet(scene) {
210
+ // 포탄 크기 증가
211
+ const bulletGeometry = new THREE.CylinderGeometry(0.2, 0.2, 2, 8);
212
  const bulletMaterial = new THREE.MeshBasicMaterial({ color: 0xffd700 });
213
  const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
214
 
215
+ // ν¬νƒ‘μ˜ μ›”λ“œ μœ„μΉ˜μ™€ λ°©ν–₯ κ°€μ Έμ˜€κΈ°
216
+ const muzzleOffset = new THREE.Vector3(0, 0.5, 4); // 포ꡬ μœ„μΉ˜ μ‘°μ • (μ•žμͺ½μœΌλ‘œ 더 이동)
217
+ const muzzlePosition = new THREE.Vector3();
218
+ const turretWorldQuaternion = new THREE.Quaternion();
219
+
220
+ // ν¬νƒ‘μ˜ μ›”λ“œ λ³€ν™˜ ν–‰λ ¬ κ°€μ Έμ˜€κΈ°
221
+ this.turret.getWorldPosition(muzzlePosition);
222
+ this.turret.getWorldQuaternion(turretWorldQuaternion);
223
+
224
+ // 포ꡬ μ˜€ν”„μ…‹ 적용
225
+ muzzleOffset.applyQuaternion(turretWorldQuaternion);
226
+ muzzlePosition.add(muzzleOffset);
227
+
228
+ // 포탄 μœ„μΉ˜μ™€ νšŒμ „ μ„€μ •
229
+ bullet.position.copy(muzzlePosition);
230
+ bullet.quaternion.copy(turretWorldQuaternion);
231
+
232
+ // λ°œμ‚¬ λ°©ν–₯ μ„€μ •
233
  const direction = new THREE.Vector3(0, 0, 1);
234
+ direction.applyQuaternion(turretWorldQuaternion);
 
235
  bullet.velocity = direction.multiplyScalar(5);
236
 
237
  scene.add(bullet);