Lantern Relay is a small Canvas game: guide a firefly, collect three light seeds, avoid a moth, and return to a lantern within 35 seconds. You will need a text editor, a browser with developer tools, and Python 3 to serve the files locally. An AI coding assistant can make the changes, but you still need to read its instructions, run commands, and judge what happens on screen. No model subscription or external API is required to run the supplied game.

This guide is for a small single-player game served as static files. The main example uses Canvas; the puzzle, runner, and 3D sections explain how the rules and checks change for those projects. Multiplayer architecture and a complete course in each engine are outside this build.

Run the starter

Download the AI Browser Game Build Ledger v1.0, extract it, and open a terminal inside the extracted folder. That folder should contain README.md, test-game.mjs, and a game directory. Start the server there:

python3 -m http.server 8773 --bind 127.0.0.1
# Open http://127.0.0.1:8773/game/

Click Start relay or press Enter. Move with the arrow keys or WASD. On a narrow viewport, hold the direction buttons. Seeds disappear when collected, the counter increases, and the timer counts down. Press R to return to the ready screen; the header button starts a fresh attempt immediately. Those are two slightly different restart paths, so check both when changing the game.

The implementation is small enough to inspect without a build system:

  • game/index.html contains the canvas, instructions, status, start button, and direction controls.
  • game/styles.css sets the layout and shows direction controls on narrow screens or devices with a coarse pointer.
  • game/game.js contains the rules, fixed simulation steps, drawing functions, input mapping, and test helpers.
  • The files outside game/ provide briefs, an asset manifest, a milestone ledger, tests, and review checklists. They support development; they are not required to serve this particular game.

The original twelve-check Chrome suite passed again locally on October 15, 2026. We also completed a separate keyboard route from Start to a three-seed win, checked that returning without seeds did not win, and reset twice. Those additional checks are described below; the v1.0 download retains its original suite. Physical-phone usability and device performance still need separate testing.

Make your first change: give the player 45 seconds

Work in a copy of the extracted kit. Open game/game.js and find START_MS near the top. Change this one value:

const START_MS = 45000;

makeState() uses that constant for every new attempt. In game/index.html, also change the initial text inside timeLeft from 35.0s to 45.0s. The running game updates that text from state, but keeping the initial HTML consistent avoids a misleading value before JavaScript starts.

Stop the original Python server with Ctrl+C. In a terminal opened at the copied kit's root, start the same server command again. Otherwise the browser will keep serving the original folder. Reload the game. Before starting, the time should read 45.0s. Start, let it count down, press R, and confirm that the ready screen restores 45.0s and zero seeds. Also click Restart relay during an attempt. That path should create a fresh 45-second attempt immediately.

The original browser test expects 35 seconds in its restart-baseline check. In your copied test-game.mjs, change only this comparison:

restarted.remainingMs === 45000

Keep the counter and position assertions beside it. They catch unrelated reset failures. Do not remove the timeout check: its preset deliberately leaves eight milliseconds so it can test expiry quickly at either duration. If you keep the copied briefs as instructions for later work, change their 35-second description to 45 seconds too.

We made these edits in a separate local copy. Its display showed 45.0s and all twelve checks passed with the updated reset expectation. The original download still uses 35 seconds. A longer timer changes difficulty, so have someone try the route before choosing the final duration.

Choose a stack for the game you are building

Choose the interaction first. A turn-based word puzzle mostly needs selectable cells, text, focus, and rule validation. A platformer needs continuous movement and collision response. A 3D exploration game needs a camera and spatial navigation. These projects need different foundations even if the same AI assistant writes their code.

Starting pointA useful fitWork to account for
HTML, CSS, and JavaScriptA card game, quiz, word puzzle, or small turn-based board.Represent legal moves and turns in data. Use HTML controls for selection and keyboard focus.
Canvas and JavaScriptA compact 2D action game with a few moving objects, such as Lantern Relay.Write the loop, input, collisions, loading, and accessible controls around the drawing surface.
PhaserA 2D game with several scenes, animated sprites, tilemaps, or physics interactions.Learn the framework's lifecycle and pick a physics approach that matches the mechanics. Keep game rules separate from scene decoration.
Three.jsA game whose interaction depends on 3D space, a controllable camera, or 3D objects.Add the game rules and interaction systems around the renderer. Decide how movement, collision, and camera obstruction work.
Godot WebA project that benefits from an editor, reusable scenes, or possible native exports.Check the web export's renderer, browser, and hosting requirements before committing to the engine.

Phaser's first-game tutorial shows loading, scene functions, input, and physics in one playable project. For Godot, read the current web-export documentation before designing around desktop features. Lantern Relay uses Canvas because its single screen and geometric objects fit in three files. That choice would become less convenient if each new level required rebuilding a scene system by hand.

If an existing demo already has working movement and a suitable engine, keep it while you finish the loop. Ask the assistant to identify where state, input, and rendering live before proposing a migration. A switch is justified when you can name the blocked requirement, such as collision response the current code cannot maintain. Our inspectable browser-scene guide covers scene and camera inspection in more detail.

Write the rules before asking for more features

For one attempt in Lantern Relay, the rules are specific: the player starts at a known position with zero seeds and 35 seconds remaining. Each seed can be collected once. Contact with the moth ends the attempt. Reaching the lantern wins only after collecting all three seeds. Restart restores the objects, timer, and input state required by the chosen restart behavior.

Name the phases so the assistant cannot treat the start screen, active game, and result screen as unrelated visual effects:

PhaseWhat can happenWhat to verify
READYShow the goal and wait for Start.Movement and the countdown do not begin early.
PLAYINGMove, collect, update the moth, and evaluate outcomes.Every collected seed changes both the world and the counter exactly once.
WONShow the completed route and offer another attempt.The timer and hazards cannot turn the win into a later loss.
LOSTExplain the loss and offer another attempt.Input cannot keep moving the player underneath the result screen.

Resolve simultaneous events explicitly. The supplied code checks moth contact first, timeout second, and a completed return third. That means a collision on the same update as reaching the lantern loses. You may prefer a different rule, but write it down and test it. Otherwise a later refactor can change the game's outcome without changing its appearance.

Write different rules for each genre. For a sliding puzzle, define a legal move, a solved board, undo, and whether every generated starting board must be solvable. For a runner, define a valid jump, landing, obstacle contact, scoring, and restart speed. For a card game, define whose turn it is, which actions are legal, and when a turn ends. A screenshot of a board or a moving character leaves these questions unanswered.

Give the coding assistant a sequence of small builds

Use a new folder or a recoverable copy of the current project. For an existing demo, first ask for the entry file, run command, dependencies, state locations, and known failures. Run that version yourself and retain a working checkpoint before editing. The vibe-coding safety guide explains the broader file and command boundaries.

Use this editable brief to ask a coding assistant for the first playable version:

Build milestone 1: one playable browser-game loop.

Use HTML, CSS, Canvas, and JavaScript in this project folder.
The player moves a firefly, collects three seeds, avoids one moth,
and returns to a lantern before a 35-second timer expires.

Use READY, PLAYING, WON, and LOST states.
Use simple original shapes. Add no external service or dependency.
Keep keyboard and visible direction controls on the same input state.
Specify the priority if collision, timeout, and win happen together.
Document what Start, Restart, and R each do.

Deliver the source files, a local run command, and checks for:
start, movement, single collection, premature return, loss, win,
and two consecutive restarts. Report checks you did not run.

Preserve unrelated files. Do not deploy the project.
Stop after this loop works; defer extra levels, art, and audio.

Review each milestone against an observable result. First get a complete attempt working with shapes. Next add inspection and reproducible outcome checks. Then check input and the smallest supported layout. Replace one asset group, replay the same checks, and only then add another level or mechanic. Keep a short note with the files changed, checks run, failures, and open decisions at each checkpoint.

When a change fails, describe how to reproduce it and what should happen. This hypothetical bug report shows the level of detail to provide:

Bug: after a loss, restarting leaves one seed missing.
Reproduce: start, collect seed-a, lose to the moth, press R, start.
Expected: zero collected; seed-a, seed-b, and seed-c all present.
Inspect reset and collection state first. Keep art and movement unchanged.
Add a regression check that follows this sequence twice.
Show the smallest fix and its actual check result.

For a feature request, be equally precise: adding a second moth changes hazard configuration and reset data, so ask for a starting state containing two distinct hazards and a check that neither survives into the next attempt in an old position. Avoid combining that change with new art and a new engine in the same revision.

Keep movement, time, and collision consistent

Use one input state and a separate update function

Keyboard and touch handlers should record intentions such as left: true. The simulation reads those intentions and changes the player position. Drawing then reads the resulting state. If each input handler moves the player directly, keyboard repeat and touch events can produce different speeds and make repeatable checks harder.

Lantern Relay normalizes diagonal input, so holding up and right does not move faster than holding right alone. Its logical canvas is 900 by 560, with movement at 218 coordinate units per second. The displayed canvas can scale with the page; movement stays in those same game coordinates. At 100 milliseconds, an unobstructed horizontal movement is about 21.8 units. The existing movement check reads a rounded change from x=450 to x=472. Try the route yourself before deciding whether that speed is comfortable.

Separate simulation time from drawing frames

requestAnimationFrame usually follows the screen's refresh rate. Movement by a fixed distance on every callback therefore varies with the display. Calculate progress from time or use fixed simulation steps. The starter accumulates elapsed time and updates in steps of 1000 / 60 milliseconds before drawing.

Also choose what a hidden tab means. A single-player puzzle might pause; an online match may need to follow server time. Browsers commonly suspend animation callbacks and throttle timers in background tabs, as documented by the Page Visibility API guide. Lantern Relay limits the time processed after one drawing frame to 80 milliseconds. It has no explicit pause screen, so its 35-second countdown is simulation time and should not be described as a reliable wall-clock deadline after tab switching.

For an explicit pause feature, clear held input when hiding the page, suspend simulation, and show a Resume action on return. Reset the frame timestamp when resuming so the first frame does not consume the hidden interval. Test leaving the tab while moving, returning, and resuming without touching a direction control. These are extension requirements; the supplied four-state starter does not implement them.

Match collision shapes to the rule

The starter uses circles and compares the distance between their centers with the sum of their radii. That simple approach fits its round player, seeds, and lantern; MDN describes it alongside rectangle tests in its 2D collision guide. The decorative glow extends beyond the player's collision radius. Increasing the glow should not silently make the player easier to hit.

Add a temporary collision outline when contact feels unfair. Try a near miss, an edge touch, and an overlap from each direction. For fast projectiles or a runner, an object can move from one side of an obstacle to the other between discrete updates. If a reproducible check shows that happening, use smaller physics steps or a collision method that considers the traveled segment. Merely enlarging every obstacle's hitbox changes difficulty and can conceal the timing problem.

Keep restart data in a fresh state factory. Restore collected flags, counters, hazard positions, timer, and phase. Clear held keys, active pointer controls, and temporary effects according to the restart behavior you chose. Lantern Relay's R-reset calls clearInput(), while the header button's start function does not. Our targeted local check confirmed that holding Right through a button restart continues movement in the new attempt. Decide whether that continuity is intended, then make both the interface wording and the regression check match it.

Test complete routes as well as preset outcomes

In the browser console, the starter exposes a small snapshot:

window.__LANTERN_RELAY__.getState()
// contractVersion, phase, fixture, collected, required, remainingMs,
// player, moth, uncollectedSeedIds, reducedMotion

The snapshot is a summary of the current game, with copied values that a test can read without changing the world. Compare the visible seed counter with uncollectedSeedIds to catch a display that disagrees with the rules. Keep these returned fields small and version them when a test-relevant field changes.

The test helpers can load four preset scenes, called fixtures in the code: baseline, near-win, collision, and timeout. Loading one switches off automatic simulation; step(ms) advances it manually. For example, this reaches a timeout without waiting 35 seconds:

window.__LANTERN_RELAY__.loadFixture('timeout');
window.__LANTERN_RELAY__.step(17);
window.__LANTERN_RELAY__.getState();
// Expected: phase === 'LOST', remainingMs === 0

A near-win fixture tests the last transition. It skips collecting the seeds and most of the route. Also play from a fresh start with ordinary controls, checking that each seed disappears once and returning early does not win. Repeat after a loss and a win. Reading state to check progress is useful; teleporting the player or pre-filling the counter skips the actions this run needs to exercise.

For this revision, we used ordinary keyboard input through browser automation to complete one local attempt without loading fixtures or changing game state. The route collected the lower-right seed, continued up the right side for the upper-right seed, crossed the upper part for the upper-left seed, and approached the lantern from above. The game showed 3 / 3, WON, and 27.9 seconds remaining. A separate early return with zero seeds stayed in PLAYING; R restored READY, zero seeds, and 35.0s after both sequences. This is one observed route, not a guarantee that every route or timing works.

To rerun the original suite, install Node.js and Google Chrome, then install Playwright inside the extracted kit folder. Keep the Python server running in one terminal and use a second terminal in the same folder:

npm install --no-save --no-package-lock playwright
node test-game.mjs
python3 release-gate.py

The script looks for common Chrome installation paths. If yours differs, set CHROME_PATH to the browser executable. It writes results and screenshots into evidence/, replacing the extracted copies. Preserve that folder first if you want to compare it with the September run. Read the new timestamp and all twelve named results before interpreting the Python validator: running it alone checks the existing evidence and does not launch a browser.

The suite uses 1440 × 900 and 390 × 844 viewports with reduced motion. Playwright emulation can configure viewport, touch support, and other browser properties, but it does not reproduce the hardware or operating system of a phone. The supplied mobile check dispatches synthetic pointer events, so add actual interaction and physical-device checks for the devices you intend to support.

Remove or protect helpers that change game state if they reveal hidden information or grant abilities that matter in a published game. In a local single-player example they are useful inspection tools. In a competitive game, a client-side counter or fixture must never authorize a reward or establish a trusted score.

Make the controls usable on phones and with a keyboard

First check the interface at the smallest supported size: goal, playfield, status, and controls should remain readable without document-level horizontal scrolling. The user's thumb should not cover an objective that the game requires them to see. Test portrait and landscape, browser zoom, and rotating the device during an attempt. A screenshot can show layout; it cannot show whether a finger reaches a control comfortably.

For held touch controls, handle press, release, cancellation, and loss of focus. Pointer events provide one input model for mouse, pen, and touch. Pointer capture can help a control receive the release after a finger moves outside it. Apply touch-behavior rules to the play area or controls that need them; suppressing scrolling and zoom across the entire page makes instructions and navigation harder to use.

The starter clears input on window blur and releases a direction on pointer cancellation or leaving its button. It does not implement a full multi-pointer ownership system. If you add simultaneous movement and action buttons, track which pointer owns which action and test lifting one finger while another stays down. A single boolean can otherwise be cleared by the wrong release event.

Keep Start, Restart, sound settings, and result messages in HTML. As the Canvas accessibility guidance explains, drawn objects do not expose semantics like HTML elements do. HTML around a canvas helps with instructions and status; it does not automatically make a spatial action game playable with a screen reader. For a turn-based board, HTML cells with labels and deliberate focus behavior may be a more useful starting point.

Our local check found another starter limitation: pressing Space on its focused Right direction button did not move the player. Keyboard users can use the arrow keys or WASD, but the visible direction buttons currently respond to pointer events. If those buttons are part of your keyboard interaction design, implement and test that activation path. Also review the live status region: announcing a changing timer repeatedly can obscure a collection or result message. Test announcements with the intended assistive technology.

If you add sound, begin playback from the player's Start or sound-toggle action and handle a rejected play request. Browser autoplay restrictions can block audible playback without interaction. Provide a mute control, retain visible feedback for events, and check that repeated restarts do not layer multiple music tracks. Lantern Relay has no audio, so its passing suite provides no evidence about sound behavior.

Adapt the loop to puzzles, runners, and 3D games

Turn-based puzzles and card games

Replace continuous movement with an action function such as applyMove(state, action). Validate the action before changing state. For a card game, selecting a card and playing it are different actions; decide whether selection alone consumes a turn. Record enough information to test an illegal move, a legal move, the last winning move, and restart from a partially completed board.

If you generate puzzles, record a seed and the generated board so a failure can be reproduced. For a sliding puzzle, one proposed approach is to scramble by legal moves from a solved board while rejecting the solved result. Whatever generator you choose, verify its solvability guarantees and actual difficulty separately. A large shuffle count alone does not measure how hard a puzzle will be for a person. This is an adaptation plan, not functionality included in Lantern Relay.

Runners and platformers

Test jump initiation, time in the air, landing, contact with an obstacle, and recovery. State whether holding Jump repeats the action or requires a new press. If you add a brief grace period after leaving a ledge or allow a jump press just before landing, name those rules and their durations so an assistant does not accidentally remove them during cleanup.

For generated obstacles, start with a fixed sequence. Check that the distance between obstacles allows the defined jump to finish before the next required action. Then add generation with a reproducible seed and reject sequences that violate those constraints. Replay the same sequence after changing speed or jump physics. Lantern Relay's circular overlap test does not supply platform collision response or prove a runner's routes are possible.

3D exploration and larger projects

Prove walking, turning, camera control, one interaction, and recovery from a blocked path in an untextured scene before importing a detailed environment. Check the camera near walls and behind the player, object scale, collision proxies, and what happens when pointer lock is released. Keep a visible route back to the instructions and controls.

Local saves, accounts, leaderboards, and multiplayer add different requirements. For local progress, localStorage persists by origin across normal browser sessions, but access may be blocked and users can clear the data. Catch storage errors, validate loaded data, and offer a reset. Test missing, malformed, and older-version saves. The starter has no persistence. For multiplayer or rewards, plan server-authoritative rules and independent security review; extending this static example does not supply a trusted backend.

Add assets without changing the rules accidentally

Diagram showing game rules and visual design developing in parallel before joining for release
Rules and presentation can develop in parallel, but they come together around the same playable loop before release. Credit: Original diagram by Grow AI Skills. Open full-size image.

Keep a placeholder build that still runs while you integrate art. Replace the player first, then one collectible or hazard, and replay collection, collision, and restart. Compare the visible body with its collision outline at the size it appears during play. A detailed sprite that faces the wrong direction or hides behind its own glow can make a working rule difficult to read.

Record each asset's path, role, source, creator or provider, usage terms, dimensions, and file size. For generated assets, retain the tool and generation record plus the terms you relied on. The label “AI-generated” alone does not answer what permissions you have. The supplied manifest covers the original geometric artwork drawn by the JavaScript source. Add a separate record for each image or sound you introduce.

For 2D art, check transparency, sprite-sheet frames, anchor points, and whether outlines remain visible against the actual background. For 3D assets, check units, orientation, texture references, animation names, and a simple collision proxy. For audio, check event timing and overlapping instances. Integrate the exported asset into the game; a successful render in an art tool cannot establish its in-game size or readability.

If you use Blender, keep the source file and generation script together, record the exact Blender version, and export to a predictable directory. Review a few useful angles and one in-game capture before replacing the placeholder. This Canvas game needs no 3D asset pipeline.

Keep experimental art and mechanics recoverable. An experiment note should state what changes and what would justify keeping it: for example, “replace the moth silhouette while preserving its collision radius; retain it if the hazard remains distinguishable at the smallest supported viewport.” If the result is unclear, restore the last accepted asset and continue with the playable build.

Diagnose the failure before asking for a rewrite

Record the URL, browser, input sequence, expected result, observed state, and first relevant console or network error. Change one likely cause and replay that sequence. Start with the evidence in the middle column, then replay the action in the last column.

SymptomInspect firstCheck after the change
Blank page or canvasJavaScript exceptions, script response, canvas lookup, and asset paths.Reload in a fresh session; the ready screen and first frame must both appear.
Character moves faster diagonally or on another displayInput-vector normalization and whether speed uses elapsed time.Compare distance for equal simulated durations with horizontal and diagonal input.
Movement continues after releasing a controlRelease, cancellation, focus loss, and pointer ownership.Drag outside the button, switch tabs while holding, and release one of two fingers.
A seed counts twice or returns after a lossCollected flag, unique ID, counter derivation, and state reset.Overlap the same seed repeatedly, lose, restart, and collect it again.
Timer jumps after a tab switchPause policy, timestamps, and accumulated elapsed time.Hide and restore the page, then compare the result with the documented policy.
Preset win passes but normal play cannot winReachability, collection rules, early-return behavior, and outcome priority.Complete an attempt from the initial state using ordinary controls.
Local build works; hosted build failsExact asset filename case, base paths, MIME types, response bodies, and required headers.Open the hosted URL directly and inspect each failed request before changing game logic.
Playwright cannot load or find ChromePackage installation location, Node environment, and the browser executable path.Run from the kit root; install the package there or provide the documented environment configuration.
Evidence looks successful after a new changeResult timestamp, target URL, required check names, and whether the browser suite actually ran.Regenerate results against the changed build before running the evidence validator.

If the browser cannot launch or a package cannot load, fix that setup failure before interpreting the game results. If the checks pass while a player still gets stuck, add the missing action sequence to the suite. The supplied validator checks exact result names; it cannot discover an untested route by itself.

Check performance, player understanding, and effort

For performance, choose a device and scene before naming a target. A 60-frame-per-second target leaves about 16.7 milliseconds per frame; a 30-frame-per-second target leaves about 33.3. These are frame intervals, not measured Lantern Relay results. Record start-up time, frame pacing in the busiest scene, and response to input on representative hardware. A desktop recording or reduced-motion layout check does not provide those measurements.

Use a browser performance recording to locate a repeatable stall. web.dev's long-task guidance explains how extended main-thread work can delay interaction. If art introduced the slowdown, compare against the placeholder build: inspect image size, decoding, draw count, and repeated allocations. Cache an unchanged background or reduce an expensive effect only when the comparison points to that work. Recheck collision and feedback after simplifying visuals.

For player understanding, ask someone who has not seen the brief to make an attempt without coaching. Observe whether they can identify the player, understand the return condition, notice why they lost, and find restart. Record the action or misunderstanding that occurred. If they repeatedly return before collecting all seeds, improve the visible return requirement and check again; adding another level will not resolve the instruction problem.

For production effort, keep elapsed project time, human attention, agent activity, and actual spending in separate columns. Record what was built and what still needs work. Two assistants working for an hour overlap in elapsed time, and repeated art attempts can consume effort without changing the accepted build. Set a checkpoint before a new art or architecture experiment so you can stop with the last working version.

Prepare hosting and verify the exact public URL

For this starter, the deployable game is the contents of game/. If you put those files directly in a host's public directory, the entry is index.html at that directory's URL. If you upload the whole kit instead, the game remains under /game/. Decide which address you intend to share and test it directly. You do not need to publish test reports or development briefs to make the game run.

Use relative paths that work at the chosen location, exact filename case, and HTTPS for the public release. For a bundled framework project, upload the generated output directory documented by that project, along with all required assets. Opening the HTML through file:// is not an adequate hosting test, especially once modules, fetched files, or storage are involved.

Engine exports can require additional host configuration. Godot's threaded web exports require a secure context and cross-origin isolation; follow the serving instructions linked earlier. Do not add isolation headers to a whole existing site without checking its other integrations. A non-threaded export may be a simpler fit when you cannot configure the host, subject to that export's documented limitations.

  1. Keep the previous working files or a versioned release directory so you can restore them.
  2. Upload only the intended build, then open the final URL in a fresh browser session.
  3. Check the network panel for missing files, incorrect content types, and HTML error pages returned where scripts or assets were expected.
  4. Start normally, collect an object, lose, restart, finish a complete route, and restart again. Refresh the shared URL directly.
  5. Repeat on the promised browsers and physical devices. Check sound and focus behavior if those features exist.
  6. Record the build version, URL, device, browser, date, result, and unresolved failures before calling the release ready.

If an older build still appears, compare the served script with the uploaded file and inspect caching before changing the rules. Use your host's normal cache invalidation or versioned assets to deliver a consistent release. If the hosted version fails a core start, movement, outcome, or restart check, restore the previous working build and investigate the failed request or state transition.

To practice the full method, add a second moth to a copy of Lantern Relay. Preserve the three-seed return rule, give both hazards distinct IDs, reset both on a new attempt, and update the inspection data and outcome fixtures. Then complete a normal-input route and try two consecutive restarts. Save the changed source, new test results, and device observations together; those files tell you which version you can reproduce and which release decisions remain open.