# Add Radial menu with slow motion to my game

Add the game element below to MY existing game, which you have not seen. It is a finished module file given with this prompt:

- `radial-slowmo.js` (one global, `GameDNA_RadialSlowmo`), API reference `radial-slowmo.README.md`

README example names are placeholders.

## Shared premises

1. **Include each module file verbatim; never edit it.** Load it with its own `<script src>` before the game's script, or paste it unchanged into its own `<script>` tag. If a module seems to need a change, adapt my game around it and tell me.
2. **Resolution:** keep my game's native resolution and integer scaling as they are. Call module draw functions on my 2D context inside the same transform as my sprites (one module pixel = one game pixel), and keep my game's own image-smoothing setting (off for pixel art, on for smooth or HD games; never switch it).
3. **Time:** drive every module from one fixed 60 Hz step (1000 / 60 ms). If my loop uses variable delta time, accumulate it and run whole steps (at most 250 ms per frame).
4. **Coordinates:** native screen pixels (world minus camera) unless a section says tiles.
5. **Art and names:** anything new you draw or name is original (no real game, character, place or brand names); English UI text; do not restyle my game.
6. **Hook, don't replace:** add calls or change bodies; never delete or rename a function.
7. **Keep every other caller working.** Find every caller and reader of what you change (turn order, input, moves, menus, HUD): autopilot/AI, test hooks, URL parameters such as `?auto=1`, `?t=` and `?freeze=1`, keyboard shortcuts, end-turn buttons. Update each one. My game's own autoplay must still finish a whole game. Keep existing HUD info (HP bars, max HP) and existing commands.

## Order of work

1. **Read the game first.** Write down (file, function) where these live: loop/update step; draw pass and its order (background, actors, effects, HUD); input; where damage/HP changes are applied; where turns, actions or selections are chosen and played; HUD windows and their rects; camera; battle/scene start and end; and every caller from premise 7.
2. **Check the prerequisites** below against those notes. If one is missing, add the smallest working version and tell me.
3. **Integrate one element at a time** (foundations, systems, UI, effects): (1) Radial menu with slow motion [ui].
4. **After each element, check the game still runs:** `node --check` each touched script (inline: copy to a temp .js), reload if you have a browser, run its self-check. Then the next.
5. Then the cross-element wiring and the merged checks.

## Prerequisites my game must already have

- **Radial menu with slow motion:** a fixed 60 Hz update step; a neutral input object for the world while radial.capturing(); the hero's screen position (anchor), the HUD / dialog rects, the canvas and its logical size; the things the player can pick (slots) and what each does (onSelect); render: radial.draw(ctx) last, after the HUD; radial.clear() on new game / scene change.

## Element 1: Radial menu with slow motion (`radial-slowmo.js`, `GameDNA_RadialSlowmo`)

Hold a key (default Q), the right mouse button or a touch button to open a ring of 4-8 slots (weapons, items, spells) around the hero; the world runs at 0.1-0.3x while it is open (a fixed-step gate: one world step in five at 0.2x), the scene dims and greys out except around the hero, and releasing on a slot picked by arrow keys, stick, mouse angle or finger drag uses it. A quick tap never opens it; Escape, a click outside or a second finger cancels. The ring stays on screen and off the HUD, and never covers the hero.

**Parameters chosen:** `slowmo` = 0.2, `slots` = 6, `holdMs` = 180, `dim` = 0.5, `desat` = 0.85, `key` = q, `spring` = springy, `style` = auto.

**Where it goes** (by role; find these places in my game):

1. *Once, after the canvas and the hero exist:* `radial = GameDNA_RadialSlowmo.create({canvas, view: {w: VIEW_W, h: VIEW_H}, anchor: () => ({x: <hero centre x - camera x>, y: <hero centre y - camera y (+ HUD offset if the field is drawn below it)>}), slots: () => [<{id, label, icon, count} for each weapon / item / spell / action>], uiRects: () => [<HUD rects, plus open dialog boxes>], canOpen: () => <normal play only>, onSelect: slot => <use it>, params: {slowmo: 0.2, holdMs: 180, key: 'q', dim: 0.5}})`.
2. *The fixed step (the one ?t= fast-forward and ?auto=1 also run), right after input is read:* `if (!radial.step(STEP_MS)) return;` before the autopilot and the world update; then the world gets `radial.capturing() ? <input with nothing pressed> : <the usual input>`.
3. *Things to pick:* With fewer than 4 existing weapons / items / actions, add slots that reuse existing mechanics (a heal on the existing HP, a dash on existing movement), each visibly doing something.
4. *Render:* `radial.draw(ctx)` as the very last call, after the HUD.
5. *New game / level / scene / respawn:* `radial.clear()`.

**Common mistakes** (symptom -> fix):

- The world runs at full speed with the ring open -> `step()` result ignored or called from render.
- The hero keeps walking while the ring is open -> the world still reads the held-key set; pass neutral input while `capturing()`.
- Timers or the play clock keep counting in slow motion -> they sit above the gate.
- The ring opens far from the hero -> `anchor()` in world coords; subtract the camera.
- The ring opens on the title or in a dialog -> `canOpen()` missing.
- The hold key also does something in the game -> pick another `key`.

## Merged acceptance checks (screenshot if you can; otherwise describe the trace)

- [Radial menu with slow motion] Hold the key in play: the ring springs open around the hero, the scene dims, enemies crawl at the slow speed; arrows / mouse / finger highlight a slot and release uses it.
- [Radial menu with slow motion] A quick tap does not open the ring; Escape cancels; next to an edge the ring stays on screen and never covers the hero; `?auto=1` ends as before.
- [combined] My game's autoplay (if any) still finishes a whole game; a full battle or turn cycle and a restart run with no console errors; at 500 px wide, no horizontal scroll.

## Self-check without a browser (report each)

- Each module file is byte-identical to the one given: `radial-slowmo.js` sha256 `347cafc57095700d...` (`shasum -a 256`).
- No function removed or renamed (compare name lists before/after).
- Every identifier you call exists where called; each instance exists before first use.
- [Radial menu with slow motion] The gate is right after input reading in the ONE fixed step; a skipped step changes nothing.
- [Radial menu with slow motion] The neutral input has every field the update reads; `canOpen()` is false off-play; `clear()` on each new run; `draw` last.
- [Radial menu with slow motion] Walk one use: hold 0.18 s (opens), 1 s open = 12 world steps instead of 60, Up highlights the top slot, release calls `onSelect` once.
- **Mandatory traces** (write each step: function, values): (1) one full autoplay battle or turn cycle through the new code, from start to the next turn or the end; (2) one enemy phase or enemy action. If my game has no autoplay, trace the same path from player input.
- Say how each caller listed in step 1 still works.
- Report which of my functions you changed for each element, and anything you could not do.
