Level builder

Players can build their own levels and share them as links. There is no server: the whole level travels inside the URL. This page covers the routes, the drawing board, the validation, and the link format.

Routes

RouteWhat it is
/buildA new level. The draft is restored from this browser when one is saved.
/build/<payload>Editing a shared level; the payload is decoded into the draft.
/shared/<payload>Playing a shared level, through the regular level screen.

Entry points: the paintbrush button in the app header (always there), and "Build a level" in the win modal once all 20 built-in levels are completed.

The drawing board

The solution, trying and validation

The creator writes the level's ideal program with the regular block palette and drop zones; that program is what gets stored and shown to players.

Try runs the program right on the builder page, through the same simulator as the game, so the creator sees the mouse walk, slide, win or die without leaving the page. Outcomes arrive as toasts, exactly like on a level. Open level page plays the finished level on its real page instead.

Validation and the draft save run 300ms after the last change, so continuous painting is never interrupted while slower edits are checked almost immediately. Save does not validate: any state can be the saved builder level. Nothing is reported inline: pressing Try, or Share when the level cannot be published, explains itself through a toast. A level is shareable when:

Share copies the link; the link itself is never shown. The publish button reads Save while the work differs from the saved builder level, and Share once the two match. Share stays disabled until the level is shareable, with the missing piece as its tooltip, so an unplayable level can never be published.

The link is base64url over a compact byte payload, never JSON:

version | random salt (4 bytes) | width | height | terrain | player | target
| cells (3 bits each) | title | author | solution | checksum (2 bytes)

Limits, chosen so an over-long link is practically impossible:

ThingLimit
Board16 by 16
Solution20 blocks
Level name60 characters
Creator name40 characters (empty means anonymous)
Link2000 characters (a worst case is under 400)

Playing a shared level

A shared level is adapted into the same LevelData a built-in level uses: the Playground, the simulator, the export and the outcome modal work unchanged. The differences:

Not in this version

There is no automatic path search: the creator authors the solution, and that is the validation. There is also no DOM test harness, so the builder's UI itself is covered by hand, not by tests; the codec, the schema, the adapter and the validation all have direct tests (see Testing).

Next: Algorithy Documentation.