What it does
Each round owns its own 3D rigid-body world. A structure of pieces stands on a floor under gravity, with goal pieces sheltered in it. A shot leaves the launcher at the velocity you give it; when a piece is struck harder than its material's strength it breaks into a few fragments, whatever it was holding up falls, and anything knocked off the play area counts as destroyed. The round is busy until the structure settles (or a time limit passes), so the next shot always meets the aftermath of the last. Destroy every goal piece within the shots you have to win; each destroyed piece scores its material's points, and a win earns three stars for using at most six tenths of the shots, two for fewer than all, and one otherwise.
The round gives a game the controls it needs. aimFromDrag turns a slingshot pull into a velocity, aimAt finds the
ballistic velocity that lands on a point within the launch speed, trajectory previews the free flight for an aiming
arc, and hint suggests a shot at a standing goal. Undo and redo rebuild the world and replay the shots, so a player
can take a shot back and the result is the same.
generateSiege builds levels from a seed and a difficulty. It draws structures from six families (towers, bridges,
pyramids, staircases, fortresses and cantilevers), mixes them on harder levels, and then plays each candidate through
the physics until it finds one it can win, returning the level, the winning shots and its measurements.
Features
- Real rigid bodies — pieces with size, mass and material on a physics world, so supports truly fail and structures fall their own way.
- Breakable materials — glass, wood, stone, goal and crystal by default, each with a strength, mass, score and shape, and your own beside them.
- Settling between shots — the round waits for the structure to come to rest, up to a set time.
- Aiming tools — a drag-to-velocity sling, aim-at-a-point, a flight preview and a shot hint.
- Undo and redo — the world rebuilt and the shots replayed.
- Stars and score — points per destroyed piece and a one-to-three star rating for a win.
- A level generator — six structure families, mixed by difficulty, each level proven winnable through the physics, with the same level from the same parameters.
Good for
- Slingshot demolition puzzles with structures to topple and targets to clear, in the style of Angry Birds.
- Siege and catapult games that knock down castles, in the style of Crush the Castle.
- Endless or daily puzzle modes, since every generated level is seeded and certified winnable.
- Physics teaching toys where players test how materials and supports fail.
Make it yours
The pack has no options; a round is its SiegeConfig. You lay out 1 to 160 pieces, each with a position, size,
material and whether it is fixed in place; set where shots leave from, gravity, the number of shots and the fastest
launch speed; merge your own materials over the defaults; choose which materials count as goals; set the floor (or
none) and the settle time. The generator takes a seed, a difficulty, a number of assemblies, a pattern (auto or one
family) and the shots allowed, and the parameters it returns rebuild the same level.
Two different uses: a hand-built level of a glass tower over a stone base with three goal pieces and four shots,
designed for a tutorial; and an endless mode that calls the generator with a new seed and auto pattern after every
win, raising the difficulty so harder levels add assemblies and tighten the shots.
A quick look
A generated level, aimed from a drag and drawn from the body poses:
const level = await game.slingshotSiege.generateSiege({ seed: 29, difficulty: 'medium' });
const round = await game.slingshotSiege.createSlingshotSiege(level.config);
const v = round.aimFromDrag(dragX, dragY);
if (released && v) round.fire(v);
round.step(dt);
for (const b of round.state.poses) if (!b.dead) drawBox(b);
Works with
physics-3d— the rigid world each round runs on; it ships with the pack and need not be composed.glass-corridor— for throwing balls at glass while travelling down a corridor instead.
Good to know
- It draws nothing: every body's pose is in the state for whatever renderer you use.
- One kind of shot; there are no special projectile abilities.
- Debris is bounded at four fragments a piece and 260 bodies in all, and a level has 1 to 8 assemblies and 1 to 60 shots.
- A certificate proves one winning sequence on the shipped physics at its fixed step, not the fewest shots, and a level for which no candidate can be proven throws an error.
- Rounds must be awaited when created and disposed when finished.






