Spaces:
Running
Running
cutechicken
commited on
Commit
β’
ba01407
1
Parent(s):
8cc3811
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) {
|