What it does
A round flies its targets on ballistic arcs from their launch times, origins and velocities, under its own gravity,
and marks fruit that fall below the floor as missed. You feed it the player's stroke: beginStroke, then
strokeTo with each new pointer position, then endStroke. Each segment of the stroke is swept against every
target's motion since the last sample, so a fast flick that jumps past a fruit between two frames still cuts it. Each
target is hit once, strokeTo returns what it hit, and a bomb ends the round at once.
Fruit cut within the combo window of a stroke's start count as one combo, and a combo of the minimum size or more
earns a bonus per fruit when the stroke ends. Too many fruit falling uncut loses. A fixed round is won once every
fruit is cut or missed with the score at the goal; an endless round runs until a bomb or the lives end it; a timed
round is judged when the time is up. For drawing, fragments() gives the two halves of every fruit cut in the last
three seconds, thrown apart by the cut and falling; they never affect play.
generateSwipeCut builds a round of waves from a seed and a difficulty in six layouts (fan, crossing, ladder,
split, ring and cascade), and certifies it with a scripted set of strokes that wins without touching a bomb, which it
returns as the solution. addTargets feeds an endless round wave by wave. Undo and redo step back and forward one
stroke, and hint() lists the fruit in flight with no bomb near them.
Features
- Ballistic targets — fruit and bombs with launch times, origins, velocities and hit radii, under configurable gravity.
- Swept strokes — each stroke segment tested against each target's motion, so fast swipes never skip a fruit.
- Combos — fruit cut within a window counted together, with a bonus from a minimum size.
- Bombs and lives — a bomb ends the round, and a set number of misses is allowed.
- Three kinds of round — fixed rounds with a score goal, endless rounds fed with new waves, and timed rounds.
- A seeded generator — six wave layouts, scaled by difficulty, each certified by a bomb-free performance.
- Cut halves — two fragments per cut fruit, flying apart, for your art.
- Hints, undo and redo — safe fruit to aim for, and strokes taken back.
- 2D or 3D — the rules use an x/y plane; project the pointer into it.
Good for
- Fruit-slicing games in any of their modes, classic, arcade or timed, in the style of Fruit Ninja.
- Endless touch games that keep throwing waves until the lives run out.
- Other swipe-to-slice mechanics, such as slashing thrown enemies, popping balloons or cutting ropes, where a hit depends on a swept stroke rather than a tap.
- Daily challenges, since a seed always builds the same round with a known winning performance.
- 3D-looking slicers, with fruit drawn as meshes and the blade projected onto the gameplay plane.
Make it yours
The pack has no manifest options; rounds are configured through its two functions. A SwipeConfig holds the targets
(1 to 10,000, each with a kind, a variety index for your art, a launch time, origin, velocity and radius), gravity,
the floor, the misses allowed, the combo window, the goal, whether the round is endless, a time limit and the scoring
(by default 10 a fruit, and 5 more a fruit for combos of three or more). The generator takes a seed, a difficulty
(easy to very-hard: more waves, fruit and bombs, faster flights, fewer lives, smaller fruit and a higher goal),
the number of waves, fruit and bombs per wave, the flight time, the layout and the misses; the parameters it returns
rebuild the same round.
Two different rounds: a classic endless game that starts from a generated round, appends two hard waves whenever the screen is clear and ends when three fruit are dropped; and a sixty-second arcade round, endless but timed, judged on its score, with bombs only in the later waves of your own authored targets.
A quick look
A generated round fed with the pointer each frame:
const level = game.swipeCut.generateSwipeCut({ seed: 8, difficulty: 'medium' });
const round = game.swipeCut.createSwipeCut(level.config);
game.step('fruit', dt => {
const p = toPlane(pointer); // your projection into the gameplay plane
if (pointer.pressed) round.beginStroke(p);
else if (pointer.down) round.strokeTo(p); // returns the ids hit by this segment
if (pointer.released) round.endStroke(); // closes the combo
round.step(dt); // 0 to 0.1 s; split longer frames
for (const t of round.active()) drawTarget(t, round.position(t));
});
Works with
shooting-gallery— for aiming at and shooting targets rather than slicing them.pointer— for tapping and aiming input.
Good to know
- The cut halves are scripted motion for drawing, not mesh slicing.
- There are no special fruit (frenzy, freeze or multipliers); add them with your own variety index and rules around
the ids
strokeToreturns. - A generated round has at most 20 waves and is certified by one scripted performance, not proven safe for every broad swipe; endless rounds built from generated pieces are not certified as a whole.
- Keep strokes and targets at the same depth, since the sweep measures 3D distance, and read
stateonce a frame, as each read is a copy.






