cutechicken commited on
Commit
4fd6374
ยท
verified ยท
1 Parent(s): 07fd491

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +83 -0
game.js CHANGED
@@ -1084,6 +1084,89 @@ class Game {
1084
  }
1085
 
1086
  this.updateWarnings();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1087
  }
1088
  }
1089
 
 
1084
  }
1085
 
1086
  this.updateWarnings();
1087
+ this.updateHUD();
1088
+ }
1089
+ }
1090
+
1091
+ updateHUD() {
1092
+ // HUD ํฌ๋กœ์Šคํ—ค์–ด ์—…๋ฐ์ดํŠธ
1093
+ const hudElement = document.getElementById('hudCrosshair');
1094
+ if (!hudElement) return;
1095
+
1096
+ // ๋กค ๊ฐ๋„์— ๋”ฐ๋ผ HUD ํšŒ์ „
1097
+ const rollDegrees = this.fighter.rotation.z * (180 / Math.PI);
1098
+ hudElement.style.transform = `translate(-50%, -50%) rotate(${-rollDegrees}deg)`;
1099
+
1100
+ // ํ”ผ์น˜ ํ‘œ์‹œ๊ธฐ ์—…๋ฐ์ดํŠธ
1101
+ const pitchIndicator = document.getElementById('pitchIndicator');
1102
+ if (pitchIndicator) {
1103
+ const pitchDegrees = this.fighter.rotation.x * (180 / Math.PI);
1104
+ const pitchOffset = pitchDegrees * 2; // ํ”ผ์น˜์— ๋”ฐ๋ฅธ ์ˆ˜์ง ์˜คํ”„์…‹
1105
+ pitchIndicator.style.transform = `translateY(${pitchOffset}px)`;
1106
+ }
1107
+
1108
+ // ์  ํƒ€๊ฒŸ ๋งˆ์ปค ์—…๋ฐ์ดํŠธ
1109
+ const targetMarkers = document.getElementById('targetMarkers');
1110
+ if (targetMarkers) {
1111
+ // ๊ธฐ์กด ๋งˆ์ปค ์ œ๊ฑฐ
1112
+ targetMarkers.innerHTML = '';
1113
+
1114
+ // ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ์  ์ฐพ๊ธฐ
1115
+ let closestEnemy = null;
1116
+ let closestDistance = Infinity;
1117
+
1118
+ this.enemies.forEach(enemy => {
1119
+ if (!enemy.mesh || !enemy.isLoaded) return;
1120
+
1121
+ const distance = this.fighter.position.distanceTo(enemy.position);
1122
+ if (distance < closestDistance) {
1123
+ closestDistance = distance;
1124
+ closestEnemy = enemy;
1125
+ }
1126
+ });
1127
+
1128
+ // ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ์ ์— ๋Œ€ํ•œ ํƒ€๊ฒŸ ๋งˆ์ปค ํ‘œ์‹œ
1129
+ if (closestEnemy && closestDistance < 5000) {
1130
+ // ์ ์˜ ์ƒ๋Œ€ ์œ„์น˜ ๊ณ„์‚ฐ
1131
+ const relativePos = closestEnemy.position.clone().sub(this.fighter.position);
1132
+
1133
+ // ์ „ํˆฌ๊ธฐ์˜ ํšŒ์ „์„ ๊ณ ๋ คํ•œ ์ƒ๋Œ€ ์œ„์น˜
1134
+ const inverseRotation = new THREE.Euler(
1135
+ -this.fighter.rotation.x,
1136
+ -this.fighter.rotation.y,
1137
+ -this.fighter.rotation.z
1138
+ );
1139
+ relativePos.applyEuler(inverseRotation);
1140
+
1141
+ // ํ™”๋ฉด ์ขŒํ‘œ๋กœ ๋ณ€ํ™˜
1142
+ const screenX = (relativePos.x / closestDistance) * 200;
1143
+ const screenY = -(relativePos.y / closestDistance) * 200;
1144
+
1145
+ // ํƒ€๊ฒŸ ๋งˆ์ปค ์ƒ์„ฑ
1146
+ const marker = document.createElement('div');
1147
+ marker.className = 'target-marker';
1148
+ marker.style.left = `${50 + screenX}%`;
1149
+ marker.style.top = `${50 + screenY}%`;
1150
+
1151
+ // ๊ฑฐ๋ฆฌ๊ฐ€ ๊ฐ€๊นŒ์šธ์ˆ˜๋ก ๋นจ๊ฐ„์ƒ‰
1152
+ const colorIntensity = Math.max(0, 1 - closestDistance / 5000);
1153
+ marker.style.borderColor = `rgba(255, ${255 * (1 - colorIntensity)}, 0, ${0.5 + colorIntensity * 0.5})`;
1154
+
1155
+ // ๋ฝ์˜จ ์ƒํƒœ
1156
+ if (closestDistance < 2000) {
1157
+ marker.classList.add('locked');
1158
+ }
1159
+
1160
+ targetMarkers.appendChild(marker);
1161
+
1162
+ // ๊ฑฐ๋ฆฌ ํ‘œ์‹œ
1163
+ const distanceLabel = document.createElement('div');
1164
+ distanceLabel.className = 'target-distance';
1165
+ distanceLabel.textContent = `${Math.round(closestDistance)}m`;
1166
+ distanceLabel.style.left = `${50 + screenX}%`;
1167
+ distanceLabel.style.top = `${50 + screenY + 5}%`;
1168
+ targetMarkers.appendChild(distanceLabel);
1169
+ }
1170
  }
1171
  }
1172