Skip to the object
Tactile UI

Snake

The dot-matrix classic as a handheld made of kit parts. Steer the snake round a field of amber LEDs and eat the blinking dot to grow; it gets quicker every five dots.

What it is for

A game you could hold, drawn from the kit's own parts: a moulded case with a 16 by 14 amber dot-matrix screen over a slim LCD, a round-well D-pad, a Start key, a sound switch and a speaker grille.

Installnpx shadcn add https://tactileui.dev/r/snake.jsonWith a Pass: how

Controls

The switch on the case. On, eating and a crash each have a tone once you have pressed a key (a browser allows sound only after a press). The visitor’s own setting is kept on their device.

What a screen reader calls the case.

Everything you set here is what the Code and Prompt tabs give you.

Seats open in 11 days. Want one email that morning?

Datasheet

Mechanism
Shared handheld case, Pointerdown keys, Dot matrix canvas, Fixed step loop, Swipe steering, Segment lcd digits, Concentric corners, Scale as an object
Stack
Vanilla ES modules, CSS
Needs
Nothing, no dependencies
States
10 documented
Version
0.1.0
Licence
With a Pass

States

  1. How to playPress Start (or Space). Steer the snake to the blinking dot and eat it to grow by one. Every five dots it goes faster. Hitting a wall or your own tail ends the run; a turn straight back into the snake is ignored.
  2. KeysThe arrow keys or W A S D steer, and the D-pad keys go down while held. Space or Enter starts, pauses and resumes. On a phone, swipe on the screen to steer and tap it to start. Sound begins with the first press.
  3. Made ofThe kit's Panel (the case), the matrix window (the 16 by 14 field, drawn dot by dot with the part's own light), LCD (score and best in seven segments, a status line and eight speed segments), Lamp (state lamp), Key (the D-pad and the primary Start key), Tray, Switch (sound) and Grille.
  4. IdleAn S of a snake heads for its blinking dot on the screen; score and best read 000 and the LCD says Press start.
  5. PlayingThree dots long at the start, heading right. The head is the brightest dot and the body dims to the tail; each dot eaten runs down the body. The step is 210 ms at speed 1 and 20 ms less at each speed up to eight.
  6. PausedStart pauses and resumes, and a hidden tab pauses the run. The food stays lit and the LCD says Paused.
  7. Game overThe snake stays where it died, dimmed, and after a moment the score comes up over it in dots. The LCD says New best or Game over; a new best is kept on this device.
  8. SoundA short beep to start, a high blip for each dot eaten and a low tone on a crash. The switch turns it off; the choice is remembered.
  9. Reduced motionA held key shades but does not move, the food stays lit and the dots switch at once; the snake still moves.
  10. Twelve finishes, two volumesThe case reads the finish and volume tokens only, and the dots take the kit's matrix colour: aluminium, graphite and the other ten finishes, Tactile or Quiet.

Notes

Steer the snake to the blinking dot to grow it; every five dots the step shortens, through eight speeds. A wall or its own tail ends the run, and the best score is kept on the visitor's device. The screen is the kit's matrix window driven dot by dot, so it takes the finish and the dot colour from the kit.

Original. The case is the library's shared handheld (originals/components/shared/handheld), drawn from the kit's parts at one size and scaled as an object. The screen draws into the kit's matrix window and imports /kit/parts/matrix.mjs, so it needs the Tactile UI Kit on the page; the Code tab's example links it from ./kit/.

Anatomy

Shared handheld case, Pointerdown keys, Dot matrix canvas, Fixed step loop, Swipe steering, Segment lcd digits, Concentric corners, Scale as an object

Usage notes

A game you could hold, drawn from the kit's own parts. Steer the snake to the blinking dot to grow it; every five dots the step shortens, through eight speeds. A wall or its own tail ends the run, and the best score is kept on the visitor's device. The screen is the kit's matrix window driven dot by dot, so it takes the finish and the dot colour from the kit.

Options

OptionTypeDescription
soundbooleanThe switch on the case. On, eating and a crash each have a tone once you have pressed a key (a browser allows sound only after a press). The visitor’s own setting is kept on their device.
labeltextWhat a screen reader calls the case.

Methods

  • hooks
  • update
  • destroy

How it works

Original. The case is the library's shared handheld (originals/components/shared/handheld), drawn from the kit's parts at one size and scaled as an object. The screen draws into the kit's matrix window and imports /kit/parts/matrix.mjs, so it needs the Tactile UI Kit on the page; the Code tab's example links it from ./kit/.