What it does
game.screwSort.create(level) makes a game of a level, and tap(screw) is the only move. A covered screw stays put.
An uncovered one goes into the open box of its colour if one has room, or else into the waiting buffer. When a box is
full it leaves and the next box in the queue opens, and any screws of its colour waiting in the buffer board it at
once. Clear the board with the buffer empty to win; tap a screw with the buffer full and the level is lost to
overflow.
The plates and screws are a plate-stack stack that belongs to the level, so plates of any shape lie in layers, cover
the screws beneath them, swing on their last screw and fall when it goes, on real rigid-body physics. That is what
makes the order of taps a puzzle: the screw you can reach now may not be the one the open boxes want.
A generator lays out layered bars, squares, discs or a mix, with screws in colours that fill whole boxes exactly, and a
search proves each level can be cleared and records its solution. The game reports every take, boarding, full box,
opened box, fall, win and loss as events, and view() gives the plates, the screws, the open boxes, the queue still to
open, the buffer and its capacity, for your game to draw.
Features
- One-tap play —
tap(screw)says whether the screw went to a box, to the buffer, or nowhere because it is covered. - Colour boxes and a queue — boxes of a set capacity open in order, a set number at a time.
- A waiting buffer — a few slots whose screws board the next box of their colour by themselves.
- Plates on real physics — layered polygons that cover, swing and fall, through
plate-stack. - Generated levels — bars, squares, discs or a mix, in layers, with colours that fill whole boxes, from a seed.
- A solver —
solve(level)finds an order of taps that clears it. - Saves and restarts —
snapshotandrestorereplay the moves, andrestartstarts over. - Validation — each colour's screws must fill its boxes exactly, and
validatesays when they do not.
Good for
- Screw-sorting puzzles in the style of Screw Jam, with colour boxes and a buffer.
- Tap-to-sort casual games — the box-and-buffer rule on layered plates that must be cleared in the right order.
- Seeded daily puzzles — generated levels that are always clearable.
- Difficulty ladders — more plates and layers, fewer open boxes or a tighter buffer as the levels climb.
Make it yours
A level is a plate-stack spec with every screw coloured, plus boxes (the colour of each box, in the order they
open), capacity (3 screws a box), open (2 boxes at a time) and buffer (5 slots). generate takes a seed,
width and height (600 by 820), plates (8), layers (4), shapes ('bars', 'squares', 'discs' or 'mix'),
colours, capacity, open, buffer and plateColours.
Two different uses: a relaxed level of eight mixed plates in four layers, with two boxes open and a five-slot buffer; and a hard level of bars only, with more plates and layers, a single box open at a time and a buffer of three, where every tap has to be planned.
A quick look
A generated level played by tapping screws:
const level = game.screwSort.generate({ seed: 3, plates: 9, layers: 4 });
const play = game.screwSort.create(level);
game.step('screws', dt => {
const p = game.input.pointer;
if (p?.pressed) {
const screw = play.view().screws.find(s => Math.hypot(s.x - p.x, s.y - p.y) < 24);
if (screw) play.tap(screw.id); // 'box', 'buffer', or null when it is covered
}
play.step(dt);
});
Works with
plate-stack— the plates, screws and physics under every level.screw-relocate— the screw-moving game on the same plates, where screws go into free holes.pull-pin— another casual physics puzzle, of pins pulled to free what they hold.
Good to know
- The search works from where the plates start; the real plates swing as they lose screws, which can uncover more, or for a moment cover something.
- Every colour's screws must fill its boxes exactly, which is what makes sure waiting screws always find a box in the end.
generatethrows when no clearable level comes of the options it is given.- It draws nothing: the view gives the plates, screws, boxes, queue and buffer to draw.






