Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -42,12 +42,6 @@ class TankPlayer {
|
|
42 |
this.scene = new THREE.Scene();
|
43 |
this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
44 |
this.renderer = new THREE.WebGLRenderer({ antialias: true });
|
45 |
-
this.cameraShake = {
|
46 |
-
active: false,
|
47 |
-
intensity: 0,
|
48 |
-
duration: 0,
|
49 |
-
time: 0,
|
50 |
-
originalPosition: null
|
51 |
}
|
52 |
// ๋ณ๋์ ๋ฉ์๋๋ก ๋ถ๋ฆฌ
|
53 |
createExplosionEffect(scene, position) {
|
@@ -309,42 +303,8 @@ class TankPlayer {
|
|
309 |
this.startReload();
|
310 |
}
|
311 |
}
|
312 |
-
// ์นด๋ฉ๋ผ ํ๋ค๋ฆผ ํจ๊ณผ ์ถ๊ฐ
|
313 |
-
this.applyCameraShake();
|
314 |
return bullet;
|
315 |
}
|
316 |
-
applyCameraShake() {
|
317 |
-
if (!this.cameraShake || !this.cameraShake.active) return;
|
318 |
-
|
319 |
-
const camera = window.gameInstance.camera;
|
320 |
-
if (!camera) return;
|
321 |
-
|
322 |
-
// ์๋ณธ ์์น ์ ์ฅ
|
323 |
-
if (!this.cameraShake.originalPosition) {
|
324 |
-
this.cameraShake.originalPosition = camera.position.clone();
|
325 |
-
}
|
326 |
-
|
327 |
-
// ์๊ฐ ์
๋ฐ์ดํธ
|
328 |
-
this.cameraShake.time += 16; // ์ฝ 60fps ๊ธฐ์ค
|
329 |
-
|
330 |
-
// ๊ฐ์ ๊ณ์ ๊ณ์ฐ (์๊ฐ์ด ์ง๋ ์๋ก ํ๋ค๋ฆผ์ด ์ค์ด๋ฆ)
|
331 |
-
const damping = 1 - (this.cameraShake.time / this.cameraShake.duration);
|
332 |
-
|
333 |
-
if (this.cameraShake.time < this.cameraShake.duration) {
|
334 |
-
// ๋๋คํ ์คํ์
์ ์ฉ
|
335 |
-
camera.position.x = this.cameraShake.originalPosition.x +
|
336 |
-
(Math.random() - 0.5) * this.cameraShake.intensity * damping;
|
337 |
-
camera.position.y = this.cameraShake.originalPosition.y +
|
338 |
-
(Math.random() - 0.5) * this.cameraShake.intensity * damping;
|
339 |
-
camera.position.z = this.cameraShake.originalPosition.z +
|
340 |
-
(Math.random() - 0.5) * this.cameraShake.intensity * damping;
|
341 |
-
} else {
|
342 |
-
// ํจ๊ณผ ์ข
๋ฃ
|
343 |
-
camera.position.copy(this.cameraShake.originalPosition);
|
344 |
-
this.cameraShake.active = false;
|
345 |
-
this.cameraShake.originalPosition = null;
|
346 |
-
}
|
347 |
-
}
|
348 |
|
349 |
startReload() {
|
350 |
if (this.isReloading) return; // ์ด๋ฏธ ์ฌ์ฅ์ ์ค์ด๋ฉด ๋ฌด์
|
@@ -2661,11 +2621,7 @@ updateCrosshair() {
|
|
2661 |
if (!this.isLoading) {
|
2662 |
this.handleMovement();
|
2663 |
this.tank.update(this.mouse.x, this.mouse.y, this.scene);
|
2664 |
-
|
2665 |
-
// ์นด๋ฉ๋ผ ํ๋ค๋ฆผ ํจ๊ณผ ์
๋ฐ์ดํธ
|
2666 |
-
if (this.tank.cameraShake && this.tank.cameraShake.active) {
|
2667 |
-
this.tank.applyCameraShake();
|
2668 |
-
}
|
2669 |
const tankPosition = this.tank.getPosition();
|
2670 |
this.enemies.forEach(enemy => {
|
2671 |
enemy.update(tankPosition);
|
|
|
42 |
this.scene = new THREE.Scene();
|
43 |
this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
44 |
this.renderer = new THREE.WebGLRenderer({ antialias: true });
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
// ๋ณ๋์ ๋ฉ์๋๋ก ๋ถ๋ฆฌ
|
47 |
createExplosionEffect(scene, position) {
|
|
|
303 |
this.startReload();
|
304 |
}
|
305 |
}
|
|
|
|
|
306 |
return bullet;
|
307 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
startReload() {
|
310 |
if (this.isReloading) return; // ์ด๋ฏธ ์ฌ์ฅ์ ์ค์ด๋ฉด ๋ฌด์
|
|
|
2621 |
if (!this.isLoading) {
|
2622 |
this.handleMovement();
|
2623 |
this.tank.update(this.mouse.x, this.mouse.y, this.scene);
|
2624 |
+
|
|
|
|
|
|
|
|
|
2625 |
const tankPosition = this.tank.getPosition();
|
2626 |
this.enemies.forEach(enemy => {
|
2627 |
enemy.update(tankPosition);
|