Spaces:
Running
Running
Manual changes saved
Browse files- index.html +84 -53
index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 6 |
-
<title>BattleZone Royale -
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 9 |
<style>
|
|
@@ -144,13 +144,11 @@
|
|
| 144 |
transform: translate(0,0);
|
| 145 |
transition: transform 0.06s linear;
|
| 146 |
}
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
right: 12px;
|
| 150 |
-
bottom: 12px;
|
| 151 |
display:flex;
|
| 152 |
-
gap:
|
| 153 |
-
|
| 154 |
pointer-events:auto;
|
| 155 |
}
|
| 156 |
.mobile-btn {
|
|
@@ -173,6 +171,7 @@
|
|
| 173 |
.mobile-controls.hidden { display:none; }
|
| 174 |
@media (min-width: 900px){
|
| 175 |
.mobile-controls { display:none !important; }
|
|
|
|
| 176 |
}
|
| 177 |
</style>
|
| 178 |
</head>
|
|
@@ -311,22 +310,23 @@
|
|
| 311 |
</div>
|
| 312 |
|
| 313 |
<div id="hudGearWrap" class="hidden">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
<div id="pickaxeSlot" class="pickaxe-slot" title="Pickaxe (press F to equip)">⛏️</div>
|
| 315 |
<div id="hudGear" aria-label="gear"></div>
|
| 316 |
</div>
|
| 317 |
|
| 318 |
-
<!-- Mobile Controls (
|
| 319 |
<div id="mobileControls" class="mobile-controls hidden" aria-hidden="true">
|
| 320 |
-
<!-- Left: joystick -->
|
| 321 |
<div id="mobileJoystick" class="mobile-joystick" role="application" aria-label="Movement joystick">
|
| 322 |
<div id="joystickThumb" class="thumb"></div>
|
| 323 |
</div>
|
| 324 |
-
<!-- Right: buttons -->
|
| 325 |
-
<div class="mobile-buttons" id="mobileButtons">
|
| 326 |
-
<div id="shootBtn" class="mobile-btn" aria-label="Shoot">SHOOT</div>
|
| 327 |
-
<div id="interactBtn" class="mobile-btn small" aria-label="Interact">USE</div>
|
| 328 |
-
<div id="buildBtn" class="mobile-btn small" aria-label="Build">BUILD</div>
|
| 329 |
-
</div>
|
| 330 |
</div>
|
| 331 |
|
| 332 |
</div>
|
|
@@ -351,6 +351,11 @@
|
|
| 351 |
const continueBtn = document.getElementById('continueBtn');
|
| 352 |
const biomeGrid = document.getElementById('biomeGrid');
|
| 353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
// Loading screen elements
|
| 355 |
const loadingScreen = document.getElementById('loadingScreen');
|
| 356 |
const loadingTipEl = document.getElementById('loadingTip');
|
|
@@ -2154,20 +2159,22 @@
|
|
| 2154 |
|
| 2155 |
// Mobile controls wiring (only show on mobile devices)
|
| 2156 |
(function setupMobileControls(){
|
| 2157 |
-
const mobileControls = document.getElementById('mobileControls');
|
| 2158 |
const joystick = document.getElementById('mobileJoystick');
|
| 2159 |
const thumb = document.getElementById('joystickThumb');
|
| 2160 |
const shootBtn = document.getElementById('shootBtn');
|
| 2161 |
const interactBtn = document.getElementById('interactBtn');
|
| 2162 |
const buildBtn = document.getElementById('buildBtn');
|
|
|
|
| 2163 |
|
| 2164 |
const isMobile = ('ontouchstart' in window) || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
| 2165 |
if (!isMobile) {
|
| 2166 |
mobileControls.classList.add('hidden');
|
|
|
|
| 2167 |
return;
|
| 2168 |
}
|
| 2169 |
mobileControls.classList.remove('hidden');
|
| 2170 |
mobileControls.setAttribute('aria-hidden','false');
|
|
|
|
| 2171 |
|
| 2172 |
// Joystick state
|
| 2173 |
let joyTouchId = null;
|
|
@@ -2258,57 +2265,81 @@
|
|
| 2258 |
}
|
| 2259 |
});
|
| 2260 |
|
| 2261 |
-
//
|
| 2262 |
-
let
|
| 2263 |
-
function
|
| 2264 |
-
|
| 2265 |
-
|
| 2266 |
-
|
| 2267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2268 |
}
|
| 2269 |
-
function
|
| 2270 |
-
|
| 2271 |
-
|
| 2272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2273 |
}
|
| 2274 |
-
shootBtn.addEventListener('touchstart',
|
| 2275 |
-
shootBtn.addEventListener('touchend',
|
| 2276 |
-
shootBtn.addEventListener('touchcancel',
|
| 2277 |
shootBtn.addEventListener('mousedown', (e)=>{ mouse.down = true; e.preventDefault(); });
|
| 2278 |
window.addEventListener('mouseup', ()=> mouse.down = false);
|
| 2279 |
|
| 2280 |
// Interact button
|
| 2281 |
-
|
| 2282 |
attemptUseOrInteract();
|
| 2283 |
-
e.preventDefault();
|
| 2284 |
-
}
|
| 2285 |
-
interactBtn.addEventListener('
|
|
|
|
| 2286 |
|
| 2287 |
// Build button
|
| 2288 |
-
|
| 2289 |
tryBuild();
|
| 2290 |
-
e.preventDefault();
|
| 2291 |
-
}
|
| 2292 |
-
buildBtn.addEventListener('
|
| 2293 |
-
|
| 2294 |
-
|
| 2295 |
-
|
| 2296 |
-
|
| 2297 |
-
|
| 2298 |
-
|
| 2299 |
-
|
| 2300 |
-
|
| 2301 |
-
|
| 2302 |
-
}
|
| 2303 |
-
}, { passive:false });
|
| 2304 |
-
});
|
| 2305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2306 |
})();
|
| 2307 |
|
| 2308 |
-
//
|
| 2309 |
-
resizeCanvas();
|
| 2310 |
-
populateWorld();
|
| 2311 |
feather.replace();
|
|
|
|
| 2312 |
</script>
|
| 2313 |
</body>
|
| 2314 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 6 |
+
<title>BattleZone Royale - Full</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 9 |
<style>
|
|
|
|
| 144 |
transform: translate(0,0);
|
| 145 |
transition: transform 0.06s linear;
|
| 146 |
}
|
| 147 |
+
/* Buttons now reside left of pickaxe slot in HUD; this container is shown only on mobile */
|
| 148 |
+
.mobile-buttons-hud {
|
|
|
|
|
|
|
| 149 |
display:flex;
|
| 150 |
+
gap:8px;
|
| 151 |
+
align-items:center;
|
| 152 |
pointer-events:auto;
|
| 153 |
}
|
| 154 |
.mobile-btn {
|
|
|
|
| 171 |
.mobile-controls.hidden { display:none; }
|
| 172 |
@media (min-width: 900px){
|
| 173 |
.mobile-controls { display:none !important; }
|
| 174 |
+
.mobile-buttons-hud { display:none !important; } /* hide HUD buttons on desktop too */
|
| 175 |
}
|
| 176 |
</style>
|
| 177 |
</head>
|
|
|
|
| 310 |
</div>
|
| 311 |
|
| 312 |
<div id="hudGearWrap" class="hidden">
|
| 313 |
+
<!-- Mobile buttons moved here (left of pickaxe slot) -->
|
| 314 |
+
<div id="mobileButtonsHud" class="mobile-buttons-hud hidden" aria-hidden="true">
|
| 315 |
+
<div id="shootBtn" class="mobile-btn small" aria-label="Shoot">SHOOT</div>
|
| 316 |
+
<div id="reloadBtn" class="mobile-btn small" aria-label="Reload">RELOAD</div>
|
| 317 |
+
<div id="interactBtn" class="mobile-btn small" aria-label="Interact">USE</div>
|
| 318 |
+
<div id="buildBtn" class="mobile-btn small" aria-label="Build">BUILD</div>
|
| 319 |
+
</div>
|
| 320 |
+
|
| 321 |
<div id="pickaxeSlot" class="pickaxe-slot" title="Pickaxe (press F to equip)">⛏️</div>
|
| 322 |
<div id="hudGear" aria-label="gear"></div>
|
| 323 |
</div>
|
| 324 |
|
| 325 |
+
<!-- Mobile Controls (joystick only) -->
|
| 326 |
<div id="mobileControls" class="mobile-controls hidden" aria-hidden="true">
|
|
|
|
| 327 |
<div id="mobileJoystick" class="mobile-joystick" role="application" aria-label="Movement joystick">
|
| 328 |
<div id="joystickThumb" class="thumb"></div>
|
| 329 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
</div>
|
| 331 |
|
| 332 |
</div>
|
|
|
|
| 351 |
const continueBtn = document.getElementById('continueBtn');
|
| 352 |
const biomeGrid = document.getElementById('biomeGrid');
|
| 353 |
|
| 354 |
+
// Mobile button references (in HUD)
|
| 355 |
+
const mobileButtonsHud = document.getElementById('mobileButtonsHud');
|
| 356 |
+
// Joystick container
|
| 357 |
+
const mobileControls = document.getElementById('mobileControls');
|
| 358 |
+
|
| 359 |
// Loading screen elements
|
| 360 |
const loadingScreen = document.getElementById('loadingScreen');
|
| 361 |
const loadingTipEl = document.getElementById('loadingTip');
|
|
|
|
| 2159 |
|
| 2160 |
// Mobile controls wiring (only show on mobile devices)
|
| 2161 |
(function setupMobileControls(){
|
|
|
|
| 2162 |
const joystick = document.getElementById('mobileJoystick');
|
| 2163 |
const thumb = document.getElementById('joystickThumb');
|
| 2164 |
const shootBtn = document.getElementById('shootBtn');
|
| 2165 |
const interactBtn = document.getElementById('interactBtn');
|
| 2166 |
const buildBtn = document.getElementById('buildBtn');
|
| 2167 |
+
const reloadBtn = document.getElementById('reloadBtn');
|
| 2168 |
|
| 2169 |
const isMobile = ('ontouchstart' in window) || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
| 2170 |
if (!isMobile) {
|
| 2171 |
mobileControls.classList.add('hidden');
|
| 2172 |
+
if (mobileButtonsHud) mobileButtonsHud.classList.add('hidden');
|
| 2173 |
return;
|
| 2174 |
}
|
| 2175 |
mobileControls.classList.remove('hidden');
|
| 2176 |
mobileControls.setAttribute('aria-hidden','false');
|
| 2177 |
+
if (mobileButtonsHud) { mobileButtonsHud.classList.remove('hidden'); mobileButtonsHud.setAttribute('aria-hidden','false'); }
|
| 2178 |
|
| 2179 |
// Joystick state
|
| 2180 |
let joyTouchId = null;
|
|
|
|
| 2265 |
}
|
| 2266 |
});
|
| 2267 |
|
| 2268 |
+
// On-screen shoot button: set mouse.down while pressed
|
| 2269 |
+
let shootTouchId = null;
|
| 2270 |
+
function shootPressStart(e){
|
| 2271 |
+
if (e.changedTouches){
|
| 2272 |
+
for (const t of e.changedTouches){
|
| 2273 |
+
if (shootTouchId === null){
|
| 2274 |
+
shootTouchId = t.identifier;
|
| 2275 |
+
mouse.down = true;
|
| 2276 |
+
// set aim to center of canvas for quick shots if not touching canvas
|
| 2277 |
+
const rect = canvas.getBoundingClientRect();
|
| 2278 |
+
mouse.canvasX = rect.width * 0.6;
|
| 2279 |
+
mouse.canvasY = rect.height * 0.5;
|
| 2280 |
+
mouse.worldX = mouse.canvasX + camera.x;
|
| 2281 |
+
mouse.worldY = mouse.canvasY + camera.y;
|
| 2282 |
+
e.preventDefault();
|
| 2283 |
+
break;
|
| 2284 |
+
}
|
| 2285 |
+
}
|
| 2286 |
+
} else {
|
| 2287 |
+
mouse.down = true;
|
| 2288 |
+
}
|
| 2289 |
}
|
| 2290 |
+
function shootPressEnd(e){
|
| 2291 |
+
if (e.changedTouches){
|
| 2292 |
+
for (const t of e.changedTouches){
|
| 2293 |
+
if (t.identifier === shootTouchId){
|
| 2294 |
+
shootTouchId = null;
|
| 2295 |
+
mouse.down = false;
|
| 2296 |
+
e.preventDefault();
|
| 2297 |
+
break;
|
| 2298 |
+
}
|
| 2299 |
+
}
|
| 2300 |
+
} else {
|
| 2301 |
+
mouse.down = false;
|
| 2302 |
+
}
|
| 2303 |
}
|
| 2304 |
+
shootBtn.addEventListener('touchstart', shootPressStart, { passive:false });
|
| 2305 |
+
shootBtn.addEventListener('touchend', shootPressEnd, { passive:false });
|
| 2306 |
+
shootBtn.addEventListener('touchcancel', shootPressEnd, { passive:false });
|
| 2307 |
shootBtn.addEventListener('mousedown', (e)=>{ mouse.down = true; e.preventDefault(); });
|
| 2308 |
window.addEventListener('mouseup', ()=> mouse.down = false);
|
| 2309 |
|
| 2310 |
// Interact button
|
| 2311 |
+
function interactActivate(e){
|
| 2312 |
attemptUseOrInteract();
|
| 2313 |
+
if (e && e.preventDefault) e.preventDefault();
|
| 2314 |
+
}
|
| 2315 |
+
interactBtn.addEventListener('touchstart', interactActivate, { passive:false });
|
| 2316 |
+
interactBtn.addEventListener('mousedown', interactActivate);
|
| 2317 |
|
| 2318 |
// Build button
|
| 2319 |
+
function buildActivate(e){
|
| 2320 |
tryBuild();
|
| 2321 |
+
if (e && e.preventDefault) e.preventDefault();
|
| 2322 |
+
}
|
| 2323 |
+
buildBtn.addEventListener('touchstart', buildActivate, { passive:false });
|
| 2324 |
+
buildBtn.addEventListener('mousedown', buildActivate);
|
| 2325 |
+
|
| 2326 |
+
// Reload button
|
| 2327 |
+
function reloadActivate(e){
|
| 2328 |
+
reloadEquipped();
|
| 2329 |
+
if (e && e.preventDefault) e.preventDefault();
|
| 2330 |
+
}
|
| 2331 |
+
reloadBtn.addEventListener('touchstart', reloadActivate, { passive:false });
|
| 2332 |
+
reloadBtn.addEventListener('mousedown', reloadActivate);
|
|
|
|
|
|
|
|
|
|
| 2333 |
|
| 2334 |
+
// Prevent buttons from stealing canvas touch when pressing them
|
| 2335 |
+
[shootBtn, interactBtn, buildBtn, reloadBtn].forEach(b => {
|
| 2336 |
+
b.addEventListener('touchmove', (ev)=> ev.preventDefault(), { passive:false });
|
| 2337 |
+
});
|
| 2338 |
})();
|
| 2339 |
|
| 2340 |
+
// Initialize UI state
|
|
|
|
|
|
|
| 2341 |
feather.replace();
|
| 2342 |
+
resizeCanvas();
|
| 2343 |
</script>
|
| 2344 |
</body>
|
| 2345 |
</html>
|