Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -42,6 +42,12 @@ 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 |
}
|
46 |
// ๋ณ๋์ ๋ฉ์๋๋ก ๋ถ๋ฆฌ
|
47 |
createExplosionEffect(scene, position) {
|
@@ -308,28 +314,36 @@ class TankPlayer {
|
|
308 |
return bullet;
|
309 |
}
|
310 |
applyCameraShake() {
|
311 |
-
if (!
|
312 |
-
|
313 |
const camera = window.gameInstance.camera;
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
}
|
334 |
|
335 |
startReload() {
|
@@ -2647,7 +2661,11 @@ updateCrosshair() {
|
|
2647 |
if (!this.isLoading) {
|
2648 |
this.handleMovement();
|
2649 |
this.tank.update(this.mouse.x, this.mouse.y, this.scene);
|
2650 |
-
|
|
|
|
|
|
|
|
|
2651 |
const tankPosition = this.tank.getPosition();
|
2652 |
this.enemies.forEach(enemy => {
|
2653 |
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 |
+
this.cameraShake = {
|
46 |
+
active: false,
|
47 |
+
intensity: 0,
|
48 |
+
duration: 0,
|
49 |
+
time: 0,
|
50 |
+
originalPosition: null
|
51 |
}
|
52 |
// ๋ณ๋์ ๋ฉ์๋๋ก ๋ถ๋ฆฌ
|
53 |
createExplosionEffect(scene, position) {
|
|
|
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() {
|
|
|
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);
|