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: Sampler Serpent
  • Inspired by: the Snake genre (a growing line that must not hit itself)
  • File: games/06-sampler-serpent/index.html (one self-contained file, no network requests)
  • Built by: Job B, 2026-11-14

What I built

A thread snake on a 16 by 20 cell cloth. It eats small motifs and grows. The game ends when the head hits its own body or a knot.

Additions to the genre:

  • The edges wrap around. The thread leaves one side and returns on the opposite side. This is kinder on a phone than walls.
  • Streak. Each motif you catch within 5 seconds of the last one raises a multiplier, up to ×5. A thin line under the cloth shows the time that is left.
  • Knots. After every fifth motif, a knot appears on the cloth as an obstacle (12 at most). A new knot never appears close to the head.
  • Scissors. A pair of scissors appears now and then for 8 seconds. It trims up to 5 segments from the tail, removes the oldest knot, and gives 30 points.
  • Gold star. A timed bonus worth 50 points times the streak.
  • The cloth remembers. Each motif you eat leaves a pale copy stitched into the cloth, so a long game fills the sampler.
  • Buffered turns. Up to three turns are stored, so fast double turns work.
  • Self-playing start screen. A simple pilot steers the snake behind the start card.

Controls: arrow keys or W A S D. On touch: swipe on the cloth (each 18 pixels of travel is one turn, so you can chain turns without lifting the finger), or use the four arrow buttons. Left and right are under the left thumb. Up and down are under the right thumb.

Looks

  1. Cross-Stitch (main). Linen cloth with a woven texture and a hole at every stitch corner. Every mark is an X made of two thread strokes: the snake (5 by 5 stitches for each cell), the motifs (heart, tulip, strawberry, bird, cherries), the knots, the scissors, and a border band with a zigzag vine. The head cell is stitched in during each step and the tail cell is unpicked stitch by stitch. When the game ends, the snake unravels from the tail.
  2. Bead String. Glass beads on dark velvet inside a gold frame. The snake is a string of shaded beads that glides smoothly. The food is a turning cut gem. Knots are steel nuts. When the game ends, the beads scatter.
  3. Circuit Trace. A green circuit board. The snake is a copper trace with right-angle corners, a solder-ball head, and light pulses that run along it. The food is a glowing LED. Knots are small black chips. When the game ends, the trace flashes red and fades.

Techniques

  • All art is drawn by code on a canvas. No images.
  • Cross stitches are collected by thread colour and drawn in two passes (the lower leg in a darker shade, the upper leg in the main shade). This gives each X a small amount of depth and keeps drawing fast.
  • The cloth, velvet, and board are drawn one time to a hidden canvas with a seeded random generator, so the texture is the same on every frame.
  • In the smooth looks the path is "unwrapped" across the board edges, then drawn again shifted by one board, with a clip. That is how the bead string and the trace cross the edge without a jump.
  • Sound is generated with the Web Audio API (plucked tones, a scissor snip from filtered noise).

What I am proud of

The cross-stitch look. The stitch-by-stitch head and tail make the snake look sewn, not moved. The pale copies of eaten motifs turn each game into a different finished sampler.

Known issues

  • The board is always upright (16 by 20). On a phone in landscape it is small (about 250 by 300 pixels) but playable.
  • In the Cross-Stitch look the eyes on the head are only two stitches. They are hard to see on a small phone. The head is a lighter green so it is still easy to find.
  • I did not tune the speed curve with human players.

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/t06.js) confirmed the rules: six motifs in a row give length 10 and a ×5 streak, a knot appears after the fifth motif, the gold star scores, the scissors trim the tail and remove a knot, a knot ends the game, Enter restarts with score 0, and a swipe turns the snake.

Issue found and fixed during testing: the background traces in the Circuit Trace look were too bright next to the snake. They are now fainter.