Update game.js
Browse files
game.js
CHANGED
|
@@ -862,6 +862,7 @@ class Game {
|
|
| 862 |
this.renderer.shadowMap.enabled = true;
|
| 863 |
this.renderer.shadowMap.type = THREE.PCFSoftShadowMap; // ๋ถ๋๋ฌ์ด ๊ทธ๋ฆผ์
|
| 864 |
this.renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
|
|
| 865 |
document.getElementById('gameContainer').appendChild(this.renderer.domElement);
|
| 866 |
|
| 867 |
|
|
@@ -923,7 +924,7 @@ class Game {
|
|
| 923 |
maxZ: mapBoundary
|
| 924 |
};
|
| 925 |
}
|
| 926 |
-
|
| 927 |
async initialize() {
|
| 928 |
try {
|
| 929 |
// BGM์ด ์์ง ์ฌ์๋์ง ์์ ๊ฒฝ์ฐ์๋ง ์ฌ์
|
|
@@ -1837,6 +1838,47 @@ this.enemies.forEach(enemy => {
|
|
| 1837 |
}
|
| 1838 |
}
|
| 1839 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1840 |
|
| 1841 |
animate() {
|
| 1842 |
if (this.isGameOver) {
|
|
@@ -1869,7 +1911,7 @@ this.enemies.forEach(enemy => {
|
|
| 1869 |
enemy.shoot(tankPosition);
|
| 1870 |
}
|
| 1871 |
});
|
| 1872 |
-
|
| 1873 |
this.updateParticles();
|
| 1874 |
this.checkCollisions();
|
| 1875 |
this.updateUI();
|
|
|
|
| 862 |
this.renderer.shadowMap.enabled = true;
|
| 863 |
this.renderer.shadowMap.type = THREE.PCFSoftShadowMap; // ๋ถ๋๋ฌ์ด ๊ทธ๋ฆผ์
|
| 864 |
this.renderer.outputColorSpace = THREE.SRGBColorSpace;
|
| 865 |
+
this.enemyLabels = new Map(); // ์ ๋ผ๋ฒจ์ ์ถ์ ํ๊ธฐ ์ํ Map ์ถ๊ฐ
|
| 866 |
document.getElementById('gameContainer').appendChild(this.renderer.domElement);
|
| 867 |
|
| 868 |
|
|
|
|
| 924 |
maxZ: mapBoundary
|
| 925 |
};
|
| 926 |
}
|
| 927 |
+
|
| 928 |
async initialize() {
|
| 929 |
try {
|
| 930 |
// BGM์ด ์์ง ์ฌ์๋์ง ์์ ๊ฒฝ์ฐ์๋ง ์ฌ์
|
|
|
|
| 1838 |
}
|
| 1839 |
}
|
| 1840 |
}
|
| 1841 |
+
updateEnemyLabels() {
|
| 1842 |
+
const labelsContainer = document.getElementById('enemyLabels');
|
| 1843 |
+
|
| 1844 |
+
// ๊ธฐ์กด ๋ผ๋ฒจ ๋ชจ๋ ์ ๊ฑฐ
|
| 1845 |
+
labelsContainer.innerHTML = '';
|
| 1846 |
+
|
| 1847 |
+
this.enemies.forEach((enemy, index) => {
|
| 1848 |
+
if (!enemy.mesh || !enemy.isLoaded) return;
|
| 1849 |
+
|
| 1850 |
+
// ์ ์์น๋ฅผ ํ๋ฉด ์ขํ๋ก ๋ณํ
|
| 1851 |
+
const enemyPosition = enemy.mesh.position.clone();
|
| 1852 |
+
enemyPosition.y += 3; // ์ ๋จธ๋ฆฌ ์์ ํ์ํ๊ธฐ ์ํด ๋์ด ์กฐ์
|
| 1853 |
+
|
| 1854 |
+
const screenPosition = enemyPosition.project(this.camera);
|
| 1855 |
+
|
| 1856 |
+
// ํ๋ฉด์ ๋ณด์ด๋์ง ํ์ธ
|
| 1857 |
+
if (screenPosition.z > 1) return; // ์นด๋ฉ๋ผ ๋ค์ ์๋ ๊ฒฝ์ฐ
|
| 1858 |
+
|
| 1859 |
+
// ์ ๊ณผ ํ๋ ์ด์ด ์ฌ์ด์ ๊ฑฐ๋ฆฌ ๊ณ์ฐ
|
| 1860 |
+
const distance = enemy.mesh.position.distanceTo(this.tank.getPosition());
|
| 1861 |
+
|
| 1862 |
+
// ๋ ์ด๋ ๋ฒ์ ๋ด์ ์๋ ๊ฒฝ์ฐ์๋ง ํ์
|
| 1863 |
+
if (distance <= this.radarRange) {
|
| 1864 |
+
const x = (screenPosition.x + 1) / 2 * window.innerWidth;
|
| 1865 |
+
const y = (-screenPosition.y + 1) / 2 * window.innerHeight;
|
| 1866 |
+
|
| 1867 |
+
// ๋ผ๋ฒจ ์์ฑ
|
| 1868 |
+
const label = document.createElement('div');
|
| 1869 |
+
label.className = 'enemy-label';
|
| 1870 |
+
label.textContent = 'T-90';
|
| 1871 |
+
label.style.left = `${x}px`;
|
| 1872 |
+
label.style.top = `${y}px`;
|
| 1873 |
+
|
| 1874 |
+
// ๊ฑฐ๋ฆฌ์ ๋ฐ๋ฅธ ํฌ๋ช
๋ ์กฐ์
|
| 1875 |
+
const opacity = Math.max(0.2, 1 - (distance / this.radarRange));
|
| 1876 |
+
label.style.opacity = opacity;
|
| 1877 |
+
|
| 1878 |
+
labelsContainer.appendChild(label);
|
| 1879 |
+
}
|
| 1880 |
+
});
|
| 1881 |
+
}
|
| 1882 |
|
| 1883 |
animate() {
|
| 1884 |
if (this.isGameOver) {
|
|
|
|
| 1911 |
enemy.shoot(tankPosition);
|
| 1912 |
}
|
| 1913 |
});
|
| 1914 |
+
this.updateEnemyLabels(); // ์ ๋ผ๋ฒจ ์
๋ฐ์ดํธ ์ถ๊ฐ
|
| 1915 |
this.updateParticles();
|
| 1916 |
this.checkCollisions();
|
| 1917 |
this.updateUI();
|