Spaces:
Running
Running
RemiFabre commited on
Commit ·
a05977c
1
Parent(s): 18467ee
HUD shield
Browse files
spaceship_game/static/index.html
CHANGED
|
@@ -33,9 +33,32 @@
|
|
| 33 |
#shield-status {
|
| 34 |
margin-top: 6px;
|
| 35 |
color: #00d5ff;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
font-size: 18px;
|
| 37 |
}
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
#debug-info {
|
| 40 |
position: fixed;
|
| 41 |
bottom: 20px;
|
|
@@ -247,7 +270,12 @@
|
|
| 247 |
<div>WAVE: <span id="wave">0</span></div>
|
| 248 |
<div>SCORE: <span id="score">0</span></div>
|
| 249 |
<div id="status">HP: <span style="color: #0f0">100</span></div>
|
| 250 |
-
<div id="shield-status">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
<div>GOLD: <span id="gold">0</span></div>
|
| 252 |
</div>
|
| 253 |
|
|
|
|
| 33 |
#shield-status {
|
| 34 |
margin-top: 6px;
|
| 35 |
color: #00d5ff;
|
| 36 |
+
font-size: 16px;
|
| 37 |
+
display: flex;
|
| 38 |
+
flex-direction: column;
|
| 39 |
+
gap: 4px;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
#shield-status-text {
|
| 43 |
font-size: 18px;
|
| 44 |
}
|
| 45 |
|
| 46 |
+
.shield-bar {
|
| 47 |
+
width: 220px;
|
| 48 |
+
height: 10px;
|
| 49 |
+
border: 1px solid rgba(0, 213, 255, 0.6);
|
| 50 |
+
border-radius: 8px;
|
| 51 |
+
overflow: hidden;
|
| 52 |
+
background: rgba(0, 20, 30, 0.6);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.shield-bar-fill {
|
| 56 |
+
height: 100%;
|
| 57 |
+
width: 0%;
|
| 58 |
+
background: linear-gradient(90deg, #00b7ff, #00ffdd);
|
| 59 |
+
transition: width 0.15s ease-out;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
#debug-info {
|
| 63 |
position: fixed;
|
| 64 |
bottom: 20px;
|
|
|
|
| 270 |
<div>WAVE: <span id="wave">0</span></div>
|
| 271 |
<div>SCORE: <span id="score">0</span></div>
|
| 272 |
<div id="status">HP: <span style="color: #0f0">100</span></div>
|
| 273 |
+
<div id="shield-status">
|
| 274 |
+
<div id="shield-status-text">Shield: READY</div>
|
| 275 |
+
<div class="shield-bar">
|
| 276 |
+
<div class="shield-bar-fill" id="shield-bar-fill"></div>
|
| 277 |
+
</div>
|
| 278 |
+
</div>
|
| 279 |
<div>GOLD: <span id="gold">0</span></div>
|
| 280 |
</div>
|
| 281 |
|
spaceship_game/static/main.js
CHANGED
|
@@ -1097,18 +1097,30 @@ function updateHUD() {
|
|
| 1097 |
const goldEl = document.getElementById('gold');
|
| 1098 |
if (goldEl) goldEl.textContent = playerGold;
|
| 1099 |
|
| 1100 |
-
const
|
| 1101 |
-
|
|
|
|
| 1102 |
const now = Date.now();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1103 |
if (shieldActive) {
|
| 1104 |
const remaining = Math.max(0, shieldEndTime - now);
|
| 1105 |
-
|
|
|
|
| 1106 |
} else if (now < shieldCooldownReadyAt) {
|
| 1107 |
const cd = Math.max(0, shieldCooldownReadyAt - now);
|
| 1108 |
-
|
|
|
|
| 1109 |
} else {
|
| 1110 |
-
|
|
|
|
| 1111 |
}
|
|
|
|
|
|
|
|
|
|
| 1112 |
}
|
| 1113 |
|
| 1114 |
// Check for game over
|
|
|
|
| 1097 |
const goldEl = document.getElementById('gold');
|
| 1098 |
if (goldEl) goldEl.textContent = playerGold;
|
| 1099 |
|
| 1100 |
+
const shieldStatusText = document.getElementById('shield-status-text');
|
| 1101 |
+
const shieldBarFill = document.getElementById('shield-bar-fill');
|
| 1102 |
+
if (shieldStatusText && shieldBarFill) {
|
| 1103 |
const now = Date.now();
|
| 1104 |
+
let statusText = 'Shield: READY';
|
| 1105 |
+
let progress = 1;
|
| 1106 |
+
|
| 1107 |
+
const cooldownWindow = Math.max(1, shieldCooldown || BASE_SHIELD_COOLDOWN);
|
| 1108 |
+
|
| 1109 |
if (shieldActive) {
|
| 1110 |
const remaining = Math.max(0, shieldEndTime - now);
|
| 1111 |
+
statusText = `Shield: ACTIVE (${(remaining / 1000).toFixed(1)}s)`;
|
| 1112 |
+
progress = Math.max(0, Math.min(1, remaining / shieldDuration));
|
| 1113 |
} else if (now < shieldCooldownReadyAt) {
|
| 1114 |
const cd = Math.max(0, shieldCooldownReadyAt - now);
|
| 1115 |
+
statusText = `Shield: RECHARGE ${(cd / 1000).toFixed(1)}s`;
|
| 1116 |
+
progress = Math.max(0, Math.min(1, 1 - cd / cooldownWindow));
|
| 1117 |
} else {
|
| 1118 |
+
statusText = 'Shield: READY';
|
| 1119 |
+
progress = 1;
|
| 1120 |
}
|
| 1121 |
+
|
| 1122 |
+
shieldStatusText.textContent = statusText;
|
| 1123 |
+
shieldBarFill.style.width = `${Math.round(progress * 100)}%`;
|
| 1124 |
}
|
| 1125 |
|
| 1126 |
// Check for game over
|