astara / index.html
system's picture
system HF Staff
dd4a694: The key was invisible, and it is called an inventory
f38d705 verified
Raw History Blame Contribute Delete
13 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, viewport-fit=cover">
<!-- Safari on iPhone has no Fullscreen API at all β€” only iPad does. What it has
instead is Add to Home Screen, and these are what make that open without
any browser chrome round it. Android reads the second one. -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="ASTARA">
<meta name="theme-color" content="#000000">
<title>ONLY HUMAN β€” torch demo</title>
<style>
html, body { margin:0; padding:0; height:100%; background:#000; overflow:hidden; }
body { display:grid; place-items:center; touch-action:none;
-webkit-user-select:none; user-select:none; cursor:default; }
canvas { display:block; }
#protocol-warning {
position:fixed; inset:0; display:none; place-items:center; background:#111;
color:#ddd; font:16px/1.6 ui-monospace, Menlo, Consolas, monospace; padding:8vw;
text-align:center;
}
#protocol-warning code { color:#ffb45a; }
/* ---- touch controls -------------------------------------------------
Only ever shown on a touch device. A phone has no keyboard, so without
these you can raise the torch and swing but you cannot walk, and walking
is most of this game β€” which is why walking is the one under the right
thumb. Parked in the bottom corners, over the black ground band, which is
the least important part of the frame.
The three actions sit in a wheel rather than a row. A row grows sideways
across the picture; a wheel stays in the corner and puts every action one
short flick from where the thumb already is. The fourth slot holds the pages on
purpose β€” it keeps the ring reading as a ring, and it is where the next
verb goes. */
#pad { position:fixed; inset:0; pointer-events:none; --thumb:50%; }
#pad[hidden] { display:none; }
/* HALFWAY DOWN, NOT AT THE BOTTOM.
A phone held sideways is gripped at the middle of its long edges, and the
thumb pivots from there. Buttons in the bottom corners are a reach away
from where the hand already is; at the vertical middle they are under the
thumb at rest. The game is unaffected β€” the prince is at the horizontal
centre and these hug the edges, which on a 16:9 canvas in a phone-shaped
window is mostly letterbox anyway. */
#pad .cluster { position:absolute; top:var(--thumb); transform:translateY(-50%); }
#pad .left { left:max(12px, env(safe-area-inset-left)); }
#pad .right { right:max(12px, env(safe-area-inset-right)); }
/* A WHEEL ON THIS SIDE TOO. Two arrows in a row grow sideways across the
picture and give a thumb nothing to pivot around; a wheel keeps the same
footprint whatever gets added to it, and the two hands now hold the same
shape. Walking is at three and nine where a thumb rocks left and right
without moving, which is what it does all game. */
#pad .walkwheel { width:176px; height:176px; }
#pad .walkwheel::before { inset:38px; }
/* MARK WAS HERE AND IS GONE. It existed because pinning a page needed PAGES
held and TAKE pressed, and both of those live on the left wheel β€” one thumb
cannot hold one and press the other, so the act needed a button under the
other thumb. The top page of the pile is now what he is holding and TAKE
acts on it wherever he is standing, so there is no hold, no second button,
and nothing for this side to do but walk. The workaround outlived its
problem by one build. */
/* Six o'clock, holding the wheel's shape open until there is a fourth thing
to do with the right thumb. Solid and small β€” a dashed circle reads as
something broken rather than something reserved. */
#pad .wheel .empty.s { transform:translateX(-50%) scale(.6); }
#pad button {
pointer-events:auto; touch-action:none; -webkit-tap-highlight-color:transparent;
appearance:none; margin:0; cursor:pointer;
font:600 10px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing:.06em;
color:rgba(255,220,180,.62); background:rgba(0,0,0,.30);
border:1.5px solid rgba(255,220,180,.34); border-radius:50%;
width:62px; height:62px; display:grid; place-items:center;
transition:background .08s linear, border-color .08s linear, color .08s linear,
opacity .18s linear;
}
#pad button.arrow { font-size:24px; letter-spacing:0; width:70px; height:70px; }
/* The wheel. Four slots at twelve, three, six and nine o'clock. */
#pad .wheel { position:relative; width:158px; height:158px; }
#pad .wheel button { position:absolute; }
#pad .wheel .n { top:0; left:50%; transform:translateX(-50%); }
#pad .wheel .s { bottom:0; left:50%; transform:translateX(-50%); }
#pad .wheel .w { left:0; top:50%; transform:translateY(-50%); }
#pad .wheel .e { right:0; top:50%; transform:translateY(-50%); }
/* A faint ring behind them, so it reads as one control and not four buttons. */
#pad .wheel::before {
content:""; position:absolute; inset:31px; border-radius:50%;
border:1px solid rgba(255,220,180,.10);
}
/* TORCH is the one you hold for seconds at a time, so it sits lowest β€” the
restful end of a thumb's arc β€” and it is the only one with the fire in it. */
#pad .wheel [data-act="torch"] {
color:rgba(255,180,90,.88); border-color:rgba(255,180,90,.52);
}
/* The empty slot. Present, obviously inert, holding a wheel's shape open until
there is a fourth thing to do with that thumb. Solid and small β€” a dashed
circle read as something broken rather than something reserved. The left
wheel had one until the pages took it; the right one has it now. */
#pad .wheel .empty {
pointer-events:none; background:none; transform-origin:center;
border-color:rgba(255,220,180,.11);
}
#pad .wheel .empty.w { transform:translateY(-50%) scale(.68); }
/* Pressed. Bright enough to be obvious under a thumb. */
#pad button.on {
background:rgba(255,180,90,.24); border-color:rgba(255,205,140,.9);
color:rgba(255,235,205,.98);
}
/* TAKE only exists when there is something to take. */
#pad button[data-act="pickup"] { opacity:.16; pointer-events:none; }
#pad button[data-act="pickup"].live { opacity:1; pointer-events:auto; }
/* A phone held sideways is about 390px tall, and a 158px wheel is 40% of it.
Shrink, but not below a thumb β€” 46px is still a comfortable target, and the
walk arrows stay the biggest thing on screen because walking is most of
what a thumb does here. */
@media (max-height: 430px) {
#pad button { width:46px; height:46px; font-size:8.5px; border-width:1.25px; }
#pad button.arrow { width:56px; height:56px; font-size:19px; }
/* 120 and 144, not 112 and 128. Measured: at 112 the left wheel's circles
cleared each other by 0.7px and the right pair by 4px, which is touching
to a thumb even though the boxes do not overlap. */
#pad .wheel { width:120px; height:120px; }
#pad .wheel::before { inset:24px; }
#pad .walkwheel { width:144px; height:144px; }
#pad .walkwheel::before { inset:32px; }
}
/* Full screen. Top-left, out of the way of both thumbs now that the clusters
sit at mid-height, and dimmer than the controls because it is chrome
rather than a verb. Hidden outright where the browser cannot do it. */
#fs {
position:fixed; top:max(10px, env(safe-area-inset-top));
left:max(10px, env(safe-area-inset-left));
pointer-events:auto; touch-action:manipulation;
-webkit-tap-highlight-color:transparent; appearance:none; cursor:pointer;
width:38px; height:38px; border-radius:9px; display:none; place-items:center;
font:600 15px/1 ui-monospace, Menlo, Consolas, monospace;
color:rgba(255,220,180,.42); background:rgba(0,0,0,.28);
border:1.25px solid rgba(255,220,180,.2);
}
#fs.show { display:grid; }
/* Said once, only on a phone that cannot do it, and only until it is tapped. */
#addhome {
position:fixed; left:50%; transform:translateX(-50%);
bottom:max(10px, env(safe-area-inset-bottom));
display:none; pointer-events:auto; cursor:pointer;
padding:7px 13px; border-radius:9px; max-width:80vw;
font:12px/1.5 ui-monospace, Menlo, Consolas, monospace; text-align:center;
color:rgba(255,220,180,.55); background:rgba(0,0,0,.42);
border:1px solid rgba(255,220,180,.16);
}
#addhome.show { display:block; }
/* 16:9 in portrait is a postage stamp. Ask once, in the game's own voice. */
#turn { position:fixed; inset:0; display:none; place-items:center; background:#000;
color:rgba(255,220,180,.8); font:15px/1.7 ui-monospace, Menlo, Consolas, monospace;
text-align:center; padding:10vw; z-index:5; }
@media (hover:none) and (pointer:coarse) and (orientation:portrait) {
#turn { display:grid; }
}
</style>
</head>
<body>
<canvas id="stage" width="1920" height="1080"></canvas>
<div id="pad" hidden>
<div class="cluster left">
<div class="wheel">
<button type="button" class="n" data-act="pickup" aria-label="take the object">TAKE</button>
<button type="button" class="e" data-act="attack" aria-label="swing the sword">SWING</button>
<button type="button" class="s" data-act="torch" aria-label="hold to raise the torch">TORCH</button>
<button type="button" class="w" data-act="sheaf" aria-label="hold to look through everything you are carrying">ITEMS</button>
</div>
</div>
<div class="cluster right">
<div class="wheel walkwheel">
<button type="button" class="n empty" tabindex="-1" aria-hidden="true"></button>
<button type="button" class="w arrow" data-act="left" aria-label="walk left">&#9664;</button>
<button type="button" class="e arrow" data-act="right" aria-label="walk right">&#9654;</button>
<button type="button" class="s empty" tabindex="-1" aria-hidden="true"></button>
</div>
</div>
</div>
<button type="button" id="fs" aria-label="full screen">&#9974;</button>
<div id="addhome">Share &rarr; Add to Home Screen for full screen. Tap to dismiss.</div>
<div id="turn"><div>Turn your phone sideways.</div></div>
<div id="protocol-warning">
<div>
<p>This demo uses ES modules, which browsers refuse to load over <code>file://</code>.</p>
<p>Serve the folder instead:</p>
<p><code>python3 -m http.server 8000</code></p>
<p>then open <code>http://localhost:8000/</code></p>
</div>
</div>
<script>
// --- full screen ------------------------------------------------------
//
// Two different problems wearing one name. Android and iPad have the
// Fullscreen API; iPhone Safari has never had it and still does not. So the
// button appears only where it can actually work, and an iPhone is told the
// one thing that does work there instead β€” the meta tags above make Add to
// Home Screen open with no browser chrome at all.
(function () {
const root = document.documentElement;
const fs = document.getElementById('fs');
const hint = document.getElementById('addhome');
const touch = matchMedia('(hover: none) and (pointer: coarse)').matches;
const can = !!(root.requestFullscreen || root.webkitRequestFullscreen);
const standalone = matchMedia('(display-mode: standalone)').matches ||
window.navigator.standalone === true;
if (touch && can) {
fs.classList.add('show');
fs.addEventListener('click', async () => {
try {
if (document.fullscreenElement || document.webkitFullscreenElement) {
await (document.exitFullscreen || document.webkitExitFullscreen).call(document);
} else {
await (root.requestFullscreen || root.webkitRequestFullscreen).call(root);
// Worth asking for and not worth failing over: only Android honours it.
try { await screen.orientation.lock('landscape'); } catch { /* no */ }
}
} catch { /* refused, and there is nothing to say about it */ }
});
const mark = () => {
const on = !!(document.fullscreenElement || document.webkitFullscreenElement);
fs.innerHTML = on ? '&#10005;' : '&#9974;';
};
document.addEventListener('fullscreenchange', mark);
document.addEventListener('webkitfullscreenchange', mark);
} else if (touch && !standalone) {
hint.classList.add('show');
hint.addEventListener('click', () => hint.classList.remove('show'));
setTimeout(() => hint.classList.remove('show'), 12000);
}
}());
if (location.protocol === 'file:') {
document.getElementById('protocol-warning').style.display = 'grid';
document.getElementById('stage').style.display = 'none';
}
</script>
<script type="module" src="src/main.js"></script>
</body>
</html>