cutechicken commited on
Commit
fa41962
โ€ข
1 Parent(s): 68a71f4

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +24 -8
game.js CHANGED
@@ -363,8 +363,20 @@ class Game {
363
  }
364
 
365
  // ์นด๋ฉ”๋ผ ์„ค์ • ์ˆ˜์ •
366
- this.camera.position.set(0, 15, -30); // ์ „์ฐจ ํ›„๋ฐฉ ์ƒ๋‹จ์— ์œ„์น˜
367
- this.camera.lookAt(new THREE.Vector3(0, 0, 0));
 
 
 
 
 
 
 
 
 
 
 
 
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
- Math.sin(tankRotation) * cameraDistance,
476
- cameraHeight,
477
- Math.cos(tankRotation) * cameraDistance
478
- );
479
 
480
  this.camera.position.copy(tankPos).sub(cameraOffset);
481
- this.camera.lookAt(tankPos);
 
 
 
 
 
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 = [