cutechicken commited on
Commit
f9ba10f
โ€ข
1 Parent(s): e44b683

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +15 -0
game.js CHANGED
@@ -953,6 +953,8 @@ class Game {
953
  this.renderer.shadowMap.type = THREE.PCFSoftShadowMap; // ๋ถ€๋“œ๋Ÿฌ์šด ๊ทธ๋ฆผ์ž
954
  this.renderer.outputColorSpace = THREE.SRGBColorSpace;
955
  this.enemyLabels = new Map(); // ์  ๋ผ๋ฒจ์„ ์ถ”์ ํ•˜๊ธฐ ์œ„ํ•œ Map ์ถ”๊ฐ€
 
 
956
  document.getElementById('gameContainer').appendChild(this.renderer.domElement);
957
 
958
 
@@ -1941,6 +1943,17 @@ this.enemies.forEach(enemy => {
1941
  }
1942
  }
1943
  }
 
 
 
 
 
 
 
 
 
 
 
1944
  updateEnemyLabels() {
1945
  const labelsContainer = document.getElementById('enemyLabels');
1946
 
@@ -2019,6 +2032,8 @@ this.enemies.forEach(enemy => {
2019
  this.checkCollisions();
2020
  this.updateUI();
2021
  this.updateRadar(); // ๋ ˆ์ด๋” ์—…๋ฐ์ดํŠธ ์ถ”๊ฐ€
 
 
2022
  }
2023
 
2024
  this.renderer.render(this.scene, this.camera);
 
953
  this.renderer.shadowMap.type = THREE.PCFSoftShadowMap; // ๋ถ€๋“œ๋Ÿฌ์šด ๊ทธ๋ฆผ์ž
954
  this.renderer.outputColorSpace = THREE.SRGBColorSpace;
955
  this.enemyLabels = new Map(); // ์  ๋ผ๋ฒจ์„ ์ถ”์ ํ•˜๊ธฐ ์œ„ํ•œ Map ์ถ”๊ฐ€
956
+ this.raycaster = new THREE.Raycaster();
957
+ this.crosshair = document.getElementById('crosshair');
958
  document.getElementById('gameContainer').appendChild(this.renderer.domElement);
959
 
960
 
 
1943
  }
1944
  }
1945
  }
1946
+ // ํฌ๋กœ์Šคํ—ค์–ด ์—…๋ฐ์ดํŠธ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
1947
+ updateCrosshair() {
1948
+ this.raycaster.setFromCamera(new THREE.Vector2(), this.camera);
1949
+ const intersects = this.raycaster.intersectObjects(this.scene.children, true);
1950
+
1951
+ if (intersects.length > 0) {
1952
+ this.crosshair.classList.add('target-detected');
1953
+ } else {
1954
+ this.crosshair.classList.remove('target-detected');
1955
+ }
1956
+ }
1957
  updateEnemyLabels() {
1958
  const labelsContainer = document.getElementById('enemyLabels');
1959
 
 
2032
  this.checkCollisions();
2033
  this.updateUI();
2034
  this.updateRadar(); // ๋ ˆ์ด๋” ์—…๋ฐ์ดํŠธ ์ถ”๊ฐ€
2035
+ // ํฌ๋กœ์Šคํ—ค์–ด ์—…๋ฐ์ดํŠธ ์ถ”๊ฐ€
2036
+ this.updateCrosshair();
2037
  }
2038
 
2039
  this.renderer.render(this.scene, this.camera);