Character Play SDK
Make games for Character App: fans play them beside a creator's Episodes, on phones, desktop and X. You write the game; the platform draws everything around it.
Full guide as plain textEverything here is true in play 1.18, the newest minor. Kit play-kit-1.18.1.tgz.
Start
mkdir play-games && cd play-games
npm install https://character.app/_play/kit/play-kit-1.18.1.tgz
npx playwright install chromium webkit
npx play doctor
npx play new game-my-game --genre arcade # canvas template + the arcade playbook in game-my-game/AGENTS.md
cd game-my-game && npx play dev # checks play.json in seconds, prints http://127.0.0.1:<port>play new with no --genre writes the arcade playbook. --template canvas is the default and the one to start from.
The loop: fast first, full check last
play devafter everyplay.jsonedit. Seconds. It refuses a bad manifest with the path and the fix.play shotsafter every game edit. About 10 seconds. It writes poster, first-input, mid-round and result PNGs for phone, landscape and desktop. Look at them.play checkonce, at the end, with nothing else running. About 11 minutes alone on a laptop, 20 to 40 minutes when other checks share the machine. It runs your game in Chromium and WebKit at every size, with an idle bot and a random bot, and writes.play/check.json(findings block, quality warnings do not) and.play/sheet.png.play packwrites the ZIP you hand to Publishing.
Codex's sandbox cannot start a browser: run new, the static part of check and pack inside it, and dev, shots and the full check outside.
What are you making?
| You want | Make it as | Start |
|---|---|---|
| Catch, dodge, tap, a score that climbs | a Play bundle | play new <id> --genre arcade. Playbook: docs/playbooks/arcade.md, example examples/game-fish-dash |
| A rhythm game | a Play bundle | --genre arcade and change the loop: schedule notes on host.clock.frame from the song's time, play the song on host.audio.music, and keep count-in + song + outro under 50 s of play time (all of it counts, PLAY-Q002) |
| A puzzle, turn or move based | a Play bundle | --genre arcade and change the loop: seed each level from run.seed, let idle lose on a move or time limit, store progress at each cleared level with host.save |
| A game with choices and a score | a Play bundle | --template dom. Each ending is an outcome with its own id and title; the idle bot only reads win, won, victory, success as a win and notes other ids as unclassified, so give the ending an idle player reaches the id loss (titled as you like). A choice is a button on your stage; endings found go in a records set. A bundle has no choice nodes (choices and kind: "story" are refused) |
| A branching story (scenes and choices, no score) | the story format tale@1, not a bundle | Connect the Character App MCP, call get_publishing_workspace, then get_tale_format and stage_tale_episode. Needs Publishing access and a role on the Story |
| Levels on a grid, simple scenes, or a simple arcade game, with no code | the JSON game format (levels, scenes or arcade) | get_game_format on the Character App MCP returns it with examples |
| A remix of a house game (slicer, rhythm) | not open yet | Build your own on canvas |
A finished bundle goes live through Publishing: the "Import a bundle you built" screen, or stage_creator_game then publish_creator_game on the MCP. The creator approves it in Publishing.
What the platform draws, and what you draw
The platform draws every screen and control around your stage: the Front with Play, the mode row, the score chips, pause, sound, Settings, the result card, sharing, the store, prices, Buy, sign-in, and every way out. You draw only your stage: the world, the player, the hazards, feedback.
- Never draw a score or a timer (declare them in
statsandhud), a pause or sound button, a price, a store or Buy button, a sign-in, a link out, or a "Play again". - Money: a game never shows a price, opens a payment, or holds a spend. Declare items; the platform sells them.
PLAY-Q025,PLAY-Q027. - Full list with the codes that enforce it:
docs/platform.md.
Never use these (refused by `play check`)
| Refused | Use | Code |
|---|---|---|
requestAnimationFrame, setTimeout, setInterval; listening for visibilitychange, blur, pagehide, fullscreenchange | host.clock.frame, host.clock.after, host.on('pause' | 'resume'). They stop while the platform pauses | PLAY-S106 |
Math.random, Date.now, crypto.getRandomValues (once "seeded": true) | a generator seeded from run.seed | PLAY-S112 |
localStorage, sessionStorage, indexedDB, caches | host.save (progress, 16 KiB of JSON) and host.records (collections) | PLAY-S105 |
fetch or XMLHttpRequest off your bundle, WebSocket, EventSource | files in your bundle, loaded with new URL('./x.png', import.meta.url) | PLAY-S103 |
parent, top, opener, document.body, document.querySelector | elements under the stage you are given, queried from your own root | PLAY-S104 |
new Audio, new AudioContext | host.audio.context, effects into host.audio.output, songs into host.audio.music | PLAY-S107 |
eval, Function, Worker, SharedArrayBuffer | plain ES modules on the stage thread | PLAY-S108 |
location, alert, confirm, prompt, open | nothing: the platform owns navigation | PLAY-S109 |
keys Escape, KeyP, KeyM, KeyF in input.actions | other keys; those four are the platform's pause, mute and full screen | PLAY-M001 |
Gotchas (each one cost a tester time)
run.finish({ stats })takes only ids listed inresult. Ahud-only id fails the run withPLAY-R001, and theL005,L007,Q001,Q002after it are echoes.- Keys are
KeyboardEvent.codevalues:ArrowLeft,KeyA,Space,Digit1. Not"a"or"1". - A bundle is always
"kind": "game", with an id startinggame-,"x": { "card": false },"verifier": { "kind": "none" }and norankedmode. - A bundle cannot award an
earn: earns need a registered verifier, and only house games have one. A prize is stars (scoring.stars), a verdict, and optionally arecordsset kept on the fan's device. Seedocs/concepts/scoring-and-prizes.md. run.variantcan benull. Never build an id from it.hudshows the first 3 stats that have a value, althoughhudmay list 4.- Idle must lose: the checker's idle bot must not win or reach the clock cap (
PLAY-Q001), and must not earn a star (PLAY-Q011). - Accept the first input within 3 s of Play (
PLAY-Q003) and change pixels within 150 ms of a press (PLAY-Q004). Focus your canvas onstart. - Keep a round under 50 s of play time, counting any count-in and outro (
PLAY-Q002, a warning). - Settings rows are
toggleorchoice(2 to 6 options of up to 16 characters), at most 6. Difficulty goes here, never in a screen before play. - The pad:
"pad": trueon up to 3 actions draws 64 px buttons over the foot of your stage.viewport.safedoes not count them, so keep80 / viewport.scalestage px clear abovesafe.bottomwhile the pad shows. - Map pointer positions through
canvas.getBoundingClientRect(): the stage is scaled. Touch targets are at least 44 CSS px (32 with a mouse); divide byviewport.scalefor stage px. - The end of a round (1.18): call
run.finish(result, { linger: true }), play your closing moment onhost.clock, thenrun.showResult()within 3000 ms (PLAY-Q028if the card has to rise without it). When the card rises the platform hides your stage and shows your cover under it; nothing you draw after that is seen. Seedocs/concepts/run-and-end.md. - A locked level (
variants[].unlock) can be declared, but a creator cannot sell one yet: its files ship to every viewer. Only wearables are sellable. play devlistens on 127.0.0.1 only, on a new port each time; use the origin it prints. Use127.0.0.1, notlocalhost.
Boundaries
- Always: start from
canvas(ordomfor text-led games); rundevandshotsbeforecheck; keep everything you load inside the bundle; send errors tohost.report. - Ask the creator first: the game's title, cover and characters; anything priced; what a mode or setting changes about the score.
- Never: draw platform chrome or money; read or store fan data; load from another origin; ship content unfit for minors (bundles are public and playable signed out).
The members you will use
export function mount(stage, host) { // game.js's one export, called after the Play tap
/* build under stage */ host.ready() // once, within 3 s, when your first frame is drawn; a 15 s stall fails PLAY-L001
return () => {} // cleanup: remove DOM, listeners and audio; a remount must start fresh
}
host.on('start', run => {}) // every run: reset, seed from run.seed, read settings, focus
host.clock.frame((dt, now) => {}) // your loop; stops while paused
host.clock.after(ms, fn) // play-time timer; holds across pauses
host.hud.set({ score: 0 }) // the platform's score chips
host.input.actions((id, down) => {}) // declared keys and pad buttons
host.input.pad.show(viewport.pointer === 'coarse')
host.settings.get('speed') // a declared setting's value
host.audio.output / host.audio.music // effects / songs
host.save.store(data) / run.resume // progress and Continue
host.records.add('endings', 'truth') // a collection kept on the device
host.store.worn / host.on('worn') // the wearable she has on
run.finish({ outcome, verdict, score, stats }, { linger: true }) // once; stats from `result` only
host.on('resultArea', area => {}) // 1.18: where the card will rest (area.safe)
run.showResult() // 1.18: your closing moment is done; the card rises
host.report(error) // errors; play goes onFull types: kit.d.ts and types/. Your ids: play.gen.d.ts (regenerated by play new and play check).
The bundle: play.json at the root, one ES module entry, relative imports, lowercase file names. At most 400 files, 32 MiB, and 1.5 MiB gzipped for the first load (lazy-import the rest). A cover of at least 1200 px on its short side and at most 500 KiB, untitled (titled: false). Details: docs/concepts/manifest.md.
Pages
Paths are inside the kit: node_modules/@charactr/play/ in your project.
docs/platform.md: what the platform draws and the code that enforces each line.docs/formats.md: game, story or Episode, with the limits of each.docs/concepts/:manifest.md,run-and-end.md,stage-and-input.md,modes-and-settings.md,scoring-and-prizes.md,store-and-unlocks.md,saves-records-sound.md,quality-and-testing.md.docs/playbooks/arcade.md: the genre pageplay newcopied below.docs/codes.md: every code, what it means, the fix.docs/checklist.md: every finding (must fix) and warning (should fix), one line each.docs/reference/:manifest.md,host.md,limits.md,minors.md: every field, member and limit, generated from the code.CHANGELOG.md: what each minor added, and what a patch changed.
Web copies: this page at https://character.app/_play/kit/AGENTS.md, each page at https://character.app/_play/kit/docs/<page>.md, and everything in one file at https://character.app/_play/kit/llms-full.txt.
What the platform draws, and what you draw
Every Play game shares one platform shell. A fan who learns a control in one game finds it in the same place, doing the same thing, in every other game, Episode and story.
The three layers
- Set in stone (platform-owned): the top bar, sheets, sign-in, money, navigation and keys. A game cannot restyle, cover or redraw them.
- Platform-drawn, game-filled: the Front, mode row, HUD chips, Settings rows, Store, result card and share copy. You declare them in
play.json; the shell draws them. - The game's own: everything inside your
stageelement and withinviewport.safe— your world, gameplay, effects, sound and stage controls.
The bar (one meaning per slot)
| Slot | Outside a round (Front, result, lobby) | Playing | Paused |
|---|---|---|---|
| Left | The world (picture + name → Home; Character App mark beside it on Front) | Empty (game owns the screen) | The world |
| R1 (outer right) | You | Pause | Resume |
| R2 | Sound | Sound | Sound |
| R3 | Share | None | None |
| R4 (wide screens) | Fullscreen | None | Fullscreen |
While paused, the account lives inside the pause menu ("You" opens as a step and Back returns to Pause). Only Resume resumes the round. Draw nothing in the bar strip above viewport.safe.top.
What the platform draws (never draw these)
| Surface or control | Who owns it | Enforced by |
|---|---|---|
| Top bar (world, You, Pause/Resume, Sound, Share, Fullscreen) | Platform; keep clear of viewport.safe.top | PLAY-V002 (safe area) |
| Front, pause/More, Settings, Leaderboard, result/All stats, share | Platform (calm card from play.json) | PLAY-Q022 (dialogs, h2, button overlays while playing) |
| Score and timer chips | Platform (stats + hud + host.hud.set) | not checked |
Shell keys: Escape, KeyP, KeyM, KeyF (plus R on pause, Enter on result) | Platform | PLAY-M001 (manifest), PLAY-Q020 (swallowed Escape/P/M/F); R/Enter not checked |
| Navigation: home, Episodes, profile, Back, links out | Platform (from episodes and the page) | PLAY-S104, PLAY-S109 (blocking); PLAY-Q024, PLAY-Q017 (warnings) |
| Sign-in, account status, save-status line | Platform | PLAY-S105 (storage, blocking); PLAY-Q026 (sign-in copy/inputs, warning); save-status copy not checked |
| Store, Buy sheet, checkout, coins and prices | Platform (store, unlocks, host.store) | PLAY-Q025 (prices), PLAY-Q027 (store/payment, warnings); PLAY-R013 (store.open during play) |
| Clock, pause/resume, audio construction and network | Platform (host.clock, host.audio, bundle files) | PLAY-S103, PLAY-S106, PLAY-S107, PLAY-S108, PLAY-L004, PLAY-L008 |
| End of a round (the result card, your cover under it) | Platform (see below) | PLAY-L005, PLAY-R001, PLAY-R002, PLAY-R003; PLAY-Q028 (a linger that hits its ceiling, warning) |
Money: the never-list
The server decides what a fan owns, her coin balance, every price, membership and media access — never the browser or game code.
- Never show a price in money (
$4.99,10 USD) anywhere in code or stage text (PLAY-Q025). In-game currencies ("Get 50 coins") are gameplay and allowed. - Never open a payment or draw a store (
Stripe,PaymentRequest,ApplePaySession,/_a/coins, card copy:PLAY-Q027). Declare items instoreandunlocks; the platform sells them. - Never hold or trust a spend: a sandboxed game's buy request opens only the platform store; money controls enforce a 500 ms dwell and the game frame is hidden and inert while a money sheet is open.
- Pricing guard (1.17 and 1.18): creators can price only
wear: trueunlocks not named by a variant. Paid levels wait until a level's files are served from the server.
What you supply
play.json:title,art,stage,start,variants(withblurb),scoring(withstars),outcomes,verdicts,stats/hud/result,store/unlocks/settings,episodes,share.post.- The stage: your world, rules, sound and stage controls inside
viewport.safe. - End of a round (1.18):
run.finish(result, { linger: true }), your closing moment, thenrun.showResult();host.on('resultArea')says where the card will rest. When the card rises on a published bundle, the shell hides your frame and shows your cover art under the card. Seedocs/concepts/run-and-end.md.
Game, story or Episode?
Pick the format that fits what you are making before writing any code.
| Format | Best for | Entry point |
|---|---|---|
Play bundle (play@1) | Custom interactive games (arcade, rhythm, puzzle, action, choice game with a score) | play new <id> (kit play-kit-1.18.1.tgz) |
Story Episode (tale@1) | Branching picture and sound stories with choices and endings (no score) | Character App MCP (get_tale_format, stage_tale_episode) |
JSON game (character-game-v1) | No-code grid puzzles, simple branching scenes, or tiny 160×120 arcade games | Character App MCP (get_game_format, stage_creator_game) |
| House-game remix (engine pack) | Reskinning a house engine (slicer, rhythm) with art, copy and tuning | Not open yet; build on --template canvas |
Play bundle (`play@1`, up to 1.18)
A ZIP with play.json, an ES module exporting mount(stage, host) and local assets. Bundle mode enforces (PLAY-M001):
- Always
"kind": "game"—"kind": "story"andchoicesare refused. idstarts withgame-(2–48 chars); noart.scene."x": { "card": false },"verifier": { "kind": "none" }when scored, and norankedvariants.- Limits: ≤400 files, ≤16 MiB/file, ≤32 MiB total, ≤1.5 MiB gzip first load; up to 8 variants, 24 outcomes, 16 verdicts, 8 stats, 16 unlocks, 6 settings.
Story Episode (`tale@1`)
Interactive branching Episodes played inside the Episode player with pictures, captions, voice, cues, flags and shareable choice splits.
- Graph and copy limits: 2–24 nodes (
key≤24 chars), 2–4 choices perasknode (label ≤48 chars, prompt ≤80 chars), at least one unconditional choice per fork, up to 8 flags, up to 2 conditional variants per node. - Media and size limits: 48 KiB JSON document, up to 4 lines per node (≤280 chars each), hold timing 1.5–12 s (1500–12000 ms), voice ≤30 s, up to 1 cue and 3 effects per node, ≤5 tags, package ≤200 files and ≤200 MiB.
- How to build and stage: connect an MCP client to the Character App MCP, call
get_publishing_workspace, thenget_tale_formatandstage_tale_episode(upload media to the Story's library first). - Access rules: requires Studio Publishing access and a role on the destination Story. The creator approves a 7-day coding-tool connection in Publishing (
/app/next/tools, revocable under Account → Coding tool access). Stories with sound require an audio-rights confirmation in Publishing before release.
JSON game (`character-game-v1`)
Data-only games hosted by first-party platform code (no custom JS). Call get_game_format on the Character App MCP for the strict schema and examples. Overall limits: ≤24 KiB JSON, up to 8 games per Story. Pick exactly one shape:
levels(grid puzzle): 1–8 levels, rectangular rows 2–16 high × up to 20 wide, optional turn limit 1–999, 9 tile symbols (. # @ * X E B S G).scenes(branching scenes): 1–24 scenes (body ≤600 chars, optional library picture, nosprites), 1–6 choices per non-ending scene (label ≤80 chars), up to 8 distinct flags (requires/excludes/set/clear).arcade(programmable arcade): 160×120 canvas at 20 fps, 1–160 frame instructions (≤100 chars each, forward labels only), up to 32 signed 16-bit integer variables (-32768..32767).
House-game remix (not open yet)
The engine registry on main is empty, so no engine pack id can be staged by creators yet. Start from play new <id> --template canvas instead.
Manifest and bundle files
Put play.json at the ZIP root beside an ES module entry exporting mount(stage, host) and declared relative assets. Every object in play.json is closed (unknown keys fail PLAY-M001), and text fields must be nonempty without a URL.
Bundle rules and refusals (`PLAY-M001`)
- Always
"kind": "game"—"kind": "story"andchoicesare refused. - Stable
idstarting withgame-, 2–48 chars ([a-z0-9-]); omitart.scene. "x": { "card": false },"verifier": { "kind": "none" }when scored, and norankedvariants.- Declare
playup to"1.18",title(≤80),entry,art.cover,stage.design,audio, and at least 1 outcome.
File names, assets and budgets (`PLAY-S001`–`PLAY-S010`, `PLAY-S102`–`S103`)
- Names (
PLAY-S001): lowercase ASCII (a-z,0-9,.,_,-), no leading dot, ≤8 path segments, ≤200 chars.__MACOSX/and.DS_Storeare dropped. - Budgets (
PLAY-S003–S005): ≤400 files, ≤16 MiB/file, ≤32 MiB total, ≤1.5 MiB gzip first load (entry, static imports,play.json,art.cover); lazy-import optional modules afterready(). - Cover (
PLAY-S007): PNG, JPEG or WebP, ≥1200 px on the short side, ≤500 KiB, untitled (titled: false). - Self-contained (
PLAY-S102–S103): bundle all dependencies, use relative imports, load own files withnew URL('./art/star.png', import.meta.url). Keep all content appropriate for fans, including minors (bundles are public and playable signed out).
Attribution, Episodes, sharing and telemetry (`PLAY-M001`)
sources(≤64): for bundled copies of Story pictures or member uploads, record{ file, asset_id, source_sha256, source: "studio" | "publishing" | "upload" }.episodes(≤3): link the game to Story Episodes with{ part, why: "origin" | "continue" }.share.post(≤120, one line): placeholders{verdict},{score},{unit},{stat:<id>},{title},{link}(at most once) and{worn}(1.7+).telemetry.events(1.16, ≤16): up to 4 closedenum(2–16 values),int(min..max) orboolfields per event — no free text. Lifecycle telemetry is automatic.- Type your mount with
Mount<Ids>(using generatedplay.gen.d.ts) orPlayHostAt<Minor, Ids>for older minors.
Expanded field shapes (`PLAY-M001`)
`setting` (up to 6, 1.17)
{ id, label (≤24), note? (≤60), kind: "toggle", default: boolean } or { ..., kind: "choice", options: [{ id, label (≤16) }] (2–6), default: optionId }. No audience or board words.
{ "id": "speed", "label": "Speed", "note": "Next run.", "kind": "choice",
"options": [{ "id": "calm", "label": "Calm" }, { "id": "fast", "label": "Fast" }], "default": "calm" }`idKey` (keys inside `input.actions[].keys`)
A KeyboardEvent.code string matching /^[A-Z][A-Za-z0-9]{1,19}$/. Never Escape, KeyP, KeyM or KeyF.
{ "id": "jump", "label": "Jump", "keys": ["Space", "ArrowUp", "KeyW"], "pad": true }`cell` (sprite-sheet crop on wearable `still`, 1.17)
Four integers [x, y, w, h] with x, y >= 0 and w, h >= 1, in pixels inside still (must fit image bounds).
{ "id": "gold", "title": "Gold Cat", "wear": true, "still": "art/sheet.png", "cell": [0, 0, 256, 320] }`earn` (up to 16, 1.10+ — registered house verifiers only, refused in bundles)
{ id, kind: "keepsake" | "achievement", title (≤40), line (≤90), art? (required for keepsake), wear?, wearLabel?, moves?, type?, still?, cell?, layer?, section?, when: { variant?, score?, outcome?, stats?: { [statId]: { min?, max? } } } }.
{ "id": "crown", "kind": "keepsake", "wear": true, "title": "Crown", "line": "Hit 500.",
"art": "art/crown.png", "when": { "variant": "ranked", "score": 500 } }Publishing
Run play pack to build .play/<id>.zip and print bundle_sha. Bind the show in Studio Publishing (or stage_creator_game on the Publishing MCP), play the preview, and approve that exact bundle_sha.
Mount, run and end
Every Play experience exports mount(stage, host) and follows one lifecycle so pause, remount, saves and result cards work cleanly.
Mount, ready and cleanup (`PLAY-L001`, `PLAY-L002`, `PLAY-L003`, `PLAY-L006`)
- Subscribe to
host.on('start', run => ...)before callinghost.ready(). - Call
host.ready()once when your first frame is drawn, within 3 s (PLAY-L003; a 15 s stall failsPLAY-L001; calling it twice failsPLAY-L002). - Return a cleanup function that removes DOM, listeners, audio nodes and WebGL contexts (
PLAY-L006verifies cleanup and a clean second mount). - From 1.8, direct games may also export
prepareFront(stage, viewport, reducedMotion, signal, report), which runs after the Front paints and beforemount.
export function mount(stage, host) {
const canvas = document.createElement('canvas')
canvas.tabIndex = 0
stage.append(canvas)
const offStart = host.on('start', run => {
reset(run.seed, run.variant ?? 'classic', run.resume)
canvas.focus({ preventScroll: true })
})
host.ready()
return () => { offStart(); canvas.remove() }
}Start, seed and variant (`PLAY-Q006`, `PLAY-S112`, `PLAY-L009`, `PLAY-L007`)
- On every
start(Play again included): reset state, read settings, update HUD chips, and focus your input element (focus({ preventScroll: true })) so keys arrive immediately. - Derive all chance from
run.seed(PLAY-Q006). With"seeded": true,Math.random,Date.nowandcrypto.getRandomValuesare refused (PLAY-S112) andplay checkreplays the round to verify deterministic output (PLAY-L009). run.variantcan benull(single-variant games and X-window runs): never build a record or save id directly from it. Readrun.resume(Continue),run.best,run.via,run.stepandrun.arrival.- Call
host.track(name, fields?)(1.16) on discrete gameplay beats declared intelemetry.events(rate-limited to 2/s burst 5, 30/run, 100/visit; bursts failPLAY-L007).
Clock and pause (`PLAY-S106`, `PLAY-L004`, `PLAY-R007`)
- Drive animation with
host.clock.frame((dt, now) => ...)(dtin ms, capped at 100) and timers withhost.clock.after(ms, fn). Never callrequestAnimationFrame,setTimeout,setIntervalor listen forvisibilitychange/blur/pagehide/fullscreenchange(PLAY-S106). - Both clock helpers stop automatically during pause (
PLAY-L004). Listen tohost.on('pause', why)('fan' | 'hidden' | 'sheet' | 'resize' | 'leaving') to save synchronously whenwhy === 'hidden' || why === 'leaving'. Callhost.requestPause()if a GL context is lost.
Finishing a run (`PLAY-R001`, `PLAY-R002`, `PLAY-R003`, `PLAY-L005`)
- Call
run.finish({ outcome, verdict, score, stats })once during an active run (PLAY-R002,PLAY-L005). finish({ stats })accepts only ids listed inresult— passing ahud-only id throwsPLAY-R001. Supply an integerscoreinscoring.min..max(PLAY-R003).- Stop your round logic at your own
finish. Catch the promise and pass errors tohost.report(err); callhost.fail('broken')only if unrecoverable. The promise resolves once the result card is up.
The end of a round (play 1.18: `linger`, `resultArea`, `showResult`, `PLAY-Q028`)
The new end follows the minor your play.json declares, not the kit you build with.
run.finish(result, { linger: true })holds the result card so your closing moment plays. Your stage stays live and visible, andhost.clockkeeps running.host.on('resultArea', area => ...)says where the card will rest:area.safehas the shape ofviewport.safe, each side at least as large. Compose your closing shot once, inside the stage minusarea.safe; if that space is smaller than your subject, keep your play shot.viewport.safenever includes the card, so never pad your own UI for it.run.showResult()says your moment is done: the card rises. Call it within 3000 ms; at the ceiling the card rises anyway andplay checkwarnsPLAY-Q028. The fan's Pause, P, Escape or Enter, a hidden page, a size change,requestPauseor a failure ends a linger early; thefinishpromise tells you.- Without
lingerthe card rises at once. A crash after yourfinishis reported but never costs the fan the result.
function end(run, outcome, verdict, score, stats) {
if (ended) return
ended = true; endRun = run; endAt = host.clock.now()
host.input.pad.show(false)
playEndCue()
run.finish({ outcome, verdict, score, stats }, { linger: true })
.then(() => { shown = true }).catch(err => host.report(err))
}
host.clock.frame(() => { // keeps running during the linger
if (ended && !shown && !called && host.clock.now() - endAt >= 600) { called = true; endRun.showResult() }
draw()
})What a fan sees at the end
- A published bundle runs in its own frame. During the linger the fan sees your stage. When the card rises, the platform hides your frame and shows your cover art under the card; nothing you draw after that is seen. The platform keeps only a small thumbnail of your frame at
showResult(atfinishwithoutlinger), which stands for the run on the sign-in step. The frame's clock stops once the card is shown. play devandplay checkrun your game in the same page: the stage stays visible under the card,host.clockruns until the card rests, and a resize while the card is up sends a newresultArea(re-frame at once, no animation). Thecanvastemplate shows the whole pattern.- A manifest below 1.18:
finishstopshost.clock, and in the kit's samples the platform sends oneviewportchange with the card folded intosafewhen the card rests. Settle your camera once on it.
Stage, layout and input
Draw only inside the stage element you are given. Never draw exit, home, profile, Episode or save-status controls; the platform draws them.
Scaled stage and size classes (`PLAY-V001`, `PLAY-Q008`)
- Declare
stage.design(240–1280 px; start at[300, 400]),stage.aspect(0.4–2.4; omitting warnsPLAY-Q008) and optionalstage.orientation. - The shell scales your stage (
0.6to1) and mirrorsdata-sizeand--play-safe-*on it. Size canvases usingviewport.dpr(already includesscale, capped at 2). - Read
host.viewport.sizeClass:tinykeeps the Poster (never mounts; X links out),shortis shallow landscape (side controls),regularwide desktop/tablet,portraittall stack,compactsquare/other. Sizesps,pe,pa,pp,dtmust play (PLAY-V001).
Safe area, geometry and CSS (`PLAY-V002`, `PLAY-V003`, `PLAY-S110`, `PLAY-Q019`)
- Background art may fill
viewport.width × viewport.height; keep all text and interactive controls insideviewport.safe(PLAY-V002). - After scaling: hit targets ≥44 CSS px coarse / ≥32 CSS px fine, ≥8 CSS px gap between controls, ≥11 CSS px text (
PLAY-V003). Divide CSS minimums byviewport.scaleonhost.on('viewport', fn). - Scope CSS to your stage root and use container or stage units — never
body,html,:root,*orvw/vh(PLAY-S110). Guard:hoverinside@media (hover:hover) and (pointer:fine)(PLAY-Q019). - Map pointer coordinates through
el.getBoundingClientRect()and calle.preventDefault()on canvas press/move.
let view = host.viewport
host.on('viewport', v => { view = v; host.input.pad.show(v.pointer === 'coarse') })
const padGap = () => (view.pointer === 'coarse' ? 80 : 0) / view.scale
canvas.addEventListener('pointerdown', e => {
e.preventDefault()
const r = canvas.getBoundingClientRect()
const x = (e.clientX - r.left) * (view.width / r.width)
const y = (e.clientY - r.top) * (view.height / r.height)
handleTap(x, y, view.safe.bottom + padGap())
})Actions, pad, stick and press (`PLAY-M001`, `PLAY-Q020`)
- Declare up to 12
input.actions(id,label≤16 chars, 1–4keysasKeyboardEvent.code, optionalpad: trueon ≤3 actions). Never bind or swallowEscape,KeyP,KeyM,KeyF(PLAY-M001,PLAY-Q020). - With
pad: true,host.input.pad.show(true)draws round 64 px buttons at the stage's foot. Up to 1.18viewport.safedoes not include them, so keep80 / viewport.scalestage px clear abovesafe.bottomwhile shown. - Add
input.stick: trueto readhost.input.pad.stick(x,yin-1..1); callhost.input.pad.cooldown(id, rem, dur)for cooldown arcs. - Stage buttons get platform press feedback automatically (
data-press="down"). Usehost.input.act(el, { busy, fail? }, run)(1.15) for non-money async actions (slow text at 1.5 s, aborts at 10 s).
"input": { "stick": false, "actions": [
{ "id": "left", "label": "Left", "keys": ["ArrowLeft", "KeyA"], "pad": true },
{ "id": "right", "label": "Right", "keys": ["ArrowRight", "KeyD"], "pad": true }
] }Stage consumer kit (`fk-*` and `--fk-*`)
| Class / token | What it looks like | When to use it |
|---|---|---|
.fk-pill + variant | 52 px (44 px .sm) rounded pill; pair with .tonal, .her, .ours or .soft (bare has no fill) | Primary or secondary stage buttons |
.fk-chip (+ .tonal) | 24 px rounded badge on dark glass | Compact state tags or labels |
.fk-disc (+ .raised) | 44×44 px circular icon button on glass | Compact icon controls |
.fk-row (.lead, .tx, .val) | ≥60 px hairline row with lead slot, copy and tabular value | Stage lists, non-wearable pickers |
.fk-kv | 3-column bordered stat strip (small label over tabular b) | Compact multi-stat stage strips |
.fk-t-<role> | Archivo type scale (display, title, heading, label, body, meta, micro, figure) | Consistent stage typography |
--fk-* tokens | Theme-mapped ground, sheet, ink, accent fill, hit size and radii (--fk-ground, --fk-ink, --fk-fill, --fk-hit, --fk-r-*) | Custom stage DOM matching the show |
Testing on a phone
play dev binds 127.0.0.1 only on a fresh port each run — open the exact 127.0.0.1 origin it prints (localhost is refused). Use play shots to check pp, pl and dt PNGs in ~10 s; X in-app phone sizes are checked in play check (docs/concepts/quality-and-testing.md).
Next (play 1.19): the platform draws more on-stage UI pieces and the safe area covers the touch pad.
Modes, start and settings
One press on the Front plays the first free mode. Declare modes and settings in play.json so the platform draws the mode row and Settings sheet instead of a pre-play menu.
Modes (`variants`, `PLAY-M001`, `PLAY-Q007`)
- Declare up to 8
variants(id,title, optionalblurb≤48,step≤16,stars,episode,unlock). - Fewer than 2 variants raises
PLAY-Q007. - The first variant (
variants[0]) must be free (variants[0].unlockis refused byPLAY-M001). Bundles cannot setranked: true(PLAY-M001). - Always handle
run.variant === null(single-variant games and X-window runs).
Start and home (`start`, `PLAY-M001`)
start.label(≤24) sets the Play button words;start.howTo(≤3 lines, ≤80 chars each, single-line strings) fills the Front and pause's How to play.- Default
start.modeis"direct". Start new games in"direct"mode and use platformstoreandsettings. - Legacy
"lobby"mode requiresvariantsand supportsstart.homeLabel(≤24),start.returnHome(1.6),host.on('lobby', fn),host.requestStart({ variant, step? })andhost.lobbyClock(1.12).
"start": { "label": "Play", "howTo": ["Tap or use Left/Right to catch fish.", "Dodge falling pots."] },
"variants": [
{ "id": "classic", "title": "Classic", "blurb": "40 s timed run" },
{ "id": "rush", "title": "Rush", "blurb": "25 s, faster drops" }
]Settings (`settings`, 1.17, `PLAY-M001`, `PLAY-R001`, `PLAY-Q022`)
- Declare up to 6 rows in
settings; the platform renders them in the Settings sheet. - Put difficulty, pace, handedness or control preferences here — never draw a pre-play difficulty dialog or modal on the stage (
PLAY-Q022). - Two kinds:
toggle:{ id, label (≤24), note? (≤60), kind: "toggle", default: boolean }.choice:{ id, label, note?, kind: "choice", options: [{ id, label (≤16) }] (2–6), default: optionId }.
- Copy rule (
PLAY-M001):label,noteandoptions[].labelcannot contain audience or board words (fan,player,rank,leaderboard,standings,podium,1st place,place,position). - Read
host.settings.get(id)on everystart(an undeclared id throwsPLAY-R001), and subscribe withhost.on('settings', values => ...)if a setting can change mid-session.
"settings": [
{ "id": "speed", "kind": "choice", "label": "Pace", "note": "Applies next run.",
"options": [{ "id": "calm", "label": "Calm" }, { "id": "quick", "label": "Quick" }], "default": "calm" },
{ "id": "hints", "kind": "toggle", "label": "Show cues", "default": true }
]let pace = host.settings.get('speed')
let hints = host.settings.get('hints')
host.on('settings', values => { pace = values.speed; hints = values.hints })
host.on('start', run => {
const mode = run.variant ?? 'classic'
startRound(mode, pace === 'quick' ? 1.25 : 1, Boolean(hints))
})Scoring, stats and prizes
Declare scores, chips, result stats, outcomes and verdicts in play.json so the shell draws the HUD and result card consistently.
Scoring (`PLAY-M001`, `PLAY-R003`)
- SDK bundles return personal scores only: set
"verifier": { "kind": "none" }and omitvariants[].ranked. Public leaderboards require a registered house verifier (only five exist:loft,rhythm,court,descent,keynote). scoringdeclaresunit,order("asc" | "desc"), integermin..max(min <= max), positive integerrules, and optionalstars: [s1, s2, s3](three strictly improving integers insidemin..max).- Every
run.finishin a scored game must pass an integerscoreinsidemin..max(PLAY-R003).
Stats, HUD and result (`PLAY-M001`, `PLAY-R001`, `PLAY-Q007`, `PLAY-Q009`)
- Declare up to 8
stats:{ id, label (≤16), format?: "int" | "seconds" | "label", labels?: [2..16 labels], of?: positiveInt }. format: "label"(1.17) displays an integer stat index as a short word fromlabels. Neitherlabelnorlabelsmay use audience/board words (PLAY-M001).hud(≤4): chips shown during play. The platform shows the first 3 stats that have a non-null value; update them withhost.hud.set(values, { tone })(passnullto hide a chip;tone: 'warn'highlights urgency).result(≤8): the first 3 appear inline on the result card and the rest in All stats.run.finish({ stats })accepts only ids listed inresult— ahud-only id throwsPLAY-R001. Report each declaredresultstat in at least one run (PLAY-Q009).
"scoring": { "unit": "fish", "order": "desc", "min": 0, "max": 999, "rules": 1,
"stars": [8, 18, 30], "verifier": { "kind": "none" } },
"stats": [
{ "id": "score", "label": "Fish" },
{ "id": "hits", "label": "Pots", "of": 3 },
{ "id": "best-streak", "label": "Best streak" },
{ "id": "time", "label": "Time", "format": "seconds" }
],
"hud": ["score", "hits"],
"result": ["best-streak", "time"]Outcomes, verdicts and stars (`PLAY-M001`, `PLAY-R010`, `PLAY-Q001`, `PLAY-Q007`, `PLAY-Q011`)
- Declare 1–24
outcomes(id,title≤40). Name themwinandlossso the idle bot classifies the run automatically (PLAY-Q001). - Declare up to 16
verdicts(id,headline≤40,line≤90, optionaltip≤80). Missing verdicts or stats raisesPLAY-Q007. - Stars (
PLAY-R010,PLAY-Q011): use manifeststarsthresholds (scoring.starsorvariants[].stars) OR passstars(0–3) andtoNextStar(>0 when<3) inrun.finish, never both (PLAY-R010). Setstars[0]above idle luck andstars[2]above random noise (PLAY-Q011).
Prizes in a creator bundle (`PLAY-M001`, `PLAY-R001`)
- A creator bundle cannot declare
earns(1.10+, up to 16 keepsakes/achievements): earns require a registered server verifier (PLAY-M001). - A bundle's prizes are stars, a verdict and an optional
recordsset kept on the fan's device (whichshare.keepsakecan name from 1.7; never an entitlement and never sold). - From 1.12,
Result.worn(optional) must be a declared unlock or wearable earn (PLAY-R001).
host.hud.set({ score: caught, hits: pots }, { tone: { hits: pots >= 2 ? 'warn' : null } })
if (caught >= 20) host.records.add('trophies', 'master-angler')
run.finish({
outcome: pots >= 3 ? 'loss' : 'win',
verdict: pots >= 3 ? 'bonked' : 'feast',
score: caught,
stats: { 'best-streak': bestStreak, time: Math.round(elapsed / 1000) },
}).catch(err => host.report(err))Store and unlocks (play 1.17 and later)
Declare store and unlocks in play.json so the platform draws the store, rows, Buy handoff and reveal. Never draw a store, price or Buy button (PLAY-Q025, PLAY-Q027).
Declaring the store and unlocks (`PLAY-M001`, `PLAY-S002`)
store:title(≤24),base: { id?, title, art }, optionalsale(≤24),featured,default("base" | "earned"),figure: { art, size: [w, h] }, and up to 6sections. Withoutsections, items group by state.unlocks(≤16):id,title(≤40), shorttypeword ("Outfit","Level", ≤16),line(≤90), optionalsection,art,wear,still,cell,layer,moves,veil.- Wearables (
wear: true): onlywear: trueunlocks (and wearable keepsake earns) show on the stand and acceptstill,cell([x, y, w, h]intostill) orlayer(transparent PNG matchingstore.figure.size). Today (1.17 and 1.18), a wearable not named by a variant is the only thing a creator can sell. - Non-wearables (omit
wear): shown as a 4:5 card and never worn. Readhost.unlocks.get(id)?.state === 'owned'and let fans pick among owned non-wearables (maps, themes, kits) in your own stage UI.
"store": {
"title": "Wardrobe", "base": { "title": "Classic", "art": "art/base.png" },
"figure": { "art": "art/figure.png", "size": [320, 400] },
"sections": [{ "id": "looks", "title": "Looks" }]
},
"unlocks": [{
"id": "star-cape", "title": "Star Cape", "type": "Outfit", "line": "A bright cape.",
"wear": true, "section": "looks", "art": "art/cape-card.png", "layer": "art/cape-layer.png"
}]Runtime store API (`PLAY-R001`, `PLAY-R013`)
host.store.wornis always a declared id (never null; base defaults to"base").- Subscribe with
host.on('worn', id => ...), callhost.store.wear(id)for base or owned wearables, and open between rounds viahost.store.open({ section?, item?, note? })(PLAY-R013during play;noteis direct-only).
let worn = host.store.worn
host.on('worn', id => { worn = id; draw() })
const hasNightMap = () => host.unlocks.get('night-map')?.state === 'owned'
// The platform draws the store's doors (Front, pause, result). To open it yourself: between rounds only (PLAY-R013 while playing)
host.store.open({ section: 'looks' })Picture budgets (`PLAY-Q023`) and art without an artist
- Store image caps (
PLAY-Q023, warnings; PNG/WebP/JPEG,PLAY-S002):still≤40 KiB and ≤512×640; sprite sheet (still+cell) ≤400 KiB and ≤2048×2048;layer≤80 KiB and ≤768×960;figure≤120 KiB and ≤768×960; all store pictures combined ≤1.5 MiB. - Without an artist, start from the
canvastemplate's store assets or generate clean transparent PNG layers and 4:5 card art within those dimensions.
Locked levels, legacy unlocks and sales (`PLAY-M001`, `PLAY-R011`)
- Bind a paid level with
variants[].unlockon an unranked, non-first variant (variants[0]must be free); the shell gates Play and Mode picks. A creator cannot price a locked level yet, because its files ship to every viewer. - Legacy APIs: read
host.unlocks.list()/get(id)/on('unlocks')(signedIn,reason,revoked,edition/limited). On legacy lobbies (start.mode: "lobby"),host.save.storebeforebuy(id)(PLAY-R011, checkout leaves the page);host.result.action,host.lobbyClock(1.12),veil(hides name/art until owned) andmoves(≤24, ≤4/item) apply there. Release-local unlockartworks from 1.10. - A bundle item sells in coins once its Story sells coins and opens a sale for it in Publishing's Money section; until then its state reads
unavailable. - Reserved for later minors (not in 1.18):
unlocks[].kind,unlocks[].helps,unlocks[].perRun,unlocks[].slot,store.stand,scoring.board,store.count,store.use,PLAY-R014.
Next (play 1.19): store layouts. Levels locked on the server, so creators can sell them, come later.
Saves, records and sound
Use the host for progress, collections and audio so saves carry across sessions and sound obeys mute, volume sliders and pause.
Saves and Continue (`PLAY-R004`, `PLAY-R005`, `PLAY-R009`, `PLAY-L006`, `PLAY-L010`, `PLAY-Q012`, `PLAY-Q013`)
host.save.store(data, options?)stores up to 16 KiB of JSON (PLAY-R004; over 8 KiB warnsPLAY-Q013;nullclears). Pass aplacestring (≤128 chars,PLAY-R005) or{ place?, continue?: { variant?, step? } }to offer Continue on the Front (stepis 1–9999 on a variant declaringstep:PLAY-R009).- Store only at checkpoints (cleared level, choice) and synchronously inside
host.on('pause', why)whenwhy === 'hidden' || why === 'leaving'— never every frame (PLAY-L010) and never only afterfinish(PLAY-Q012). - Read
host.save.read()andrun.resumedefensively: check your own version field and fall back to fresh state (PLAY-L006). Saves stay on the fan's device;host.save.durableisfalsewhen this browser refuses storage (an X card's partition, private mode), and the save then lasts only for this visit. - Pass
next: { variant, step }or{ episode }inrun.finishfor a next-step button (seetemplates/reference/game.js// 1.4:comments).
function loadSave() {
const raw = host.save.read()
return raw && raw.v === 1 && Number.isInteger(raw.level) ? raw : { v: 1, level: 1 }
}
function checkpoint(level, variant) {
host.save.store({ v: 1, level }, { place: 'level-' + level, continue: { variant, step: level } })
}
host.on('pause', why => {
if (why === 'hidden' || why === 'leaving') checkpoint(currentLevel, currentVariant)
})Records (`PLAY-R001`)
- Declare up to 4 grow-only
setrecords (up to 64 items each, id ≤48 chars) for collections like endings found or rare catches. - Call
host.records.add(recordId, itemId)andhost.records.has(recordId, itemId)(undeclared ids throwPLAY-R001). Records stay on the device and are never entitlements.
"records": [{ "id": "trophies", "kind": "set", "label": "Catches", "items": ["gold-koi", "eel"] }]Sound (`PLAY-S107`, `PLAY-L008`, `PLAY-R012`, `PLAY-Q005`, `PLAY-Q021`)
- Create all Web Audio nodes on
host.audio.context— nevernew Audio()ornew AudioContext()(PLAY-S107,PLAY-L008). - Connect sound effects to
host.audio.output(nevercontext.destination,PLAY-S107). Play distinct cues for input, hit, miss and the end (PLAY-Q005warns ifoutputstays silent during a round). - Connect songs, looping beds and declared
audio.channels(≤8) tohost.audio.music(1.13). Continuous audio onoutputfor ≥8 s with Music at 0 warnsPLAY-Q021. - From 1.9, call
host.audio.request(true)inside a fan's tap whenhost.audio.state === 'locked'to lift browser audio locks; muting viarequest(false)requiresaudio.toggle: true(PLAY-R012).
function beep(freq, dur = 0.08) {
const ctx = host.audio.context
if (!ctx || host.audio.state === 'muted') return
const osc = ctx.createOscillator(), gain = ctx.createGain()
osc.frequency.value = freq
gain.gain.setValueAtTime(0.18, ctx.currentTime)
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + dur)
osc.connect(gain).connect(host.audio.output)
osc.start(); osc.stop(ctx.currentTime + dur)
}
canvas.addEventListener('pointerdown', () => {
if (host.audio.state === 'locked') void host.audio.request(true)
beep(520)
})Quality, checks and testing
Run fast checks while iterating and save the full play check for the end.
Tooling, templates and loop
- Requires Node 22+ and Playwright
1.64.0(--browserorPLAY_BROWSER, defaultchromium,webkit). A child folder uses the parent's CLI and Playwright; runplay <command> --helpfor options. play doctorverifies Node, the production shell and browser launch.play newandplay checkemitplay.gen.d.ts(under.play/in Studio's flat folder); type your mount asMount<Ids>orPlayHostAt<Minor, Ids>.- Templates:
canvas(1.18: 2D store, locked level, toggle setting, a lingering end — start here),dom(1.18: HTML/text/cards, an end without linger),reference(Shelf Cat, 1.14 lowest-minor example). - Loop:
play devafterplay.jsonedits (seconds; opens the 14-frame grid to inspect layout, input, theme, motion and pause) →play shotsafter game edits (~10 s; seeded PNGs atpp,pl,dtin.play/shots/) →play checkonce at the end (~11 min alone on a laptop, 20–40 min shared; writes.play/check.jsonand.play/sheet.png) →play pack(.play/<id>.zip+bundle_sha).
What `play check` verifies
- Lifecycle matrix (
findingsblock pass/fail): in Chromium and WebKit across sizes (ps,pe,pa,pp,dt, etc.), checks Poster, input, pause/resume (frames, clock, audio and animations must stop:PLAY-L004), finish (PLAY-L005) and remount with save restore (PLAY-L006). Atpp, also tests leave, sheet pause, Continue and deterministic seeded replay (PLAY-L009). - Bots (Chromium, every variant at
pp; name outcomeswin/loss;qualitywarnings do not block):PLAY-Q001: idle bot won or hit the 60 s clock cap.PLAY-Q011: idle earned ≥1 star or random earned 3 stars.PLAY-Q002: round ran past 50 s of play time (count-in and outro included).PLAY-Q003: no accepted input within 3 s of Play.PLAY-Q004: no canvas pixel change within 150 ms of input.PLAY-Q005: no signal onhost.audio.outputduring the round.
- Other quality warnings:
PLAY-Q006(norun.seedread),PLAY-Q007(<2 variants, or missing verdicts/stats),PLAY-Q008(nostage.aspect),PLAY-Q009(declaredresultstat never reported),PLAY-Q010(1.4 members below 1.4),PLAY-Q012(saves only after finish),PLAY-Q013(save >8 KiB),PLAY-Q019(unguarded:hover),PLAY-Q020(swallowedEscape/P/M/F),PLAY-Q021(≥8 s continuous audio onoutput),PLAY-Q022(stage dialogs/h2/button overlays while playing),PLAY-Q023(store picture over budget),PLAY-Q024–Q027(exits, prices, sign-in, store/payment),PLAY-Q028(a lingering finish reached 3000 ms withoutrun.showResult()).
X windows (`PLAY-Q014`–`Q018`)
Phones open the full page in X's in-app browser (390×664 iPhone, 412×780 Android); desktop uses link cards (564×564, 504×504, registered games only). Read host.surface and host.window (1.14) instead of user-agent strings; fit the stage, honor pause, never draw links out (PLAY-Q017) or debug readouts like fps or 390x664 (PLAY-Q018).
Theme, performance and accessibility
- Fun in 10 s: respond within 3 s, clear feedback within 10 s, 30–50 s rounds, idle loses, seed-driven ramp, ≥2 variants, ≥4 audio cues, show art, untitled cover (
titled: false), uniform scale, one primary gesture across touch/mouse/keyboard, real ending with verdicts and result stats. - Theme: set
theme.accent(#rrggbb) and readhost.theme(--play-ground,--play-ink,--play-accent,reducedMotion). - Performance: ≤1.5 MiB gzip first load (
PLAY-S005) andready()within 3 s under 4× CPU throttling (PLAY-L003). - Accessibility: honor
host.theme.reducedMotion, keep 44/32 px hit targets, 11 px text and 8 px spacing (PLAY-V003), focus your stage input onstart, and setaria-labelon interactive stage controls.
import type { Mount } from '@charactr/play'
import type { Ids } from './play.gen.js'
export const mount: Mount<Ids> = (stage, host) => {
let calm = host.theme.reducedMotion, compact = host.window.fit === 'window'
const offTheme = host.on('theme', t => { calm = t.reducedMotion })
const offWin = host.on('window', w => { compact = w.fit === 'window' })
host.ready()
return () => { offTheme(); offWin() }
}Arcade playbook (play 1.18)
Catch, dodge, tap: one verb, a short round, a score that climbs. Everything on this page is true in play 1.18, the newest minor. A Next line names a coming minor and is never something you can use yet.
The feel
- One verb the player can do in the first second: tap, drag, or steer left and right.
- The round lasts 25 to 45 seconds of play and speeds up as she scores. Standing still loses.
- Every touch answers at once with a sound, a flash, a shake or a haptic. The end lands on a moment she can see: the last catch, or the pot that got her.
Start here
npm install https://character.app/_play/kit/play-kit-1.18.1.tgz
npx play new game-my-arcade --genre arcade # canvas template (Starfall) + this page in AGENTS.md
cd game-my-arcade && npx play dev # validates play.json in seconds and prints http://127.0.0.1:<port>- Example to copy:
examples/game-fish-dash(node_modules/@charactr/play/examples/game-fish-dashin a project:play.jsonand a 150-linegame.js). It adds keys, the touch pad and a choice setting to the canvas template, and ends on a lingering finish. - Don't start from:
reference, which is Shelf Cat at 1.14 and has no store or settings. It stays in the kit as the lowest-minor example. - No arcade engine yet. Engines are not open to creators yet, so a game draws its own stage on a canvas. Next: a remix of a house game on the slicer engine.
The manifest for an arcade game
| Field | What to declare | Why |
|---|---|---|
variants | 2 or 3 modes: classic (a timed round) and rush (shorter and denser). The first one is free and never locked | The platform draws the mode row, and Play starts the first mode with one press. Fewer than 2 modes raises PLAY-Q007 |
stats | score; a lives or misses stat with of: 3; best-streak; time with format: "seconds" | of makes the chip read "Pots 1/3" |
hud | ["score", "hits"] | The platform draws these as chips in the bar while she plays. It shows the first 3 that have a value, although hud allows 4. Never draw a score on your stage |
result | ["best-streak", "time"]. The score is shown anyway | finish({ stats }) accepts only ids listed in result. A hud-only id there fails the run (PLAY-R001) |
outcomes | win and loss. Your own titles go in title | The idle bot reads these ids: other ids land "unclassified" |
verdicts | 2 to 4 short headlines with a line each (feast, bonked, short) | The result card's words. Missing verdicts raise PLAY-Q007 |
scoring | unit, order: "desc", min, max, rules: 1, stars: [a, b, c], verifier: { "kind": "none" } | Bundle scores are personal: no ranked mode and no public board (only registered house games rank) |
input.actions | left and right, each with keys and pad: true | Keys are KeyboardEvent.code values: ArrowLeft, KeyA, Space, Digit1. Escape, KeyP, KeyM and KeyF are the platform's pause, mute and full screen, and are refused (PLAY-M001) |
settings | Up to 6 rows. Use choice (2 to 6 options of up to 16 chars) or toggle | The platform draws them in Settings. Difficulty and controls go here and are never asked before play |
start | label (up to 24 chars) and howTo (up to 3 lines of up to 80) | The Front and the pause sheet's How to play |
x | { "card": false } | Bundles do not run inside the X card |
"input": { "actions": [
{ "id": "left", "label": "Left", "keys": ["ArrowLeft", "KeyA"], "pad": true },
{ "id": "right", "label": "Right", "keys": ["ArrowRight", "KeyD"], "pad": true } ] },
"settings": [ { "id": "speed", "kind": "choice", "label": "Cat speed", "note": "Applies from your next run.",
"options": [ { "id": "calm", "label": "Calm" }, { "id": "quick", "label": "Quick" } ], "default": "calm" } ]Prizes
A creator game cannot award an earn. Earns need a registered score verifier, and only house games have one (play dev says "Earned things need a registered verifier"). An arcade prize is three things:
- Stars, from
scoring.stars. Set the first threshold above what an idle player gets, orPLAY-Q011fires. - A verdict that names the moment ("A feast.").
- A
recordsset, optional: a souvenir kept on this device ("Rare fish caught"). It is never an entitlement and never sold.
Goods and the store
- A creator can sell a wearable: an unlock with
wear: true, itsart(the shop card) and itslayer. The layer is a transparent PNG the size ofstore.figure.size, and the game draws it over its figure. - Copy the two looks in the canvas template, including
host.store.wornandon('worn'). - The platform draws the store, prices, Buy and ownership. The game draws no price, no store and no buy button (
PLAY-Q025andPLAY-Q027). - Picture budgets (
PLAY-Q023, warnings):- a still up to 40 KiB and at most 512×640;
- a layer up to 80 KiB and a figure up to 120 KiB, both at most 768×960;
- all store pictures together up to 1.5 MiB.
- The cover is a bundle rule, not a store one: at least 1200 px on its short side and up to 500 KiB.
- A locked level (
variants[].unlock) can be declared, but a creator cannot price it yet. The level's files ship to every viewer, so only wearables are sellable until levels are served from the server. - Next (play 1.19): store layouts.
The round
Start (host.on('start', run => …), every run, Play again included):
- Reset all state.
- Seed your chance with run.seed. Never use Math.random. PLAY-Q006 warns when no read of the seed is found, and with "seeded": true in play.json, Math.random, Date.now and crypto.getRandomValues are refused (PLAY-S112).
- Read settings with host.settings.get(id).
- Set the chips with host.hud.set({ score: 0, hits: 0 }).
- Show the pad on touch: host.input.pad.show(viewport.pointer === 'coarse').
- Focus your canvas so keys reach it.
- Arm the round's end on play time: host.clock.after(ms, end).
The first ten seconds:
- The first input must be accepted within 3 s of Play (PLAY-Q003). Paint feedback within 150 ms of a press (PLAY-Q004).
- Something worth catching arrives in the first second or two, and the danger ramps slowly.
- Teach by playing. howTo holds the words, so draw no tutorial screen.
Pause: do nothing.
- host.clock.frame and host.clock.after stop while the platform pauses.
- requestAnimationFrame, setTimeout and setInterval are refused (PLAY-S106), so nothing of yours keeps running.
The end:
- Call run.finish exactly once, with outcome, verdict, score and only result stats. Catch its promise and pass errors to host.report.
- Make sure idle loses: let some hazards fall on the player, or use a miss fuse, or PLAY-Q001 fires.
- Keep the round under 50 s of play time, counting any count-in or outro (PLAY-Q002).
- The closing moment (1.18): play one end sound, hide the pad, then call run.finish(result, { linger: true }). The card waits and host.clock keeps running, so play a short closing beat (Fish Dash flashes a ring round the cat for 600 ms), then call run.showResult(). Call it within 3000 ms, or the card rises anyway and play check warns PLAY-Q028. A pause or a hidden page ends the linger early; that is fine.
- Where the card will rest: host.on('resultArea', area => …) gives area.safe. Compose the closing shot inside the stage minus area.safe, or keep your play shot when the free space is smaller than your subject. viewport.safe never grows for the card, so nothing in your layout needs to move.
- What a fan sees: a published bundle runs in its own frame. During the linger she sees your stage; when the card rises, the platform hides your frame and shows your cover art under the card. So design the cover and the closing beat; nothing you draw after the rise is seen.
- In play dev and play check the game runs in the same page, so the stage stays visible under the card and host.clock runs until the card rests. The canvas template settles its figure into the free space with resultArea.
Input on touch and keyboard
- Touch: handle
pointerdownandpointermoveon your own canvas, and callpreventDefault().- The stage is scaled, so map each point through
canvas.getBoundingClientRect(). - Hit areas are at least 44 CSS px on touch and 32 with a mouse. Divide by
viewport.scaleto get stage pixels.
- The stage is scaled, so map each point through
- Keys: declare
input.actionsand listen withhost.input.actions((id, down) => …). You get down and up events, so held keys steer. - The pad: with
pad: true(up to 3 actions), the platform draws round 64 px buttons at the stage's foot.- Up to 1.18 the pad floats over the foot of the stage, inside the safe rect, and
viewport.safedoes not count it. Keep80 / viewport.scalestage px clear abovesafe.bottomwhile it shows. - Next (play 1.19): the safe area covers the pad.
- Up to 1.18 the pad floats over the foot of the stage, inside the safe rect, and
- Keep it fair: every device gets the same rules. A setting may change the speed, but never what a score means.
The three most common mistakes
- A
hud-only stat infinish. You getPLAY-R001"The manifest does not declare this id" atfinish. ThePLAY-L005,PLAY-L007,Q001andQ002that follow are only echoes. Send only ids fromresult. - Timers and chance from the browser.
PLAY-S106(requestAnimationFrame,setTimeout,setInterval, always refused).PLAY-Q006warns when the seed is never read, andPLAY-S112refusesMath.random,Date.nowandcrypto.getRandomValuesonce you declare"seeded": true. Usehost.clockand a generator seeded fromrun.seed, as in the example. - An idle player who survives.
PLAY-Q001, orQ011when idle earns a star. Aim some hazards at the player, end onloss, and setstars[0]above idle luck.
The loop:
1. Run play dev after each play.json edit (seconds).
2. Run play shots after each game edit (about 10 s). It writes poster, first-input, mid-round and result PNGs for phone, landscape and desktop.
3. Run play check once at the end, alone: about 11 to 13 minutes on a laptop (Fish Dash: 628, 670, 753 and 776 s), 20 to 40 minutes while other checks run.
The warnings an arcade game will see
| Code | What it means | The answer |
|---|---|---|
PLAY-Q001 | The idle player won or reached the clock cap | Aim hazards at the player, or use a miss fuse, and end on loss |
PLAY-Q002 | The round ran past 50 s of play time | Shorten the round. A count-in counts |
PLAY-Q003 / Q004 | No accepted input in 3 s; no pixels changed within 150 ms of a press | Focus on start, preventDefault() the press, and paint at once |
PLAY-Q005 | No sound reached host.audio.output in a round | Play cues for input, hit, miss and the end through host.audio.output |
PLAY-Q006 | No read of run.seed was found | Seed your generator from run.seed |
PLAY-Q007 | Fewer than 2 modes, or no verdicts or stats | Declare them |
PLAY-Q011 | The idle bot earned a star, or the random bot earned three | Raise the stars thresholds |
Warnings never block, but a passing check with none is the bar for a playbook example.
What standout means here
- Fruit Ninja: every swipe answers in the same frame with a slice, juice, a sound and a combo word, so the verb itself feels good before any score matters.
- Crossy Road: a near miss is the drama, and Play again is one press. The run that just ended shows why she lost.
- For your game:
- give each catch a rising pitch with the streak;
- give the danger a tell before it lands;
- make the closing beat readable: the last catch, or the pot that got her;
- let the verdict name what happened.
The example and its check
examples/game-fish-dash (node_modules/@charactr/play/examples/game-fish-dash in a project) is a 150-line canvas game with:
- two modes and four stats, of which two are HUD chips;
- win and loss, and three verdicts;
- stars, keys and the touch pad;
- a choice setting;
- "seeded": true, a seeded spawn, idle that loses, and a lingering finish with a 600 ms closing flash.
It has no store: add one from the canvas template. Its cover is the template's Starfall placeholder.
Its last check: on play 1.18 with the lingering end, play check from the kit 1.18.1 source on the production shell, alone on a laptop (Nov 27): passed 26 runs in Chromium and WebKit, 0 findings, 0 warnings in 776 s. The seeded replay matched in both modes in both browsers, so S112 and the replay are exercised, and no PLAY-Q028. On kit 1.17.0 it had passed the same way (628 s, then 753 s once seeded).
Next
- Next (play 1.19): the platform draws more on the stage for you (score gauges, a callout line, pick-one cards), and the safe area covers the pad.
- Later: levels locked on the server, so a creator can sell them; a remix of a house arcade game on the slicer engine, from a pack of art, words and tuning.
Play codes
Generated from CODES in packages/play/src/check/codes.ts (ERROR_CODES blocking findings plus PLAY-Q001–PLAY-Q027 quality warnings).
PLAY-M001
- Kind: finding (blocks check)
- Message: Invalid manifest field or declaration.
- Cause: A field in play.json is missing, malformed, outside its limit, refused in bundle mode, uses an audience/board word, binds a reserved shell key, or uses a member from a newer minor.
- Fix: Correct the reported field in play.json or declare the required play minor.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-M002
- Kind: finding (blocks check)
- Message: Too many files and uploaded pictures for one game.
- Cause: The game exceeds the combined count of bundle files and uploaded pictures allowed for one game.
- Fix: Reduce the number of bundle files or uploaded pictures.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-R001
- Kind: finding (blocks check)
- Message: The manifest does not declare this id or allow it here.
- Cause: A runtime call passed an undeclared id or one not permitted in that slot (such as a hud-only stat in run.finish({ stats }), an undeclared outcome/verdict/record/unlock/earn/setting, or a non-finite stat value).
- Fix: Pass only ids declared for that slot in play.json (for finish.stats, only ids listed in result).
- Page: [concepts/scoring-and-prizes.md](concepts/scoring-and-prizes.md)
PLAY-R002
- Kind: finding (blocks check)
- Message: A run can finish only once, during an active run.
- Cause: run.finish() was called more than once for the same run, while paused, after unmount, or outside an active run.
- Fix: Guard your end path and call run.finish() once during an active run.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-R003
- Kind: finding (blocks check)
- Message: A scored run needs a score within the declared bounds.
- Cause: A scored game called run.finish() without an integer score inside scoring.min through scoring.max (or compatible rules max).
- Fix: Supply an integer score within the declared scoring.min..max range.
- Page: [concepts/scoring-and-prizes.md](concepts/scoring-and-prizes.md)
PLAY-R004
- Kind: finding (blocks check)
- Message: A save must be JSON of at most 16 KiB.
- Cause: host.save.store() received a non-JSON value or serialized JSON larger than 16 KiB.
- Fix: Store plain JSON of at most 16 KiB containing only the state needed to resume.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-R005
- Kind: finding (blocks check)
- Message: The saved place exceeds 128 characters or uses an unsupported character.
- Cause: The place string passed to host.save.store() is longer than 128 characters or contains unsupported characters.
- Fix: Use a short place string of at most 128 safe characters.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-R006
- Kind: finding (blocks check)
- Message: The game sent invalid messages.
- Cause: The isolated stage frame sent malformed, oversized, or rate-limited bridge messages.
- Fix: Use the host API within its documented limits and payloads.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-R007
- Kind: finding (blocks check)
- Message: The game did not pause in time.
- Cause: The game blocked the main thread or failed to acknowledge a host pause before the pause deadline.
- Fix: Keep frame work and pause handlers fast and synchronous.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-R008
- Kind: finding (blocks check)
- Message: The game could not connect to the player.
- Cause: The game stage failed to complete the handshake with the Play host.
- Fix: Export mount(stage, host) without blocking module evaluation or breaking host messaging.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-L001
- Kind: finding (blocks check)
- Message: The experience made no load progress for 15 seconds before it called ready().
- Cause: The experience made no load progress for 15 seconds before calling host.ready().
- Fix: Draw the first frame and call host.ready().
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-L002
- Kind: finding (blocks check)
- Message: The experience called ready() twice.
- Cause: host.ready() was called more than once during a single mount.
- Fix: Call host.ready() only once per mount.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-S001
- Kind: finding (blocks check)
- Message: Invalid bundle path.
- Cause: A bundle file path contains uppercase letters, disallowed characters, empty/dot segments, more than 8 segments, or more than 200 characters.
- Fix: Use lowercase relative paths up to eight segments and 200 characters.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S002
- Kind: finding (blocks check)
- Message: Unsupported bundle file type.
- Cause: A bundle contains a file extension outside BUNDLE_TYPES or a store picture whose bytes are not PNG, JPEG or WebP.
- Fix: Remove this file or convert it to a supported format (PNG, JPEG or WebP for store pictures).
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S003
- Kind: finding (blocks check)
- Message: A file exceeds 16 MiB.
- Cause: A single file in the bundle is larger than 16 MiB.
- Fix: Split or compress the file.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S004
- Kind: finding (blocks check)
- Message: The bundle exceeds 32 MiB or 400 files.
- Cause: The uncompressed bundle exceeds 32 MiB in total size or 400 files.
- Fix: Reduce total bytes or file count.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S005
- Kind: finding (blocks check)
- Message: First load exceeds 1.5 MiB gzip.
- Cause: The gzipped first load (play.json, art.cover, entry and its static imports) exceeds 1.5 MiB.
- Fix: Move nonessential assets or modules behind a dynamic import after ready().
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S006
- Kind: finding (blocks check)
- Message: The entry is missing or does not export mount.
- Cause: The declared entry module is missing from the bundle or does not export mount.
- Fix: Export mount(stage, host) from the entry ES module.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S007
- Kind: finding (blocks check)
- Message: The cover is missing or outside its format, size or dimension limits.
- Cause: The declared art.cover is missing, not PNG/JPEG/WebP, over 500 KiB, or smaller than 1200 px on its short side.
- Fix: Supply a PNG, JPEG or WebP cover up to 500 KiB and at least 1200 px on both sides.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S008
- Kind: finding (blocks check)
- Message: Unusable archive or duplicate path.
- Cause: The archive is unreadable, contains a duplicate or non-regular file entry, or wraps all files in an extra top-level folder.
- Fix: Keep each path once and zip the files directly with play pack.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S009
- Kind: finding (blocks check)
- Message: Declared size, inflation ratio or inflated bytes exceed a cap.
- Cause: A ZIP entry exceeds its declared size, the per-file size cap, or the 200x inflation ratio cap.
- Fix: Repack the original files using play pack.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S010
- Kind: finding (blocks check)
- Message: Missing root play.json.
- Cause: The bundle has no play.json file at its root.
- Fix: Put play.json at the root.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S011
- Kind: finding (blocks check)
- Message: This file is not allowed in an engine pack.
- Cause: An engine pack bundle includes a file type outside the engine accepted media list.
- Fix: Use only the images and audio accepted by the declared engine.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S012
- Kind: finding (blocks check)
- Message: The engine pack is missing or invalid.
- Cause: An engine pack is missing root pack.json or its pack.json fails the engine schema.
- Fix: Put a valid UTF-8 pack.json matching the engine schema at the bundle root.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S101
- Kind: finding (blocks check)
- Message: Invalid JavaScript module.
- Cause: A .js or .mjs file in the bundle failed to parse as a valid UTF-8 ES module.
- Fix: Ship a valid UTF-8 ES module.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S102
- Kind: finding (blocks check)
- Message: An import does not resolve to a bundle file.
- Cause: An import or export specifier does not resolve to an existing file inside the bundle.
- Fix: Bundle dependencies and import existing files with relative module specifiers.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S103
- Kind: finding (blocks check)
- Message: Network access outside bundle files.
- Cause: Game code or CSS accesses external network APIs or non-bundle URLs (fetch, XMLHttpRequest, WebSocket, EventSource, RTCPeerConnection, WebTransport, sendBeacon, external src/href/url).
- Fix: Load only your own files relative to import.meta.url.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S104
- Kind: finding (blocks check)
- Message: Access outside the stage.
- Cause: Game code reaches outside its stage element (parent, top, opener, frames, document.body/head/title/documentElement/defaultView/querySelector/getElementById).
- Fix: Create elements under stage and query your own root.
- Page: [concepts/stage-and-input.md](concepts/stage-and-input.md)
PLAY-S105
- Kind: finding (blocks check)
- Message: Private browser storage or identity access.
- Cause: Game code reads or writes private browser storage or cookies (localStorage, sessionStorage, indexedDB, caches, document.cookie, navigator.storage).
- Fix: Use host.save for progress and host.records for collections.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-S106
- Kind: finding (blocks check)
- Message: The host owns the lifecycle and clock.
- Cause: Game code calls browser timers or lifecycle hooks (requestAnimationFrame, setTimeout, setInterval, visibilitychange, blur, pagehide, fullscreenchange, requestFullscreen, requestPointerLock, orientation.lock).
- Fix: Use host.clock, host.viewport and host pause/resume notifications.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-S107
- Kind: finding (blocks check)
- Message: The host owns audio construction and routing.
- Cause: Game code creates its own audio element or context or connects directly to AudioContext.destination (Audio, AudioContext, OfflineAudioContext, createElement("audio")).
- Fix: Use host.audio.context, host.audio.output for effects, host.audio.music for music and declared host channels.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-S108
- Kind: finding (blocks check)
- Message: Dynamic code, workers or shared memory.
- Cause: Game code uses dynamic code evaluation, workers, service workers, or SharedArrayBuffer (eval, Function, Worker, SharedWorker, serviceWorker, SharedArrayBuffer).
- Fix: Ship ES modules or wasm and run the game on the stage thread.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-S109
- Kind: finding (blocks check)
- Message: Child frames, navigation or browser dialogs.
- Cause: Game code attempts navigation, popups, browser dialogs, or child frames (location, open, alert, confirm, prompt, iframe/frame).
- Fix: Keep interaction inside the stage and leave navigation to the shell.
- Page: [concepts/stage-and-input.md](concepts/stage-and-input.md)
PLAY-S110
- Kind: finding (blocks check)
- Message: A stylesheet reaches beyond the stage or uses viewport units.
- Cause: A stylesheet targets global selectors (body, html, :root, *) or uses viewport units (vw, vh, vmin, vmax, dvh, svh, lvh).
- Fix: Scope selectors to your game root and use container or logical stage units.
- Page: [concepts/stage-and-input.md](concepts/stage-and-input.md)
PLAY-S111
- Kind: finding (blocks check)
- Message: The entry exports a member outside its declared Play surface.
- Cause: The entry module exports identifiers other than mount (and optional prepareFront on direct play 1.8+ games).
- Fix: Expose only mount (and optionally prepareFront) from the entry; keep other exports in internal modules.
- Page: [concepts/manifest.md](concepts/manifest.md)
PLAY-V001
- Kind: finding (blocks check)
- Message: The required page size cannot play.
- Cause: A required page size in SIZE_MATRIX cannot mount the stage with the declared stage.design and stage.aspect.
- Fix: Reduce stage.design or widen stage.aspect so this page size plays.
- Page: [concepts/stage-and-input.md](concepts/stage-and-input.md)
PLAY-V002
- Kind: finding (blocks check)
- Message: Content extends outside the stage or safe area.
- Cause: Rendered art extends outside the stage rect, or rendered text or controls extend outside viewport.safe.
- Fix: Size art from host.viewport and keep text and controls inside viewport.safe.
- Page: [concepts/stage-and-input.md](concepts/stage-and-input.md)
PLAY-V003
- Kind: finding (blocks check)
- Message: Text, hit targets or spacing are too small after scaling.
- Cause: After stage scaling, text is smaller than 11 CSS px, a control is smaller than 44 CSS px (touch) or 32 CSS px (mouse), or two controls are closer than 8 CSS px.
- Fix: Allow 11 CSS px for text, 44 CSS px for touch targets (32 for mouse), and at least 8 CSS px between controls after scaling.
- Page: [concepts/stage-and-input.md](concepts/stage-and-input.md)
PLAY-L003
- Kind: finding (blocks check)
- Message: Ready exceeded the 3 second phone budget.
- Cause: host.ready() took longer than the 3 second phone budget under CPU throttling.
- Fix: Draw a first frame within 3 seconds and defer optional loads.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-L004
- Kind: finding (blocks check)
- Message: Frames, time or sound continued during pause.
- Cause: Animation frames, timers, CSS/Web animations, or audio continued advancing while the host was paused.
- Fix: Drive frames and sound through host.clock and host.audio.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-L005
- Kind: finding (blocks check)
- Message: The run did not produce one valid result.
- Cause: The checked run did not finish once with a valid result (often triggered after an earlier PLAY-R001 or runtime error).
- Fix: Complete one run with declared result ids and a valid score.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-L006
- Kind: finding (blocks check)
- Message: Cleanup or a second mount failed.
- Cause: Mount cleanup left DOM nodes or active subscriptions behind, failed to read its own save on remount, or failed a second mount.
- Fix: Return cleanup, release resources and subscriptions, read saves defensively, and initialize fresh state on mount.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-L007
- Kind: finding (blocks check)
- Message: The game or a required resource failed at runtime.
- Cause: The game threw an uncaught error, triggered a rejected host call, exceeded the host.track rate limit, or failed to load a bundle resource.
- Fix: Fix the reported runtime error, missing resource, or host API misuse.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-L008
- Kind: finding (blocks check)
- Message: The game created an audio context outside the host.
- Cause: The game constructed its own AudioContext instead of using host.audio.context.
- Fix: Build every audio node on host.audio.context.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-R009
- Kind: finding (blocks check)
- Message: A step is a whole number from 1 to 9999 on a variant that declares a step noun.
- Cause: A continue or next step was not an integer from 1 to 9999 or targeted a variant without a declared step noun.
- Fix: Use a whole number from 1 to 9999 on a variant that declares step.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-R010
- Kind: finding (blocks check)
- Message: Stars come from the manifest thresholds or from the result, never both.
- Cause: The game supplied result.stars when the manifest already declares stars thresholds, passed an invalid star count, or passed an invalid toNextStar distance.
- Fix: Use manifest thresholds or supply stars (0 to 3) and a positive integer toNextStar when stars < 3, never both.
- Page: [concepts/scoring-and-prizes.md](concepts/scoring-and-prizes.md)
PLAY-R011
- Kind: finding (blocks check)
- Message: An unlock is bought, or earns are kept, only from the game’s home, one sheet at a time.
- Cause: host.unlocks.buy() or host.earned.keep() was called outside the game home/lobby or while another sheet was already open.
- Fix: Open buy or keep sheets only from the game home, one sheet at a time.
- Page: [concepts/store-and-unlocks.md](concepts/store-and-unlocks.md)
PLAY-R012
- Kind: finding (blocks check)
- Message: Muting from the game needs play.json audio.toggle.
- Cause: host.audio.request(false) was called without declaring audio.toggle: true in play.json.
- Fix: Declare audio.toggle: true in play.json (play 1.9+) or let the platform mute button handle muting.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-R013
- Kind: finding (blocks check)
- Message: The store opens only between rounds.
- Cause: host.store.open() was called while a round was actively playing.
- Fix: Call host.store.open() only between rounds (on the Front, lobby, pause or result).
- Page: [concepts/store-and-unlocks.md](concepts/store-and-unlocks.md)
PLAY-S112
- Kind: finding (blocks check)
- Message: A seeded game takes all chance from run.seed.
- Cause: A seeded game ("seeded": true) reads nondeterministic entropy (Math.random, crypto.getRandomValues, or Date.now).
- Fix: Derive it from run.seed.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-L009
- Kind: finding (blocks check)
- Message: A seeded game gave two results for one seed and the same input.
- Cause: A seeded game ("seeded": true) produced different results or timings across two replays with the same run.seed and input.
- Fix: Take every random choice from run.seed and every time from host.clock.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-L010
- Kind: finding (blocks check)
- Message: Saves are checkpoints, not frames.
- Cause: host.save.store() was called in a burst exceeding the per-second checkpoint limit.
- Fix: Store at a checkpoint: a cleared level, a choice, the pause handler.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-C001
- Kind: finding (blocks check)
- Message: The picture safety check flagged a frame.
- Cause: The automated picture safety check flagged a captured frame from the game.
- Fix: Keep all art and rendered frames appropriate for fans, including minors.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q001
- Kind: warning (does not block)
- Message: The idle round won or reached the clock cap.
- Cause: During the idle bot run (no input), the round finished with a win outcome or ran until the 60 s clock cap.
- Fix: Give each variant a clock or fuse and finish with a loss when the player makes no moves.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q002
- Kind: warning (does not block)
- Message: The round ran past 50 seconds of play time.
- Cause: A bot round exceeded 50 s of play time on host.clock (including any count-in or outro).
- Fix: End the round by 50 seconds on host.clock.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q003
- Kind: warning (does not block)
- Message: No accepted input was observed within three seconds of Play.
- Cause: The random bot did not observe an accepted pointer or keyboard input within 3000 ms of starting the round.
- Fix: Focus the game on start and make the primary action playable immediately.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q004
- Kind: warning (does not block)
- Message: No canvas pixels changed within 150 ms of an input.
- Cause: After a pointer or keyboard input on a canvas stage, no canvas pixel changed within 150 ms.
- Fix: Paint immediate feedback when you receive an input.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q005
- Kind: warning (does not block)
- Message: No signal was observed on host.audio.output during the round.
- Cause: The random bot completed a round without observing any audio signal on host.audio.output.
- Fix: Play your input, hit, miss and result cues through host.audio.output.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-Q006
- Kind: warning (does not block)
- Message: No read of the run seed was detected.
- Cause: Static inspection found no property read or destructuring of seed in any game module.
- Fix: Read run.seed from the start event and derive the level sequence from it.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
PLAY-Q007
- Kind: warning (does not block)
- Message: Missing two variants, verdicts, or stats.
- Cause: play.json declares fewer than two variants, no verdicts, or no stats.
- Fix: Declare at least two variants, verdict lines and stats for the result.
- Page: [concepts/scoring-and-prizes.md](concepts/scoring-and-prizes.md)
PLAY-Q008
- Kind: warning (does not block)
- Message: No stage aspect range is declared.
- Cause: play.json omits stage.aspect.
- Fix: Set stage.aspect and use one uniform scale for the playfield and input mapping.
- Page: [concepts/stage-and-input.md](concepts/stage-and-input.md)
PLAY-Q009
- Kind: warning (does not block)
- Message: A declared result stat was never reported.
- Cause: Across all checked runs that reached a result, at least one id in play.json result was never included in finish.stats.
- Fix: Report the declared result stats or remove the unused ids.
- Page: [concepts/scoring-and-prizes.md](concepts/scoring-and-prizes.md)
PLAY-Q010
- Kind: warning (does not block)
- Message: Used play 1.4 members while declaring an older minor.
- Cause: The game called play 1.4 runtime members (such as save.read, records.has, run.best/via/step, Result.stars/next) while play.json declares below 1.4.
- Fix: Declare play 1.4.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q011
- Kind: warning (does not block)
- Message: The idle round earned a star or the random round earned three stars.
- Cause: The star thresholds awarded at least 1 star to the idle bot or 3 stars to random input.
- Fix: Raise the thresholds: one star should need real play.
- Page: [concepts/scoring-and-prizes.md](concepts/scoring-and-prizes.md)
PLAY-Q012
- Kind: warning (does not block)
- Message: Every checkpoint was stored after finish.
- Cause: The game only called host.save.store() after run.finish() and never saved during play.
- Fix: Store before you finish.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-Q013
- Kind: warning (does not block)
- Message: A checkpoint exceeds half of the 16 KiB save limit.
- Cause: A saved checkpoint serialized to more than 8192 bytes.
- Fix: Keep only the progress needed to resume within the 16 KiB save limit.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-Q014
- Kind: warning (does not block)
- Message: The Front or a shell panel does not fit an X window.
- Cause: In one of the four X windows (564×564, 504×504, 390×664, 412×780), the Front scrolled or had clipped controls, or a panel cut off a control.
- Fix: Keep the title, description and art short enough for a 504 px square. The shell lays out the Front and panels; do not draw your own.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q015
- Kind: warning (does not block)
- Message: Play is not reachable on the Front in an X window.
- Cause: In an X window, the Front Play button was missing, outside the viewport, or covered by another element.
- Fix: Do not draw over the Front or move its Play. If nothing of yours is there, report it: the platform draws this button.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q016
- Kind: warning (does not block)
- Message: The game did not complete the X window walk.
- Cause: In an X window, the game failed to open, a sheet failed to open, or start/pause/resume did not complete.
- Fix: Start on the start event, stop the clock and sound on pause and continue on resume, with input kept inside the stage box.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q017
- Kind: warning (does not block)
- Message: An X card has an unexpected link leaving the card.
- Cause: The game drew a link leaving an X card window (or the card had an unmarked platform exit in the house walk).
- Fix: Do not link out of your game. The platform draws the card's exit, "Open full game".
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q018
- Kind: warning (does not block)
- Message: Debug text is visible in an X window.
- Cause: Visible page text matched a window-size or frame-rate readout (such as "564 × 564" or "fps").
- Fix: Remove size, frame-rate and other debug readouts from anything a fan can see.
- Page: [concepts/quality-and-testing.md](concepts/quality-and-testing.md)
PLAY-Q019
- Kind: warning (does not block)
- Message: A :hover style sticks after a tap on phones.
- Cause: A stylesheet or inline style rule uses :hover outside a @media (hover: hover) guard.
- Fix: Put it inside @media (hover:hover) and (pointer:fine).
- Page: [concepts/stage-and-input.md](concepts/stage-and-input.md)
PLAY-Q020
- Kind: warning (does not block)
- Message: Reserved shell keys did not reach the shell during play.
- Cause: The game swallowed or prevented default on Escape, KeyP, KeyM, or KeyF, or the shell state did not respond to them.
- Fix: Do not bind Escape, KeyP, KeyM or KeyF in your game, and do not call preventDefault or stopPropagation on them.
- Page: [concepts/stage-and-input.md](concepts/stage-and-input.md)
PLAY-Q021
- Kind: warning (does not block)
- Message: The effects bus carried continuous audio with Music at 0 and no input.
- Cause: During the idle round with Music set to 0 and effects at 100, host.audio.output carried continuous audio for at least 8 s.
- Fix: Route music and looping beds to host.audio.music (play 1.13) or declared audio.channels, and keep host.audio.output for sound effects.
- Page: [concepts/saves-records-sound.md](concepts/saves-records-sound.md)
PLAY-Q022
- Kind: warning (does not block)
- Message: The stage holds game-drawn chrome while playing.
- Cause: While state is playing, the stage contained a visible dialog, an <h2> heading, or a positioned overlay with buttons covering over half the stage.
- Fix: Remove menus, dialogs, headings and button overlays from the stage; let the platform draw the Front, pause, Settings and result.
- Page: [platform.md](platform.md)
PLAY-Q023
- Kind: warning (does not block)
- Message: Store pictures exceed a per-kind or total budget.
- Cause: A store sprite sheet, still, layer, or figure exceeded its byte or pixel cap, or all store pictures together exceeded 1.5 MiB.
- Fix: Compress or resize store art, stills, sprite sheets, layers and figure to stay within the store picture budgets.
- Page: [concepts/store-and-unlocks.md](concepts/store-and-unlocks.md)
PLAY-Q024
- Kind: warning (does not block)
- Message: The platform draws every way out of a game. A game can’t leave its frame, so this control does nothing for fans: remove it.
- Cause: Source inspection found navigation, history, window.open, or external <a href="http..."> markup inside game files.
- Fix: Remove the exit or link; the platform draws home, Episodes, the profile and Back from play.json and the page.
- Page: [platform.md](platform.md)
PLAY-Q025
- Kind: warning (does not block)
- Message: The game shows a price in money. The platform draws every price, from the item’s live sale.
- Cause: Source inspection found currency price copy (such as $4.99 or 10 USD) in game source or HTML.
- Fix: Declare the item in play.json unlocks; the store and the Buy sheet show its price.
- Page: [platform.md](platform.md)
PLAY-Q026
- Kind: warning (does not block)
- Message: The game draws its own sign-in. The platform owns sign-in and the fan’s account.
- Cause: Source inspection found sign-in routes, email/password inputs, or sign-in copy inside game files.
- Fix: Remove the sign-in form or link; read host presence and let the platform ask.
- Page: [platform.md](platform.md)
PLAY-Q027
- Kind: warning (does not block)
- Message: The game draws its own store or payment. The platform owns the store and checkout.
- Cause: Source inspection found payment APIs (Stripe, PaymentRequest, ApplePaySession), checkout URLs, or purchase-card UI copy inside game files.
- Fix: Remove the payment UI; declare items in play.json store and unlocks.
- Page: [platform.md](platform.md)
PLAY-Q028
- Kind: warning (does not block)
- Message: A lingering finish reached the 3000 ms ceiling without calling run.showResult().
- Cause: run.finish(result, { linger: true }) held the result card until the LIMITS.lingerMs ceiling raised it, because run.showResult() was never called.
- Fix: Call run.showResult() when your closing animation finishes, within 3000 ms.
- Page: [concepts/run-and-end.md](concepts/run-and-end.md)
Host API reference (`@charactr/play`)
Generated from the emitted types/host.d.ts declarations, comments in packages/play/src/host.ts, arrival minors from packages/play/lock/*.json and packages/play/src/capabilities.ts, and finishStatIds in packages/play/src/manifest.ts.
Finish rule (`finishStatIds`)
- The stat ids
run.finish({ stats })accepts: only the ids listed inplay.jsonresult(neverhud-only ids). - Enforced by
checkResult(apps/character-app/playables/shell/stage.ts) usingfinishStatIds(manifest)(packages/play/src/manifest.ts). Sending an undeclared orhud-only stat throws [PLAY-R001](../codes.md#play-r001) (The manifest does not declare this id or allow it here.).
`PlayHost`
| Member | Type | Since | Notes (from host.ts) |
|---|---|---|---|
host.play | readonly { … } | ≤1.3 | — |
host.play.major | readonly major: 1 | ≤1.3 | — |
host.play.minor | readonly minor: number | ≤1.3 | — |
host.content | readonly content: C | ≤1.3 | engines only: what the engine's route released for this experience; frozen |
host.viewport | readonly viewport: Viewport | ≤1.3 | — |
host.theme | readonly theme: Theme | ≤1.3 | — |
host.surface | readonly surface: HostSurface | 1.14 | 1.14; surface is fixed, 'window' fires on a change |
host.window | readonly window: HostWindow | 1.14 | 1.14; surface is fixed, 'window' fires on a change |
host.ready | ready(): void | ≤1.3 | your first frame is drawn; the Poster lifts. Exactly once |
host.requestPause | requestPause(): void | ≤1.3 | ask for a pause (a lost GL context); answered by 'pause' |
host.requestStart | requestStart(options: { variant: I["variant"]; step?: number; }): void | ≤1.3 (widened 1.5) | — |
host.on('lobby', …) | on(e: "lobby", fn: (selection: { variant: I["variant"] | null; locked: boolean; focus?: I["unlock"]; }) => void): Off | ≤1.3 (widened 1.7) | — |
host.on('start', …) | on(e: "start", fn: (run: Run<I>) => void): Off | ≤1.3 | — |
host.on('pause', …) | on(e: "pause", fn: (why: PauseReason) => void): Off | ≤1.3 | — |
host.on('resume', …) | on(e: "resume", fn: () => void): Off | ≤1.3 | — |
host.on('viewport', …) | on(e: "viewport", fn: (v: Viewport) => void): Off | ≤1.3 | — |
host.on('window', …) | on(e: "window", fn: (w: HostWindow) => void): Off | 1.14 | 1.14 |
host.on('theme', …) | on(e: "theme", fn: (t: Theme) => void): Off | ≤1.3 | — |
host.on('audio', …) | on(e: "audio", fn: (s: AudioState) => void): Off | ≤1.3 | — |
host.on('unlocks', …) | on(e: "unlocks", fn: (all: readonly Unlock<I>[]) => void): Off | 1.5 | — |
host.on('earned', …) | on(e: "earned", fn: (ids: readonly I["earn"][]) => void): Off | 1.10 | — |
host.on('worn', …) | on(e: "worn", fn: (id: I["unlock"] | I["earn"] | I["base"]) => void): Off | 1.17 | — |
host.on('settings', …) | on(e: "settings", fn: (values: Readonly<Record<I["setting"], string | boolean>>) => void): Off | 1.17 | — |
host.on('resultArea', …) | on(e: "resultArea", fn: (area: ResultArea) => void): Off | 1.18 | — |
host.input | readonly { … } | ≤1.3 | — |
host.input.actions | actions(fn: (id: string, down: boolean) => void): Off | ≤1.3 | — |
host.input.act | act(el: HTMLElement, words: { busy: string; fail?: string; }, run: (io: { signal: AbortSignal; }) => Promise<unknown>): Promise<boolean> | 1.15 | 1.15 busy; abort at 10 s |
host.input.pad | readonly { … } | ≤1.3 | — |
host.input.pad.show | show(visible: boolean): void | ≤1.3 | — |
host.input.pad.stick | readonly { … } | ≤1.3 | — |
host.input.pad.stick.x | readonly x: number | ≤1.3 | — |
host.input.pad.stick.y | readonly y: number | ≤1.3 | — |
host.input.pad.cooldown | cooldown(id: string, remaining: number, duration: number): void | ≤1.3 | — |
host.clock | readonly clock: Clock | ≤1.3 | — |
host.lobbyClock | readonly lobbyClock: Clock | 1.12 | Play 1.12. Animates the hero only while the shell's lobby is open and visible. |
host.audio | readonly audio: Audio<I> | ≤1.3 | — |
host.hud | readonly { … } | ≤1.3 | null clears a chip |
host.hud.set | set(values: Partial<Record<I["stat"], number | null>>, options?: { readonly tone?: Partial<Record<I["stat"], Tone | null>>; }): void | ≤1.3 (widened 1.4) | — |
host.haptic | haptic(kind: "tick" | "hit" | "bad"): void | ≤1.3 | — |
host.choices | readonly { … } | ≤1.3 | — |
host.choices.ask | ask(node: I["node"]): void | ≤1.3 | a choice is on screen |
host.choices.choose | choose(node: I["node"], option: I["option"]): void | ≤1.3 | the fan picked |
host.records | readonly { … } | ≤1.3 | a set: "Endings found" |
host.records.add | add(record: I["record"], item: I["item"]): void | ≤1.3 | — |
host.records.has | has(record: I["record"], item: I["item"]): boolean | 1.4 | — |
host.save | readonly { … } | ≤1.3 | 16 KiB of JSON; null clears |
host.save.store | store(data: Json, options?: string | SaveOptions<I>): void | ≤1.3 (widened 1.4) | — |
host.save.read | read(): Json | null | 1.4 | — |
host.save.durable | readonly durable: boolean | 1.4 | — |
host.result | readonly { … } | 1.7 | — |
host.result.action | action(a: { label: string; focus: I["unlock"]; }): void | 1.7 | — |
host.unlocks | readonly { … } | 1.5 | — |
host.unlocks.signedIn | readonly signedIn: boolean | 1.7 | — |
host.unlocks.list | list(): readonly Unlock<I>[] | 1.5 | Read from mount, in manifest order. |
host.unlocks.get | get(id: I["unlock"]): Unlock<I> | 1.5 | An undeclared id throws PLAY-R001. |
host.unlocks.buy | buy(id: I["unlock"]): Promise<UnlockState> | 1.5 | Home only (PLAY-R011); store first, checkout leaves the page. |
host.unlocks.arrival | readonly arrival: I["unlock"] | null | 1.5 | Which unlock this visit came back to wear. |
host.earned | readonly { … } | 1.10 | — |
host.earned.signedIn | readonly signedIn: boolean | 1.10 | — |
host.earned.list | list(): readonly Earned<I>[] | 1.10 | — |
host.earned.has | has(id: I["earn"]): boolean | 1.10 | An undeclared id throws PLAY-R001. |
host.earned.keep | keep(): Promise<boolean> | 1.11 | 1.11. Home only (PLAY-R011): the host's sign-in sheet; true once earns are on her account. |
host.earned.arrival | readonly arrival: I["earn"] | null | 1.11 | 1.11. The earn this home entry came to give (the result card's wear button). |
host.store | readonly { … } | 1.17 | Play 1.17. Platform store (prices, ownership and counts are the host's) and declared settings rows. |
host.store.worn | readonly worn: I["unlock"] | I["earn"] | I["base"] | 1.17 | — |
host.store.open | open(options?: { section?: I["section"]; item?: I["unlock"] | I["earn"]; note?: string; }): void | 1.17 | — |
host.store.wear | wear(id: I["unlock"] | I["earn"] | I["base"]): boolean | 1.17 | — |
host.settings | readonly { … } | 1.17 | — |
host.settings.get | get(id: I["setting"]): string | boolean | 1.17 | — |
host.track | track<K extends keyof T & string>(...args: keyof T[K] extends never ? [ name: K ] : [ name: K, fields?: { readonly [P in keyof T[K]]?: T[K][P]; } ]): void | 1.16 | 1.16 |
host.report | report(error: unknown): void | ≤1.3 | the error beacon; play goes on |
host.fail | fail(reason: "unsupported" | "broken"): void | ≤1.3 | fatal: the platform shows its card and removes you |
`Run`
| Member | Type | Since | Notes (from host.ts) |
|---|---|---|---|
run.id | readonly id: string | ≤1.3 | minted by the host |
run.n | readonly n: number | ≤1.3 | 1 for the first run of this visit |
run.variant | readonly variant: I["variant"] | null | ≤1.3 | — |
run.best | readonly best: number | null | 1.4 | — |
run.via | readonly via: Via | 1.4 | — |
run.step | readonly step: number | null | 1.4 | — |
run.arm | readonly arm: string | ≤1.3 | 'off' unless the surface drew a trial arm for this visit |
run.seed | readonly seed: number | ≤1.3 | uint32: derive all chance from it |
run.ranked | readonly ranked: boolean | ≤1.3 | a verified result is possible for this run |
run.resume | readonly resume: Json | null | ≤1.3 | exactly what you last gave save.store, or null |
run.arrival | readonly arrival: string | null | ≤1.3 | a place string a link carried here, untouched; first run only; it wins over resume |
run.finish | finish(result: Result<I>, options?: FinishOptions): Promise<void> | ≤1.3 (widened 1.18) | — |
run.showResult | showResult(): void | 1.18 | — |
`Result`
| Member | Type | Since | Notes (from host.ts) |
|---|---|---|---|
result.outcome | readonly outcome: I["outcome"] | ≤1.3 | — |
result.score | readonly score?: number | ≤1.3 | an integer inside scoring.min..max; required when play.json has scoring |
result.variant | readonly variant?: I["variant"] | ≤1.3 | a personal renderer fallback can finish under its own declared rules |
result.verdict | readonly verdict?: I["verdict"] | ≤1.3 | which declared headline and line the result card shows |
result.stats | readonly stats?: Partial<Record<I["stat"], number | null>> | ≤1.3 (widened 1.4) | The stat ids run.finish({ stats }) accepts: only the ids listed in play.json result (never hud-only ids). |
result.stars | readonly stars?: 0 | 1 | 2 | 3 | 1.4 | — |
result.toNextStar | readonly toNextStar?: number | 1.4 | — |
result.next | readonly next?: { readonly variant: I["variant"]; readonly step?: number; } | { readonly episode: number; } | 1.4 | — |
result.worn | readonly worn?: I["unlock"] | I["earn"] | 1.7 (widened 1.10, 1.12) | — |
result.earned | readonly earned?: I["earn"][] | 1.10 | A hint while the host awaits the verified finish. |
result.proof | readonly proof?: Json | ≤1.3 | registered verifiers only (the four live games) |
`Clock`
LOCAL. Play time: it stops for every pause. play check runs it in real time; a seeded game is also replayed in fixed 1000/60 ms steps.
| Member | Type | Since | Notes (from host.ts) |
|---|---|---|---|
clock.now | now(): number | ≤1.3 | ms of play time since mount |
clock.frame | frame(fn: (dt: number, now: number) => void): Off | ≤1.3 | once per display frame while playing; dt in ms, at most 100 |
clock.after | after(ms: number, fn: () => void): Off | ≤1.3 | once, after ms of play time; holds across pauses |
`Audio`
LOCAL. One context and two buses, made by the host inside the Play tap. The fan's Settings level each.
| Member | Type | Since | Notes (from host.ts) |
|---|---|---|---|
audio.state | readonly state: AudioState | ≤1.3 | — |
audio.context | readonly context: AudioContext | ≤1.3 | — |
audio.output | readonly output: AudioNode | ≤1.3 | effects: connect sources here, never to destination |
audio.music | readonly music: AudioNode | 1.13 | 1.13. Songs, beds and declared channels |
audio.request | request(on: boolean): Promise<AudioState> | 1.9 | Play 1.9. From a fan's tap in your stage, request(true) lifts a browser lock; request(false) needs audio.toggle (else PLAY-R012). Resolves to the resulting state (unchanged on refusal or without activation); disposal rejects. |
audio.channel | channel(name: I["channel"]): { readonly element: HTMLAudioElement; readonly gain: AudioParam; } | ≤1.3 | One blessed media element per channel declared in play.json audio.channels, routed through its own gain. |
`Viewport`
STATE. Logical CSS px of the stage element you were given. Mirrored on it as data-size and --play-safe-*.
| Member | Type | Since | Notes (from host.ts) |
|---|---|---|---|
viewport.width | readonly width: number | ≤1.3 | the whole stage box: art may fill all of it |
viewport.height | readonly height: number | ≤1.3 | — |
viewport.safe | readonly safe: Insets | ≤1.3 | text and controls stay inside; covers device insets and the platform's control band |
viewport.scale | readonly scale: number | ≤1.3 | 0.6 to 1: under 1 when the frame is smaller than your design size |
viewport.dpr | readonly dpr: number | ≤1.3 | device px per logical px, capped at 2 and including scale: size canvases with it |
viewport.sizeClass | readonly sizeClass: Exclude<SizeClass, "tiny"> | ≤1.3 | nothing is mounted in a tiny frame |
viewport.orientation | readonly orientation: "portrait" | "landscape" | "square" | ≤1.3 | — |
viewport.pointer | readonly pointer: "coarse" | "fine" | ≤1.3 | — |
Supporting types
| Type | Definition | Since | Notes (from host.ts) |
|---|---|---|---|
Off | type Off = () => void | ≤1.3 | — |
Json | type Json = null | boolean | number | string | readonly Json[] | { readonly [key: string]: Json; } | ≤1.3 | — |
Ids | interface Ids { variant: string; outcome: string; verdict: string; stat: string; record: string; item: string; channel: string; node: string; option: string; unlock: string; earn: string; base: string; section: string; setting: string; } | ≤1.3 | Literal ids, generated from play.json into play.gen.d.ts, so a typo fails to compile. |
TrackFieldValue | type TrackFieldValue = string | number | boolean | 1.16 | — |
TrackEvents | type TrackEvents = Record<string, Record<string, TrackFieldValue>> | 1.16 | — |
Mount | type Mount<I extends Ids = Ids, C = unknown, T extends TrackEvents = TrackEvents> = (stage: HTMLElement, host: PlayHost<I, C, T>) => void | Off | Promise<void | Off> | ≤1.3 (widened 1.16) | The required export of an experience. Called once, after the fan's Play tap. Return your cleanup. |
PrepareFront | type PrepareFront = (stage: HTMLElement, viewport: Viewport, reducedMotion: boolean, signal: AbortSignal, report: (error: unknown) => void) => void | Promise<void> | 1.8 | Play 1.8. Optional direct-game entry export, after the Front paints and before mount. |
SizeClass | type SizeClass = "tiny" | "short" | "compact" | "portrait" | "regular" | ≤1.3 | — |
Insets | interface Insets { readonly top: number; readonly right: number; readonly bottom: number; readonly left: number; } | ≤1.3 | — |
ResultArea | interface ResultArea { readonly safe: Insets; } | 1.18 | Where the result card will rest, as stage insets: the same shape as viewport.safe, each side >= it. |
FinishOptions | interface FinishOptions { readonly linger?: boolean; } | 1.18 | true: the card waits for run.showResult() |
HostSurface | type HostSurface = "page" | "card" | "inapp" | 1.14 | Play 1.14. Where the host shows the game: its own page, an X post's card or an in-app browser. Never read the UA. |
HostWindow | interface HostWindow { readonly width: number; readonly height: number; readonly fit: "window" | "full"; } | 1.14 | STATE. Play 1.14. The whole play window in CSS px. fit is 'window' under 600 px high: keep your chrome compact. |
Theme | interface Theme { readonly scheme: "dark" | "light"; readonly ground: string; readonly ink: string; readonly accent: string; readonly reducedMotion: boolean; } | ≤1.3 | STATE. The show's look, read-only. Mirrored on the stage as --play-ground, --play-ink, --play-accent. |
AudioState | type AudioState = "locked" | "muted" | "on" | ≤1.3 | — |
PauseReason | type PauseReason = "fan" | "hidden" | "sheet" | "resize" | "leaving" | ≤1.3 | 'resize' is deprecated and never sent: a resize arrives as 'viewport'. It leaves the type at play@2. |
Tone | type Tone = "warn" | 1.4 | — |
Via | type Via = "start" | "continue" | "again" | "next" | "challenge" | 1.4 | — |
UnlockState | type UnlockState = "owned" | "available" | "pending" | "unavailable" | 1.5 | Owned belongs to this account; available is on sale even to a guest. Never wear pending (awaiting confirmation) or unavailable (not sold here). |
Unlock | interface Unlock<I extends Ids = Ids> { readonly id: I["unlock"]; readonly state: UnlockState; readonly reason?: "closed" | "not-here"; readonly revoked?: "refunded" | "disputed" | "account"; readonly price: string | null; readonly edition?: { readonly number: number; readonly of: number; } | null; readonly limited?: { readonly of: number; readonly soldOut: boolean; }; } | 1.5 | — |
Earned | interface Earned<I extends Ids = Ids> { readonly id: I["earn"]; readonly at: number; readonly verified: true; readonly until?: number; } | 1.10 | Play 1.10. A keepsake or achievement confirmed by server replay. |
SaveOptions | interface SaveOptions<I extends Ids = Ids> { readonly place?: string; readonly continue?: { readonly variant?: I["variant"]; readonly step?: number; }; } | 1.4 | — |
PlayError | `interface PlayError extends Error { readonly code: PLAY-${string}; readonly fix: string; readonly doc: string; }` | ≤1.3 | What the host throws and rejects with. The class itself lives in errors.ts. |
Limits reference
Generated from the exported constants that both the Play SDK checks and the documentation read.
| Constant | Value | Source |
|---|---|---|
LIMITS.hostMinor | 18 | packages/play/src/manifest.ts |
LIMITS.idMin | 2 | packages/play/src/manifest.ts |
LIMITS.idMax | 48 | packages/play/src/manifest.ts |
LIMITS.title | 80 | packages/play/src/manifest.ts |
LIMITS.tagline | 90 | packages/play/src/manifest.ts |
LIMITS.designMin | 240 | packages/play/src/manifest.ts |
LIMITS.designMax | 1280 | packages/play/src/manifest.ts |
LIMITS.aspectMin | 0.4 | packages/play/src/manifest.ts |
LIMITS.aspectMax | 2.4 | packages/play/src/manifest.ts |
LIMITS.startLabel | 24 | packages/play/src/manifest.ts |
LIMITS.howToLines | 3 | packages/play/src/manifest.ts |
LIMITS.howToLine | 80 | packages/play/src/manifest.ts |
LIMITS.channels | 8 | packages/play/src/manifest.ts |
LIMITS.variants | 8 | packages/play/src/manifest.ts |
LIMITS.outcomesMin | 1 | packages/play/src/manifest.ts |
LIMITS.outcomes | 24 | packages/play/src/manifest.ts |
LIMITS.outcomeTitle | 40 | packages/play/src/manifest.ts |
LIMITS.verdicts | 16 | packages/play/src/manifest.ts |
LIMITS.headline | 40 | packages/play/src/manifest.ts |
LIMITS.verdictLine | 90 | packages/play/src/manifest.ts |
LIMITS.stats | 8 | packages/play/src/manifest.ts |
LIMITS.statLabel | 16 | packages/play/src/manifest.ts |
LIMITS.hud | 4 | packages/play/src/manifest.ts |
LIMITS.result | 8 | packages/play/src/manifest.ts |
LIMITS.nodes | 24 | packages/play/src/manifest.ts |
LIMITS.optionsMin | 2 | packages/play/src/manifest.ts |
LIMITS.options | 6 | packages/play/src/manifest.ts |
LIMITS.optionLabel | 60 | packages/play/src/manifest.ts |
LIMITS.blurb | 48 | packages/play/src/manifest.ts |
LIMITS.tip | 80 | packages/play/src/manifest.ts |
LIMITS.stepNoun | 16 | packages/play/src/manifest.ts |
LIMITS.stepMax | 9999 | packages/play/src/manifest.ts |
LIMITS.recordItems | 64 | packages/play/src/manifest.ts |
LIMITS.itemId | 48 | packages/play/src/manifest.ts |
LIMITS.unlocks | 16 | packages/play/src/manifest.ts |
LIMITS.unlockTitle | 40 | packages/play/src/manifest.ts |
LIMITS.unlockType | 16 | packages/play/src/manifest.ts |
LIMITS.unlockLine | 90 | packages/play/src/manifest.ts |
LIMITS.storeSections | 6 | packages/play/src/manifest.ts |
LIMITS.sectionTitle | 24 | packages/play/src/manifest.ts |
LIMITS.settings | 6 | packages/play/src/manifest.ts |
LIMITS.settingLabel | 24 | packages/play/src/manifest.ts |
LIMITS.settingNote | 60 | packages/play/src/manifest.ts |
LIMITS.settingOptionLabel | 16 | packages/play/src/manifest.ts |
LIMITS.records | 4 | packages/play/src/manifest.ts |
LIMITS.episodes | 3 | packages/play/src/manifest.ts |
LIMITS.sources | 64 | packages/play/src/manifest.ts |
LIMITS.sharePost | 120 | packages/play/src/manifest.ts |
LIMITS.earns | 16 | packages/play/src/manifest.ts |
LIMITS.earnTitle | 40 | packages/play/src/manifest.ts |
LIMITS.earnLine | 90 | packages/play/src/manifest.ts |
LIMITS.moves | 24 | packages/play/src/manifest.ts |
LIMITS.moveTitle | 40 | packages/play/src/manifest.ts |
LIMITS.itemMoves | 4 | packages/play/src/manifest.ts |
LIMITS.telemetryEvents | 16 | packages/play/src/manifest.ts |
LIMITS.telemetryFields | 4 | packages/play/src/manifest.ts |
LIMITS.lingerMs | 3000 | packages/play/src/manifest.ts |
INPUT_LIMITS.actions | 12 | packages/play/src/manifest.ts |
INPUT_LIMITS.actionLabel | 16 | packages/play/src/manifest.ts |
INPUT_LIMITS.keys | 4 | packages/play/src/manifest.ts |
INPUT_LIMITS.pad | 3 | packages/play/src/manifest.ts |
HUD_SHOWN | 3 | packages/play/src/manifest.ts |
BUNDLE_LIMITS.zipBytes | 33554432 (32 MiB) | packages/play/src/bundle.ts |
BUNDLE_LIMITS.bytes | 33554432 (32 MiB) | packages/play/src/bundle.ts |
BUNDLE_LIMITS.files | 400 | packages/play/src/bundle.ts |
BUNDLE_LIMITS.fileBytes | 16777216 (16 MiB) | packages/play/src/bundle.ts |
BUNDLE_LIMITS.ratio | 200 | packages/play/src/bundle.ts |
BUNDLE_LIMITS.firstLoadGzip | 1572864 (1.5 MiB) | packages/play/src/bundle.ts |
BUNDLE_LIMITS.coverBytes | 512000 (500 KiB) | packages/play/src/bundle.ts |
BUNDLE_LIMITS.coverShortSide | 1200 px | packages/play/src/bundle.ts |
BUNDLE_LIMITS.pathMax | 200 | packages/play/src/bundle.ts |
BUNDLE_LIMITS.depthMax | 8 | packages/play/src/bundle.ts |
WIRE.message | 16384 (16 KiB) | packages/play/src/wire.ts |
WIRE.save | 24576 (24 KiB) | packages/play/src/wire.ts |
WIRE.savesPerSecond | 2 | packages/play/src/wire.ts |
WIRE.recordsPerSecond | 10 | packages/play/src/wire.ts |
WIRE.buysPerSecond | 1 | packages/play/src/wire.ts |
WIRE.storeOpensPerSecond | 1 | packages/play/src/wire.ts |
WIRE.wearsPerSecond | 4 | packages/play/src/wire.ts |
WIRE.tracksPerSecond | 2 | packages/play/src/wire.ts |
WIRE.tracksPerRun | 30 | packages/play/src/wire.ts |
WIRE.tracksPerVisit | 100 | packages/play/src/wire.ts |
WIRE.trackBytes | 256 (256 B) | packages/play/src/wire.ts |
STORE_PICTURE_BUDGETS.spriteSheet | 400 KiB, max 2048×2048 px | packages/play/src/check/quality.ts |
STORE_PICTURE_BUDGETS.still | 40 KiB, max 512×640 px | packages/play/src/check/quality.ts |
STORE_PICTURE_BUDGETS.layer | 80 KiB, max 768×960 px | packages/play/src/check/quality.ts |
STORE_PICTURE_BUDGETS.figure | 120 KiB, max 768×960 px | packages/play/src/check/quality.ts |
STORE_PICTURE_BUDGETS.totalBytes | 1572864 (1.5 MiB) | packages/play/src/check/quality.ts |
MUSIC_BUS_LIMIT_MS | 8000 ms (8 s) | packages/play/src/check/quality.ts |
LAYOUT_RULES.touchTarget | 44 CSS px | packages/play/src/check/layout.ts |
LAYOUT_RULES.mouseTarget | 32 CSS px | packages/play/src/check/layout.ts |
LAYOUT_RULES.minText | 11 CSS px | packages/play/src/check/layout.ts |
LAYOUT_RULES.gap | 8 CSS px | packages/play/src/check/layout.ts |
BOT_RULES.firstInputMs | 3000 ms (3 s) | packages/play/src/check/bots.ts |
BOT_RULES.feedbackMs | 150 ms | packages/play/src/check/bots.ts |
BOT_RULES.roundMs | 50000 ms (50 s) | packages/play/src/check/bots.ts |
BOT_RULES.capMs | 60000 ms (60 s) | packages/play/src/check/bots.ts |
BOT_RULES.winOutcomes | win, won, victory, success | packages/play/src/check/bots.ts |
BOT_RULES.lossOutcomes | loss, lose, lost, defeat, failed, failure | packages/play/src/check/bots.ts |
READY_BUDGET_MS | 3000 ms (3 s) | packages/play/src/check/budget.ts |
LOAD_STALL_MS | 15000 ms (15 s) | apps/character-app/playables/shell/load.ts |
TELEMETRY_ENUM_MIN | 2 | packages/play/src/telemetry.ts |
TELEMETRY_ENUM_MAX | 16 | packages/play/src/telemetry.ts |
TELEMETRY_INT_MIN | -1000000 | packages/play/src/telemetry.ts |
TELEMETRY_INT_MAX | 1000000 | packages/play/src/telemetry.ts |
RESERVED_SHELL_KEYS | Escape, KeyP, KeyM, KeyF | packages/play/src/check/lifecycle.ts |
Manifest reference (`play.json`)
Generated from the emitted PlayManifest declaration (types/manifest.d.ts), LIMITS, INPUT_LIMITS, HUD_SHOWN, BUNDLE_LIMITS, TELEMETRY_*, and BUNDLE_REFUSED. All named shapes (setting, idKey, earn, cell, figureSize, moves, telemetry, choices) are expanded in place by the TypeScript compiler. Hand-written JSON examples live in the linked concept pages.
Bundle and kind refusals (`BUNDLE_REFUSED`)
| Field | Scope | Rule | Fix |
|---|---|---|---|
art.scene | bundle | Bundles use the cover in play 1.4. | Remove art.scene. |
kind | bundle | Studio bundles are games. | Use kind game. |
id | bundle | Creator ids use the game namespace. | Prefix the slug with game-. |
x.card | bundle | Bundles have no X card in play@1. | Set x.card to false. |
scoring.verifier | bundle | Bundle scores are personal. | Set verifier.kind to none. |
variants[].ranked | bundle | Bundles cannot declare ranked variants. | Omit ranked. |
choices | schema | Choices belong to stories. | Remove choices from this game. |
share.post | schema | A post template belongs to games. | Remove share.post from this story. |
Field index
| Field | Required | Bundle | Example page |
|---|---|---|---|
play | yes | Allowed | [concepts/manifest.md](../concepts/manifest.md) |
id | yes | Refused in a bundle (Creator ids use the game namespace.) | [concepts/manifest.md](../concepts/manifest.md) |
title | yes | Allowed | [concepts/manifest.md](../concepts/manifest.md) |
tagline | no | Allowed | [concepts/manifest.md](../concepts/manifest.md) |
genre | no | Allowed | [concepts/manifest.md](../concepts/manifest.md) |
world | no | Allowed | [concepts/manifest.md](../concepts/manifest.md) |
seeded | no | Allowed | [concepts/run-and-end.md](../concepts/run-and-end.md) |
art | yes | art.scene refused in a bundle (Bundles use the cover in play 1.4.) | [concepts/manifest.md](../concepts/manifest.md) |
stage | yes | Allowed | [concepts/stage-and-input.md](../concepts/stage-and-input.md) |
x | yes | x.card refused in a bundle (Bundles have no X card in play@1.) | [concepts/quality-and-testing.md](../concepts/quality-and-testing.md) |
theme | no | Allowed | [concepts/quality-and-testing.md](../concepts/quality-and-testing.md) |
input | no | Allowed | [concepts/stage-and-input.md](../concepts/stage-and-input.md) |
start | no | Allowed | [concepts/modes-and-settings.md](../concepts/modes-and-settings.md) |
audio | yes | Allowed | [concepts/saves-records-sound.md](../concepts/saves-records-sound.md) |
variants | no | variants[].ranked refused in a bundle (Bundles cannot declare ranked variants.) | [concepts/modes-and-settings.md](../concepts/modes-and-settings.md) |
outcomes | yes | Allowed | [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md) |
verdicts | no | Allowed | [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md) |
stats | no | Allowed | [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md) |
hud | no | Allowed | [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md) |
result | no | Allowed | [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md) |
store | no | Allowed | [concepts/store-and-unlocks.md](../concepts/store-and-unlocks.md) |
settings | no | Allowed | [concepts/modes-and-settings.md](../concepts/modes-and-settings.md) |
unlocks | no | Allowed | [concepts/store-and-unlocks.md](../concepts/store-and-unlocks.md) |
earns | no | Allowed | [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md) |
moves | no | Allowed | [concepts/store-and-unlocks.md](../concepts/store-and-unlocks.md) |
records | no | Allowed | [concepts/saves-records-sound.md](../concepts/saves-records-sound.md) |
episodes | no | Allowed | [concepts/manifest.md](../concepts/manifest.md) |
sources | no | Allowed | [concepts/manifest.md](../concepts/manifest.md) |
share | no | Allowed in a bundle (share.post refused on stories: A post template belongs to games.) | [concepts/manifest.md](../concepts/manifest.md) |
telemetry | no | Allowed | [concepts/manifest.md](../concepts/manifest.md) |
entry | one of entry or engine | Allowed | [concepts/manifest.md](../concepts/manifest.md) |
engine | one of entry or engine | Allowed | [formats.md](../formats.md) |
kind | yes | Refused in a bundle (Studio bundles are games.) | [concepts/manifest.md](../concepts/manifest.md) |
scoring | no (kind: "game" only) | scoring.verifier refused in a bundle (Bundle scores are personal.) | [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md) |
choices | no (kind: "story" only) | Refused in a bundle (Choices belong to stories.) | [concepts/manifest.md](../concepts/manifest.md) |
Field definitions
`play`
play: `1.${number}`- Required: yes
- Limit: Up to
1.18(LIMITS.hostMinor). - Example: [concepts/manifest.md](../concepts/manifest.md)
`id`
id: string- Required: yes
- Limit: 2–48 chars (
LIMITS.idMin..LIMITS.idMax). - Refused in a bundle (
id): Creator ids use the game namespace. Prefix the slug with game-. - Example: [concepts/manifest.md](../concepts/manifest.md)
`title`
title: string- Required: yes
- Limit: At most 80 chars (
LIMITS.title). - Example: [concepts/manifest.md](../concepts/manifest.md)
`tagline`
tagline?: string- Required: no
- Limit: At most 90 chars (
LIMITS.tagline). - Example: [concepts/manifest.md](../concepts/manifest.md)
`genre`
genre?: string- Required: no
- Example: [concepts/manifest.md](../concepts/manifest.md)
`world`
world?: string- Required: no
- Example: [concepts/manifest.md](../concepts/manifest.md)
`seeded`
seeded?: boolean- Required: no
- Example: [concepts/run-and-end.md](../concepts/run-and-end.md)
`art`
art: {
cover: string;
scene?: string;
focus?: readonly [number, number];
titled?: boolean;
}- Required: yes
- Limit: Cover: ≥1200 px short side (
BUNDLE_LIMITS.coverShortSide), ≤500 KiB (BUNDLE_LIMITS.coverBytes). - Refused in a bundle (
art.scene): Bundles use the cover in play 1.4. Remove art.scene. - Example: [concepts/manifest.md](../concepts/manifest.md)
`stage`
stage: {
design: readonly [number, number];
aspect?: readonly [number, number];
orientation?: "portrait" | "landscape" | "any";
}- Required: yes
- Limit:
design: 240–1280 (LIMITS.designMin..LIMITS.designMax);aspect: 0.4–2.4 (LIMITS.aspectMin..LIMITS.aspectMax). - Example: [concepts/stage-and-input.md](../concepts/stage-and-input.md)
`x`
x: { card: boolean }- Required: yes
- Refused in a bundle (
x.card): Bundles have no X card in play@1. Set x.card to false. - Example: [concepts/quality-and-testing.md](../concepts/quality-and-testing.md)
`theme`
theme?: { accent: string }- Required: no
- Example: [concepts/quality-and-testing.md](../concepts/quality-and-testing.md)
`input`
input?: {
actions: readonly { id: string; label: string; keys: readonly string[]; pad?: boolean }[];
stick?: boolean;
}- Required: no
- Limit: 1–12 actions (
INPUT_LIMITS.actions),label≤16 chars (INPUT_LIMITS.actionLabel), 1–4 keys (INPUT_LIMITS.keys), at most 3 withpad: true(INPUT_LIMITS.pad). Each key (idKey) matches^[A-Z][A-Za-z0-9]{1,19}$and excludes reserved shell keys (Escape,KeyP,KeyM,KeyF). - Example: [concepts/stage-and-input.md](../concepts/stage-and-input.md)
`start`
start?: {
mode?: "lobby" | "direct";
label?: string;
homeLabel?: string;
returnHome?: boolean;
howTo?: readonly string[];
}- Required: no
- Limit:
label/homeLabel≤24 chars (LIMITS.startLabel);howTo≤3 single-line entries (LIMITS.howToLines) of ≤80 chars (LIMITS.howToLine). - Example: [concepts/modes-and-settings.md](../concepts/modes-and-settings.md)
`audio`
audio: { essential: boolean; channels: readonly string[]; toggle?: boolean }- Required: yes
- Limit: At most 8
channels(LIMITS.channels). - Example: [concepts/saves-records-sound.md](../concepts/saves-records-sound.md)
`variants`
variants?: readonly {
id: string;
title: string;
ranked?: boolean;
rules?: number;
blurb?: string;
step?: string;
stars?: readonly [number, number, number];
previous?: readonly number[];
episode?: number;
unlock?: string;
}[]- Required: no
- Limit: At most 8 variants (
LIMITS.variants);blurb≤48 (LIMITS.blurb);step≤16 (LIMITS.stepNoun, max step 9999,LIMITS.stepMax). - Refused in a bundle (
variants[].ranked): Bundles cannot declare ranked variants. Omit ranked. - Example: [concepts/modes-and-settings.md](../concepts/modes-and-settings.md)
`outcomes`
outcomes: readonly { id: string; title: string }[]- Required: yes
- Limit: 1–24 outcomes (
LIMITS.outcomesMin..LIMITS.outcomes);title≤40 chars (LIMITS.outcomeTitle). - Example: [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md)
`verdicts`
verdicts?: readonly { id: string; headline: string; line: string; tip?: string }[]- Required: no
- Limit: At most 16 verdicts (
LIMITS.verdicts);headline≤40 (LIMITS.headline),line≤90 (LIMITS.verdictLine),tip≤80 (LIMITS.tip). - Example: [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md)
`stats`
stats?: readonly {
id: string;
label: string;
format?: "label" | "int" | "seconds";
labels?: readonly string[];
of?: number;
}[]- Required: no
- Limit: At most 8 stats (
LIMITS.stats);label≤16 chars (LIMITS.statLabel). - Example: [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md)
`hud`
hud?: readonly string[]- Required: no
- Limit: At most 4 ids (
LIMITS.hud); platform displays the first 3 with a value (HUD_SHOWN). - Example: [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md)
`result`
result?: readonly string[]- Required: no
- Limit: At most 8 ids (
LIMITS.result).run.finish({ stats })accepts only these ids (finishStatIds). - Example: [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md)
`store`
store?: {
title?: string;
sale?: string;
featured?: string;
base?: { title: string; art: string; id?: string };
default?: "base" | "earned";
figure?: { art: string; size: readonly [number, number] };
sections?: readonly { id: string; title: string }[];
}- Required: no
- Limit:
title/sale/sections[].title≤24 chars (LIMITS.sectionTitle);base.id2–48 chars;base.title≤40; at most 6sections(LIMITS.storeSections);figure.sizeis[w, h]positive integers (figureSize). - Example: [concepts/store-and-unlocks.md](../concepts/store-and-unlocks.md)
`settings`
settings?: readonly (
| {
id: string;
label: string;
kind: "choice";
options: readonly { id: string; label: string }[];
default: string;
note?: string;
}
| { id: string; label: string; kind: "toggle"; default: boolean; note?: string }
)[]- Required: no
- Limit: At most 6 rows (
LIMITS.settings);label≤24 (LIMITS.settingLabel),note≤60 (LIMITS.settingNote);choicehas 2–6 options (LIMITS.optionsMin..LIMITS.options),options[].label≤16 (LIMITS.settingOptionLabel). - Example: [concepts/modes-and-settings.md](../concepts/modes-and-settings.md)
`unlocks`
unlocks?: readonly {
id: string;
title: string;
art?: string;
moves?: readonly string[];
veil?: { title: string; art?: string };
type?: string;
line?: string;
wear?: boolean;
still?: string;
cell?: readonly [number, number, number, number];
layer?: string;
section?: string;
}[]- Required: no
- Limit: At most 16 items (
LIMITS.unlocks);id≤48 (LIMITS.itemId),title/veil.title≤40 (LIMITS.unlockTitle),type≤16 (LIMITS.unlockType),line≤90 (LIMITS.unlockLine),moves≤4 (LIMITS.itemMoves),cellis[x, y, w, h]insidestill. - Example: [concepts/store-and-unlocks.md](../concepts/store-and-unlocks.md)
`earns`
earns?: readonly {
id: string;
kind: "keepsake" | "achievement";
title: string;
line: string;
when: {
variant?: string;
score?: number;
outcome?: string;
stats?: Record<string, { min?: number; max?: number }>;
};
wear?: boolean;
wearLabel?: string;
art?: string;
moves?: readonly string[];
type?: string;
still?: string;
cell?: readonly [number, number, number, number];
layer?: string;
section?: string;
}[]- Required: no
- Limit: At most 16 earns (
LIMITS.earns);id2–48,title≤40 (LIMITS.earnTitle),line≤90 (LIMITS.earnLine),moves≤4 (LIMITS.itemMoves),cellis[x, y, w, h]insidestill. - Example: [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md)
`moves`
moves?: readonly { id: string; title: string; art?: string }[]- Required: no
- Limit: At most 24 moves (
LIMITS.moves);title≤40 chars (LIMITS.moveTitle). - Example: [concepts/store-and-unlocks.md](../concepts/store-and-unlocks.md)
`records`
records?: readonly { id: string; kind: "set"; label: string; items: readonly string[] }[]- Required: no
- Limit: At most 4 records (
LIMITS.records); at most 64 items each (LIMITS.recordItems); ids ≤48 chars (LIMITS.itemId). - Example: [concepts/saves-records-sound.md](../concepts/saves-records-sound.md)
`episodes`
episodes?: readonly { part: number; why: "continue" | "origin" }[]- Required: no
- Limit: At most 3 episodes (
LIMITS.episodes). - Example: [concepts/manifest.md](../concepts/manifest.md)
`sources`
sources?: readonly {
file: string;
asset_id: string;
source_sha256: string;
source: "studio" | "publishing" | "upload";
}[]- Required: no
- Limit: At most 64 sources (
LIMITS.sources). - Example: [concepts/manifest.md](../concepts/manifest.md)
`share`
share?: { post?: string; keepsake?: { id: string; title: string } }- Required: no
- Limit:
post≤120 chars (LIMITS.sharePost), one line, placeholders{verdict},{score},{unit},{title},{link},{worn}plus{stat:<id>};keepsake.title≤40. - Schema refusal (
share.post): A post template belongs to games. Remove share.post from this story. - Example: [concepts/manifest.md](../concepts/manifest.md)
`telemetry`
telemetry?: {
events: Record<string, Record<string, { type: "enum"; values: readonly string[] } | { type: "int"; min: number; max: number } | { type: "bool" }>>;
}- Required: no
- Limit: At most 16 events (
LIMITS.telemetryEvents), ≤4 fields/event (LIMITS.telemetryFields);enumhas 2–16 values (TELEMETRY_ENUM_MIN..TELEMETRY_ENUM_MAX);intbounds -1000000..1000000 (TELEMETRY_INT_MIN..TELEMETRY_INT_MAX). - Example: [concepts/manifest.md](../concepts/manifest.md)
`entry`
entry?: string- Required: one of
entryorengine - Example: [concepts/manifest.md](../concepts/manifest.md)
`engine`
engine?: `${string}@${number}`- Required: one of
entryorengine - Example: [formats.md](../formats.md)
`kind`
kind: "game" | "story"- Required: yes
- Refused in a bundle (
kind): Studio bundles are games. Use kind game. - Example: [concepts/manifest.md](../concepts/manifest.md)
`scoring`
scoring?: {
unit: string;
order: "asc" | "desc";
min: number;
max: number;
rules: number;
verifier:
| { kind: "registered"; id: "loft" | "rhythm" | "court" | "descent" | "keynote" }
| { kind: "none" };
stars?: readonly [number, number, number];
compatible?: readonly { rules: number; max?: number }[];
}- Required: no (
kind: "game"only) - Refused in a bundle (
scoring.verifier): Bundle scores are personal. Set verifier.kind to none. - Example: [concepts/scoring-and-prizes.md](../concepts/scoring-and-prizes.md)
`choices`
choices?: Record<string, { options: readonly { id: string; label: string }[] }>- Required: no (
kind: "story"only) - Limit: At most 24 nodes (
LIMITS.nodes); 2–6 options (LIMITS.optionsMin..LIMITS.options),label≤60 chars (LIMITS.optionLabel). - Schema refusal (
choices): Choices belong to stories. Remove choices from this game. - Example: [concepts/manifest.md](../concepts/manifest.md)
Play minor history
Generated from PLAY_CAPABILITIES (packages/play/src/capabilities.ts) and diffs across packages/play/lock/1.*.json.
| Minor | Capabilities | Added / widened types | Added / raised limits | Added codes |
|---|---|---|---|---|
1.3 | — | Baseline lock (95 host types) | Baseline lock (41 values) | Baseline lock (45 codes) |
1.4 | records | Tone, Via, SaveOptions.place, SaveOptions.continue, SaveOptions.continue.variant, SaveOptions.continue.step, PlayHost.records.has, PlayHost.save.read, PlayHost.save.durable, Run.best, Run.via, Run.step, Result.stars, Result.toNextStar, Result.next, PlayHost.hud.set (widened), PlayHost.save.store (widened), Result.stats (widened) | LIMITS.blurb, LIMITS.tip, LIMITS.stepNoun, LIMITS.stepMax, LIMITS.recordItems, LIMITS.itemId, LIMITS.sharePost, WIRE.message, WIRE.save, WIRE.savesPerSecond, WIRE.recordsPerSecond, LIMITS.result (3 → 8) | PLAY-L009, PLAY-L010, PLAY-R009, PLAY-R010, PLAY-S112 |
1.5 | — | Ids.unlock, UnlockState, Unlock.id, Unlock.state, Unlock.price, PlayHost.on:unlocks, PlayHost.unlocks, PlayHost.unlocks.list, PlayHost.unlocks.get, PlayHost.unlocks.buy, PlayHost.unlocks.arrival, PlayHost.requestStart (widened) | LIMITS.unlocks, LIMITS.unlockTitle, WIRE.buysPerSecond | PLAY-R011 |
1.6 | — | — | — | — |
1.7 | store | Unlock.reason, Unlock.revoked, PlayHost.result, PlayHost.result.action, PlayHost.unlocks.signedIn, Result.worn, PlayHost.on:lobby (widened) | — | — |
1.8 | resumeInput | PrepareFront | — | — |
1.9 | soundRequest | Audio.request | — | PLAY-R012 |
1.10 | earns | Ids.earn, Unlock.edition, Unlock.limited, Unlock.limited.of, Unlock.limited.soldOut, Earned.id, Earned.at, Earned.verified, PlayHost.on:earned, PlayHost.earned, PlayHost.earned.signedIn, PlayHost.earned.list, PlayHost.earned.has, Result.earned, Result.worn (widened) | LIMITS.earns, LIMITS.earnTitle, LIMITS.earnLine | — |
1.11 | keepEarns | Earned.until, PlayHost.earned.keep, PlayHost.earned.arrival | LIMITS.moves, LIMITS.moveTitle, LIMITS.itemMoves | — |
1.12 | lobbyClock, unlockEdition, declaredWorn | PlayHost.lobbyClock, Result.worn (widened) | — | — |
1.13 | musicBus | Audio.music | — | — |
1.14 | hostWindow | HostSurface, HostWindow.width, HostWindow.height, HostWindow.fit, PlayHost.surface, PlayHost.window, PlayHost.on:window | — | — |
1.15 | pressAct | PlayHost.input.act | — | — |
1.16 | telemetry | TrackFieldValue, TrackEvents, PlayHost.track, Mount (widened) | LIMITS.telemetryEvents, LIMITS.telemetryFields, WIRE.tracksPerSecond, WIRE.tracksPerRun, WIRE.tracksPerVisit, WIRE.trackBytes | — |
1.17 | storeScreen, statLabels, gameSettings | Ids.base, Ids.section, Ids.setting, PlayHost.on:worn, PlayHost.on:settings, PlayHost.store, PlayHost.store.worn, PlayHost.store.open, PlayHost.store.wear, PlayHost.settings, PlayHost.settings.get | LIMITS.unlockType, LIMITS.unlockLine, LIMITS.storeSections, LIMITS.sectionTitle, LIMITS.settings, LIMITS.settingLabel, LIMITS.settingNote, LIMITS.settingOptionLabel, WIRE.storeOpensPerSecond, WIRE.wearsPerSecond | PLAY-R013 |
1.18 | resultArea | ResultArea.safe, FinishOptions.linger, PlayHost.on:resultArea, Run.showResult, Run.finish (widened) | LIMITS.lingerMs | — |
Play check checklist
Generated from CODES in packages/play/src/check/codes.ts. Every MUST item is a blocking finding; every SHOULD item is a quality warning.
MUST (blocking findings)
- [
PLAY-M001](codes.md#play-m001) — Invalid manifest field or declaration. Fix: Correct the reported field in play.json or declare the required play minor. - [
PLAY-M002](codes.md#play-m002) — Too many files and uploaded pictures for one game. Fix: Reduce the number of bundle files or uploaded pictures. - [
PLAY-R001](codes.md#play-r001) — The manifest does not declare this id or allow it here. Fix: Pass only ids declared for that slot in play.json (for finish.stats, only ids listed in result). - [
PLAY-R002](codes.md#play-r002) — A run can finish only once, during an active run. Fix: Guard your end path and call run.finish() once during an active run. - [
PLAY-R003](codes.md#play-r003) — A scored run needs a score within the declared bounds. Fix: Supply an integer score within the declared scoring.min..max range. - [
PLAY-R004](codes.md#play-r004) — A save must be JSON of at most 16 KiB. Fix: Store plain JSON of at most 16 KiB containing only the state needed to resume. - [
PLAY-R005](codes.md#play-r005) — The saved place exceeds 128 characters or uses an unsupported character. Fix: Use a short place string of at most 128 safe characters. - [
PLAY-R006](codes.md#play-r006) — The game sent invalid messages. Fix: Use the host API within its documented limits and payloads. - [
PLAY-R007](codes.md#play-r007) — The game did not pause in time. Fix: Keep frame work and pause handlers fast and synchronous. - [
PLAY-R008](codes.md#play-r008) — The game could not connect to the player. Fix: Export mount(stage, host) without blocking module evaluation or breaking host messaging. - [
PLAY-L001](codes.md#play-l001) — The experience made no load progress for 15 seconds before it called ready(). Fix: Draw the first frame and call host.ready(). - [
PLAY-L002](codes.md#play-l002) — The experience called ready() twice. Fix: Call host.ready() only once per mount. - [
PLAY-S001](codes.md#play-s001) — Invalid bundle path. Fix: Use lowercase relative paths up to eight segments and 200 characters. - [
PLAY-S002](codes.md#play-s002) — Unsupported bundle file type. Fix: Remove this file or convert it to a supported format (PNG, JPEG or WebP for store pictures). - [
PLAY-S003](codes.md#play-s003) — A file exceeds 16 MiB. Fix: Split or compress the file. - [
PLAY-S004](codes.md#play-s004) — The bundle exceeds 32 MiB or 400 files. Fix: Reduce total bytes or file count. - [
PLAY-S005](codes.md#play-s005) — First load exceeds 1.5 MiB gzip. Fix: Move nonessential assets or modules behind a dynamic import after ready(). - [
PLAY-S006](codes.md#play-s006) — The entry is missing or does not export mount. Fix: Export mount(stage, host) from the entry ES module. - [
PLAY-S007](codes.md#play-s007) — The cover is missing or outside its format, size or dimension limits. Fix: Supply a PNG, JPEG or WebP cover up to 500 KiB and at least 1200 px on both sides. - [
PLAY-S008](codes.md#play-s008) — Unusable archive or duplicate path. Fix: Keep each path once and zip the files directly with play pack. - [
PLAY-S009](codes.md#play-s009) — Declared size, inflation ratio or inflated bytes exceed a cap. Fix: Repack the original files using play pack. - [
PLAY-S010](codes.md#play-s010) — Missing root play.json. Fix: Put play.json at the root. - [
PLAY-S011](codes.md#play-s011) — This file is not allowed in an engine pack. Fix: Use only the images and audio accepted by the declared engine. - [
PLAY-S012](codes.md#play-s012) — The engine pack is missing or invalid. Fix: Put a valid UTF-8 pack.json matching the engine schema at the bundle root. - [
PLAY-S101](codes.md#play-s101) — Invalid JavaScript module. Fix: Ship a valid UTF-8 ES module. - [
PLAY-S102](codes.md#play-s102) — An import does not resolve to a bundle file. Fix: Bundle dependencies and import existing files with relative module specifiers. - [
PLAY-S103](codes.md#play-s103) — Network access outside bundle files. Fix: Load only your own files relative to import.meta.url. - [
PLAY-S104](codes.md#play-s104) — Access outside the stage. Fix: Create elements under stage and query your own root. - [
PLAY-S105](codes.md#play-s105) — Private browser storage or identity access. Fix: Use host.save for progress and host.records for collections. - [
PLAY-S106](codes.md#play-s106) — The host owns the lifecycle and clock. Fix: Use host.clock, host.viewport and host pause/resume notifications. - [
PLAY-S107](codes.md#play-s107) — The host owns audio construction and routing. Fix: Use host.audio.context, host.audio.output for effects, host.audio.music for music and declared host channels. - [
PLAY-S108](codes.md#play-s108) — Dynamic code, workers or shared memory. Fix: Ship ES modules or wasm and run the game on the stage thread. - [
PLAY-S109](codes.md#play-s109) — Child frames, navigation or browser dialogs. Fix: Keep interaction inside the stage and leave navigation to the shell. - [
PLAY-S110](codes.md#play-s110) — A stylesheet reaches beyond the stage or uses viewport units. Fix: Scope selectors to your game root and use container or logical stage units. - [
PLAY-S111](codes.md#play-s111) — The entry exports a member outside its declared Play surface. Fix: Expose only mount (and optionally prepareFront) from the entry; keep other exports in internal modules. - [
PLAY-V001](codes.md#play-v001) — The required page size cannot play. Fix: Reduce stage.design or widen stage.aspect so this page size plays. - [
PLAY-V002](codes.md#play-v002) — Content extends outside the stage or safe area. Fix: Size art from host.viewport and keep text and controls inside viewport.safe. - [
PLAY-V003](codes.md#play-v003) — Text, hit targets or spacing are too small after scaling. Fix: Allow 11 CSS px for text, 44 CSS px for touch targets (32 for mouse), and at least 8 CSS px between controls after scaling. - [
PLAY-L003](codes.md#play-l003) — Ready exceeded the 3 second phone budget. Fix: Draw a first frame within 3 seconds and defer optional loads. - [
PLAY-L004](codes.md#play-l004) — Frames, time or sound continued during pause. Fix: Drive frames and sound through host.clock and host.audio. - [
PLAY-L005](codes.md#play-l005) — The run did not produce one valid result. Fix: Complete one run with declared result ids and a valid score. - [
PLAY-L006](codes.md#play-l006) — Cleanup or a second mount failed. Fix: Return cleanup, release resources and subscriptions, read saves defensively, and initialize fresh state on mount. - [
PLAY-L007](codes.md#play-l007) — The game or a required resource failed at runtime. Fix: Fix the reported runtime error, missing resource, or host API misuse. - [
PLAY-L008](codes.md#play-l008) — The game created an audio context outside the host. Fix: Build every audio node on host.audio.context. - [
PLAY-R009](codes.md#play-r009) — A step is a whole number from 1 to 9999 on a variant that declares a step noun. Fix: Use a whole number from 1 to 9999 on a variant that declares step. - [
PLAY-R010](codes.md#play-r010) — Stars come from the manifest thresholds or from the result, never both. Fix: Use manifest thresholds or supply stars (0 to 3) and a positive integer toNextStar when stars < 3, never both. - [
PLAY-R011](codes.md#play-r011) — An unlock is bought, or earns are kept, only from the game’s home, one sheet at a time. Fix: Open buy or keep sheets only from the game home, one sheet at a time. - [
PLAY-R012](codes.md#play-r012) — Muting from the game needs play.json audio.toggle. Fix: Declare audio.toggle: true in play.json (play 1.9+) or let the platform mute button handle muting. - [
PLAY-R013](codes.md#play-r013) — The store opens only between rounds. Fix: Call host.store.open() only between rounds (on the Front, lobby, pause or result). - [
PLAY-S112](codes.md#play-s112) — A seeded game takes all chance from run.seed. Fix: Derive it from run.seed. - [
PLAY-L009](codes.md#play-l009) — A seeded game gave two results for one seed and the same input. Fix: Take every random choice from run.seed and every time from host.clock. - [
PLAY-L010](codes.md#play-l010) — Saves are checkpoints, not frames. Fix: Store at a checkpoint: a cleared level, a choice, the pause handler. - [
PLAY-C001](codes.md#play-c001) — The picture safety check flagged a frame. Fix: Keep all art and rendered frames appropriate for fans, including minors.
SHOULD (quality warnings)
- [
PLAY-Q001](codes.md#play-q001) — The idle round won or reached the clock cap. Fix: Give each variant a clock or fuse and finish with a loss when the player makes no moves. - [
PLAY-Q002](codes.md#play-q002) — The round ran past 50 seconds of play time. Fix: End the round by 50 seconds on host.clock. - [
PLAY-Q003](codes.md#play-q003) — No accepted input was observed within three seconds of Play. Fix: Focus the game on start and make the primary action playable immediately. - [
PLAY-Q004](codes.md#play-q004) — No canvas pixels changed within 150 ms of an input. Fix: Paint immediate feedback when you receive an input. - [
PLAY-Q005](codes.md#play-q005) — No signal was observed on host.audio.output during the round. Fix: Play your input, hit, miss and result cues through host.audio.output. - [
PLAY-Q006](codes.md#play-q006) — No read of the run seed was detected. Fix: Read run.seed from the start event and derive the level sequence from it. - [
PLAY-Q007](codes.md#play-q007) — Missing two variants, verdicts, or stats. Fix: Declare at least two variants, verdict lines and stats for the result. - [
PLAY-Q008](codes.md#play-q008) — No stage aspect range is declared. Fix: Set stage.aspect and use one uniform scale for the playfield and input mapping. - [
PLAY-Q009](codes.md#play-q009) — A declared result stat was never reported. Fix: Report the declared result stats or remove the unused ids. - [
PLAY-Q010](codes.md#play-q010) — Used play 1.4 members while declaring an older minor. Fix: Declare play 1.4. - [
PLAY-Q011](codes.md#play-q011) — The idle round earned a star or the random round earned three stars. Fix: Raise the thresholds: one star should need real play. - [
PLAY-Q012](codes.md#play-q012) — Every checkpoint was stored after finish. Fix: Store before you finish. - [
PLAY-Q013](codes.md#play-q013) — A checkpoint exceeds half of the 16 KiB save limit. Fix: Keep only the progress needed to resume within the 16 KiB save limit. - [
PLAY-Q014](codes.md#play-q014) — The Front or a shell panel does not fit an X window. Fix: Keep the title, description and art short enough for a 504 px square. The shell lays out the Front and panels; do not draw your own. - [
PLAY-Q015](codes.md#play-q015) — Play is not reachable on the Front in an X window. Fix: Do not draw over the Front or move its Play. If nothing of yours is there, report it: the platform draws this button. - [
PLAY-Q016](codes.md#play-q016) — The game did not complete the X window walk. Fix: Start on the start event, stop the clock and sound on pause and continue on resume, with input kept inside the stage box. - [
PLAY-Q017](codes.md#play-q017) — An X card has an unexpected link leaving the card. Fix: Do not link out of your game. The platform draws the card's exit, "Open full game". - [
PLAY-Q018](codes.md#play-q018) — Debug text is visible in an X window. Fix: Remove size, frame-rate and other debug readouts from anything a fan can see. - [
PLAY-Q019](codes.md#play-q019) — A :hover style sticks after a tap on phones. Fix: Put it inside @media (hover:hover) and (pointer:fine). - [
PLAY-Q020](codes.md#play-q020) — Reserved shell keys did not reach the shell during play. Fix: Do not bind Escape, KeyP, KeyM or KeyF in your game, and do not call preventDefault or stopPropagation on them. - [
PLAY-Q021](codes.md#play-q021) — The effects bus carried continuous audio with Music at 0 and no input. Fix: Route music and looping beds to host.audio.music (play 1.13) or declared audio.channels, and keep host.audio.output for sound effects. - [
PLAY-Q022](codes.md#play-q022) — The stage holds game-drawn chrome while playing. Fix: Remove menus, dialogs, headings and button overlays from the stage; let the platform draw the Front, pause, Settings and result. - [
PLAY-Q023](codes.md#play-q023) — Store pictures exceed a per-kind or total budget. Fix: Compress or resize store art, stills, sprite sheets, layers and figure to stay within the store picture budgets. - [
PLAY-Q024](codes.md#play-q024) — The platform draws every way out of a game. A game can’t leave its frame, so this control does nothing for fans: remove it. Fix: Remove the exit or link; the platform draws home, Episodes, the profile and Back from play.json and the page. - [
PLAY-Q025](codes.md#play-q025) — The game shows a price in money. The platform draws every price, from the item’s live sale. Fix: Declare the item in play.json unlocks; the store and the Buy sheet show its price. - [
PLAY-Q026](codes.md#play-q026) — The game draws its own sign-in. The platform owns sign-in and the fan’s account. Fix: Remove the sign-in form or link; read host presence and let the platform ask. - [
PLAY-Q027](codes.md#play-q027) — The game draws its own store or payment. The platform owns the store and checkout. Fix: Remove the payment UI; declare items in play.json store and unlocks. - [
PLAY-Q028](codes.md#play-q028) — A lingering finish reached the 3000 ms ceiling without calling run.showResult(). Fix: Call run.showResult() when your closing animation finishes, within 3000 ms.
Working example
{
"play": "1.18",
"kind": "game",
"id": "game-starfall",
"title": "Starfall",
"tagline": "Catch the falling stars before they land.",
"entry": "game.js",
"art": {
"cover": "cover.png",
"focus": [
0.5,
0.45
],
"titled": false
},
"stage": {
"design": [
300,
400
],
"aspect": [
0.5625,
1.0
],
"orientation": "any"
},
"x": {
"card": false
},
"start": {
"label": "Catch stars",
"howTo": [
"Tap a star, or press Space or Enter for the lowest one.",
"A round lasts 30 seconds. Three misses end it early."
]
},
"audio": {
"essential": false,
"channels": []
},
"scoring": {
"unit": "stars",
"order": "desc",
"min": 0,
"max": 9999,
"rules": 1,
"stars": [
5,
15,
25
],
"verifier": {
"kind": "none"
}
},
"outcomes": [
{
"id": "stargazer",
"title": "Stargazer"
},
{
"id": "star-keeper",
"title": "Star keeper"
}
],
"verdicts": [
{
"id": "steady",
"headline": "Steady hands.",
"line": "The sky ran out before you did."
},
{
"id": "missed",
"headline": "Three got away.",
"line": "They always fall faster at the end."
}
],
"stats": [
{
"id": "score",
"label": "Stars"
},
{
"id": "misses",
"label": "Misses",
"of": 3
},
{
"id": "best-streak",
"label": "Best streak"
},
{
"id": "time",
"label": "Time",
"format": "seconds"
}
],
"hud": [
"score",
"misses"
],
"result": [
"best-streak",
"time"
],
"variants": [
{
"id": "classic",
"title": "Classic",
"blurb": "30 seconds. Stars speed up as you score."
},
{
"id": "storm",
"title": "Storm",
"blurb": "30 seconds. Faster falls from the start."
},
{
"id": "midnight",
"title": "Midnight",
"blurb": "Faster stars in a darker sky.",
"unlock": "midnight-level"
}
],
"store": {
"title": "Store",
"base": {
"id": "star-base",
"title": "Stargazer",
"art": "figure.png"
},
"figure": {
"art": "figure.png",
"size": [
480,
600
]
},
"sections": [
{
"id": "looks",
"title": "Looks"
},
{
"id": "levels",
"title": "Levels"
}
]
},
"unlocks": [
{
"id": "comet-cape",
"title": "Comet cape",
"type": "Look",
"line": "A trailing stardust cape.",
"wear": true,
"section": "looks",
"art": "cape-art.png",
"layer": "cape.png"
},
{
"id": "moon-hat",
"title": "Moon hat",
"type": "Look",
"line": "A crescent brim for late skies.",
"wear": true,
"section": "looks",
"art": "hat-art.png",
"layer": "hat.png"
},
{
"id": "midnight-level",
"title": "Midnight",
"type": "Level",
"line": "Faster stars in a darker sky.",
"section": "levels",
"art": "level.png"
}
],
"settings": [
{
"id": "trails",
"kind": "toggle",
"label": "Star trails",
"note": "Soft streaks behind falling stars.",
"default": true
}
],
"share": {
"post": "Caught {score} {unit} in {title}. {link}"
},
"episodes": []
}// game.js: Starfall, a complete play@1.18 game. Tap the falling stars, or press Space or Enter for the lowest one.
// A round ends after 30 seconds of play time, or sooner at three misses.
// The platform draws the Front, pause, More, Settings (with Star trails), the Store (Looks + Levels), the result,
// You, share and sign-in from play.json: draw only the stage, never a menu, result, store, exit, sign-in, price or debug text.
// Fans open it from X links in X's in-app browser: keep input inside the stage box, honor pause and read host.window,
// never the user agent. Shelf Cat shows the rest of 1.14.
const ROUND_MS = 30000
const LAYER_FILES = { 'comet-cape': './cape.png', 'moon-hat': './hat.png' }
export function mount(stage, host) {
const root = document.createElement('div')
root.className = 'starfall'
const style = document.createElement('style') // CSS lives inside the stage, scoped to your root class
style.textContent = '.starfall,.starfall canvas{display:block;width:100%;height:100%;touch-action:none;user-select:none}'
const canvas = document.createElement('canvas')
canvas.tabIndex = 0 // focusable, so keys reach the game without listening on document
canvas.setAttribute('aria-label', 'Starfall: press Space or Enter to catch the lowest star')
root.append(style, canvas)
stage.append(root)
const g = canvas.getContext('2d')
const offs = []
let v = host.viewport, run = null, rand = seeded(0), stars = [], spawnIn = 0
let score = 0, misses = 0, streak = 0, best = 0, startedAt = 0, ended = false, roundOff = null
let endSafe = null, endAt = 0, shown = false, endRun = null, showCalled = false, easeAt = 0, settled = false
let worn = host.store.worn // 1.17: base id or an owned wearable id
let trails = host.settings.get('trails') // 1.17: declared toggle setting from Settings sheet
const pictures = new Map()
const loadPic = (key, file) => {
const img = new Image()
img.decoding = 'async'
img.onload = () => draw()
img.src = new URL(file, import.meta.url).href
pictures.set(key, img)
}
loadPic('figure', './figure.png')
for (const [id, file] of Object.entries(LAYER_FILES)) loadPic(id, file)
const resize = (next) => { // fires once on subscribe, then on every change
v = next
canvas.width = Math.round(v.width * v.dpr)
canvas.height = Math.round(v.height * v.dpr)
draw()
}
// Seeded chance: every random number comes from run.seed (mulberry32).
function seeded(a) { return () => { a |= 0; a = a + 0x6D2B79F5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a)
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296 } }
const settle = () => { // jump to final spot if the platform ended the linger early
if (!showCalled) { settled = true; draw() }
}
const begin = (r) => { // every run, including Play again
run = r; rand = seeded(r.seed); stars = []; spawnIn = 0
score = 0; misses = 0; streak = 0; best = 0; ended = false; startedAt = host.clock.now()
endSafe = null; endAt = 0; shown = false; endRun = null; showCalled = false; easeAt = 0; settled = false
host.hud.set({ score, misses })
roundOff?.()
roundOff = host.clock.after(ROUND_MS, end) // play time: it holds while paused, so the finish is predictable
canvas.focus({ preventScroll: true })
}
const blip = (freq) => { // Web Audio through the host's bus, never to destination
const ctx = host.audio.context, o = ctx.createOscillator(), a = ctx.createGain()
o.frequency.value = freq; a.gain.setValueAtTime(0.2, ctx.currentTime)
a.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.15)
o.connect(a).connect(host.audio.output); o.start(); o.stop(ctx.currentTime + 0.16)
o.onended = () => { o.disconnect(); a.disconnect() }
}
const end = () => {
if (!run || ended) return
ended = true
roundOff?.(); roundOff = null
const r = run; run = null
endRun = r; endAt = host.clock.now()
r.finish({
outcome: score >= 30 ? 'star-keeper' : 'stargazer',
verdict: score >= 30 ? 'steady' : 'missed',
score: Math.min(score, 9999),
stats: { 'best-streak': best, time: Math.round((host.clock.now() - startedAt) / 1000) },
}, { linger: true }).then(() => { shown = true; settle() }).catch((e) => host.report(e))
}
const step = (dt) => {
if (!run || ended) return
spawnIn -= dt
if (spawnIn <= 0) { // spawn inside the safe rect, clear of the bar strip
const s = v.safe, x = s.left + 20 + rand() * Math.max(0, v.width - s.left - s.right - 40)
const boost = run.variant === 'midnight' ? 1.25 : 1
stars.push({ x, y: s.top + 16, speed: (0.08 + rand() * 0.06 + score * 0.002) * boost })
const cadence = run.variant === 'midnight' ? 480 : run.variant === 'storm' ? 560 : 700
spawnIn = cadence - Math.min(400, score * 10)
}
for (const st of stars) st.y += st.speed * dt
const floor = v.height - v.safe.bottom
const landed = stars.filter((st) => st.y > floor)
if (landed.length) {
stars = stars.filter((st) => st.y <= floor)
misses += landed.length; streak = 0; host.haptic('bad'); blip(140)
host.hud.set({ misses: Math.min(misses, 3) })
if (misses >= 3) end()
}
}
const draw = () => {
g.setTransform(v.dpr, 0, 0, v.dpr, 0, 0) // draw in logical px
g.fillStyle = run?.variant === 'midnight' ? '#0b0e24' : host.theme.ground
g.fillRect(0, 0, v.width, v.height)
let flash = 0
if (ended && !showCalled && !settled) { // 1.18: 600 ms linger flash; t = 1 calls showResult() once
const t = Math.min(1, (host.clock.now() - endAt) / 600)
flash = host.theme.reducedMotion ? 0 : Math.sin(t * Math.PI)
if (t >= 1) { showCalled = true; easeAt = host.clock.now(); endRun?.showResult() }
}
const fig = pictures.get('figure')
if (fig && fig.complete && fig.naturalWidth) {
const h = Math.min(110, (v.height - v.safe.top - v.safe.bottom) * 0.32), w = h * (480 / 600)
const playY = v.height - v.safe.bottom - h
const top = endSafe ? endSafe.top : v.safe.top
const freeH = endSafe ? v.height - top - endSafe.bottom : 0
const targetY = endSafe && freeH >= h ? Math.max(top, v.height - endSafe.bottom - h) : playY
let fy = playY
if (ended && settled) fy = targetY
else if (ended && showCalled) {
const u = host.theme.reducedMotion ? 1 : Math.min(1, (host.clock.now() - easeAt) / 400)
fy = playY + (targetY - playY) * (1 - (1 - u) ** 3)
if (u >= 1) settled = true
}
const fx = (v.width - w) / 2
if (flash > 0) {
g.save(); g.globalAlpha = flash * 0.45; g.fillStyle = host.theme.accent
g.beginPath(); g.arc(fx + w / 2, fy + h / 2, h * 0.65, 0, Math.PI * 2); g.fill(); g.restore()
}
g.drawImage(fig, fx, fy, w, h)
const layer = pictures.get(worn)
if (layer && layer.complete && layer.naturalWidth) g.drawImage(layer, fx, fy, w, h)
}
for (const st of stars) {
if (trails) {
g.save(); g.globalAlpha = 0.28; g.strokeStyle = host.theme.accent; g.lineWidth = 6; g.lineCap = 'round'
g.beginPath(); g.moveTo(st.x, st.y); g.lineTo(st.x, st.y - 26); g.stroke(); g.restore()
}
g.fillStyle = host.theme.accent
g.beginPath(); g.arc(st.x, st.y, 14, 0, Math.PI * 2); g.fill()
}
}
const caught = (index) => {
stars.splice(index, 1); score++; streak++; best = Math.max(best, streak)
host.hud.set({ score }); host.haptic('tick'); blip(660 + streak * 20)
}
const tap = (e) => {
if (!run || ended) return
const r = canvas.getBoundingClientRect() // the stage may be scaled: map through the rect
const x = (e.clientX - r.left) * v.width / r.width, y = (e.clientY - r.top) * v.height / r.height
// Hit sizes are CSS pixels after scaling: a 44 px touch target is a 22 px radius divided by the scale.
const reach = Math.max(32, (v.pointer === 'coarse' ? 22 : 16) / v.scale)
const hit = stars.findIndex((st) => Math.hypot(st.x - x, st.y - y) < reach)
if (hit >= 0) caught(hit)
}
const key = (e) => {
if (!run || ended || (e.key !== ' ' && e.key !== 'Enter')) return
e.preventDefault()
if (!stars.length) return
caught(stars.reduce((low, st, i) => st.y > stars[low].y ? i : low, 0)) // the lowest star
}
canvas.addEventListener('pointerdown', tap)
canvas.addEventListener('keydown', key)
offs.push(host.on('viewport', resize))
offs.push(host.on('start', begin))
offs.push(host.on('resultArea', (area) => { endSafe = area.safe; if (shown) { settled = true; draw() } }))
offs.push(host.on('worn', (id) => { worn = id; draw() }))
offs.push(host.on('settings', (values) => { trails = values.trails; draw() }))
offs.push(host.clock.frame((dt) => { step(dt); draw() })) // runs while playing and until the result rests
draw()
host.ready() // first frame is up: the Poster lifts
return () => {
offs.forEach((off) => off()); roundOff?.()
canvas.removeEventListener('pointerdown', tap); canvas.removeEventListener('keydown', key); root.remove()
}
}