handheld-game-shell

Community@u252119f2fa58/handheld-game-shell
Community skill — not reviewed. It was shared by 秋雨微澜 and has not been checked by Neta. Read SKILL.md below before letting an agent use it.
Installation
npx -y @neta-art/neta-search-cli@latest skills add @u252119f2fa58/handheld-game-shell
Summary

Put your small game inside a retro handheld console frame, ready to play on phone or desktop.

  • Your game runs on a pixel screen between two grips, with a power key, d-pad, two sticks, X/Y/A/B buttons, Back and Pause.
  • On a phone held upright, the console turns sideways by itself. On a wider screen it stretches to fit.
  • Pick your own grip colours, button labels, title and boot logo. Without a logo, a plain placeholder card is used and you are told.
  • The power key shows an off screen and a logo boot, and your progress and saves stay when you turn it off and on.
  • Every game made this way shares the same console, so a series feels like one family. It works best with a clear one-sentence game idea.
SKILL.md
# Handheld Game Shell

The user ends up with a web Work: their game running on the screen of a handheld console. The console is a fixed shell: a left grip (power key, left stick, d-pad with letters, legend, sticker), a centre pixel screen, and a right grip (X/Y/A/B, legend, right stick, Back and Pause keys). The shell owns everything about the machine; a new game only writes what happens inside the screen. Because the shell never changes, every game made with it feels like the same series.

Read this file fully before writing files. Resolve relative paths from this skill's directory.

## Language

Reply in the user's language, whatever language this file is in, for every message including the final handover. Translate what scripts print instead of pasting it. Everything the player sees - the Work title, the button legends, labels, game text - follows the user's language and is written into `config.js` and the game files, never left in English by default. Text the user typed stays as written.

## When to use / when not

Use when the user wants a game inside a handheld console frame, or a console template to reuse across a series, or the same console restyled. Not for designing the game's mechanics, levels or art from nothing, and not for a game without the console frame - say this skill supplies the console shell and the screen wiring, and stop.

## Inputs

| Item | Required | Counts as given when |
|---|---|---|
| Game idea | yes | The user says what the player does on the screen (a sentence is enough) |
| Button uses | no, default A confirm / B cancel / X menu / Y music | The user names what buttons do |
| Colours | no, default pink left grip and green right grip | The user names a colour scheme or gives hex values |
| Boot logo and sticker | no, default a neutral placeholder card | The user attaches a logo picture |
| Title and language | no, default the user's language | The user names the game or writes in a language |

If the game idea is missing, ask once, in one message, then stop. If it is given, do not ask and do not wait for a go-ahead: state the defaults you took in one line and build through to delivery. The placeholder logo is never passed off as the user's logo; say in the handover that it is a placeholder when no logo was attached.

## Steps

1. **Open the game folder.** Choose a new lowercase kebab-case slug (`ls works/games/` first):
   `node scripts/new-game.mjs --slug <slug> --title "<game title>" --lang <language tag>`
   It copies the template to `works/games/<slug>/site` and refuses when the folder exists. Never delete an old folder to get past it.
2. **Configure the shell.** Edit only `site/config.js`: the two legend lines (what XYAB do in this game), `backLabel`, `startLabel`, colours, logo and sticker. When changing grip colours, change `leftInk` / `rightInk` (legend text) and `leftLetter` / `rightLetter` (key letters) with them so the contrast stays readable. An attached logo is converted to PNG, copied into `site/img/` and referenced from `config.js`.
3. **Write the game.** Replace `site/game.js` and `site/game.css`. Read `references/interface.md` first: it lists the `window.Handheld` interface, the events, the series button conventions and the syntax limits. The template's `game.js` is a key-test demo that shows the standard wiring. Game art goes in `site/img/` as transparent PNG or WebP made with the world's image tools or supplied by the user; canvas-drawn placeholders are for tests only.
4. **Check it.** `node scripts/verify.mjs works/games/<slug>/site`. It runs the rule check, validates `config.js`, then loads the page in headless Chrome as a portrait phone (393x730), a landscape phone (844x390) and a desktop window (1280x680): no console errors, the interface is complete, the boot logo finishes and a key press arrives, portrait rotates to landscape, the page title and legend come from the config, and no screen text reads `undefined`. It writes `verify-report.json` beside the `site` folder (so it is never published) and screenshots in `.verify/`. Look at the portrait and landscape screenshots yourself. Fix every FAIL and rerun; do not deliver while one fails.
5. **Play it.** At the three sizes above: every key, the power key off and on (progress must stay), a reload (the save must come back). A check that passes on the demo does not prove your game's screens fit; look at each game screen once.
6. **Publish.** See Deliver.
7. **Mini-tool package (only when asked).** `python3 scripts/pack-xhs.py works/games/<slug>/site works/xhs-minitool/<slug>` copies the site, subsets the pixel font to the characters used, runs the rule check, zips it with `index.html` at the root, and runs the official audit when its skill is installed. Tell the user to upload it to the creator platform, test it in the simulator, then scan-test on Android and iOS; a game that uses a leaderboard needs the avatar and nickname authorisation ticked.

## Deliver

A **web Work**:

```bash
node /mods/neta/neta work init web works/games/<slug> --title "<title in the user's language>"
node /mods/neta/neta work publish web works/games/<slug> --from works/games/<slug>/site --title "<title in the user's language>"
```

Then, as the last step - the run is not delivered until it is done:

8. **Hand over with a card.** One `interaction-components` card on its own line, target `{ "type": "work", "workId": "<id>" }`, the id from the publish output (fallback: `cohubWorkId` in `works/games/<slug>/meta.json`). Never a made-up id, a folder or a `world-file` link to `index.html`. Then one or two lines in the user's language: what the game is, the button uses, and whether the logo is the user's or a placeholder.

## Out of scope

- Do not change world settings or delete files that existed before the run.
- Do not modify memory, character cards, installed scripts, existing Works or roleplays; an older game built from this shell keeps its own copy of the shell and is never rebuilt.
- Do not edit `index.html`, `console.css` or `console.js` inside a game or the template; a shell upgrade changes the template and only affects games made afterwards.
- Make only the one game Work (and the package when asked).
- Build in this chat, on whatever model it runs; never hand the request to another chat.
- No server: the Work is a static page; never start a backend or publish a `--port` app.

## When to stop

- No game idea: ask once, then stop.
- The user asks for a game without the console frame, or for the game's design from nothing: say this skill supplies the console shell and stop.
- `new-game.mjs` says the folder exists: choose another slug; never remove the old one.

## Gotchas

- **Keep names unique in your game.js.** A dictionary named `T` collided with a tile size `T = 32`; every label printed `undefined` and the old self-check missed it. `verify.mjs` now fails on any `undefined` text on screen; keep it.
- **The POWER key belongs to the shell.** The game never receives it (keyboard `P` is power too). On `power` false pause sound and timers; on `power` true continue without resetting progress.
- **Portrait phones rotate the whole console 90 degrees.** Use `Handheld.held()` for movement and `Handheld.toLocal(dx, dy)` for drags; raw screen offsets point the wrong way.
- **Chrome 61 baseline.** Classic scripts only, ES2017 syntax, no `?.`, `??` or object spread, no CSS `inset`, flex `gap`, `clamp()`, `dvh` or `aspect-ratio`. `scripts/check.mjs` enforces this and the mini-tool container rules (no network, workers, WebAssembly, `eval`, inline scripts, external resources).
- **Save through `Handheld.storage`.** It uses the container cache on client 9.46+ and browser storage otherwise. Prefix every key with the game name so games in one browser never overwrite each other.
- **Overlays stay below z-index 1000.** The screen-off layer sits at 1000.
- **The pixel font is about 940 KB and covers Chinese.** It is licensed under the SIL Open Font License (`licenses/`); `pack-xhs.py` subsets it for the mini-tool. The web Work keeps the full font.
- **Never leave the placeholder logo as the final boot logo without saying so.**