Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

NumPlay Studio: a side bar again, clear picks, solid keys and an intro that shows what it does

Mason363570d6ff71bad
diff --git a/customize/app.css b/customize/app.css
index 94f9cbe7..e131174f 100644
--- a/customize/app.css
+++ b/customize/app.css
@@ -11,9 +11,12 @@
--blue: #0a84ff;
--lift: drop-shadow(0 6px 9px rgba(0, 0, 0, 0.18));
--ease: cubic-bezier(0.2, 0.9, 0.25, 1);
- --t: 160ms;
- /* the calculator, up close: wide enough that its screen and OK key fill the height of the window */
- --cw: clamp(420px, min(calc((100vh - 24px) * 0.925), calc(60vw - 80px)), 880px);
+ --spring: cubic-bezier(0.3, 1.45, 0.45, 1);
+ --t: 180ms;
+ /* the columns: what NumPlay is and its games, the calculator up close, the big games and your own */
+ --left: clamp(330px, 29vw, 540px);
+ --side: clamp(250px, 21vw, 390px);
+ --cw: clamp(400px, min(calc((100vh - 24px) * 0.925), calc(100vw - var(--left) - var(--side) - 40px)), 820px);
}
* { box-sizing: border-box; }
@@ -32,15 +35,19 @@ a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
-/* ---- the page: what NumPlay is and its games on the left; the calculator, up close, on the right */
+/* ---- the page: what NumPlay is and its games on the left, the calculator up close in the middle, the big
+ games and your own on the right */
main {
- display: grid; grid-template-columns: minmax(0, 1fr) calc(var(--cw) + 96px);
- grid-template-rows: auto 1fr; grid-template-areas: "head device" "games device";
+ display: grid; grid-template-columns: var(--left) minmax(0, 1fr) var(--side);
+ grid-template-rows: auto 1fr; grid-template-areas: "head device side" "games device side";
min-height: 100vh;
}
-.head { grid-area: head; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 20px; padding: 40px 32px 0 56px; container-type: inline-size; }
-.games { grid-area: games; display: flex; flex-direction: column; gap: 14px; padding: 30px 32px 28px 56px; max-width: 560px; }
-.title { margin: 0; font-size: clamp(40px, calc((100cqw - 170px) / 4.3), 76px); font-weight: 800; letter-spacing: -0.045em; line-height: 1; }
+.head { grid-area: head; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 18px; padding: 40px 20px 0 48px; container-type: inline-size; }
+.games { grid-area: games; display: flex; flex-direction: column; gap: 14px; padding: 28px 20px 28px 48px; }
+.side { grid-area: side; display: flex; flex-direction: column; gap: 14px; padding: 46px 40px 28px 8px; }
+.title { margin: 0; font-size: clamp(40px, 15cqw, 66px); font-weight: 800; letter-spacing: -0.045em; line-height: 1; }
+.title button { border: 0; padding: 0 0.04em 0.06em 0; background: none; font: inherit; letter-spacing: inherit; cursor: pointer; display: block; overflow: hidden; }
+.title span { display: block; }
.chips { display: flex; gap: 8px; }
.lede { grid-column: 1 / -1; margin: 10px 0 0; max-width: 34em; font-size: 18px; line-height: 1.4; font-weight: 550; color: var(--ink); }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
@@ -48,30 +55,50 @@ main {
.row-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.1px; }
/* ---- the game grids: the same size for every game, the best first */
-.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 12px; }
+.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px 12px; }
+.grid.big { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 14px; }
.grid:empty { display: none; }
.app {
position: relative; border: 0; background: transparent; padding: 0; cursor: pointer;
-webkit-tap-highlight-color: transparent;
- transition: opacity var(--t) var(--ease), translate 200ms var(--ease);
+ transition: transform 300ms var(--spring), opacity var(--t) var(--ease), translate 200ms var(--ease);
}
/* (the icons have their own rounded corners, so their shadow follows them, not a box) */
-.app img { display: block; width: 100%; aspect-ratio: 55 / 56; pointer-events: none; user-select: none; transition: filter var(--t) var(--ease); }
+.app img { display: block; width: 100%; aspect-ratio: 55 / 56; pointer-events: none; user-select: none; transition: filter var(--t) var(--ease), opacity var(--t) var(--ease); }
.app .badge {
position: absolute; right: -5px; top: -5px; width: 22px; height: 22px; border-radius: 11px;
- display: none; align-items: center; justify-content: center;
- background: var(--blue); color: #ffffff; box-shadow: 0 0 0 2.5px var(--bg);
+ display: flex; align-items: center; justify-content: center; transform: scale(0);
+ background: var(--blue); color: #ffffff; box-shadow: 0 0 0 2.5px var(--bg), 0 1px 3px rgba(0, 0, 0, 0.18);
+ transition: transform 260ms var(--spring), background-color 140ms var(--ease), color 140ms var(--ease);
}
.app .badge svg { width: 13px; height: 13px; }
-/* in: in colour, a blue tick; out: grey; doesn't fit: fainter */
+.app .badge .b-plus { display: none; }
+/* in: lifted, a blue tick. Out but it fits: a little smaller and paler, a white + to add it. Doesn't fit:
+ grey, faint, nothing to press */
.app.on img { filter: var(--lift); }
-.app.on .badge { display: flex; }
-.app.off { opacity: 0.5; }
-.app.off img { filter: grayscale(0.85); }
-.app.off:hover { opacity: 0.75; }
-.app.nofit { opacity: 0.22; }
-.app.nofit img { filter: grayscale(1); }
+.app.on .badge { transform: scale(1); }
+.app.off { transform: scale(0.9); }
+.app.off img { filter: saturate(0.4); opacity: 0.7; }
+.app.off .badge { transform: scale(1); background: #ffffff; color: #55524c; }
+.app.off .badge .b-tick { display: none; }
+.app.off .badge .b-plus { display: block; }
+.app.off:hover { transform: scale(0.95); }
+.app.off:hover img { filter: none; opacity: 1; }
+.app.off:hover .badge { background: var(--blue); color: #ffffff; }
+.app.nofit { transform: scale(0.84); opacity: 0.26; }
+.app.nofit img { filter: grayscale(1) contrast(0.85); }
+.app.on:hover { transform: translateY(-2px); }
+.app:active { transform: scale(0.84); transition-duration: 90ms; }
+/* picked: it springs back up and the tick draws itself; taken out: it settles back small; can't go in: no */
+.app.pop-on { animation: pop-on 460ms var(--spring); }
+.app.pop-on .b-tick path { stroke-dasharray: 11; animation: tick 300ms var(--ease) 90ms backwards; }
+.app.pop-off { animation: pop-off 380ms var(--spring); }
+.app.shake { animation: shake 380ms var(--ease); }
+@keyframes pop-on { 0% { transform: scale(0.84); } 45% { transform: scale(1.07); } 100% { transform: scale(1); } }
+@keyframes pop-off { 0% { transform: scale(0.84); } 50% { transform: scale(0.95); } 100% { transform: scale(0.9); } }
+@keyframes tick { from { stroke-dashoffset: 11; } to { stroke-dashoffset: 0; } }
+@keyframes shake { 0%, 100% { translate: 0; } 20% { translate: -6px; } 45% { translate: 5px; } 70% { translate: -3px; } }
.app.placeholder { opacity: 0.25 !important; }
.app.placeholder .badge { display: none; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; will-change: transform; }
@@ -82,13 +109,13 @@ body.dragging-icon, body.dragging-icon * { cursor: grabbing !important; user-sel
.app.held { outline: 2.5px solid var(--blue); outline-offset: 4px; border-radius: 22%; }
/* ---- the calculator, up close: its screen is the space, OK installs, Back downloads, a star sticker on it */
-.device { grid-area: device; position: sticky; top: 0; height: 100vh; overflow: hidden; align-self: start; perspective: 2400px; perspective-origin: calc(40px + var(--cw) / 2) 30%; }
+.device { grid-area: device; position: sticky; top: 0; height: 100vh; overflow: hidden; align-self: start; perspective: 2400px; perspective-origin: 50% 32%; }
/* a real calculator, built in 3D from its photo (--u is one of the photo's pixels): the front, with holes for
the screen and the keys; the screen down in its recess with the recess's walls; the keys standing up with
their sides; rounded edges, sides and top (app.js, build3d). It faces you, and turns a little toward the
pointer when it's over it (--rx, --ry) */
.calc {
- position: absolute; left: 40px; top: 30px; width: var(--cw); aspect-ratio: 1018 / 2000; --u: calc(var(--cw) / 1018);
+ position: absolute; left: calc(50% - var(--cw) / 2); top: 30px; width: var(--cw); aspect-ratio: 1018 / 2000; --u: calc(var(--cw) / 1018);
transform-style: preserve-3d; transform-origin: 50% 24%; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
}
.plate, .well, .body3d { position: absolute; inset: 0; }
@@ -104,7 +131,7 @@ body.dragging-icon, body.dragging-icon * { cursor: grabbing !important; user-sel
.facet { position: absolute; top: 0; height: 100%; display: block; }
.body3d .top { position: absolute; left: 0; top: 0; width: 100%; transform-origin: 0 0; transform: rotateX(-90deg); display: block; }
.rim, .kwall { position: absolute; transform-origin: 0 0; display: block; }
-.keybed { position: absolute; display: block; background: #77777a; } /* (seen only in the gaps round the keys) */
+.keybed { position: absolute; display: block; background: #a6a6a8; } /* (seen only in the hairline round each key) */
/* the keys: each its top, cut from the photo, standing on its sides (app.js, keys3d). OK and Back go in
under the pointer, as keys do */
@@ -224,27 +251,58 @@ body.dragging .drop-hint { display: flex; }
.xl-ok { padding: 10px 20px; font-size: 14px; }
/* ---- Retro-Go: your own games, as cartridges */
-.retro { display: flex; flex-direction: column; gap: 10px; }
-.carts-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
+.retro { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.retro input[type=file] { position: absolute; left: -9999px; }
-.add-cart {
- height: 40px; padding: 0 16px 0 12px; border-radius: 20px; border: 1.5px dashed var(--line); color: var(--ink); cursor: pointer;
- display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650;
+.drop {
+ position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer;
+ border: 2px dashed var(--line); border-radius: 18px; padding: 20px 12px 16px; text-align: center;
+ transition: border-color var(--t) var(--ease), background-color var(--t) var(--ease), transform 260ms var(--spring);
}
-.add-cart svg { color: var(--mute); }
-.add-cart:hover, body.dragging .add-cart { border-color: var(--ink); background: rgba(0, 0, 0, 0.03); }
-.carts { display: contents; }
+.drop:hover, body.dragging .drop { border-color: var(--blue); background: rgba(10, 132, 255, 0.05); }
+.drop:active { transform: scale(0.97); transition-duration: 90ms; }
+.drop.shake { animation: shake 380ms var(--ease); }
+/* three cartridges, fanned: a Game Boy's, an NES's and a Master System's, with their labels; they lift
+ apart when you point at the box or bring files over the page */
+.drop-art { position: relative; width: 92px; height: 58px; margin-bottom: 8px; }
+.drop-art i {
+ position: absolute; bottom: 0; width: 36px; height: 44px; border-radius: 3px 10px 3px 3px;
+ background: linear-gradient(#e4e4e8, #c4c4ca); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), 0 2px 5px rgba(0, 0, 0, 0.14);
+ transition: transform 340ms var(--spring);
+}
+.drop-art i::before { content: ""; position: absolute; left: 6px; right: 9px; top: 4px; height: 3px; border-radius: 2px; background: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.16) 0 2px, transparent 2px 4px); }
+.drop-art i::after { content: ""; position: absolute; left: 5px; right: 5px; top: 11px; bottom: 9px; border-radius: 2px; }
+.drop-art .c1 { left: 0; transform: rotate(-13deg); transform-origin: 50% 100%; }
+.drop-art .c1::after { background: linear-gradient(#7fa31a, #5f7f0a); }
+.drop-art .c2 { left: 28px; z-index: 1; background: linear-gradient(#5a5a60, #3f3f45); border-radius: 3px; }
+.drop-art .c2::before { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 2px, transparent 2px 4px); }
+.drop-art .c2::after { background: linear-gradient(#d84a3c, #b33327); }
+.drop-art .c3 { right: 0; transform: rotate(13deg); transform-origin: 50% 100%; background: linear-gradient(#2c2c30, #18181b); }
+.drop-art .c3::before { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0 2px, transparent 2px 4px); }
+.drop-art .c3::after { background: linear-gradient(#3b72d6, #2a55a8); }
+.drop:hover .c1, body.dragging .c1 { transform: rotate(-20deg) translate(-3px, -4px); }
+.drop:hover .c2, body.dragging .c2 { transform: translateY(-9px); }
+.drop:hover .c3, body.dragging .c3 { transform: rotate(20deg) translate(3px, -4px); }
+.drop-text { font-size: 15px; font-weight: 700; }
+.drop-sub { font-size: 12px; color: var(--mute); font-weight: 600; letter-spacing: 0.02em; }
+.carts { display: flex; flex-wrap: wrap; gap: 10px; }
+.carts:empty { display: none; }
.cart {
position: relative; width: 52px; height: 62px; border: 0; padding: 0; cursor: pointer;
border-radius: 5px 13px 5px 5px; display: flex; flex-direction: column; justify-content: flex-end;
- box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12);
+ box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12), 0 2px 5px rgba(0, 0, 0, 0.12);
+ transition: transform 260ms var(--spring);
}
.cart .label { margin: 0 6px 10px; height: 26px; border-radius: 3px; color: #ffffff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.cart .x {
position: absolute; right: -6px; top: -6px; width: 20px; height: 20px; border-radius: 10px;
- background: var(--btn); color: var(--btn-ink); display: none; align-items: center; justify-content: center;
+ background: var(--btn); color: var(--btn-ink); display: flex; align-items: center; justify-content: center;
+ opacity: 0; transform: scale(0.6); transition: opacity 120ms var(--ease), transform 200ms var(--spring);
}
-.cart:hover .x, .cart:focus-visible .x { display: flex; }
+.cart:hover .x, .cart:focus-visible .x { opacity: 1; transform: scale(1); }
+.cart:hover { transform: translateY(-3px) rotate(-2deg); }
+.cart:active { transform: scale(0.92); transition-duration: 90ms; }
+.cart.enter { animation: slot 420ms var(--spring); }
+@keyframes slot { 0% { transform: translateY(-22px) scale(0.8); opacity: 0; } 100% { transform: none; opacity: 1; } }
/* ---- tooltip, toast and the install sheet */
.tip {
@@ -274,19 +332,31 @@ body.dragging .drop-hint { display: flex; }
.star-ask { display: block; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: #fff7e0; text-decoration: none; font-size: 14px; font-weight: 600; line-height: 1.4; }
.star-ask:hover { background: #ffefc2; }
-.foot { margin-top: auto; padding-top: 22px; font-size: 12px; color: var(--mute); display: flex; gap: 8px; }
+.foot { margin-top: auto; padding-top: 22px; font-size: 12px; color: var(--mute); display: flex; flex-wrap: wrap; gap: 4px 8px; }
.foot a { color: var(--mute); text-decoration: none; }
.foot a:hover { color: var(--ink); }
.noscript { text-align: center; padding: 0 16px; }
-/* ---- narrow screens: what it is, then the calculator, then the games */
+/* ---- the intro: the games flying into the calculator */
+.flyer { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; will-change: transform, opacity; }
+.flyer img { display: block; width: 100%; aspect-ratio: 55 / 56; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.22)); }
+body.intro-on main { pointer-events: none; }
+html.intro-wait main { opacity: 0; }
+
+/* ---- smaller windows: the big games under the games; then one column */
+@media (max-width: 1180px) {
+ :root { --side: 0px; --left: clamp(330px, 38vw, 440px); }
+ main { grid-template-columns: var(--left) minmax(0, 1fr); grid-template-rows: auto auto 1fr; grid-template-areas: "head device" "games device" "side device"; }
+ .side { padding: 0 20px 28px 48px; }
+ .grid.big { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px 12px; }
+}
@media (max-width: 900px) {
:root { --cw: min(560px, calc(100vw - 32px)); }
- main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; grid-template-areas: "head" "device" "games"; }
+ main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; grid-template-areas: "head" "device" "games" "side"; }
.head { padding: 24px 16px 0; }
- .games { padding: 8px 16px 24px; max-width: none; }
+ .games { padding: 8px 16px 0; }
+ .side { padding: 22px 16px 24px; }
.device { position: relative; height: calc(var(--cw) * 1.1 + 30px); margin: 8px auto 0; width: calc(var(--cw) + 40px); perspective-origin: 50% 20%; }
- .calc { left: 20px; }
.foot { justify-content: center; }
}
@media (max-width: 520px) {
diff --git a/customize/app.js b/customize/app.js
index 4a75f1b9..b8df112d 100644
--- a/customize/app.js
+++ b/customize/app.js
@@ -209,7 +209,8 @@
have.add('c' + r.key);
if (box.querySelector('[data-k="c' + r.key + '"]')) continue;
const s = SYS[r.sys];
- const c = el('button', 'cart', { type: 'button', 'data-k': 'c' + r.key, 'aria-label': 'Remove ' + r.name });
+ const c = el('button', 'cart enter', { type: 'button', 'data-k': 'c' + r.key, 'aria-label': 'Remove ' + r.name });
+ c.addEventListener('animationend', () => c.classList.remove('enter'), { once: true });
c.style.background = s.shell;
c.dataset.tip = r.name + '|' + s.name + ', ' + size(r.bytes.length);
const lab = c.appendChild(el('span', 'label'));
@@ -247,36 +248,47 @@
}
// ------------------------------------------------------------------ picking
+ // the icon's answer to a press: up with a tick, back down, or no
+ function bump(b, cls) {
+ if (!b) return;
+ b.classList.remove('pop-on', 'pop-off', 'shake');
+ void b.offsetWidth; // (restarts it)
+ b.classList.add(cls);
+ b.addEventListener('animationend', () => b.classList.remove(cls), { once: true });
+ }
function overflow(bytes) {
toast("That doesn't fit: " + size(bytes) + ' too much' + (st.cap === 'std' ? '. 6 MB can take more' : ''));
$('#screen').classList.add('over');
setTimeout(() => render(), 500);
}
function toggle(id, quiet) {
- const s = solo();
+ const s = solo(), b = quiet ? null : buttons.get(id);
if (st.picked.has(id)) {
st.picked.delete(id);
+ bump(b, 'pop-off');
if (alone(id) && before) { st.picked = new Set(before); before = null; }
} else if (alone(id)) {
if (!s) before = ordered();
st.picked = new Set([id]);
+ bump(b, 'pop-on');
if (!quiet) {
toast(byId[id].title + ' fills the whole calculator, so it goes on its own. Pick it again to get your games back');
fetchBytes(KIT + 'apps/' + id + '.nwa.gz').catch(() => {});
}
} else {
- if (s) { if (!quiet) toast(byId[s].title + ' takes the whole calculator. Pick it again to take it out'); return; }
- if (byId[id].xl && st.lang !== 'en') { toast('The big games are in English: pick English to add them'); return; }
+ if (s) { if (!quiet) { bump(b, 'shake'); toast(byId[s].title + ' takes the whole calculator. Pick it again to take it out'); } return; }
+ if (byId[id].xl && st.lang !== 'en') { bump(b, 'shake'); toast('The big games are in English: pick English to add them'); return; }
const over = usedBytes() + flash(id) - capacity();
- if (over > 0) { if (!quiet) overflow(over); return; }
+ if (over > 0) { if (!quiet) { bump(b, 'shake'); overflow(over); } return; }
st.picked.add(id);
+ bump(b, 'pop-on');
if (!quiet) fetchObj(objPath(id)).catch(() => {}); // (ready by the time you install)
}
render();
}
async function addRoms(files) {
- if (solo()) { toast(byId[solo()].title + " takes the whole calculator, so there's no room for Retro-Go"); return; }
+ if (solo()) { bump($('#drop'), 'shake'); toast(byId[solo()].title + " takes the whole calculator, so there's no room for Retro-Go"); return; }
const ok = new Set(rg && rg.systems ? rg.systems : [1, 2, 3]);
for (const f of files) {
const ext = (f.name.split('.').pop() || '').toLowerCase(), sys = EXT[ext];
@@ -288,7 +300,7 @@
const r = { key: ++romKey, sys, bytes, name: romName(f.name) };
const extra = (st.roms.length ? 0 : flash(rg.id) + ROM_HEAD) + romBytes(r);
const over = usedBytes() + extra - capacity();
- if (over > 0) { overflow(over); continue; }
+ if (over > 0) { bump($('#drop'), 'shake'); overflow(over); continue; }
st.roms.push(r);
fetchObj(objPath(rg.id)).catch(() => {});
}
@@ -939,7 +951,7 @@
// The keys at the top of the keypad, where the photo has them (measured from it): the D-pad's cross with
// its corners rounded (a quadratic curve through each corner), OK and Back's circles, and pills.
- const KEY_H = 14;
+ const KEY_H = 12;
function roundPoly(pts, radii, n) {
const out = [];
pts.forEach((p, i) => {
@@ -953,8 +965,18 @@
});
return out;
}
- const circlePts = (cx, cy, r) => Array.from({ length: 40 }, (_, i) => [cx + r * Math.cos(i * Math.PI / 20), cy + r * Math.sin(i * Math.PI / 20)]);
- const pill = (x0, y0, x1, y1, r) => roundPoly([[x0, y0], [x1, y0], [x1, y1], [x0, y1]], [r, r, r, r], 7);
+ const circlePts = (cx, cy, r, n = 40) => Array.from({ length: n }, (_, i) => [cx + r * Math.cos(i * 2 * Math.PI / n), cy + r * Math.sin(i * 2 * Math.PI / n)]);
+ const pill = (x0, y0, x1, y1, r, n = 7) => roundPoly([[x0, y0], [x1, y0], [x1, y1], [x0, y1]], [r, r, r, r], n);
+ // an outline moved out by d (along each corner's bisector), for the hole a key stands in
+ function grow(pts, d) {
+ const nrm = (a, b) => { const dx = b[0] - a[0], dy = b[1] - a[1], l = Math.hypot(dx, dy) || 1; return [dy / l, -dx / l]; };
+ return pts.map((p, i) => {
+ const a = pts[(i + pts.length - 1) % pts.length], b = pts[(i + 1) % pts.length];
+ const n1 = nrm(a, p), n2 = nrm(p, b), bx = n1[0] + n2[0], by = n1[1] + n2[1], l = Math.hypot(bx, by) || 1;
+ const k = d / Math.max(0.35, (bx * n1[0] + by * n1[1]) / l);
+ return [p[0] + bx / l * k, p[1] + by / l * k];
+ });
+ }
// a shape as a mask (outlines in the photo's pixels, drawn on a canvas, w x h from x0, y0; evenodd: holes)
function maskOf(outlines, x0, y0, w, h, scale, evenodd) {
const c = el('canvas');
@@ -968,27 +990,37 @@
return 'url(' + c.toDataURL() + ')';
}
function keyOutlines() {
- // (each taking in the dark edge the photo draws round it)
- const cross = [[190.5, 794.5], [267.5, 794.5], [267.5, 885.5], [356.5, 885.5], [356.5, 958.5], [267.5, 958.5], [267.5, 1051.5], [190.5, 1051.5],
- [190.5, 958.5], [100.5, 958.5], [100.5, 885.5], [190.5, 885.5]];
+ // Measured from the photo: each key's outline runs along the outer edge of the dark line the photo draws
+ // round it, so its top carries that line and none of the front's white. Its sides follow a coarser outline
+ // (fewer walls) laid just outside it, and it stands in a hole a hair wider, the gap only a crease.
+ const cross = [[193, 797], [266.5, 797], [266.5, 887.5], [355.5, 887.5], [355.5, 957.5], [266.5, 957.5], [266.5, 1050.5], [193, 1050.5],
+ [193, 957.5], [104, 957.5], [104, 887.5], [193, 887.5]];
+ const cr = [22, 22, 7.5, 22, 22, 7.5, 22, 22, 7.5, 22, 22, 7.5];
const white = [222, 222, 219];
- // and the hole each sits in, 2 wider, so none of the photo's own edge is left on the front
- const hole = cross.map(([x, y]) => [x + (x > 229 ? 2 : -2), y + (y > 922 ? 2 : -2)]);
const keys = [
- { id: 'dpad', pts: roundPoly(cross, [23.5, 23.5, 7.5, 23.5, 23.5, 7.5, 23.5, 23.5, 7.5, 23.5, 23.5, 7.5], 6),
- hole: roundPoly(hole, [25.5, 25.5, 5.5, 25.5, 25.5, 5.5, 25.5, 25.5, 5.5, 25.5, 25.5, 5.5], 6), side: white },
- { id: 'home', pts: pill(438.5, 815.5, 578.5, 905.5, 44.5), hole: pill(436.5, 813.5, 580.5, 907.5, 46.5), side: [212, 148, 34] },
- { id: 'power', pts: pill(438.5, 938.5, 578.5, 1028.5, 44.5), hole: pill(436.5, 936.5, 580.5, 1030.5, 46.5), side: [36, 36, 38] },
- { id: 'ok', pts: circlePts(718, 923, 57), hole: circlePts(718, 923, 59), side: white },
- { id: 'back', pts: circlePts(857.5, 923, 57), hole: circlePts(857.5, 923, 59), side: white },
+ { id: 'dpad', pts: roundPoly(cross, cr, 6), walls: grow(roundPoly(cross, cr, 3), 0.6), side: white },
+ { id: 'home', box: [439.5, 817.5, 578.5, 906.5], side: [212, 148, 34] },
+ { id: 'power', box: [439.5, 940.5, 578.5, 1029.5], side: [36, 36, 38] },
+ { id: 'ok', pts: circlePts(718.5, 924, 56.5), walls: circlePts(718.5, 924, 57, 20), side: white },
+ { id: 'back', pts: circlePts(858, 924, 56.5), walls: circlePts(858, 924, 57, 20), side: white },
];
- return keys.concat([160, 299, 439, 578, 718, 858].map((x, i) => ({ id: 'row' + i, pts: pill(x - 58.5, 1090.5, x + 58.5, 1169.5, 39.5),
- hole: pill(x - 60.5, 1088.5, x + 60.5, 1171.5, 41.5), side: white })));
+ const xs = [[102.5, 216.5], [241.5, 356.5], [381.5, 495.5], [521.5, 635.5], [661.5, 775.5], [800.5, 914.5]];
+ [[1092.5, 1169.5], [1204.5, 1281.5], [1316.5, 1393.5]].forEach(([y0, y1], r) =>
+ xs.forEach(([x0, x1], c) => keys.push({ id: 'row' + r + c, box: [x0, y0, x1, y1], side: white })));
+ for (const k of keys) {
+ if (k.box) {
+ const [x0, y0, x1, y1] = k.box, r = (y1 - y0) / 2;
+ k.pts = pill(x0, y0, x1, y1, r);
+ k.walls = grow(pill(x0, y0, x1, y1, r, 3), 0.6);
+ }
+ k.hole = grow(k.pts, 0.4);
+ }
+ return keys;
}
// each key: its top, cut from the photo, standing on its sides, a wall at each step of its outline lit by
- // the calculator's light, darker down in its hole. Under them all, the dark of the keypad's bed. OK and
- // Back carry Install and Download.
- const KEY_DOWN = 10;
+ // the calculator's light, a little darker where it meets the front and dark down in its hole. Under them
+ // all, the keypad's bed. OK and Back carry Install and Download.
+ const KEY_DOWN = 8;
function keys3d(calc, keys) {
part(calc, 'i', 'keybed', { left: U(90), top: U(780), width: U(840), height: U(1220), transform: 'translateZ(' + U(-KEY_DOWN) + ')' });
for (const k of keys) {
@@ -997,14 +1029,15 @@
const w = Math.ceil(Math.max(...xs)) + 1 - x0, h = Math.ceil(Math.max(...ys)) + 1 - y0;
const g = part(calc, 'div', 'key3d', { left: U(x0), top: U(y0), width: U(w), height: U(h) });
g.dataset.key = k.id;
- k.pts.forEach(([x, y], i) => {
- const [x2, y2] = k.pts[(i + 1) % k.pts.length], len = Math.hypot(x2 - x, y2 - y);
+ k.walls.forEach(([x, y], i) => {
+ const [x2, y2] = k.walls[(i + 1) % k.walls.length], len = Math.hypot(x2 - x, y2 - y);
if (len < 0.01) return;
const phi = Math.atan2(y2 - y, x2 - x), n = [Math.sin(phi), -Math.cos(phi), 0]; // (facing out)
- const deep = k.side.map((v) => Math.round(v * lit(n) * 0.45)), top = k.side.map((v) => Math.round(Math.min(255, v * lit(n))));
- part(g, 'i', 'kwall', { left: U(x - x0), top: U(y - y0), width: U(len + 2), height: U(KEY_H + KEY_DOWN), // (over its neighbours: no seams)
- transform: 'rotateZ(' + (phi * 180 / Math.PI).toFixed(2) + 'deg) translate3d(' + U(-1) + ', 0, ' + U(-KEY_DOWN) + ') rotateX(90deg)',
- background: 'linear-gradient(rgb(' + deep.join(',') + '), rgb(' + top.join(',') + ') ' + (100 * KEY_DOWN / (KEY_H + KEY_DOWN)).toFixed(0) + '%, rgb(' + top.join(',') + '))' });
+ const tone = (f) => 'rgb(' + k.side.map((v) => Math.round(Math.min(255, v * lit(n) * f))).join(',') + ')';
+ const at = (z) => (100 * (z + KEY_DOWN) / (KEY_H + KEY_DOWN)).toFixed(1) + '%';
+ part(g, 'i', 'kwall', { left: U(x - x0), top: U(y - y0), width: U(len + 1.4), height: U(KEY_H + KEY_DOWN), // (over its neighbours: no seams)
+ transform: 'rotateZ(' + (phi * 180 / Math.PI).toFixed(2) + 'deg) translate3d(' + U(-0.7) + ', 0, ' + U(-KEY_DOWN) + ') rotateX(90deg)',
+ background: 'linear-gradient(' + tone(0.4) + ', ' + tone(0.78) + ' ' + at(0) + ', ' + tone(0.94) + ' ' + at(KEY_H * 0.45) + ', ' + tone(1) + ')' });
});
const top = part(g, 'i', 'ktop', { transform: 'translateZ(' + U(KEY_H) + ')' });
top.style.setProperty('--key', maskOf([k.pts], x0, y0, w, h, 3));
@@ -1217,11 +1250,123 @@
document.addEventListener('pointerdown', () => tip.classList.remove('show'));
}
+ // ------------------------------------------------------------------ the intro
+ // The page puts itself together. The calculator comes up into place, then the name and what NumPlay is,
+ // and the games take their places. Then each game you have goes into the calculator, in launcher order:
+ // its tick comes on, it lifts off its place, flies into the screen, and its block opens there as the
+ // count of space goes up. Last, the big games and your own come in beside it. Any key or click ends it.
+ let introRun = null;
+ function intro(force) {
+ const ready = () => document.documentElement.classList.remove('intro-wait');
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches || innerWidth < 900) return ready();
+ if (!force && store('numplay-intro3')) return ready();
+ store('numplay-intro3', '1');
+ if (introRun) introRun();
+ const anims = [], flyers = [], E = {
+ out: 'cubic-bezier(0.16, 1, 0.3, 1)', spring: 'cubic-bezier(0.34, 1.36, 0.64, 1)', soft: 'cubic-bezier(0.22, 1, 0.36, 1)',
+ };
+ const anim = (node, kf, opt) => { if (node) anims.push(node.animate(kf, { fill: 'backwards', ...opt })); };
+ const rect = (n) => n.getBoundingClientRect();
+ hidePreview();
+ document.body.classList.add('intro-on');
+ $('#tip').classList.remove('show');
+ // where everything ends up, before anything moves
+ const list = items(), cap = capacity(), used = list.reduce((a, it) => a + it.bytes, 0);
+ const games = ordered().filter((id) => buttons.get(id) && buttons.get(id).parentNode.id === 'small');
+ const from = new Map(games.map((id) => [id, rect(buttons.get(id).querySelector('img'))]));
+ const to = new Map(games.map((id) => [id, tiles.get(id) && rect(tiles.get(id))]));
+ // 1. the calculator, then the words, then the games in their places (a wave down the grid)
+ anim($('.device'), [{ opacity: 0 }, { opacity: 1 }], { duration: 700, easing: 'linear' });
+ anim($('#calc'), [{ translate: '0 80px', scale: '0.93' }, { translate: '0 0', scale: '1' }], { duration: 1400, easing: E.out });
+ anim($('.title span'), [{ transform: 'translateY(108%)' }, { transform: 'none' }], { duration: 1000, delay: 180, easing: E.out });
+ anim($('.lede'), [{ opacity: 0, transform: 'translateY(16px)' }, { opacity: 1, transform: 'none' }], { duration: 900, delay: 340, easing: E.out });
+ anim($('.chips'), [{ opacity: 0, transform: 'translateY(10px)' }, { opacity: 1, transform: 'none' }], { duration: 800, delay: 420, easing: E.out });
+ anim($('.games .row-head'), [{ opacity: 0 }, { opacity: 1 }], { duration: 600, delay: 520, easing: 'linear' });
+ [...$('#small').children].forEach((b, i) => {
+ anim(b.querySelector('img'), [{ opacity: 0, transform: 'translateY(14px) scale(0.6)' }, { opacity: 1, transform: 'none' }],
+ { duration: 700, delay: 560 + i * 24, easing: E.spring });
+ if (!st.picked.has(b.dataset.id)) // (their + comes with them)
+ anim(b.querySelector('.badge'), [{ opacity: 0 }, { opacity: 1 }], { duration: 300, delay: 900 + i * 24, easing: 'linear' });
+ });
+ // 2. on the screen: the free space and NumPlay's own block first, the games' blocks as they land
+ const T0 = 1150, GAP = 70, FLY = 760, landed = [];
+ for (const [key, e] of tiles) {
+ const id = key, gi = games.indexOf(id);
+ const at = key === '_free' ? 700 : key === '_core' ? 980 : gi >= 0 ? T0 + gi * GAP + FLY * 0.82 : T0 + games.length * GAP + FLY;
+ anim(e, [{ opacity: 0, scale: '0.55' }, { opacity: 1, scale: '1' }], { duration: key === '_free' ? 500 : 620, delay: at, easing: key === '_free' ? 'linear' : E.spring });
+ const it = list.find((x) => x.key === key);
+ if (it) landed.push([at, it.bytes]);
+ }
+ // 3. the flights: each game's copy lifts off its place and arcs into its block on the screen
+ games.forEach((id, i) => {
+ const a = from.get(id), b = to.get(id), btn = buttons.get(id);
+ anim(btn.querySelector('.badge'), [{ transform: 'scale(0)' }, { transform: 'scale(1)' }], { duration: 420, delay: T0 + i * GAP - 60, easing: E.spring });
+ if (!a || !b) return;
+ const f = el('div', 'flyer');
+ f.appendChild(el('img', '', { src: btn.querySelector('img').src, alt: '' }));
+ f.style.width = a.width + 'px';
+ f.style.opacity = '0';
+ document.body.appendChild(f);
+ const tw = Math.max(10, Math.min(b.width, b.height) * 0.62);
+ flyers.push({ f, start: T0 + i * GAP, x0: a.left, y0: a.top, w0: a.width, x1: b.left + b.width / 2 - tw / 2, y1: b.top + b.height / 2 - tw / 2, w1: tw });
+ });
+ // the count of space and the flights, a frame at a time
+ const t0 = performance.now(), ease = (t) => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2);
+ let raf = 0, shown = 0;
+ const end = T0 + games.length * GAP + FLY + 300;
+ const frame = (now) => {
+ const t = now - t0;
+ for (const fl of flyers) {
+ const k = (t - fl.start) / FLY;
+ if (k < 0 || k > 1.05) { fl.f.style.opacity = '0'; continue; }
+ const e = ease(Math.min(1, k)), lift = 150 + 0.1 * Math.abs(fl.x1 - fl.x0);
+ const cx = (fl.x0 + fl.x1) / 2, cy = Math.min(fl.y0, fl.y1) - lift;
+ const x = (1 - e) * (1 - e) * fl.x0 + 2 * (1 - e) * e * cx + e * e * fl.x1;
+ const y = (1 - e) * (1 - e) * fl.y0 + 2 * (1 - e) * e * cy + e * e * fl.y1;
+ const sc = (fl.w0 + (fl.w1 - fl.w0) * e) / fl.w0;
+ fl.f.style.transform = 'translate(' + x.toFixed(1) + 'px,' + y.toFixed(1) + 'px) scale(' + sc.toFixed(3) + ')';
+ fl.f.style.opacity = String(k < 0.06 ? k / 0.06 : k > 0.86 ? Math.max(0, (1 - k) / 0.14) : 1);
+ }
+ const target = landed.reduce((a, [at, bytes]) => a + (t >= at ? bytes : 0), 0);
+ shown += (target - shown) * 0.2;
+ $('#status-line').textContent = (shown / MiB).toFixed(2) + ' OF ' + +(cap / MiB).toFixed(2) + ' MB';
+ $('#battery').style.width = 'calc(' + Math.min(100, 100 * shown / cap) + '% - 2px)';
+ if (t < end) raf = requestAnimationFrame(frame); else finish();
+ };
+ raf = requestAnimationFrame(frame);
+ ready();
+ // 4. beside it: the big games and your own
+ const S = T0 + games.length * GAP + 200;
+ const side = $('.side');
+ [...side.querySelectorAll(':scope > .row-head, #retro > .row-head, .drop, .foot')].forEach((n, i) =>
+ anim(n, [{ opacity: 0, transform: 'translateX(26px)' }, { opacity: 1, transform: 'none' }], { duration: 900, delay: S + (i ? 260 + i * 70 : 0), easing: E.out }));
+ [...$('#big').children].forEach((b, i) =>
+ anim(b, [{ opacity: 0, translate: '18px 0' }, { opacity: 1, translate: '0 0' }], { duration: 800, delay: S + 80 + i * 26, easing: E.out }));
+ function finish(e) {
+ // (a click that ends it is only that: it doesn't also pick the game under it)
+ if (e && e.type === 'pointerdown') addEventListener('click', (c) => { c.stopPropagation(); c.preventDefault(); }, { capture: true, once: true });
+ cancelAnimationFrame(raf);
+ for (const a of anims) a.finish();
+ for (const fl of flyers) fl.f.remove();
+ flyers.length = 0;
+ document.body.classList.remove('intro-on');
+ removeEventListener('pointerdown', finish, true);
+ removeEventListener('keydown', finish, true);
+ introRun = null;
+ hidePreview();
+ render();
+ }
+ addEventListener('pointerdown', finish, true);
+ addEventListener('keydown', finish, true);
+ introRun = finish;
+ }
+
// ------------------------------------------------------------------ start
async function start() {
try {
kit = await fetch(KIT + 'kit.json').then((r) => { if (!r.ok) throw new Error(r.status); return r.json(); });
} catch (e) {
+ document.documentElement.classList.remove('intro-wait');
toast("The games didn't load, try again in a minute");
return;
}
@@ -1236,7 +1381,9 @@
} catch (e) { custom = null; }
const small = $('#small'), big = $('#big');
- const badge = '<span class="badge" aria-hidden="true"><svg viewBox="0 0 12 12"><path d="M2.5 6.2l2.3 2.3 4.7-5" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg></span>';
+ const badge = '<span class="badge" aria-hidden="true">' +
+ '<svg class="b-tick" viewBox="0 0 12 12"><path d="M2.5 6.2l2.3 2.3 4.7-5" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg>' +
+ '<svg class="b-plus" viewBox="0 0 12 12"><path d="M6 2.5v7M2.5 6h7" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/></svg></span>';
for (const g of kit.games) {
if (g === rg) continue;
const b = el('button', 'app off', { type: 'button', 'aria-label': g.title, 'aria-pressed': 'false', 'data-id': g.id });
@@ -1315,7 +1462,7 @@
$('#retro').hidden = false;
const exts = Object.keys(EXT).filter((x) => (rg.systems || [1, 2, 3]).includes(EXT[x]));
$('#rom-file').accept = exts.map((x) => '.' + x).join(',');
- $('#drop').dataset.tip = 'Add a game|' + exts.map((x) => '.' + x).join(' ') + ', or drop the files anywhere';
+ $('#drop-sub').textContent = exts.map((x) => '.' + x).join(' ');
$('#rom-file').addEventListener('change', (e) => { addRoms([...e.target.files]); e.target.value = ''; });
let depth = 0;
const files = (e) => e.dataTransfer && [...e.dataTransfer.types].includes('Files');
@@ -1336,6 +1483,8 @@
restore();
if (st.lang !== 'en') loadKit(st.lang).then(render).catch(() => { st.lang = 'en'; render(); });
render();
+ $('#replay').addEventListener('click', () => intro(true));
+ requestAnimationFrame(() => intro(new URLSearchParams(location.search).has('intro')));
addEventListener('hashchange', () => { restore(); render(); });
stars();
(window.requestIdleCallback || setTimeout)(() => loadTools().catch(() => {}), { timeout: 3000 });
diff --git a/customize/index.html b/customize/index.html
index 6b3eebcc..a10cd7a3 100644
--- a/customize/index.html
+++ b/customize/index.html
@@ -38,11 +38,19 @@
}
</script>
<link rel="stylesheet" href="app.css">
+<script>
+ // (the intro plays the first time: the page stays hidden until it starts, so it doesn't show twice)
+ try {
+ if ((!localStorage.getItem('numplay-intro3') || /[?&]intro\b/.test(location.search)) && innerWidth >= 900 &&
+ !matchMedia('(prefers-reduced-motion: reduce)').matches) document.documentElement.classList.add('intro-wait');
+ } catch (e) {}
+ setTimeout(() => document.documentElement.classList.remove('intro-wait'), 5000);
+</script>
</head>
<body>
<main id="studio">
<div class="head">
- <h1 class="title">NumPlay</h1>
+ <h1 class="title"><button id="replay" type="button" data-tip="Play the intro again"><span>NumPlay</span></button></h1>
<div class="chips">
<button id="app-chip" type="button" class="chip" aria-haspopup="dialog" aria-expanded="false" data-tip="Its icon and name on your calculator, and how it opens">
<img id="app-chip-icon" src="kit/variants/NumPlay.png" alt="" width="28" height="28">
@@ -58,7 +66,10 @@
<div class="games">
<div class="row-head"><h2>Games in NumPlay</h2></div>
- <section id="small" class="grid" aria-label="Games in NumPlay, best first"></section>
+ <section id="small" class="grid small" aria-label="Games in NumPlay, best first"></section>
+ </div>
+
+ <aside class="side" aria-label="Big games, and your own Game Boy, NES and Sega games">
<div class="row-head">
<h2>Big games</h2>
<div class="cap" role="radiogroup" aria-label="Space for apps">
@@ -66,24 +77,23 @@
<button type="button" role="radio" data-cap="xl" aria-checked="false" data-tip="With Enlarged Extra Apps">6 MB</button>
</div>
</div>
- <section id="big" class="grid" aria-label="Big games, best first"></section>
+ <section id="big" class="grid big" aria-label="Big games, best first"></section>
<section id="retro" class="retro" aria-label="Your own Game Boy, NES and Sega games" hidden>
<div class="row-head"><h2>Your own Game Boy, NES and Sega games</h2></div>
- <div class="carts-row">
- <div id="carts" class="carts" aria-label="Your games"></div>
- <label id="drop" class="add-cart" for="rom-file" data-tip=".gb .gbc .nes .sms .gg">
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14"/><path d="M5 12h14"/></svg>
- Add game files
- </label>
- <input id="rom-file" type="file" multiple accept=".gb,.gbc,.nes,.sms,.gg">
- </div>
+ <label id="drop" class="drop" for="rom-file">
+ <span class="drop-art" aria-hidden="true"><i class="c1"></i><i class="c2"></i><i class="c3"></i></span>
+ <span class="drop-text">Add game files</span>
+ <span id="drop-sub" class="drop-sub">.gb .gbc .nes .sms .gg</span>
+ </label>
+ <input id="rom-file" type="file" multiple accept=".gb,.gbc,.nes,.sms,.gg">
+ <div id="carts" class="carts" aria-label="Your games"></div>
</section>
<footer class="foot">
<a href="https://github.com/Mason363/NumPlay">Made by Mason Chen as part of NumPlay</a>
<span aria-hidden="true">·</span>
<a href="../">NumPlay's page</a>
</footer>
- </div>
+ </aside>
<section class="device" aria-label="Your calculator">
<div id="calc" class="calc">