ExperimentsFable 5.2 Retro Games

The game has the keyboard when this page opens. If the keys stop working, click or tap the game. On a phone, Play full screen gives the game the whole screen.

  • Original title: Chalk Drift
  • Inspired by: the Asteroids genre (a drifting ship that breaks rocks into smaller rocks on a wrap-around field)
  • File: games/04-chalk-drift/index.html (one self-contained file, no network requests)
  • Built by: Job C, 2026-11-14

What I built

A small ship drifts on a field whose edges wrap around. Large rocks split into two medium rocks, and medium rocks split into two small rocks. A rock that touches the ship costs a life. The game ends when all lives are gone.

Additions to the genre:

  • Wipe. A limited shockwave that clears every rock, shot, and enemy near the ship. You start with one charge and can hold three. A small rock sometimes drops a pickup that gives one more charge.
  • Streak. Each rock you break within 2.6 seconds of the last one builds a multiplier, up to ×5.
  • The scribbler. A rogue doodle flies across the field and shoots at the ship. It is worth 250 points.
  • Extra life at every 5000 points (5 lives at most).
  • The field changes shape. It is 480 by 360 on a wide screen and 360 by 480 on a tall screen. Because the edges wrap, the field can change shape in the middle of a game.
  • Self-playing start screen. A simple pilot flies the ship behind the start card. It does not score and makes no sound.

Controls: Left and Right turn, Up thrusts, Space fires (hold to keep firing), Down or X uses a wipe. On touch there are five buttons (turn left, turn right, wipe, thrust, fire). You can also drag a thumb on the board: the ship turns to the direction of the drag and fires, and a long drag also thrusts.

Looks

  1. Chalkboard (main). A green slate board in a wooden frame, with eraser smears and a half-erased old lesson. Everything is a chalk line that "boils" slightly, like hand-drawn animation. Shots and the engine leave chalk dust that stays on the board and fades slowly. A broken rock leaves a puff of dust. A lost ship leaves a pink X. The wipe is an eraser: it rubs the dust off the board.
  2. Soap Bubbles. Underwater light shafts. The rocks are shiny bubbles with rainbow rims that wobble and pop into smaller bubbles. The ship is a bath duck. The enemy is a sea urchin. The pickup is a bar of soap.
  3. Microscope. A stained slide seen through an eyepiece with a reticle and a scale bar. The rocks are cells with a wobbling membrane and a nucleus, and they divide when hit. The ship is a small swimmer with a tail that whips faster under thrust. The enemy is a virus.

Techniques

  • All art is drawn by code on a canvas. No images.
  • Chalk texture: all chalk marks are drawn on a separate layer. Then a tile of random holes is cut out of that layer. The holes are fixed to the board, so a moving line looks like chalk dragged over a rough surface.
  • Chalk trails: a second layer keeps the dust. It is faded a little several times each second. Rounding stops the fade before zero, so a faint ghost stays, like a real board.
  • The bubbles are drawn one time for each size (a radial fill, a conic rainbow rim, and highlights) and then stamped with a wobble.
  • Cell membranes are closed curves through points that move with a sine wave.
  • Everything that crosses an edge is drawn on both sides.
  • Sound is generated with the Web Audio API.

What I am proud of

The chalk. The grain, the boiling line, and the dust that stays behind make the main look read as chalk and not as white vector lines. The eraser wipe that also cleans the board connects the look to a game rule.

Known issues

  • The ship is small on a phone in portrait (the field is about 360 pixels wide).
  • A wipe that catches many rocks at a high multiplier gives a large score. I did not tune the scoring with human players.
  • The drag control always fires while the thumb is down.
  • Phone landscape: the playfield is about 400 by 300 pixels, because the touch buttons take the sides.

Self-test

Tested with headless Chrome through .tools/selftest.js at 375x667, 740x360, and 1440x900. Result: all checks passed (no console errors, no network requests, start, pause, restart, all three looks, and all buttons and pads inside the screen).

A second scripted test (.tools/t04.js) confirmed the rules: the start screen plays itself without scoring, a large rock splits in two, a wipe destroys the rocks near the ship and uses its charge, a pickup gives a wipe, the last life ends the game, Enter restarts with score 0 and 3 lives, a drag turns the ship, a look change keeps the game state, and the field turns tall on a tall window. Result: pass.

Issue found and fixed during testing: the caustic rings in the Soap Bubbles background were too strong and looked like scribbles. They are now fainter.