What it does
You create a stack from a spec: the board's holes, the plates and the screws. A plate is any polygon, concave too, on a layer, with holes of its own; a screw sits in a board hole and fastens every plate whose hole lies over it, within a tolerance. A screw is covered while a plate on a higher layer lies over its head, and it cannot come out until that plate has gone.
Take screws out and the physics takes over. A plate held by two or more screws stays put; held by one, it swings round
it; held by none, it falls off the board. The plates are real rigid bodies on a physics-2d world that belongs to the
stack, so they turn and settle as a player expects, and a plate balanced over its last screw gets a small push rather
than standing there for ever. A screw that is out can be put into a free hole, or moved straight from one hole to
another, and fastens whatever plates line up there.
The stack knows nothing of colours, boxes, moves or winning. It reports what happened as events (a screw out, a screw
in with the plates it fastened, a plate pivoting, falling or gone) and says where everything is: plates() with their
outlines, holes, state, centre and angle, and screws() with their positions, the plates they fasten and whether they
are covered. Your game draws them.
Features
- Plates of any shape — any polygon, concave included, with holes of its own, on layers.
- Coverage — a screw is covered while a higher plate lies over its head, worked out from where the plates are now.
- Held, pivoting, falling, gone — each plate's state follows from its screws, on real rigid bodies.
- Moving screws —
remove,placeinto a free hole, andmovefrom one hole to another, each fastening what lines up. - Free holes —
free(hole)andfreeHoles()find holes with no screw and no plate's solid part over them. - Events —
out,in,pivot,fallandgone, drained after each step. - Validation —
createthrows listing every problem, andvalidatereturns them as sentences. - Colours as data — plates and screws carry a colour for rules that sort by it.
Good for
- Screw-sorting puzzles — tap screws out into colour boxes, with the
screw-sortrules. - Screw-moving puzzles — move screws between holes until every plank falls, with the
screw-relocaterules. - Screw puzzles with rules of your own — a different win, scoring or parking rule on the same plates and screws.
- Bolted pieces in other puzzles — a panel held by screws that swings loose and drops as they are taken out.
Make it yours
The spec is the configuration, and the pack has no options of its own: the board's size, holes anywhere on it, any
number of plates on any number of layers, any number of screws, tolerance (12 units) for how near a plate's hole must
be to a board hole to fasten there, and gravity (900).
Two different uses: a sorting game where bars, squares and discs in four layers are held by coloured screws that the player taps out, and the rules on top decide where each screw goes; and a relocation game where planks lie across a grid of holes with two spare holes, and the player moves screws into the spare holes so that one plank drops while another is caught.
A quick look
A bar on two screws, one taken out so it swings on the other:
const stack = game.plateStack.create({
width: 600, height: 800,
holes: [{ id: 'h1', x: 120, y: 200 }, { id: 'h2', x: 480, y: 200 }, { id: 'h3', x: 560, y: 600 }],
plates: [{ id: 'bar', layer: 0, points: [[100, 180], [500, 180], [500, 220], [100, 220]], holes: [[120, 200], [480, 200]] }],
screws: [{ id: 'a', hole: 'h1' }, { id: 'b', hole: 'h2' }],
});
stack.remove('a'); // the bar swings on b
game.step('stack', dt => stack.step(dt));
for (const e of stack.drain()) if (e.kind === 'fall') thud();
Works with
screw-sort— the rules of a screw-sorting game on these plates.screw-relocate— the rules of a screw-moving game on these plates.physics-2d— the rigid-body world each stack plays on, and the pack for bodies and joints in general.
Good to know
- Plates pass over and through each other: they hang from their screws and collide with nothing, as plates on separate layers do in these games.
- Coverage is worked out from where the plates are now, so a swinging plate can cover a screw for a moment.
- It is 2D, in the board's own units with y down, and it draws nothing.






