// Dewhop: game screen (fixed-tick loop, canvas, sound, daily/practice/archive, share grid, Fun Pass, Skin Pack). (c) 2026 CyberMax. import { makeSim, grid, leafX, HZ, HOP, DRY, X0 } from './core.js'; import { dayNumber, dateOf, count, store, toast, share, intents, download, canvasBlob, pwa, themeToggle } from './cmx.js'; import * as skins from './skins.js'; import * as pass from './funpass.js'; const GAME = 'dewhop'; const PATH = '/games/dewhop/'; // The Skin Pack sells through revenue/packs/stripe/dewhop-skins: flip to true once stripe_publish.py has created its // Payment Link and the data Worker with /unlock/dewhop-skins is deployed (never sell what isn't delivered). const PACK_LIVE = true; const $ = (id) => document.getElementById(id); const cv = $('c'); const g = cv.getContext('2d'); // tier: free | pass (CyberMax Fun Pass) | pack (Dewhop Skin Pack, one-time, cosmetic only) const SKINS = { morning: { name: 'Morning', tier: 'free', sky1: '#0F2A3A', sky2: '#1F5E57', leaf: '#5CC46A', rib: '#2F7D3E', vine: '#3C8E4A', drop: '#9FE3FF', hi: '#FFFFFF', text: '#F2FFF4', sun: '#FFE38A' }, dusk: { name: 'Dusk', tier: 'pass', sky1: '#1B1033', sky2: '#5A2D5E', leaf: '#8BC34A', rib: '#4E7A22', vine: '#6E8F3A', drop: '#FFB4E1', hi: '#FFFFFF', text: '#FFF0FA', sun: '#FF9E6B' }, paper: { name: 'Paper', tier: 'pass', sky1: '#F4EEDF', sky2: '#E5DAC2', leaf: '#3E7C4A', rib: '#22492A', vine: '#5C7A55', drop: '#2E6FD8', hi: '#FFFFFF', text: '#11141B', sun: '#E2581F' }, rose: { name: 'Rose', tier: 'pack', sky1: '#2A1020', sky2: '#6B2346', leaf: '#FF8FB8', rib: '#C2457A', vine: '#7A3A55', drop: '#FFF0F6', hi: '#FFFFFF', text: '#FFF0F6', sun: '#FFD1E3' }, maple: { name: 'Maple', tier: 'pack', sky1: '#2B1608', sky2: '#7A3B12', leaf: '#FF7A2F', rib: '#B4410E', vine: '#6B3A1E', drop: '#FFE7B0', hi: '#FFFFFF', text: '#FFF2E4', sun: '#FFD166' }, lily: { name: 'Lily', tier: 'pack', sky1: '#05202B', sky2: '#0E5A63', leaf: '#3FD3A5', rib: '#16866A', vine: '#2E7A6A', drop: '#F7A8D8', hi: '#FFFFFF', text: '#E6FFFA', sun: '#FFE066' }, neon: { name: 'Neon', tier: 'pack', sky1: '#05040F', sky2: '#1A0F3D', leaf: '#39FF88', rib: '#00B85C', vine: '#7B5CFF', drop: '#5CF2FF', hi: '#FFFFFF', text: '#F4F2FF', sun: '#FF4DD8' }, honey: { name: 'Honey', tier: 'pack', sky1: '#2A1E05', sky2: '#6E5410', leaf: '#C9E25A', rib: '#7F9A1E', vine: '#8A7A2A', drop: '#FFB627', hi: '#FFF6D6', text: '#FFF8E1', sun: '#FFE38A' }, frost: { name: 'Frost', tier: 'pack', sky1: '#0B1D33', sky2: '#2C5A86', leaf: '#BFE7FF', rib: '#6FA8D6', vine: '#8FB8D8', drop: '#FFFFFF', hi: '#DFF4FF', text: '#E3F4FF', sun: '#FFFFFF' }, }; if (!PACK_LIVE) for (const k of Object.keys(SKINS)) if (SKINS[k].tier === 'pack') delete SKINS[k]; const PACK = Object.values(SKINS).filter((s) => s.tier === 'pack'); const todayIso = new Date().toISOString().slice(0, 10); // UTC day: the same leaves for everyone on Earth const todayNum = dayNumber(todayIso); // capture() reads ?unlock=skins#cmx-pro= and must run before pass.init (shared skins.js) skins.capture({ game: GAME, name: 'Dewhop', skins: PACK.length, price: '$1.99', preview: PACK.map((s) => s.leaf), perks: [`${PACK.length} looks with their own sky, leaves and drop: ${PACK.map((s) => s.name).join(', ')}`, 'Every look also on your share card'] }); pass.init({ game: GAME, name: 'Dewhop', perks: ['Every past daily vine in the archive', 'Dusk and Paper themes'] }); const canUse = (s) => s.tier === 'free' || (s.tier === 'pass' && pass.isPro()) || (s.tier === 'pack' && skins.owned()); let skin = SKINS[store('dewhop:skin')] && canUse(SKINS[store('dewhop:skin')]) ? store('dewhop:skin') : 'morning'; let muted = !!store('dewhop:mute'); let mode = { kind: 'daily', date: todayIso }; let sim, state = 'ready', pending = false, acc = 0, last = 0, deadAt = 0, flash = 0, shake = 0, splash = 0, scroll = 0, fall = 0, lastRun = null; let landed = []; // { x, side } of every leaf the drop landed on (they stop swaying), newest last const install = pwa(GAME, $('install')); themeToggle($('theme')); // ------------------------------------------------------------------ sound (WebAudio blips, no files) let ac; function blip(f, d = 0.06, type = 'sine', vol = 0.08, to = 1.5) { if (muted) return; try { ac = ac || new (window.AudioContext || window.webkitAudioContext)(); const o = ac.createOscillator(), v = ac.createGain(); o.type = type; o.frequency.setValueAtTime(f, ac.currentTime); o.frequency.exponentialRampToValueAtTime(f * to, ac.currentTime + d); v.gain.setValueAtTime(vol, ac.currentTime); v.gain.exponentialRampToValueAtTime(0.0001, ac.currentTime + d); o.connect(v); v.connect(ac.destination); o.start(); o.stop(ac.currentTime + d + 0.02); } catch { /* no audio */ } } const setMuteLabel = () => { $('mute').textContent = muted ? '๐Ÿ”‡' : '๐Ÿ”Š'; }; setMuteLabel(); $('mute').onclick = () => { muted = !muted; store('dewhop:mute', muted); setMuteLabel(); }; // ------------------------------------------------------------------ modes + stats (all in one small menu: calm screen) const seedOf = (m) => (m.kind === 'practice' ? m.seed : m.date); const dayKey = (m) => `dewhop:day:${m.date}`; const dayStats = (m) => store(dayKey(m)) || { best: 0, tries: 0, marks: [] }; function renderModes() { const el = $('modes'); el.innerHTML = ''; const items = [ { t: `Daily #${todayNum}`, on: mode.kind === 'daily' && mode.date === todayIso, go: () => setMode({ kind: 'daily', date: todayIso }) }, { t: 'Practice', on: mode.kind === 'practice', go: () => setMode({ kind: 'practice', seed: `p${Date.now()}` }) }, { t: 'Archive', on: mode.kind === 'daily' && mode.date !== todayIso, lock: !pass.isPro(), go: archive }, ]; for (const it of items) { const b = document.createElement('button'); b.className = 'chip'; b.type = 'button'; b.setAttribute('aria-pressed', String(it.on)); b.innerHTML = `${it.t}${it.lock ? ' ๐Ÿ”’' : ''}`; b.onclick = it.go; el.appendChild(b); } } function archive() { if (!pass.isPro()) { pass.open('archive'); return; } const n = todayNum - 1; if (n < 1) { toast('The archive fills up day by day; the first archived vine arrives tomorrow.', 4000); return; } const k = Number(prompt(`Play a past daily vine: enter a number from 1 to ${n}`, String(n))); if (k >= 1 && k <= n) setMode({ kind: 'daily', date: dateOf(k) }); } function setMode(m) { mode = m; $('num').textContent = m.kind === 'practice' ? 'practice' : `#${dayNumber(m.date)}`; $('over').hidden = true; renderModes(); reset(); hud(); } function hud() { const s = mode.kind === 'daily' ? dayStats(mode) : { best: store('dewhop:practice-best') || 0, tries: 0 }; $('best').textContent = s.best; $('tries').textContent = s.tries || 0; } // ------------------------------------------------------------------ loop function reset() { sim = makeSim(seedOf(mode)); state = 'ready'; pending = false; acc = 0; flash = 0; shake = 0; splash = 0; scroll = 0; fall = 0; landed = [{ x: X0, side: 1 }]; } function start() { if (mode.kind === 'practice') mode.seed = `p${Date.now()}`; reset(); state = 'run'; last = performance.now(); count(GAME, 'play', mode.kind === 'daily' ? (mode.date === todayIso ? 'daily' : 'archive') : 'practice'); $('over').hidden = true; } function input() { if (state === 'ready') { start(); return; } if (state === 'run') { pending = true; return; } if (state === 'dead' && performance.now() - deadAt > 300) start(); } function die() { state = 'dead'; deadAt = performance.now(); flash = 1; shake = sim.dried ? 4 : 12; fall = 0.001; lastRun = { score: sim.score, perfect: sim.perfect, marks: sim.marks.slice(), dried: sim.dried }; if (sim.dried) blip(520, 0.4, 'sine', 0.06, 0.3); else blip(170, 0.32, 'sawtooth', 0.1, 0.3); if (navigator.vibrate) try { navigator.vibrate([30, 40, 30]); } catch { /* */ } let newBest = false; if (mode.kind === 'daily') { const s = dayStats(mode); s.tries = (s.tries || 0) + 1; if (sim.score > (s.best || 0) || (sim.score === s.best && sim.perfect > (s.perfect || 0))) { s.best = sim.score; s.perfect = sim.perfect; s.marks = lastRun.marks; newBest = sim.score > 0; } store(dayKey(mode), s); } else if (sim.score > (store('dewhop:practice-best') || 0)) { store('dewhop:practice-best', sim.score); newBest = true; } hud(); showOver(newBest); if (sim.score >= 5) install.offer(); } function frame(now) { requestAnimationFrame(frame); if (state === 'run') { acc += Math.min(0.25, (now - last) / 1000); last = now; let n = 0; while (acc >= 1 / HZ && n++ < 8) { acc -= 1 / HZ; const tap = pending && sim.wait === 0 && sim.hop === 0; pending = false; if (tap) blip(420, 0.08, 'triangle', 0.05, 1.8); const lx = leafX(sim.cur, sim.t + 1), landedSide = sim.cur.side; const ev = sim.step(tap); if (ev === 'perfect' || ev === 'good') { landed.push({ x: lx, side: landedSide }); if (landed.length > 6) landed.shift(); scroll = -1; splash = ev === 'perfect' ? 1 : 0.6; blip(ev === 'perfect' ? 900 + Math.min(sim.streak, 12) * 45 : 600, ev === 'perfect' ? 0.1 : 0.07, 'sine', 0.08); } if (sim.dead) { die(); break; } } } else last = now; draw(now); } // ------------------------------------------------------------------ drawing const TAU = Math.PI * 2; const GAPF = 0.21; // vertical gap between leaves (fraction of the canvas) function leafShape(ctx, x, y, hw, S, tilt = 0) { const h = Math.max(12, hw * 0.4); ctx.save(); ctx.translate(x, y); ctx.rotate(tilt); ctx.fillStyle = S.leaf; ctx.beginPath(); ctx.moveTo(-hw, 0); ctx.quadraticCurveTo(-hw * 0.2, -h * 1.6, hw, 0); ctx.quadraticCurveTo(-hw * 0.2, h * 1.1, -hw, 0); ctx.fill(); ctx.strokeStyle = S.rib; ctx.lineWidth = 3; ctx.beginPath(); ctx.moveTo(-hw * 0.92, 0); ctx.quadraticCurveTo(0, -h * 0.25, hw * 0.92, 0); ctx.stroke(); ctx.restore(); } function vine(ctx, side, x, y, W, S) { const ex = side < 0 ? -20 : W + 20; ctx.strokeStyle = S.vine; ctx.lineWidth = 5; ctx.lineCap = 'round'; ctx.beginPath(); ctx.moveTo(ex, y - W * 0.22); ctx.quadraticCurveTo((ex + x) / 2, y - W * 0.02, x + side * 6, y - 4); ctx.stroke(); } function drop(ctx, x, y, r, S, squash = 0) { ctx.save(); ctx.translate(x, y); ctx.scale(1 + squash * 0.25, 1 - squash * 0.25); ctx.fillStyle = S.drop; ctx.globalAlpha = 0.95; ctx.beginPath(); ctx.moveTo(0, -r * 1.45); ctx.bezierCurveTo(r * 0.9, -r * 0.55, r, r * 0.25, 0, r); ctx.bezierCurveTo(-r, r * 0.25, -r * 0.9, -r * 0.55, 0, -r * 1.45); ctx.fill(); ctx.globalAlpha = 0.85; ctx.fillStyle = S.hi; ctx.beginPath(); ctx.ellipse(-r * 0.32, -r * 0.2, r * 0.18, r * 0.3, -0.4, 0, TAU); ctx.fill(); ctx.restore(); } function sky(ctx, W, H, S, now) { const gr = ctx.createLinearGradient(0, 0, 0, H); gr.addColorStop(0, S.sky1); gr.addColorStop(1, S.sky2); ctx.fillStyle = gr; ctx.fillRect(-20, -20, W + 40, H + 40); ctx.fillStyle = S.sun; ctx.globalAlpha = 0.1; ctx.beginPath(); ctx.arc(W * 0.18, H * 0.16, W * 0.14, 0, TAU); ctx.fill(); ctx.globalAlpha = 0.16; ctx.fillStyle = S.rib; // soft foliage at the foot of the vine ctx.beginPath(); ctx.moveTo(0, H); for (let i = 0; i <= 8; i++) ctx.quadraticCurveTo(W * (i - 0.5) / 8, H * (0.86 + (i % 2) * 0.05), W * i / 8, H * 0.9); ctx.lineTo(W, H); ctx.fill(); ctx.fillStyle = S.hi; ctx.globalAlpha = 0.08; for (let i = 0; i < 14; i++) { const x = (i * 97 + now / 90) % W, y = (i * 53) % H; ctx.beginPath(); ctx.arc(x, y, 2 + (i % 3), 0, TAU); ctx.fill(); } ctx.globalAlpha = 1; } function draw(now) { const S = SKINS[skin], W = cv.width, H = cv.height, gap = W * GAPF, baseY = H * 0.74, R = W * 0.046; g.save(); if (shake > 0) { g.translate((Math.random() - 0.5) * shake, (Math.random() - 0.5) * shake); shake *= 0.85; if (shake < 0.5) shake = 0; } sky(g, W, H, S, now); scroll *= 0.8; if (scroll > -0.01) scroll = 0; const off = scroll * gap; // 0 at rest; -gap right after a landing, easing to 0 (the vine climbs) // landed leaves (still), newest = the drop's leaf landed.forEach((l, k) => { const y = baseY + (landed.length - 1 - k) * gap + off; if (y < H + 60) { g.globalAlpha = k === landed.length - 1 ? 1 : 0.75; vine(g, l.side, l.x * W, y, W, S); leafShape(g, l.x * W, y, W * 0.11, S); g.globalAlpha = 1; } }); // the next leaf, swaying on its vine const L = sim.cur, t = sim.t, lx = leafX(L, t) * W, ly = baseY - gap + off; vine(g, L.side, lx, ly, W, S); leafShape(g, lx, ly, L.w * W, S, Math.cos(t / 9) * 0.05); // the drop: sits, hops (an arc onto the next leaf) or falls; it shrinks as the sun dries it const dry = state === 'run' && sim.hop === 0 ? Math.max(0, (sim.t - DRY * 0.55) / (DRY * 0.45)) : 0; let dx = X0 * W, dy = baseY - R + off; if (state === 'run' && sim.hop > 0) { const p = 1 - sim.hop / HOP; dy = baseY - R - p * gap - Math.sin(p * Math.PI) * gap * 0.45; } if (state === 'dead' && !lastRun.dried) { fall = Math.min(1.6, fall * 1.12 + 0.02); dy = baseY - gap - R + fall * H * 0.7; } if (!(state === 'dead' && lastRun.dried)) { const gl = g.createRadialGradient(dx, dy, 0, dx, dy, R * 3); gl.addColorStop(0, S.drop); gl.addColorStop(1, 'rgba(0,0,0,0)'); g.globalAlpha = 0.25; g.fillStyle = gl; g.beginPath(); g.arc(dx, dy, R * 3, 0, TAU); g.fill(); g.globalAlpha = 1; drop(g, dx, dy, R * (1 - dry * 0.45), S, splash); } splash *= 0.85; // sun warning (only in the last 45% of the wait, so the screen stays calm) if (dry > 0) { g.globalAlpha = Math.min(0.5, dry * 0.5); g.fillStyle = S.sun; g.beginPath(); g.arc(W - 60, 60, 26 + dry * 10, 0, TAU); g.fill(); g.globalAlpha = 1; } // one score chip at the top g.fillStyle = S.text; g.textAlign = 'center'; g.textBaseline = 'middle'; if (state === 'ready') { g.font = '900 60px system-ui, sans-serif'; g.fillText('TAP TO HOP', W / 2, 70); g.font = '700 24px system-ui, sans-serif'; g.globalAlpha = 0.85; g.fillText('land on the leaf as it swings under you', W / 2, 116); g.globalAlpha = 1; } else { g.font = '900 72px system-ui, sans-serif'; g.fillText(String(sim.score), W / 2, 60); if (state === 'run' && sim.wait > 0 && sim.last) { g.font = '900 32px system-ui, sans-serif'; g.fillStyle = sim.last === 'perfect' ? '#3DDC84' : '#FFC93C'; g.fillText(sim.last === 'perfect' ? (sim.streak > 1 ? `PERFECT ร—${sim.streak}` : 'PERFECT') : 'GOOD', W / 2, 112); } if (state === 'dead') { g.font = '800 28px system-ui, sans-serif'; g.fillStyle = S.text; g.fillText(lastRun.dried ? 'the sun dried it ยท tap to retry' : 'missed the leaf ยท tap to retry', W / 2, 112); } } if (flash > 0) { g.fillStyle = `rgba(255,77,77,${flash * 0.25})`; g.fillRect(0, 0, W, H); flash *= 0.88; if (flash < 0.02) flash = 0; } g.restore(); } // ------------------------------------------------------------------ results, share, card function result() { if (mode.kind === 'daily') { const s = dayStats(mode); return { best: s.best, perfect: s.perfect || 0, marks: s.marks || [], tries: s.tries }; } return { best: lastRun ? lastRun.score : 0, perfect: lastRun ? lastRun.perfect : 0, marks: lastRun ? lastRun.marks : [] }; } function shareText() { const r = result(); const head = mode.kind === 'practice' ? 'Dewhop practice ๐Ÿ’ง' : `Dewhop #${dayNumber(mode.date)} ๐Ÿ’ง`; return `${head} ${r.best} leaves, ${r.perfect} perfect${r.tries ? ` (${r.tries} tries)` : ''}\n${grid(r.marks)}\nHow high can your drop climb?`; } function showOver(newBest) { const s = mode.kind === 'daily' ? dayStats(mode) : null; $('over-title').textContent = newBest ? `New best: ${lastRun.score}!` : `${lastRun.score} leaf${lastRun.score === 1 ? '' : 'ves'}`; $('over-line').textContent = `${lastRun.perfect} perfect. ` + (s ? `Today's best ${s.best} after ${s.tries} tries.` : 'Practice vine.'); $('over-grid').textContent = grid(lastRun.marks); const it = intents(GAME, shareText(), PATH); $('sx').href = it.x; $('sb').href = it.bsky; $('sw').href = it.whatsapp; $('over').hidden = false; pass.afterWin($('over'), 'over'); } function card() { const S = SKINS[skin], c = document.createElement('canvas'); c.width = 1080; c.height = 1350; const x = c.getContext('2d'); sky(x, 1080, 1350, S, 0); for (let k = 0; k < 4; k++) leafShape(x, 540 + Math.sin(k * 2.1) * 180, 1060 - k * 210, 130 - k * 12, S); drop(x, 540 + Math.sin(3 * 2.1) * 180, 1060 - 3 * 210 - 40, 40, S); const r = result(); x.fillStyle = S.text; x.textAlign = 'left'; x.font = '900 66px system-ui, sans-serif'; x.fillText('DEWHOP', 80, 130); x.globalAlpha = 0.85; x.font = '700 40px system-ui, sans-serif'; x.fillText(mode.kind === 'daily' ? `Daily vine #${dayNumber(mode.date)} ยท ${mode.date}` : 'Practice vine', 80, 190); x.globalAlpha = 1; x.textAlign = 'right'; x.font = '900 120px system-ui, sans-serif'; x.fillText(String(r.best), 1000, 150); x.font = '700 34px system-ui, sans-serif'; x.fillText(`leaves ยท ${r.perfect} perfect`, 1000, 195); x.textAlign = 'left'; r.marks.slice(0, 30).forEach((m, i) => { x.fillStyle = m === 'perfect' ? '#3DDC84' : m === 'good' ? '#FFC93C' : '#FF4D4D'; x.fillRect(80 + (i % 10) * 92, 1150 + Math.floor(i / 10) * 30 - 60, 76, 22); }); x.fillStyle = S.text; x.font = '800 44px system-ui, sans-serif'; x.fillText('How high can your drop climb?', 80, 1230); x.globalAlpha = 0.75; x.font = '600 32px system-ui, sans-serif'; x.fillText('Play free: cybermaxtools.com/games/dewhop', 80, 1295); return c; } $('share').onclick = async () => share(GAME, shareText(), PATH, await canvasBlob(card()), `dewhop-${mode.date || 'practice'}.png`); ['sx', 'sb', 'sw'].forEach((id) => $(id).addEventListener('click', () => count(GAME, 'share', { sx: 'x', sb: 'bsky', sw: 'whatsapp' }[id]))); $('card').onclick = async () => { download(await canvasBlob(card()), `dewhop-${mode.date || 'practice'}.png`); count(GAME, 'share', 'png'); }; // ------------------------------------------------------------------ input, looks, start cv.addEventListener('pointerdown', (e) => { e.preventDefault(); input(); }); cv.addEventListener('keydown', (e) => { if (e.key === ' ' || e.key === 'Enter') { e.preventDefault(); input(); } }); document.addEventListener('keydown', (e) => { if (/^(INPUT|TEXTAREA|SELECT)$/.test(document.activeElement && document.activeElement.tagName)) return; if (e.key === ' ' && document.activeElement === document.body) { e.preventDefault(); input(); } else if (e.key === 'r' || e.key === 'R') { e.preventDefault(); if (state !== 'ready') start(); } else if (e.key === 'm' || e.key === 'M') $('mute').click(); }); $('pass-btn').onclick = () => pass.open('header'); $('again').onclick = () => { start(); cv.focus(); }; $('skins-btn').hidden = !PACK_LIVE; $('skins-btn').onclick = () => skins.open('header'); document.addEventListener('click', (e) => { const b = e.target.closest('[data-pass]'); if (b) pass.open(b.dataset.pass); const k = e.target.closest('[data-skins]'); if (k) skins.open(k.dataset.skins); }); document.addEventListener('visibilitychange', () => { if (document.hidden && state === 'run') last = performance.now(); }); function renderSkins() { const el = $('skins'); el.innerHTML = ''; for (const [id, s] of Object.entries(SKINS)) { const b = document.createElement('button'); const lock = !canUse(s); b.type = 'button'; b.title = `${s.name}${s.tier === 'pass' ? ' (Fun Pass)' : s.tier === 'pack' ? ' (Skin Pack)' : ''}`; b.setAttribute('aria-label', b.title); b.style.background = `linear-gradient(135deg, ${s.sky2} 50%, ${s.leaf} 50%)`; b.setAttribute('aria-pressed', String(id === skin)); if (lock) b.classList.add('locked'); b.onclick = () => { if (lock) { if (s.tier === 'pass') pass.open('theme'); else skins.open('dot'); return; } skin = id; store('dewhop:skin', id); renderSkins(); }; el.appendChild(b); } $('skins-btn').textContent = skins.owned() ? '๐Ÿ’ง Looks' : '๐Ÿ’ง Skin Pack $1.99'; } const refresh = () => { if (!canUse(SKINS[skin])) { skin = 'morning'; store('dewhop:skin', 'morning'); } renderSkins(); renderModes(); }; pass.onChange(refresh); skins.onChange(refresh); // Screenshot helper for scripts/games/render_assets.mjs: a mid-run frame on today's vine (no effect on normal play). window.__cmxShot = async (stage = 1) => { const { bestTap } = await import('./core.js'); start(); const s = makeSim(todayIso); while (s.score < 4 && !s.dead) { const b = bestTap(s.cur, s.t); for (let k = 0; k < b.k; k++) s.step(false); s.step(true); while (s.hop > 0) s.step(false); while (s.wait > 0) s.step(false); landed.push({ x: X0, side: s.cur.side }); } for (let i = 0; i < 20; i++) s.step(false); sim = s; state = 'shot'; if (stage === 2) { s.marks.push('miss'); s.dead = true; die(); } }; // Read-only view for the e2e test and the Shorts recorder (no way to change a run from here). window.__dewhop = { state: () => ({ state, score: sim.score, perfect: sim.perfect, t: sim.t, hop: sim.hop, wait: sim.wait, i: sim.i, cur: { ...sim.cur } }) }; setMode(mode); requestAnimationFrame(frame);