Spaces:
Running
Running
cutechicken
commited on
Commit
โข
fa41962
1
Parent(s):
68a71f4
Update game.js
Browse files
game.js
CHANGED
@@ -363,8 +363,20 @@ class Game {
|
|
363 |
}
|
364 |
|
365 |
// ์นด๋ฉ๋ผ ์ค์ ์์
|
366 |
-
|
367 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
|
369 |
// ๋ก๋ฉ ์๋ฃ
|
370 |
this.isLoading = false;
|
@@ -442,7 +454,6 @@ class Game {
|
|
442 |
if (this.keys.left) direction.x -= 1;
|
443 |
if (this.keys.right) direction.x += 1;
|
444 |
|
445 |
-
// ์์ ๋ณ๊ฒฝ
|
446 |
if (direction.length() > 0) {
|
447 |
direction.normalize();
|
448 |
|
@@ -472,13 +483,18 @@ class Game {
|
|
472 |
// ์นด๋ฉ๋ผ ์์น ๊ณ์ฐ
|
473 |
const tankRotation = this.tank.body.rotation.y;
|
474 |
const cameraOffset = new THREE.Vector3(
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
);
|
479 |
|
480 |
this.camera.position.copy(tankPos).sub(cameraOffset);
|
481 |
-
|
|
|
|
|
|
|
|
|
|
|
482 |
}
|
483 |
createBuildings() {
|
484 |
const buildingTypes = [
|
|
|
363 |
}
|
364 |
|
365 |
// ์นด๋ฉ๋ผ ์ค์ ์์
|
366 |
+
// ํฑํฌ์ ํ์ฌ ์์น ๊ฐ์ ธ์ค๊ธฐ
|
367 |
+
const tankPosition = this.tank.getPosition();
|
368 |
+
// ์นด๋ฉ๋ผ๋ฅผ ํฑํฌ ์์น ๊ธฐ์ค์ผ๋ก ์ค์
|
369 |
+
this.camera.position.set(
|
370 |
+
tankPosition.x,
|
371 |
+
tankPosition.y + 15, // ํฑํฌ๋ณด๋ค 15 ์ ๋ ์์
|
372 |
+
tankPosition.z - 30 // ํฑํฌ๋ณด๋ค 30 ์ ๋ ๋ค์
|
373 |
+
);
|
374 |
+
// ์นด๋ฉ๋ผ๊ฐ ํฑํฌ๋ฅผ ๋ฐ๋ผ๋ณด๋๋ก ์ค์
|
375 |
+
this.camera.lookAt(new THREE.Vector3(
|
376 |
+
tankPosition.x,
|
377 |
+
tankPosition.y + 2, // ํฑํฌ์ ์๋จ ๋ถ๋ถ์ ๋ฐ๋ผ๋ณด๋๋ก
|
378 |
+
tankPosition.z
|
379 |
+
));
|
380 |
|
381 |
// ๋ก๋ฉ ์๋ฃ
|
382 |
this.isLoading = false;
|
|
|
454 |
if (this.keys.left) direction.x -= 1;
|
455 |
if (this.keys.right) direction.x += 1;
|
456 |
|
|
|
457 |
if (direction.length() > 0) {
|
458 |
direction.normalize();
|
459 |
|
|
|
483 |
// ์นด๋ฉ๋ผ ์์น ๊ณ์ฐ
|
484 |
const tankRotation = this.tank.body.rotation.y;
|
485 |
const cameraOffset = new THREE.Vector3(
|
486 |
+
Math.sin(tankRotation) * cameraDistance,
|
487 |
+
cameraHeight,
|
488 |
+
Math.cos(tankRotation) * cameraDistance
|
489 |
+
);
|
490 |
|
491 |
this.camera.position.copy(tankPos).sub(cameraOffset);
|
492 |
+
// ํฑํฌ์ ์๋จ์ ๋ฐ๋ผ๋ณด๋๋ก ์์
|
493 |
+
this.camera.lookAt(new THREE.Vector3(
|
494 |
+
tankPos.x,
|
495 |
+
tankPos.y + 2, // ํฑํฌ์ ์๋จ ๋ถ๋ถ์ ๋ฐ๋ผ๋ณด๋๋ก
|
496 |
+
tankPos.z
|
497 |
+
));
|
498 |
}
|
499 |
createBuildings() {
|
500 |
const buildingTypes = [
|