Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -1097,56 +1097,56 @@ class Game {
|
|
| 1097 |
|
| 1098 |
// ๋ ์ด๋ ์
๋ฐ์ดํธ ๋ฉ์๋ ์ถ๊ฐ
|
| 1099 |
updateRadar() {
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
|
| 1107 |
-
|
| 1108 |
-
|
| 1109 |
|
| 1110 |
-
|
| 1111 |
-
|
| 1112 |
-
|
| 1113 |
-
|
| 1114 |
-
|
| 1115 |
|
| 1116 |
-
|
| 1117 |
-
|
| 1118 |
|
| 1119 |
-
|
| 1120 |
-
|
| 1121 |
-
|
| 1122 |
|
| 1123 |
-
|
| 1124 |
-
|
| 1125 |
|
| 1126 |
-
|
| 1127 |
-
|
| 1128 |
-
|
| 1129 |
-
|
| 1130 |
-
|
| 1131 |
-
|
| 1132 |
-
|
| 1133 |
|
| 1134 |
-
|
| 1135 |
-
|
| 1136 |
-
|
| 1137 |
-
|
| 1138 |
-
|
| 1139 |
-
|
| 1140 |
-
|
| 1141 |
-
|
| 1142 |
-
|
| 1143 |
-
|
| 1144 |
-
|
| 1145 |
-
|
| 1146 |
-
|
| 1147 |
|
| 1148 |
-
|
| 1149 |
-
|
| 1150 |
|
| 1151 |
async addDesertDecorations() {
|
| 1152 |
if (!this.obstacles) {
|
|
|
|
| 1097 |
|
| 1098 |
// ๋ ์ด๋ ์
๋ฐ์ดํธ ๋ฉ์๋ ์ถ๊ฐ
|
| 1099 |
updateRadar() {
|
| 1100 |
+
const currentTime = Date.now();
|
| 1101 |
+
if (currentTime - this.lastRadarUpdate < this.radarUpdateInterval) return;
|
| 1102 |
+
|
| 1103 |
+
const radar = document.getElementById('radar');
|
| 1104 |
+
const radarRect = radar.getBoundingClientRect();
|
| 1105 |
+
const radarCenter = {
|
| 1106 |
+
x: radarRect.width / 2,
|
| 1107 |
+
y: radarRect.height / 2
|
| 1108 |
+
};
|
| 1109 |
|
| 1110 |
+
// ๊ธฐ์กด ์ ๋ํธ ์ ๊ฑฐ
|
| 1111 |
+
const oldDots = radar.getElementsByClassName('enemy-dot');
|
| 1112 |
+
while (oldDots[0]) {
|
| 1113 |
+
oldDots[0].remove();
|
| 1114 |
+
}
|
| 1115 |
|
| 1116 |
+
// ํฑํฌ ์์น ๊ฐ์ ธ์ค๊ธฐ
|
| 1117 |
+
const tankPos = this.tank.getPosition();
|
| 1118 |
|
| 1119 |
+
// ๋ชจ๋ ์ ์ ๋ํด ๋ ์ด๋์ ํ์
|
| 1120 |
+
this.enemies.forEach(enemy => {
|
| 1121 |
+
if (!enemy.isLoaded || !enemy.body) return; // body ์ฒดํฌ๋ก ๋ณ๊ฒฝ
|
| 1122 |
|
| 1123 |
+
const enemyPos = enemy.body.position; // mesh ๋์ body ์ฌ์ฉ
|
| 1124 |
+
const distance = tankPos.distanceTo(enemyPos);
|
| 1125 |
|
| 1126 |
+
// ๋ ์ด๋ ๋ฒ์ ๋ด์ ์๋ ๊ฒฝ์ฐ๋ง ํ์
|
| 1127 |
+
if (distance <= this.radarRange) {
|
| 1128 |
+
// ํฑํฌ ๊ธฐ์ค ์๋ ๊ฐ๋ ๊ณ์ฐ
|
| 1129 |
+
const angle = Math.atan2(
|
| 1130 |
+
enemyPos.x - tankPos.x,
|
| 1131 |
+
enemyPos.z - tankPos.z
|
| 1132 |
+
);
|
| 1133 |
|
| 1134 |
+
// ์๋ ๊ฑฐ๋ฆฌ๋ฅผ ๋ ์ด๋ ํฌ๊ธฐ์ ๋ง๊ฒ ์ค์ผ์ผ๋ง
|
| 1135 |
+
const relativeDistance = distance / this.radarRange;
|
| 1136 |
+
const dotX = radarCenter.x + Math.sin(angle) * (radarCenter.x * relativeDistance);
|
| 1137 |
+
const dotY = radarCenter.y + Math.cos(angle) * (radarCenter.y * relativeDistance);
|
| 1138 |
+
|
| 1139 |
+
// ์ ๋ํธ ์์ฑ ๋ฐ ์ถ๊ฐ
|
| 1140 |
+
const dot = document.createElement('div');
|
| 1141 |
+
dot.className = 'enemy-dot';
|
| 1142 |
+
dot.style.left = `${dotX}px`;
|
| 1143 |
+
dot.style.top = `${dotY}px`;
|
| 1144 |
+
radar.appendChild(dot);
|
| 1145 |
+
}
|
| 1146 |
+
});
|
| 1147 |
|
| 1148 |
+
this.lastRadarUpdate = currentTime;
|
| 1149 |
+
}
|
| 1150 |
|
| 1151 |
async addDesertDecorations() {
|
| 1152 |
if (!this.obstacles) {
|