Skip to content

244 pixel art effects, every one a small piece of code. Plus a Claude Code skill to make your own.

pixelfx 0.3.0: give the effects a body that performs them

rehan-remadea84159688af3
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index 1ba7302..0fece42 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "pixelfx",
"displayName": "pixelfx",
- "version": "0.2.0",
+ "version": "0.3.0",
"description": "Pixel art effects and animations as code: a library of ready-made effects in 20 categories, sprite sheet export for any engine, and a skill that makes new effects by drafting, rendering, looking and refining.",
"author": {
"name": "Patch",
diff --git a/NOTICE.md b/NOTICE.md
index 2c3098d..bd049df 100644
--- a/NOTICE.md
+++ b/NOTICE.md
@@ -3,5 +3,9 @@
**Hugo Duprez.** `src/core/sim.js` and the effects that say so at the top of their file adapt Sprite Fusion's
open-source pixel art VFX (https://www.spritefusion.com/pixel-art-vfx), Copyright (c) 2026 Hugo Duprez, MIT License.
+**Hollow Crown.** `src/core/act.js` adapts how Hollow Crown plays its skills (poses on 12 fps steps, hit-stops, the springy
+straw target), from
+https://github.com/rehan-remade/hollow-crown, Copyright (c) 2026 rehan-remade, MIT License.
+
**Patch Pixel.** The font in `gallery/fonts` is Patch's own and is not covered by this repository's MIT license. See
`gallery/fonts/NOTICE.md`.
diff --git a/README.md b/README.md
index e55fcad..0c38247 100644
--- a/README.md
+++ b/README.md
@@ -4,13 +4,16 @@
# pixelfx.
-**<!-- count -->232<!-- /count --> pixel art effects and animations, every one a small piece of code.** Fire,
+**<!-- count -->244<!-- /count --> pixel art effects and animations, every one a small piece of code.** Fire,
explosions, magic, weather, UI, pickups, critters and more. Play them live, recolor and mirror them, drop them into
a browser game, or export sprite sheets for any engine. Plus a Claude Code skill that makes new ones the way a
picky pixel artist would: draft, render, look, refine.
-**[open the gallery](https://patch-gg.github.io/pixelfx/)** · [catalog](docs/CATALOG.md) · [the skill](#the-skill) ·
-[make your own](#make-your-own) · [how it works](#how-it-works)
+Every effect that involves a character is **acted out**: he winds up, lets go, freezes on contact and recovers, and a
+target takes the hit. Twelve whole moves chain the effects into attacks from wind-up to recovery.
+
+**[open the gallery](https://patch-gg.github.io/pixelfx/)** · [catalog](docs/CATALOG.md) · [acting](#acting) ·
+[the skill](#the-skill) · [make your own](#make-your-own) · [how it works](#how-it-works)
The method is [Hugo Duprez](https://x.com/HugoDuprez)'s, from [How to make (good) pixel art effects with
Claude](https://www.spritefusion.com/blog/how-to-make-good-pixel-art-effects-with-claude): code is clay, trust your
@@ -23,6 +26,7 @@ the idea at library scale, with a skill to keep going.
<!-- catalog -->
| category | effects | some of them |
|---|---|---|
+| **moves** | 12 | arrow shot, dash strike, earth stomp, fireball throw, ground pound, holy smite… |
| **fire** | 12 | brazier, campfire, candle, fire breath, fire ring, fire tornado… |
| **explosions** | 12 | barrel explosion, big explosion, cartoon pow, dirt explosion, firework burst, firework rocket… |
| **water** | 12 | bubbles, drip, fountain, geyser, rain splash, ripples… |
@@ -89,6 +93,60 @@ pink without touching its code:
node tools/render.mjs fire/torch --gif --opts '{"palette": ["#102","#215","#43a","#8cf","#cff","#fff"]}'
```
+## acting.
+
+<p align="center">
+ <img src="docs/readme/acts.gif" width="800" alt="A grey dummy fighting a straw target: a three-stroke sword combo, a hammer smash, a ground pound, a holy smite, a frost nova and a run with after-images, each with a wind-up, a freeze on contact and a recovery.">
+</p>
+
+An effect on its own looks like a sticker. What sells a hit is the body around it: the wind-up that says something is
+coming, the freeze on contact, the target rocking back, the recovery. So the 61 effects with a character, and the 12
+moves, say what the body does and when:
+
+```js
+export const act = {
+ target: { x: 58 },
+ poses: [
+ [-0.55, GUARD], // he starts before the effect does (t = 0 is the effect's first frame)
+ [-0.3, WIND_UP],
+ [0, CUT, "snap"], // "snap" holds the last pose and jumps on the key
+ [0.06, FOLLOW_THROUGH, "snap"],
+ [0.86, GUARD],
+ ],
+ hits: [{ t: 0.06, stop: 0.14, shake: 0.18, amp: 2, push: 2.8, straw: 18 }], // freeze for 0.14 s on contact
+};
+```
+
+**Play the whole thing**, character and target included, by swapping `createFx` for `createAct`:
+
+```js
+import { createFrame, clearFrame, createAct, composite } from "pixelfx";
+import * as slash from "pixelfx/fx/melee/sword-slash";
+
+const act = createAct(slash, { x: 80, y: 140 });
+
+function tick(dt) {
+ act.update(dt); // holds still by itself during a freeze
+ clearFrame(frame);
+ act.draw(frame); // { body: false } and { target: false } leave them out
+ composite(frame, img.data, backgroundColor);
+ const [sx, sy] = act.shake; // throw the picture this far
+ ctx.putImageData(img, sx, sy);
+}
+```
+
+**Got your own character?** Effect ids haven't changed and a sprite sheet is still the effect alone, so existing games
+keep working. (Effects drawn on the body paint the stock dummy, so regenerate those if you ship them.) The timing is plain data: read `slash.act`, or `meta.pixelfx.act` in a sprite sheet's
+JSON (`windup`, `recovery`, `hits` with `t` and `freeze`, `poses`). Start your own wind-up animation that long before the effect, and
+stop updating everything for `freeze` seconds at each hit.
+
+Effects drawn on the body (frost, poison, a scan line) are written against the standing character and follow him
+wherever he goes: each pixel of a pose knows which pixel of the standing body it came from. `node tools/act.mjs
+<id> --sheet` bakes a whole act, character included, into a sprite sheet.
+
+The body is yours to use too: `skeleton(pose)` gives you every joint of a pose in 3D, to hang your own things on, and
+`posedParts(pose)` gives you each part drawn on its own.
+
## the skill.
The `pixelfx` skill teaches Claude Code to find, use, export and make effects. Install it as a plugin:
@@ -104,6 +162,7 @@ or copy `skills/pixelfx` into `~/.claude/skills/`. Then ask for what you want:
- "Make five takes on a coin pickup sparkle and show me the best two."
- "Export the fire and explosions categories as sprite sheets for Godot."
- "This hit effect feels floaty. Make it punchier."
+- "Give this spell a wind-up and make the enemy react to it."
## make your own.
@@ -114,7 +173,8 @@ node tools/check.mjs arcane/my-spell # spills, seams, unseeded randomness, s
```
Then go round: look at the contact sheet, fix the worst thing, render again. `--gif` and `--mp4` show the motion,
-`--all` shows every frame. [docs/AUTHORING.md](docs/AUTHORING.md) has the contract, the drawing API and the quality
+`--all` shows every frame. `node tools/act.mjs arcane/my-spell` shows an act as consecutive 12 fps steps, because motion
+bugs don't show in samples. [docs/AUTHORING.md](docs/AUTHORING.md) has the contract, the drawing API and the quality
bar. `node tools/serve.mjs` runs the gallery locally with your effects in it.
## how it works.
@@ -127,12 +187,17 @@ bar. `node tools/serve.mjs` runs the gallery locally with your effects in it.
- **Seeded everything.** Every random number comes from the effect's seed, so frame 40 is the same every time.
- **Local space.** Effects draw around their own origin; the painter places, mirrors and rotates them. Directional
effects face right. A 24×38 stock character stands in for status effects, auras and hits.
+- **A real skeleton, drawn down to pixels.** The grey dummy is neutral on purpose, so the eye goes to the move and any effect's
+ colors read on it. He's a 3D skeleton with fixed-length bones, pelvis to spine to shoulders, rendered in a few flat tones with one clean
+ ink line, the way Dead Cells makes its sprites. So he can twist, bend and really turn round, and depth decides what's in front. Poses hold on 12 fps
+ steps, the way hand-drawn sprites do, while particles run at full rate.
- **Same frame shape as Sprite Fusion's VFX** (`{ w, h, ox, oy, color, light }`), so both libraries can draw into
one frame.
## license.
-MIT, code and effects. Use them in anything, commercial included. Parts are adapted from Hugo Duprez's MIT effects,
-and the Patch Pixel font in `gallery/fonts` is Patch's own and not covered: see [NOTICE.md](NOTICE.md).
+MIT, code and effects. Use them in anything, commercial included. Parts are adapted from Hugo Duprez's MIT effects
+and from Hollow Crown's MIT source, and the Patch Pixel font in `gallery/fonts` is Patch's own and not covered: see
+[NOTICE.md](NOTICE.md).
Made by [Patch](https://patch.gg).
diff --git a/docs/AUTHORING.md b/docs/AUTHORING.md
index 4e56104..7d6b258 100644
--- a/docs/AUTHORING.md
+++ b/docs/AUTHORING.md
@@ -62,10 +62,68 @@ that loop come from `cycle`, motion from `fly`, noise from `loopNoise`/`tileFbm`
silhouette and its own colors (`pixels`, a Uint32Array, 0 where empty) in local space, feet at (0, 0). Recolor
`pixels` for frozen, poisoned, stone; outline `mask` for auras. Export `actorAlpha(t, o)` (0..1) when the
character should vanish or appear; previews follow it.
+- **Acts** (`export const act`): what the body does around the effect. Any effect with a character should have one; see
+ below.
- **Credit.** If you adapt a specific recipe from one of Hugo's files, put a two-line credit at the top of yours:
`// ... adapted from Sprite Fusion's open-source <name> (https://www.spritefusion.com/pixel-art-vfx/<name>),`
`// MIT License, Copyright (c) 2026 Hugo Duprez.`
+## Acts
+
+An effect shows what the magic does. Its act shows what the character does. Without one, the best effect looks like a
+sticker on a mannequin. Replies to the first release said it best: "lack of anticipation and cooldown phases".
+
+```js
+const GUARD = { ...READY, weapon: "sword", fx: 12, fy: -19, sa: -0.75 };
+const COCK = { ...GUARD, crouch: 4, lean: -4, fx: -9, fy: -33, sa: -2.7, bx: 9, by: -22, armsFront: true };
+const CUT = { ...GUARD, crouch: 4, lean: 5, fx: 24, fy: -19, sa: 0.6, ffx: 13, fbx: -10, ghost: 1 };
+
+export const act = {
+ target: { x: 58 }, // or targets: [{ x: 58 }, { x: 104 }]
+ poses: [[-0.5, GUARD], [-0.2, COCK], [0.06, CUT, "snap"], [0.7, GUARD]],
+ hits: [{ t: 0.06, stop: 0.14, shake: 0.18, amp: 2, push: 2.8, straw: 18, skin: "char" }],
+ dust: [{ t: 0.06, x: 12, n: 6, dir: 1 }],
+};
+```
+
+- **Time** is the effect's own: t = 0 is its first frame, so a negative key is a wind-up. A one-shot's act runs to its last
+ key, which may be after the effect has ended. A loop's keys run 0 to `duration` and match at both ends.
+- **Poses** only say what differs from standing easy. `src/core/poses.js` lists every field and how the body works: where the feet and
+ hands are, crouch, lean, turn, what's held and at what angle. The character is a real skeleton in 3D, drawn down to pixels: hands and
+ feet are placed where they should end up, in px from the feet, and elbows, knees, spine and shoulders work themselves out. Between keys, limbs step at 12 fps and the feet's position stays smooth.
+ `"snap"` holds the last pose and jumps on the key, `"out"` arrives fast and settles, `"in"` starts slow, `"line"` keeps a
+ steady speed.
+- **Hits** freeze everything for `stop` seconds and shake it by `amp` px for `shake` seconds; the target takes `push` (negative
+ rocks it towards the caster), `straw`, `flash`, a `skin` (char, ice, shock, holy, shadow, red, poison; `null` clears it) and `shiver`.
+ `at` picks one of several targets; `target: false` leaves them out of it. Line these up with the effect's own constants.
+- **Weapons** are `sword greatsword dagger spear hammer scythe claw bow pistol launcher handle`. `two: true` puts both hands on it.
+- **Hold it like you mean it.** An arm reaches about 15 px from its shoulder and bones don't stretch, so step the body (`x`) rather than ask too much,
+ and keep a little bend in the elbow. On a swing the blade lags the hand: at mid-swing the arm has gone forward while the blade still points up, so the
+ wrist breaks and it whips. Weapons stop at the floor by themselves. A long weapon rests in one hand, butt on the floor, and takes the second hand to swing.
+- **Use the third dimension.** He faces right, three-quarters towards us, so for arms raised or open the near hand goes left of the chest (`fx < 0`) and the
+ far hand right (`bx > 0`), usually with `turn: 1` so the chest faces us. `yaw` turns the whole body about its feet, weapon included: a spin is really a spin.
+- **Line the hand up** with where the effect fires from: if a beam leaves `(15, -24)`, the pose's `fx, fy` are `15, -24` at t = 0.
+- **`onBody: true`** when the effect reads `o.actor` (recolors `pixels`, outlines `mask`, exports `actorAlpha`). Draw it against the
+ standing body as usual: each pixel of a pose knows which standing pixel it came from, so frost, poison and scan lines follow. What's
+ off the body moves with the chest above the belt and stays put on the floor; `follow: 0` keeps it fixed, for a core at the hand.
+- **What sells it:** a wind-up in the opposite direction to the blow. A big silhouette change on the release frame. A freeze
+ on contact, longer for heavier blows (0.03 to 0.2 s). A follow-through that overshoots. Sword tips and hammer heads that meet the effect's arc.
+ Raised hands go behind the head by themselves, so the face stays visible; put wind-ups beside or above the head, not across it.
+
+**Moves** (`src/fx/moves/`) are effects made of effects. `chain` plays other effects as cues; a projectile is an effect whose `x`
+is a function of time; `shiftKeys` reuses other effects' acts.
+
+```js
+export const create = chain([
+ { fx: charge, t: 0.08, until: THROW, palette: PAL.fire },
+ { fx: fireball, t: THROW, until: HIT, x: (t) => 28 + (t - THROW) * SPEED, y: -22 },
+ { fx: blast, t: HIT, x: TX },
+]);
+```
+
+Judge acts by their motion: `node tools/act.mjs <id>` shows consecutive 12 fps steps, `--mp4` plays it, and `tools/check.mjs` catches keys out of
+order, unknown pose fields, loop seams and hands that teleport.
+
## The toolkit (`src/core/sim.js`, from Sprite Fusion's code)
- `new Particles({ rng, ground: (x) => floorY, sparks: [head..tail colors], haze: color, onLand })`,
@@ -107,7 +165,7 @@ Coordinates local, floats fine. `c` a color number; `a` alpha 0..1 (dithered unl
| `p.text(str, x, y, c, {font, scale, align, outline, shadow, a})`, `p.measure` | pixel text (`mini` 3x5, `big` 5x7; use `scale: 2` at this size) |
| `p.mask(m, x, y, c, a)`, `p.outline(m, x, y, c, a)`, `p.get(x, y)` | silhouettes; read back a pixel |
-Helpers from `src/core/index.js`: `clamp lerp seg smooth bump ease.* TAU`, `Rng rng rand`, `noise noise2 fbm
+Helpers from `src/core/index.js`: `createAct actTiming READY chain shiftKeys shiftHits skeleton posedParts`, `clamp lerp seg smooth bump ease.* TAU`, `Rng rng rand`, `noise noise2 fbm
loopNoise tileNoise tileFbm`, `fly flyV burst cycle stream`, `bolt forks star ngon trail`, `PAL RAMP ramp fit at
blend mix scale hex rgb luma WHITE`, `stockActor(2) drawActor HERO2 HERO_PAL`.
@@ -151,4 +209,5 @@ your eyes, feed your references.
4. **Benchmark**: put his and yours next to each other at the same height on screen. If his has more detail, light
or life, yours isn't done.
5. **Fix the worst thing, render again.** Three rounds minimum; showpieces take more.
-6. **Check**: `node tools/check.mjs <id>` until it passes clean.
+6. **Act it out** if there's a character: `node tools/act.mjs <id>`. Consecutive frames, not samples.
+7. **Check**: `node tools/check.mjs <id>` until it passes clean.
diff --git a/docs/CATALOG.md b/docs/CATALOG.md
index 74553bb..3c11f5f 100644
--- a/docs/CATALOG.md
+++ b/docs/CATALOG.md
@@ -1,8 +1,27 @@
# Catalog
-232 effects in 20 categories. Every one is a file in
+244 effects in 21 categories. Every one is a file in
`src/fx/<category>/<name>.js`; render any of them with `node tools/render.mjs <id> --gif`.
+## moves
+
+whole attacks, wind-up to recovery, chained from the effects below.
+
+| effect | id | | size | what it does |
+|---|---|---|---|---|
+| Arrow shot | `moves/arrow-shot` | one-shot 1.9s | 300×74 | He raises the bow, draws to his cheek, holds his breath and looses: the string snaps forward, the arrow crosses the floor and thuds home. |
+| Dash strike | `moves/dash-strike` | one-shot 2.3s | 372×156 | A crouch, then he's across the floor in a blur of after-images and already cutting: a critical hit, a beat, and he hops back to where he started. |
+| Earth stomp | `moves/earth-stomp` | one-shot 3.46s | 290×142 | A knee comes up, the boot slams down, the floor heaves under the target and a stone spike rams up through it. |
+| Fireball throw | `moves/fireball-throw` | one-shot 6.81s | 356×244 | He gathers fire in his hand, leans back and hurls it: the ball flies, the target takes it in a blast and comes out charred. |
+| Ground pound | `moves/ground-pound` | one-shot 3.82s | 304×204 | He coils, leaps out of frame height, hangs, and comes down like a rock: the floor cracks, shock waves race out and throw the target about as they pass. |
+| Holy smite | `moves/holy-smite` | one-shot 2.8s | 252×182 | Both hands go up and a glint marks the target; he brings them down and a bolt of light drops like a hammer, leaving the target blanched. |
+| Ice lance throw | `moves/ice-lance-throw` | one-shot 4.34s | 310×136 | Frost gathers into a spear in his hand, he throws it like a javelin, and the target ices over in a burst of snowflakes and shivers. |
+| Lightning call | `moves/lightning-call` | one-shot 3s | 290×266 | An arm goes up, a sigil lights under the target, and on the downswing a thick bolt comes down on it; the target jolts through the aftershocks. |
+| Meteor call | `moves/meteor-call` | one-shot 6.43s | 380×240 | A long chant: a circle draws itself round him, it flares, he points, and a burning rock comes down on the target and flattens the scene. |
+| Pistol shots | `moves/pistol-shots` | one-shot 2.6s | 378×76 | Three aimed shots: the gun kicks up each time and settles, tracers cross the floor, and the target staggers under each hit. |
+| Rocket launcher | `moves/rocket-launcher` | one-shot 6.56s | 480×244 | He drops to one knee, shoulders the tube and fires: the kick shoves him back along the floor, the rocket crawls out on its jet and the target goes up. |
+| Sword combo | `moves/sword-combo` | one-shot 2.98s | 264×150 | Three strokes walking forward: a slash, a crossing double cut, and a two-handed cleave into the floor that throws the target about. |
+
## fire
torches, breath, pillars, walls of flame.
@@ -183,7 +202,7 @@ poofs, portals, souls, shatters.
| Egg hatch | `spawn/egg-hatch` | one-shot 3.1s | 120×96 | A speckled egg rocks three times, each rock cracking it further with warm light leaking out, then pops: light pours out of the opening and lit shell halves tumble away. |
| Poof | `spawn/poof` | one-shot 1.6s | 112×92 | A cartoon death poof: a white pop, a ring of soft round smoke balls bursting out between speed lines, little stars spinning off, and the cloud lifting and thinning away. |
| Respawn beam | `spawn/respawn-beam` | one-shot 2.5s | 128×150 | A guide line drops, a pillar of light slams onto the spot, and a scan bar climbs from the feet writing the character back in row by row, white-hot lines cooling to its colors. |
-| Shatter death | `spawn/shatter-death` | one-shot 3.3s | 168×96 | Frost races up the body and seals it in faceted ice, a glint sweeps it, cracks spread from the chest, then it bursts into its own facets that tumble, bounce and melt. |
+| Shatter death | `spawn/shatter-death` | one-shot 3.3s | 172×96 | Frost races up the body and seals it in faceted ice, a glint sweeps it, cracks spread from the chest, then it bursts into its own facets that tumble, bounce and melt. |
| Soul rise | `spawn/soul-rise` | one-shot 3.2s | 96×140 | The body's outline flares and dims, then a pale glowing copy of it lifts out, stretching as its legs melt into a rippling wisp, shedding motes until it thins into light. |
| Spawn portal | `spawn/spawn-portal` | one-shot 3.8s | 208×150 | A rift tears open on the floor and swirls, belches violet smoke and sparks, spits a fountain of wisps up out of itself, then twists shut with a pop. |
| Summon rise | `spawn/summon-rise` | one-shot 4.6s | 176×116 | A rune circle burns into the floor, the ground bursts, and a horned brute heaves up out of it through dust and rubble, lit from below, until its eyes flare. |
@@ -216,7 +235,7 @@ heals, halos, pillars of light.
| Blessing | `holy/blessing` | loop 3s | 80×128 | A soft cone of light rests on the character from above; sparkles drift down through it, twinkling, and wink out where they land on the head and shoulders. |
| Divine shield | `holy/divine-shield` | loop 2.4s | 88×84 | A bubble of gold light round the character: a bright rim and a thin gold film, meridians turning like a slow globe, a sheen sweeping across and sparkles winking on it. |
| Feather burst | `holy/feather-burst` | one-shot 3s | 160×160 | A white puff pops and throws feathers that brake hard, then rock from side to side as they sink and fade, with down drifting after them. |
-| Halo | `holy/halo` | loop 2s | 56×80 | A ring of gold light floats over the head with a glint running round it; fine dust sifts down from it and the hair catches its light. |
+| Halo | `holy/halo` | loop 2s | 56×80 | A ring of gold light floats over the head with a glint running round it; fine dust sifts down from it and the head catches its light. |
| Heal | `holy/heal` | one-shot 1.9s | 80×104 | Petals of light bloom under the feet, a hoop of light rises up the body restoring its colour and leaving sparkles, and motes spiral up and pop into tiny hearts. |
| Healing ring | `holy/heal-aoe` | one-shot 2.9s | 256×136 | A seed of green light sinks into the floor and a soft ring rolls out from it; the floor glows where it passes and plus signs sprout and float up. |
| Holy pillar | `holy/holy-pillar` | one-shot 3.5s | 192×232 | Light breaks through from above: a sun opens at the top and a fan of shafts converges on the mark, pulsing, while a sigil burns on the floor; then the fan folds shut. |
@@ -254,7 +273,7 @@ burning, frozen, poisoned, asleep.
| Charmed | `status/charmed` | loop 2.4s | 60×76 | Smitten: a big heart beats over the head, throwing a ring and a flush of light with every beat, little hearts float up, the eyes go pink and the cheeks blush. |
| Confused | `status/confused` | loop 2.4s | 60×78 | Head in a spin: a glowing spiral whirls over the head, question marks pop up round it and bob, the eyes dart left and right. |
| Cursed | `status/cursed` | loop 2.4s | 64×84 | Hexed: violet smoke rises off the body in winding trails, a dark stain creeps up from the feet with a glowing edge, the eyes burn, a skull glitches in overhead. |
-| Frozen | `status/frozen` | loop 2s | 72×64 | Chilled to the bone: frost ferns creep over the body, icicles hang from chin, hands and hair and drip, breath steams, snow settles, a shiver every second, frost spreads underfoot. |
+| Frozen | `status/frozen` | loop 2s | 72×64 | Chilled to the bone: frost ferns creep over the body, icicles hang from chin and hands and drip, breath steams, snow settles, a shiver every second, frost spreads underfoot. |
| Haste | `status/haste` | loop 1.2s | 100×56 | Sped up: striped after-images stream out behind, speed lines whip past, dust kicks off the heels and the leading edge catches the wind. Faces right. |
| Petrified | `status/petrified` | one-shot 3.8s | 120×74 | Turned to stone: grey creeps up from the feet behind a crackling edge that spits grit, the statue holds, cracks run through it, and it bursts into tumbling chunks and dust. |
| Poisoned | `status/poisoned` | loop 1.6s | 72×64 | Sick to the bone: green rolls up the body in waves, dark veins creep from a wound, toxic sweat drips and hisses; every 0.8 s it wobbles, blisters pop and a ring pulses out. |
diff --git a/docs/readme/acts.gif b/docs/readme/acts.gif
new file mode 100644
index 0000000..b360e0b
Binary files /dev/null and b/docs/readme/acts.gif differ
diff --git a/docs/readme/montage.gif b/docs/readme/montage.gif
index db6aa17..3f47b1b 100644
Binary files a/docs/readme/montage.gif and b/docs/readme/montage.gif differ
diff --git a/gallery/app.js b/gallery/app.js
index f4cb86b..f7728ef 100644
--- a/gallery/app.js
+++ b/gallery/app.js
@@ -2,7 +2,7 @@
// opens one effect with its options, a sprite sheet and the code to use it.
import { effects, categories } from "../src/fx/index.js";
-import { createFrame, clearFrame, createFx, composite, backdrop, drawActor, painterFor, stockActor, actorAlphaOf, PAL, BACKDROPS } from "../src/core/index.js";
+import { createFrame, clearFrame, createFx, createAct, actBounds, composite, backdrop, drawActor, painterFor, stockActor, actorAlphaOf, PAL, BACKDROPS } from "../src/core/index.js";
const REPO = "https://github.com/patch-gg/pixelfx";
const FX = Object.entries(effects).map(([id, mod]) => {
@@ -28,11 +28,17 @@ class Player {
}
// the art-pixel stage: the effect's canvas plus some room, stretched to the tile's aspect; CSS scales it up
layout(aspect, pad) {
- const [w, h] = this.fx.meta.size, [ox, oy] = this.fx.meta.origin;
- this.W = Math.ceil(Math.max(w * pad, h * pad * aspect));
+ Object.assign(this, { aspect, pad });
+ // an act needs room for the whole performance, not just the effect's canvas
+ const acted = this.acted, b = acted ? { ...actBounds(this.fx.mod) } : null;
+ // an act happens above the floor: don't spend the tile on bricks
+ if (b) b.y1 = Math.min(b.y1, 22);
+ const [w, h] = acted ? [b.x1 - b.x0, b.y1 - b.y0] : this.fx.meta.size, [ox, oy] = acted ? [-b.x0, -b.y0] : this.fx.meta.origin;
+ this.W = Math.ceil(Math.max(w * (acted ? Math.min(pad, 1.1) : pad), h * (acted ? Math.min(pad, 1.1) : pad) * aspect));
this.H = Math.ceil(this.W / aspect);
this.x = Math.floor((this.W - w) / 2) + ox;
- this.y = Math.floor((this.H - h) / 2) + oy;
+ // an act stands near the bottom of its tile, with the room above it
+ this.y = acted ? Math.max(oy + 2, this.H - b.y1 - 2) : Math.floor((this.H - h) / 2) + oy;
this.canvas.width = this.W;
this.canvas.height = this.H;
// shrinking pixel art nearest-neighbour drops whole 1 px lines; smooth it only when it has to shrink
@@ -48,8 +54,12 @@ class Player {
this.bgBuf = kind === "none" ? null : backdrop(kind, this.W, this.H, this.y);
this.dirty = true;
}
+ // an effect with an act plays it, unless the character is switched off
+ get acted() {
+ return !!this.fx.mod.act && this.actor;
+ }
restart() {
- this.inst = createFx(this.fx.mod, { x: this.x, y: this.y, flip: this.flip, ...this.opts });
+ this.inst = (this.acted ? createAct : createFx)(this.fx.mod, { x: this.x, y: this.y, flip: this.flip, ...this.opts });
this.acc = 0;
this.wait = 0;
this.dirty = true;
@@ -60,7 +70,7 @@ class Player {
let moved = false;
while (this.acc >= step) {
this.acc -= step;
- if (!m.loop && this.inst.t >= m.duration) {
+ if (!m.loop && (this.acted ? this.inst.done() : this.inst.t >= m.duration)) {
this.wait += step;
if (this.wait > 0.45) this.restart();
} else this.inst.update(step);
@@ -75,6 +85,15 @@ class Player {
}
render() {
const f = clearFrame(this.frame);
+ if (this.acted) {
+ this.inst.draw(f);
+ composite(f, this.img.data, this.bgBuf);
+ const [sx, sy] = this.inst.shake;
+ if (sx || sy) this.ctx.clearRect(0, 0, this.W, this.H);
+ this.ctx.putImageData(this.img, sx, sy);
+ this.dirty = false;
+ return;
+ }
this.inst.draw(f, "back");
const m = this.fx.meta, tt = m.loop ? this.inst.t % m.duration : Math.min(this.inst.t, m.duration);
if (m.actor && this.actor) drawActor(painterFor(f).place(this.x, this.y, this.flip), this.inst.options.actor ?? stockActor(), actorAlphaOf(this.fx.mod, tt, this.inst.options));
@@ -99,10 +118,10 @@ function build() {
sections.push({ c, sec, list });
for (const fx of list) {
const cv = el("canvas", { ariaLabel: fx.name });
- const [fw, fh] = fx.meta.size;
- const fig = el("figure", { className: isScreen(fx) ? "tile big screen" : fw > 200 || fh > 170 ? "tile big" : "tile", tabIndex: 0 }, [
+ const b = fx.mod.act ? actBounds(fx.mod) : null, [fw, fh] = b ? [b.x1 - b.x0, b.y1 - b.y0] : fx.meta.size;
+ const fig = el("figure", { className: isScreen(fx) ? "tile big screen" : fw > 200 || fh > 170 || (b && (fw > 130 || fx.mod.act.target || fx.mod.act.targets)) ? "tile big" : "tile", tabIndex: 0 }, [
el("div", { className: "stage" }, cv),
- el("figcaption", {}, [el("b", { textContent: fx.name }), el("small", { textContent: fx.meta.loop ? "loop" : `${fx.meta.duration}s` })]),
+ el("figcaption", {}, [el("b", { textContent: fx.name }), el("small", { textContent: fx.meta.loop ? "loop" : `${+fx.meta.duration.toFixed(2)}s` })]),
]);
const t = { fx, fig, cv, player: null, visible: false, hover: false };
fig.addEventListener("click", () => openDetail(fx));
@@ -177,7 +196,7 @@ function openDetail(fx) {
$("#d-desc").textContent = m.desc;
const frames = Math.round(m.duration * m.fps) + (m.loop ? 0 : 1);
$("#d-facts").replaceChildren(
- ...[["kind", m.loop ? "loop" : "one-shot"], ["length", `${m.duration} s, ${frames} frames at ${m.fps} fps`], ["canvas", `${m.size[0]} × ${m.size[1]} px`], ["tags", m.tags.join(", ")]].flatMap(([k, v]) => [el("dt", { textContent: k }), el("dd", { textContent: v })]),
+ ...[["kind", m.loop ? "loop" : "one-shot"], ["length", `${+m.duration.toFixed(2)} s, ${frames} frames at ${m.fps} fps`], ...(fx.mod.act ? [["acted", actFacts(fx.mod)]] : []), ["canvas", `${m.size[0]} × ${m.size[1]} px`], ["tags", m.tags.join(", ")]].flatMap(([k, v]) => [el("dt", { textContent: k }), el("dd", { textContent: v })]),
);
// controls
$("#d-bg").replaceChildren(...BACKDROPS.concat("none").map((b) => btn(b, () => detail.setBg(b), b === m.bg, "bg")));
@@ -195,6 +214,15 @@ function openDetail(fx) {
d.showModal();
d.scrollTop = 0;
}
+// what the body does around the effect, in a line: the wind-up, the freeze, the recovery
+function actFacts(mod) {
+ const k = mod.act.poses, lead = Math.max(0, -k[0][0]), end = k[k.length - 1][0] - mod.meta.duration, hits = (mod.act.hits ?? []).filter((h) => h.stop);
+ const parts = [];
+ if (lead > 0) parts.push(`${lead.toFixed(2)} s wind-up`);
+ if (hits.length) parts.push(`${hits.length === 1 ? `${Math.round(hits[0].stop * 1000)} ms freeze` : `${hits.length} freezes`} at ${hits[0].t.toFixed(2)} s`);
+ if (!mod.meta.loop && end > 0.02) parts.push(`${end.toFixed(2)} s recovery`);
+ return parts.join(", ") || "the body moves with it";
+}
function btn(label, fn, on, group) {
const b = el("button", { className: "btn", type: "button", textContent: label });
b.setAttribute("aria-pressed", String(!!on));
@@ -207,17 +235,19 @@ function btn(label, fn, on, group) {
function code(fx) {
const v = fx.id.split("/")[1].replace(/-(\w)/g, (_, c) => c.toUpperCase());
const opts = { x: 160, y: 120, ...(detail.opts.palette ? { palette: "[…]" } : {}), ...(detail.flip ? { flip: true } : {}) };
+ const acted = !!fx.mod.act, make = acted ? "createAct" : "createFx";
$("#d-code").textContent = [
- `import { createFrame, createFx, composite } from "pixelfx";`,
+ `import { createFrame, ${make}, composite } from "pixelfx";`,
`import * as ${v} from "pixelfx/fx/${fx.id}";`,
``,
`const frame = createFrame(320, 180);`,
- `const fx = createFx(${v}, ${JSON.stringify(opts).replace(/"\[…\]"/, "[…]").replace(/"(\w+)":/g, "$1: ").replace(/,/g, ", ")});`,
+ `const fx = ${make}(${v}, ${JSON.stringify(opts).replace(/"\[…\]"/, "[…]").replace(/"(\w+)":/g, "$1: ").replace(/,/g, ", ")});`,
``,
`// every tick`,
`fx.update(dt);`,
`fx.draw(frame); // color + light buffers`,
`composite(frame, imageData.data, null);`,
+ ...(acted ? [``, `// your own character? read the timing: ${v}.act (poses, hits, freezes)`] : []),
].join("\n");
$("#d-src").href = `${REPO}/blob/main/src/fx/${fx.id}.js`;
}
@@ -257,6 +287,8 @@ function wireDetail() {
$("#d-actor").addEventListener("click", (e) => {
detail.actor = !detail.actor;
e.target.setAttribute("aria-pressed", String(detail.actor));
+ // with an act, the character is the performance: off shows the effect alone, as a sprite sheet has it
+ if (detail.fx.mod.act) detail.layout(detail.aspect, detail.pad);
detail.dirty = true;
});
$("#d-seed").addEventListener("click", () => {
diff --git a/package.json b/package.json
index 3137e13..5ffd9d1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "pixelfx",
- "version": "0.2.0",
+ "version": "0.3.0",
"description": "Code-driven pixel art effects and animations, and a Claude Code skill to make your own.",
"type": "module",
"license": "MIT",
diff --git a/skills/pixelfx/SKILL.md b/skills/pixelfx/SKILL.md
index 1c012b4..c75d1e2 100644
--- a/skills/pixelfx/SKILL.md
+++ b/skills/pixelfx/SKILL.md
@@ -1,6 +1,6 @@
---
name: pixelfx
-description: Make pixel art effects and sprite animations in code with the pixelfx library, which has 232 ready-made ones (fire, explosions, water, ice, lightning, sci-fi, melee, impacts, projectiles, spawn and death, arcane, holy, shadow, status, nature, weather, UI, pickups, transitions, critters) to drop into a game, recolor, export as sprite sheets or remix, plus a draft, render, look, refine loop that makes new ones look hand-animated. Use when someone wants pixel art VFX, sprite animations or sprite sheets, game juice, a specific effect ("a frost nova for my mage", "a coin pickup sparkle"), wants to use or export a pixelfx effect in Godot, Unity, Phaser or a canvas game, or wants their pixel effects to look better.
+description: Make pixel art effects and sprite animations in code with the pixelfx library, which has 244 ready-made ones, acted out by a character who winds up, freezes on contact and recovers (fire, explosions, water, ice, lightning, sci-fi, melee, impacts, projectiles, spawn and death, arcane, holy, shadow, status, nature, weather, UI, pickups, transitions, critters) to drop into a game, recolor, export as sprite sheets or remix, plus a draft, render, look, refine loop that makes new ones look hand-animated. Use when someone wants pixel art VFX, sprite animations or sprite sheets, game juice, a specific effect ("a frost nova for my mage", "a coin pickup sparkle"), wants to use or export a pixelfx effect in Godot, Unity, Phaser or a canvas game, or wants their pixel effects to look better.
license: MIT
compatibility: Node 18 or newer. ffmpeg is optional (GIF and MP4 previews).
---
@@ -73,6 +73,17 @@ additive over dark scenes; for bright scenes, render a recolored version or keep
For the full library: `node tools/render.mjs <category> --sheet` does a whole category.
+**A hit needs a body behind it.** An effect alone looks like a sticker. Effects with a character carry an `act`: when the body winds
+up, when to freeze, how the target reacts. Use it whichever way the game is built:
+
+- With the stock character: `createAct(slash, { x, y })` instead of `createFx`. `act.update(dt)`, `act.draw(frame)`, and throw the
+ picture by `act.shake`. It holds still by itself during a freeze. `node tools/act.mjs <id> --sheet` bakes the lot into a sprite sheet.
+- With the game's own character: read the timing, `slash.act` or `meta.pixelfx.act` in a sheet's JSON (`windup`, `recovery`, `hits`
+ with `t` and `freeze`). Play the character's attack animation `windup` seconds before the effect, and at each hit stop updating
+ everything, effect and characters both, for `freeze` seconds. Host-side hit-stop works on any effect, with or without an act.
+
+`src/fx/moves/` has whole attacks chained from the effects, wind-up to recovery: start there when someone asks for a move, not an effect.
+
## 3. Make a new one
Read `docs/AUTHORING.md` first: it is the contract (meta, `draw(p, t, o)` for pure effects or `create(o)` for
@@ -94,8 +105,12 @@ Then:
4. **Look, judge, fix.** Render, open `records/<id>/contact.png`, and judge like a picky pixel artist. Fix the
worst thing, render again. Three rounds minimum; a showpiece takes more. `--all` shows every frame,
`--mp4` shows motion at full speed.
-5. **Check.** `node tools/check.mjs <id>` catches drawing outside the canvas, one-shots that don't end empty,
- loop seams, unseeded randomness and slow frames. Fix until it passes clean. Delete the drafts you didn't keep.
+5. **Act it out** if a character is involved: add `export const act` (see "Acts" in `docs/AUTHORING.md`), with a wind-up before t = 0,
+ a pose change on the release frame, a freeze on contact and a recovery. `node tools/act.mjs <id>` shows consecutive 12 fps steps:
+ judge motion from those and from `--mp4`, not from a contact sheet's samples.
+6. **Check.** `node tools/check.mjs <id>` catches drawing outside the canvas, one-shots that don't end empty,
+ loop seams, unseeded randomness and slow frames, and in an act: keys out of order, unknown pose fields and hands
+ that teleport. Fix until it passes clean. Delete the drafts you didn't keep.
What to look for, and the usual fix:
@@ -111,6 +126,11 @@ What to look for, and the usual fix:
| a checkerboard where smoke should be | `SMOKE`, `VAPOUR` or `DUST` particles, or `p.disc`: truly translucent, lit on top |
| seam when a loop wraps | `cycle`, `loopNoise(phase)`, whole-cell `tileNoise` scrolls, `sin(phase * TAU * n)` |
| a one-shot that pops off | let it shrink, dither out or fall away before t = duration |
+| a great effect on a dead character | give it an act: wind-up, release pose, freeze on contact, a target that reacts, recovery |
+| the act feels weightless | a wind-up the opposite way to the blow, a longer freeze (up to 0.2 s), a bigger silhouette change, shake |
+| the hit lands out of sync | move the hit key to the effect's own constant, not to a time you eyeballed |
+| he holds the weapon badly | keep a bend in the elbow, shafts in front of the chest; on a swing the blade lags the hand; arms reach about 15 px and don't stretch, so step the body in |
+| his arms cross or the pose looks flat | he faces three-quarters towards us: for open arms the near hand goes left (`fx < 0`), far hand right, with `turn: 1`; `yaw` really turns him |
Directional effects face right, ground effects stand on y = 0, actor effects wrap `o.actor` (a 24 x 38 stock
character's mask and pixels), and nothing uses `Math.random`. Generic motifs are fine; never recreate a specific game's
diff --git a/src/core/act.js b/src/core/act.js
new file mode 100644
index 0000000..731e56c
--- /dev/null
+++ b/src/core/act.js
@@ -0,0 +1,486 @@
+// An act: an effect performed. The character winds up, lets go and recovers, a target takes the hit, and everything
+// freezes for a moment on contact. Effects describe it as data (`export const act`), so a game with its own character
+// can read the same timing. The freeze, the shake, the springy target and poses held on 12 fps steps are how Hollow Crown
+// plays its skills (https://github.com/rehan-remade/hollow-crown), MIT License, Copyright (c) 2026 rehan-remade.
+
+import { Rng, clamp } from "./math.js";
+import { hex, mix } from "./color.js";
+import { createFrame, clearFrame, createFx, painterFor } from "./fx.js";
+import { stockActor, drawActor, actorAlphaOf, HERO2, DUMMY_PAL } from "./actor.js";
+import { posed, STAND } from "./rig.js";
+
+export { STAND, posed };
+
+// ---- poses over time
+const lerp = (a, b, u) => a + (b - a) * u;
+/** Between two poses: numbers move, everything else changes at the later key. */
+export function lerpPose(a, b, u) {
+ const out = { ...STAND, ...a };
+ const B = { ...STAND, ...b };
+ for (const k of Object.keys(B)) {
+ const v = B[k];
+ if (typeof v === "number" && typeof out[k] === "number") out[k] = lerp(out[k], v, u);
+ else if (out[k] === undefined && typeof v === "number") out[k] = v;
+ }
+ // what the later pose doesn't mention eases back to its default
+ for (const k of ["hx", "hy", "lean", "crouch"]) if (B[k] === undefined && typeof out[k] === "number") out[k] = lerp(out[k], 0, u);
+ if (B.wl === undefined && typeof out.wl === "number") out.wl = lerp(out.wl, 1, u);
+ return out;
+}
+const eases = { out: (u) => 1 - (1 - u) * (1 - u), in: (u) => u * u, line: (u) => u };
+/**
+ * The pose at time t on a track of keys [t, pose, how]: `how` says how the pose arrives: smoothly by default, "out"
+ * fast then settling, "in" slowly then fast, "snap" holding the last pose and jumping on the key. Limbs move in whole
+ * 12 fps steps counted from each key, so they read as held drawings; the feet's position over the floor (x, y) stays smooth.
+ */
+export function poseAt(track, t) {
+ if (t <= track[0][0]) return track[0][1];
+ for (let i = 0; i < track.length - 1; i++) {
+ const [t0, a] = track[i], [t1, b, how] = track[i + 1];
+ if (t >= t1) continue;
+ if (how === "snap") return a;
+ const e = eases[how] ?? ((u) => u * u * (3 - 2 * u));
+ const stepped = t0 + Math.floor((t - t0) * 12 + 1e-6) / 12;
+ const out = lerpPose(a, b, e((stepped - t0) / (t1 - t0)));
+ const u = e((t - t0) / (t1 - t0));
+ out.x = lerp(a.x ?? 0, b.x ?? 0, u);
+ out.y = lerp(a.y ?? 0, b.y ?? 0, u);
+ return out;
+ }
+ return track[track.length - 1][1];
+}
+
+/** Is the body between keys that hardly differ, or past the last? */
+function isHeld(track, t) {
+ if (t >= track[track.length - 1][0] || t < track[0][0]) return true;
+ for (let i = 0; i < track.length - 1; i++) {
+ if (t >= track[i + 1][0]) continue;
+ const a = { ...STAND, ...track[i][1] }, b = { ...STAND, ...track[i + 1][1] };
+ return track[i + 1][0] - track[i][0] > 0.4 && ["fx", "fy", "bx", "by", "crouch", "lean", "x", "y"].every((k) => Math.abs((a[k] ?? 0) - (b[k] ?? 0)) < 1.5);
+ }
+ return true;
+}
+
+// ---- the target
+const TW = 38, TH = 52;
+const TP = Object.fromEntries(Object.entries({ ink: "#0b0a1a", wood: "#724c2e", woodL: "#a0703a", woodD: "#4e331f", straw: "#d2aa55", strawL: "#f0d98a", burlapD: "#86643a", burlap: "#b38b57", burlapL: "#c9a26c", red: "#9a2f3c", redL: "#c4434f", white: "#ffffff" }).map(([k, v]) => [k, hex(v)]));
+const DUST = ["#efe7dc", "#c9bfb8", "#8f8693", "#5a5468"].map(hex);
+const DUMMY = new Uint32Array(TW * TH);
+(function buildDummy() {
+ const px = (x, y, c) => { if (x >= 0 && y >= 0 && x < TW && y < TH) DUMMY[y * TW + x] = c; };
+ const R = (x, y, w, h, c) => { for (let j = 0; j < h; j++) for (let i = 0; i < w; i++) px(x + i, y + j, c); };
+ // the post and the crossbar
+ R(15, 38, 8, 14, TP.ink); R(16, 34, 6, 18, TP.wood); R(16, 34, 2, 18, TP.woodL); R(20, 34, 2, 18, TP.woodD);
+ R(1, 18, 36, 1, TP.ink); R(1, 23, 36, 1, TP.ink); R(1, 19, 36, 4, TP.wood); R(1, 19, 36, 1, TP.woodL); R(1, 22, 36, 1, TP.woodD);
+ // straw bursting out of the ends of the arms
+ for (const [bx, s] of [[0, -1], [33, 1]]) {
+ R(bx, 17, 5, 8, TP.straw);
+ for (const [dx, dy, c] of [[2, 16, TP.straw], [3, 15, TP.strawL], [1, 17, TP.strawL], [2, 25, TP.straw], [1, 26, TP.strawL], [3, 25, TP.burlapD], [2, 19, TP.strawL], [3, 21, TP.strawL], [1, 22, TP.burlapD], [2, 23, TP.strawL]]) px(bx + dx, dy, c);
+ px(s < 0 ? bx - 1 : bx + 5, 19, TP.straw); px(s < 0 ? bx - 1 : bx + 5, 22, TP.strawL);
+ }
+ const sack = (x, y, w, h) => {
+ R(x + 1, y, w - 2, 1, TP.ink); R(x + 1, y + h - 1, w - 2, 1, TP.ink);
+ R(x, y + 1, 1, h - 2, TP.ink); R(x + w - 1, y + 1, 1, h - 2, TP.ink);
+ R(x + 1, y + 1, w - 2, h - 2, TP.burlap);
+ R(x + w - 4, y + 1, 3, h - 2, TP.burlapD);
+ R(x + 1, y + h - 3, w - 2, 2, TP.burlapD);
+ R(x + 1, y + 1, 1, h - 4, TP.burlapL); R(x + 1, y + 1, w - 6, 1, TP.burlapL);
+ // the weave
+ for (let j = y + 2; j < y + h - 2; j += 3) for (let i = x + 3 + (j % 2); i < x + w - 4; i += 4) px(i, j, TP.burlapD);
+ };
+ sack(9, 17, 20, 24);
+ // the rings on its chest
+ for (let y = 19; y < 36; y++) for (let x = 11; x < 27; x++) { const d = Math.hypot(x - 18.5, y - 27); if ((d > 4 && d < 5.4) || d < 1.9) px(x, y, x + y < 45 ? TP.redL : TP.red); }
+ // the rope belt, and straw coming out under it
+ for (let x = 10; x < 28; x++) { px(x, 36, x & 1 ? TP.woodL : TP.straw); px(x, 37, x & 1 ? TP.woodD : TP.wood); }
+ for (const [x, y, c] of [[11, 41, TP.straw], [12, 42, TP.strawL], [14, 41, TP.strawL], [15, 42, TP.straw], [23, 41, TP.straw], [24, 42, TP.strawL], [26, 41, TP.straw], [13, 43, TP.straw], [25, 43, TP.straw]]) px(x, y, c);
+ sack(10, 1, 18, 16);
+ // X for eyes and a stitched mouth
+ for (const ex of [14, 23]) for (let d = -2; d <= 2; d++) { px(ex + d, 7 + d, TP.ink); px(ex - d, 7 + d, TP.ink); }
+ for (let x = 14; x < 24; x++) px(x, 12, x & 1 ? TP.ink : TP.burlapD);
+ for (const x of [15, 18, 21]) { px(x, 11, TP.ink); px(x, 13, TP.ink); }
+ // the rope at its neck, and straw for hair
+ for (let x = 12; x < 26; x++) { px(x, 16, x & 1 ? TP.woodL : TP.straw); px(x, 17, x & 1 ? TP.wood : TP.woodD); }
+ for (const [x, y, c] of [[13, 0, TP.straw], [15, 0, TP.strawL], [18, 0, TP.straw], [21, 0, TP.strawL], [24, 0, TP.straw], [9, 4, TP.straw], [28, 6, TP.straw], [8, 7, TP.strawL], [29, 3, TP.strawL]]) px(x, y, c);
+})();
+/** What a hit can leave on the target: [color, how much of it]. */
+export const SKINS = { flash: [TP.white, 1], char: [hex("#1a0c0e"), 0.72], ice: [hex("#a8e8ff"), 0.72], shadow: [hex("#3a1a70"), 0.5], holy: [hex("#fff4c0"), 0.5], red: [hex("#ff2040"), 0.45], shock: [hex("#8fd6ff"), 0.6], poison: [hex("#58c43a"), 0.5] };
+const STRAW = [TP.strawL, TP.straw, TP.straw, TP.burlapD, TP.burlapD];
+
+/** A straw target on a spring: it sways, flashes, takes a skin, shivers and sheds straw. (x, y): the floor under it, local space. */
+export class Target {
+ constructor(x, seed = 5) {
+ Object.assign(this, { x, theta: 0, omega: 0, flashT: 0, skin: null, skinFade: 0, shiver: 0, clock: 0, R: new Rng(seed), straw: [] });
+ }
+ hit({ push = 1.2, straw = 8, flash = 0.05, skin, shiver = 0, y = -26 } = {}) {
+ this.omega += push;
+ this.flashT = Math.max(this.flashT, flash);
+ if (skin !== undefined) this.skin = skin;
+ if (shiver) this.shiver = shiver;
+ const R = this.R;
+ for (let k = 0; k < straw; k++) {
+ const back = R.next() < 0.3;
+ this.straw.push({ x: this.x + R.range(-3, 3), y: y + R.range(-3, 3), vx: back ? R.range(-60, -5) : R.range(10, 130), vy: R.range(-120, -5), age: 0, life: R.range(1.2, 2.2), big: R.next() < 0.5 });
+ }
+ }
+ step(dt) {
+ this.clock += dt;
+ this.omega += (-60 * this.theta - 3.4 * this.omega) * dt;
+ this.theta = clamp(this.theta + this.omega * dt, -0.4, 0.42);
+ if (this.flashT > 0) this.flashT -= dt;
+ if (this.shiver > 0) this.shiver -= dt;
+ for (const s of this.straw) {
+ s.age += dt;
+ s.vy += 210 * dt;
+ s.x += s.vx * dt;
+ s.y += s.vy * dt;
+ if (s.y >= 0) { s.y = 0; s.vx *= 0.2; s.vy = 0; }
+ }
+ this.straw = this.straw.filter((s) => s.age < s.life);
+ }
+ draw(C, W, H, X, Y, flip) {
+ const tan = Math.tan(this.theta), sv = this.shiver > 0 ? (Math.floor(this.clock * 30) & 1 ? 1 : -1) : 0, name = this.flashT > 0 ? "flash" : this.skin, sk = name ? SKINS[name] : null;
+ const base = X + (flip ? -this.x - 1 : this.x);
+ for (let r = 0; r < TH; r++) {
+ const o = Math.round((TH - 1 - r) * tan * 0.8) + sv;
+ for (let x = 0; x < TW; x++) {
+ const c = DUMMY[r * TW + x];
+ if (!c) continue;
+ const px = base + (flip ? -(x - 19 + o) - 1 : x - 19 + o), py = Y - TH + r;
+ if (px >= 0 && py >= 0 && px < W && py < H) C[py * W + px] = sk ? mix(c, sk[0], sk[1]) : c;
+ }
+ }
+ }
+ drawStraw(C, W, H, X, Y, flip) {
+ for (const s of this.straw) {
+ const c = STRAW[Math.min(4, Math.floor((s.age / s.life) * 5))], lx = Math.round(s.x), ly = Math.round(s.y) - 1;
+ for (let i = 0; i < (s.big ? 2 : 1); i++) {
+ const px = X + (flip ? -(lx + i) - 1 : lx + i), py = Y + ly;
+ if (px >= 0 && py >= 0 && px < W && py < H) C[py * W + px] = c;
+ }
+ }
+ }
+}
+
+// ---- the act itself
+const GHOST_LIFE = 0.16;
+const REST_MASK = new Uint8Array(24 * 38), REST_PX = new Uint32Array(24 * 38);
+HERO2.forEach((row, r) => [...row].forEach((ch, c) => {
+ if (ch !== ".") {
+ REST_MASK[r * 24 + c] = 1;
+ REST_PX[r * 24 + c] = hex(DUMMY_PAL[ch]);
+ }
+}));
+
+// every cell of the standing sprite, mapped to the nearest cell that's on the body
+const NEAREST = new Int16Array(24 * 38).fill(-1);
+for (let r = 0; r < 38; r++)
+ for (let c = 0; c < 24; c++) {
+ let best = -1, bd = 1e9;
+ for (let y = Math.max(0, r - 7); y < Math.min(38, r + 8); y++)
+ for (let x = Math.max(0, c - 7); x < Math.min(24, c + 8); x++) {
+ const d = (x - c) * (x - c) + (y - r) * (y - r);
+ if (REST_MASK[y * 24 + x] && d < bd) { bd = d; best = y * 24 + x; }
+ }
+ NEAREST[r * 24 + c] = best;
+ }
+const lum = (c) => (0.3 * (c & 255) + 0.59 * ((c >>> 8) & 255) + 0.11 * ((c >>> 16) & 255)) / 255;
+// an effect's color over the standing body, moved onto a pixel of the pose: its color, at this pixel's own light and shade
+function carry(v, rest, own) {
+ const lv = lum(v);
+ if (lv > 0.9 || v >>> 24 < 255) return v;
+ const k = Math.max(0.45, Math.min(1.5, lum(own) / Math.max(0.08, lum(rest))));
+ const ch = (n) => Math.min(255, Math.round(((v >>> n) & 255) * k));
+ return (255 << 24) | (ch(16) << 16) | (ch(8) << 8) | ch(0);
+}
+
+/** When an act's poses begin and end, in effect time (a loop ends when it's told to). */
+export function actSpan(mod) {
+ const a = mod.act, D = mod.meta?.duration ?? 1, k = a?.poses;
+ return { from: Math.min(0, k?.[0]?.[0] ?? 0), to: mod.meta?.loop ? Infinity : Math.max(D, k?.[k.length - 1]?.[0] ?? 0) };
+}
+
+/**
+ * An effect performed: { fx, t, update(dt), draw(frame, { body, target }), shake, done() }. t runs from the first pose
+ * (before the effect's own t = 0) to the last. update() holds everything still during a freeze; draw() paints the effect, the
+ * character and the target together. o: the effect's options, with x, y placing the feet. Without an act, it just plays.
+ */
+export function createAct(mod, o = {}) {
+ const a = mod.act ?? {}, meta = mod.meta ?? {}, D = meta.duration ?? 1, flip = !!o.flip, seed = o.seed ?? meta.options?.seed ?? 1;
+ const fx = createFx(mod, o), track = a.poses ?? [[0, { ...STAND }]], span = actSpan(mod);
+ const X = o.x ?? 0, Y = o.y ?? 0;
+ const targets = (a.targets ?? (a.target ? [a.target] : [])).map((g, i) => new Target(g.x ?? 66, seed + 4 + i));
+ const hits = (a.hits ?? []).map((h) => ({ ...h })).sort((p, q) => p.t - q.t), dust = (a.dust ?? []).slice();
+ const R = new Rng(seed + 9), specks = [];
+ // after-images take the effect's own color unless the act names one
+ const ramp = o.palette ?? meta.options?.palette, ghosts = [], gc = hex(a.ghost ?? ramp?.[Math.floor(ramp.length * 0.7)] ?? "#8fb4ff");
+ let t = span.from, stop = 0, stopped = false, shakeT = 0, shake0 = 0, amp = 0, nh = 0, nd = 0, loopN = 0, gAcc = 0, last = null;
+ const poseNow = () => {
+ let tt = t;
+ if (meta.loop && t >= D) tt = t % D;
+ let q = poseAt(track, tt);
+ // nothing is asked of him: he breathes
+ if (!meta.loop && isHeld(track, tt)) {
+ const up = Math.floor(tt * 3) & 1;
+ q = { ...STAND, ...q, crouch: (q.crouch ?? 0) + up, fy: (q.fy ?? STAND.fy) + up, by: (q.by ?? STAND.by) + up };
+ }
+ last = q;
+ return q;
+ };
+ let scratch = null;
+ const scratchFor = (f) => {
+ if (!scratch || scratch.a.w !== f.w || scratch.a.h !== f.h) scratch = { a: createFrame(f.w, f.h, f.ox, f.oy), b: createFrame(f.w, f.h, f.ox, f.oy) };
+ return scratch;
+ };
+ const out = {
+ fx, meta, act: a, targets,
+ get t() { return t; },
+ /** How far the whole picture is thrown right now, in px. */
+ get shake() {
+ if (shakeT <= 0) return [0, 0];
+ const k = amp * (shakeT / shake0), f = Math.floor(shakeT * 60);
+ return [Math.round(Math.sin(f * 2.4) * k), Math.round(Math.cos(f * 3.7) * k * 0.7)];
+ },
+ get frozen() { return stop > 0; },
+ /** The pose he's in right now. */
+ get pose() { return last; },
+ update(dt) {
+ if (shakeT > 0) shakeT -= dt;
+ if (stop > 0) {
+ stop -= dt;
+ return;
+ }
+ const t0 = t;
+ t += dt;
+ if (t >= 0) fx.update(t0 < 0 ? t : dt);
+ if (meta.loop && t >= D) {
+ const n = Math.floor(t / D);
+ if (n !== loopN) {
+ loopN = n;
+ nh = 0;
+ nd = 0;
+ }
+ }
+ const tt = meta.loop && t >= D ? t % D : t;
+ for (; nh < hits.length && hits[nh].t <= tt; nh++) {
+ const h = hits[nh];
+ if (h.stop) stop = Math.max(stop, h.stop);
+ if (h.shake) {
+ shakeT = shake0 = h.shake;
+ amp = h.amp ?? 2;
+ }
+ if (h.target !== false) targets.forEach((g, i) => (h.at === undefined || h.at === i) && g.hit(h));
+ out.onHit?.(h);
+ }
+ for (; nd < dust.length && dust[nd].t <= tt; nd++) {
+ const d = dust[nd], n = d.n ?? 6;
+ for (let i = 0; i < n; i++) {
+ const dir = d.dir ?? (R.next() < 0.5 ? -1 : 1);
+ specks.push({ x: d.x + R.range(-3, 3), y: -1 - R.range(0, 2), vx: dir * R.range(22, 90), vy: R.range(-34, -6), age: 0, life: R.range(0.16, 0.4), big: R.next() < 0.45, c: d.c ? hex(d.c) : 0 });
+ }
+ }
+ for (const k of specks) {
+ k.age += dt;
+ k.vx *= 1 - 5 * dt;
+ k.vy += 110 * dt;
+ k.x += k.vx * dt;
+ k.y = Math.min(-1, k.y + k.vy * dt);
+ }
+ for (let i = specks.length - 1; i >= 0; i--) if (specks[i].age >= specks[i].life) specks.splice(i, 1);
+ const q = poseNow();
+ for (const g of targets) g.step(dt);
+ // after-images while a key asks for them
+ gAcc += dt;
+ if (q.ghost && gAcc >= 1 / 30) {
+ gAcc = 0;
+ ghosts.push({ q, age: 0 });
+ if (ghosts.length > 7) ghosts.shift();
+ }
+ for (const g of ghosts) g.age += dt;
+ while (ghosts.length && ghosts[0].age > GHOST_LIFE) ghosts.shift();
+ },
+ /** Paint it. { body: false } leaves the character out, { target: false } the target. */
+ draw(frame, { body = true, target: showTarget = true } = {}) {
+ const W = frame.w, H = frame.h, q = last ?? poseNow(), active = t >= 0;
+ const tgt = showTarget ? targets : [];
+ const drawTargets = () => tgt.forEach((g) => g.draw(frame.color, W, H, FX, FY, flip));
+ const drawStraw = () => tgt.forEach((g) => g.drawStraw(frame.color, W, H, FX, FY, flip));
+ const drawDust = () => {
+ for (const k of specks) {
+ const c = k.c || DUST[Math.min(3, Math.floor((k.age / k.life) * 4))], lx = Math.round(k.x), py = FY + Math.round(k.y);
+ for (let i = 0; i < (k.big ? 2 : 1); i++) {
+ const px = flip ? FX - lx - i - 1 : FX + lx + i;
+ if (px >= 0 && py >= 0 && px < W && py < H) frame.color[py * W + px] = c;
+ }
+ }
+ };
+ const FX = X - (frame.ox | 0), FY = Y - (frame.oy | 0);
+ if (!body) {
+ if (active) fx.draw(frame, "back");
+ drawTargets();
+ if (active) fx.draw(frame, "front");
+ drawStraw();
+ return;
+ }
+ const rx = Math.round(q.x ?? 0), ry = Math.round(q.y ?? 0), BX = FX + (flip ? -rx : rx), BY = FY + ry;
+ const r = posed(q), mirror = flip;
+ const paint = (i, color) => {
+ const px = mirror ? BX - r.xs[i] - 1 : BX + r.xs[i], py = BY + r.ys[i];
+ if (px < 0 || py < 0 || px >= W || py >= H) return;
+ frame.color[py * W + px] = color;
+ // he stays crisp in front of his own after-images
+ if (ghosts.length) frame.light[py * W + px] = 0;
+ };
+ const drawGhosts = () => {
+ for (const g of ghosts) {
+ // after-images are light, not paint: they brighten what's behind them and leave nothing muddy
+ const gr = posed(g.q), gx = FX + (flip ? -Math.round(g.q.x ?? 0) : Math.round(g.q.x ?? 0)), gy = FY + Math.round(g.q.y ?? 0), k = 0.5 * (1 - g.age / GHOST_LIFE);
+ const gm = flip, r0 = (gc & 255) * k, g0 = ((gc >>> 8) & 255) * k, b0 = ((gc >>> 16) & 255) * k;
+ for (let i = 0; i < gr.n; i++) {
+ const px = gm ? gx - gr.xs[i] - 1 : gx + gr.xs[i], py = gy + gr.ys[i];
+ if (px < 0 || py < 0 || px >= W || py >= H) continue;
+ const j = py * W + px, d = frame.light[j];
+ frame.light[j] = (255 << 24) | (Math.min(255, ((d >>> 16) & 255) + b0) << 16) | (Math.min(255, ((d >>> 8) & 255) + g0) << 8) | Math.min(255, (d & 255) + r0);
+ }
+ }
+ };
+ const shadow = () => {
+ const sy = FY, cx = FX + (flip ? -rx : rx), hw = 10 + (Math.abs(q.ffx - q.fbx) >> 1) - Math.min(8, Math.abs(ry) >> 1);
+ if (sy < 0 || sy >= H) return;
+ for (let dy = 0; dy < 2; dy++)
+ for (let x = -hw + dy * 2; x <= hw - dy * 2; x++) {
+ const px = cx + x, i = (sy + dy) * W + px;
+ if (px < 0 || px >= W || sy + dy >= H) continue;
+ frame.color[i] = (frame.color[i] & 0xffffff) | (Math.max(frame.color[i] >>> 24, 110) << 24);
+ }
+ };
+ if (!a.onBody) {
+ // the effect doesn't care about the body: back, body, front
+ if (active) fx.draw(frame, "back");
+ drawTargets();
+ shadow();
+ drawGhosts();
+ for (let i = 0; i < r.n; i++) paint(i, r.color[i]);
+ if (active) fx.draw(frame, "front");
+ drawStraw();
+ drawDust();
+ return;
+ }
+ // the effect paints the standing body: draw it there, then carry each body pixel to where the pose put it
+ const { a: A, b: B } = scratchFor(frame);
+ clearFrame(A);
+ clearFrame(B);
+ if (active) fx.draw(A, "back");
+ B.color.set(A.color);
+ B.light.set(A.light);
+ const tt = meta.loop ? (t < 0 ? 0 : t % D) : clamp(t, 0, D), alpha = active ? actorAlphaOf(mod, tt, fx.options) : 1;
+ drawActor(painterFor(B).place(FX, FY, flip), fx.options.actor ?? stockActor(2), alpha);
+ if (active) fx.draw(B, "front");
+ const follow = a.follow ?? 1, lean = (q.lean ?? 0) * follow, cr = (q.crouch ?? 0) * follow;
+ // what's up on the body goes with it; what's on the floor stays on the floor
+ const shiftOf = (ly) => {
+ const k = clamp((-11 - ly) / 7, 0, 1), f = clamp((-1 - ly) / 6, 0, 1);
+ return [Math.round(lean * k + rx * f), Math.round(cr * k + ry * f)];
+ };
+ const rest = (sx, sy) => {
+ const c = (flip ? FX - sx - 1 : sx - FX) + 12, r0 = sy - FY + 38;
+ return c >= 0 && r0 >= 0 && c < 24 && r0 < 38 && REST_MASK[r0 * 24 + c] === 1;
+ };
+ const C = frame.color, Ls = frame.light;
+ const copy = (buf, sx, sy, s) => {
+ const [dx, dy] = shiftOf(sy - FY), px = sx + (flip ? -dx : dx), py = sy + dy;
+ if (px < 0 || py < 0 || px >= W || py >= H) return;
+ const i = py * W + px;
+ if (buf === Ls) {
+ const d = Ls[i];
+ Ls[i] = (255 << 24) | (Math.min(255, ((d >>> 16) & 255) + ((s >>> 16) & 255)) << 16) | (Math.min(255, ((d >>> 8) & 255) + ((s >>> 8) & 255)) << 8) | Math.min(255, (d & 255) + (s & 255));
+ } else if (s >>> 24 === 255 || !C[i]) C[i] = s;
+ else {
+ const k = (s >>> 24) / 255, d = C[i];
+ const ch = (n) => Math.round(((s >>> n) & 255) * k + ((d >>> n) & 255) * (1 - k));
+ C[i] = (Math.max(s >>> 24, d >>> 24) << 24) | (ch(16) << 16) | (ch(8) << 8) | ch(0);
+ }
+ };
+ drawTargets();
+ shadow();
+ for (let sy = 0; sy < H; sy++)
+ for (let sx = 0; sx < W; sx++) {
+ const c = A.color[sy * W + sx];
+ if (c) copy(C, sx, sy, c);
+ }
+ drawGhosts();
+ const restIndex = (s) => {
+ const c = s % 24, r0 = (s / 24) | 0, sx = flip ? FX - (c - 12) - 1 : FX + c - 12, sy = FY + r0 - 38;
+ return sx >= 0 && sy >= 0 && sx < W && sy < H ? sy * W + sx : -1;
+ };
+ for (let i = 0; i < r.n; i++) {
+ const s = r.src[i] >= 0 ? NEAREST[r.src[i]] : -1;
+ if (s < 0) {
+ if (alpha > 0.5) paint(i, r.color[i]);
+ continue;
+ }
+ const j = restIndex(s), v = j >= 0 ? B.color[j] : REST_PX[s];
+ if (!v) continue;
+ // the effect left this bit of body alone, or changed it: carry the change, on top of this pixel's own shading
+ paint(i, v === REST_PX[s] ? r.color[i] : carry(v, REST_PX[s], r.color[i]));
+ }
+ for (let sy = 0; sy < H; sy++)
+ for (let sx = 0; sx < W; sx++) {
+ const j = sy * W + sx;
+ if (B.color[j] && B.color[j] !== A.color[j] && !rest(sx, sy)) copy(C, sx, sy, B.color[j]);
+ if (B.light[j] & 0xffffff) copy(Ls, sx, sy, B.light[j]);
+ }
+ drawStraw();
+ drawDust();
+ },
+ /** Let a loop end: it fades out and done() goes true. */
+ stop() {
+ fx.stop();
+ stopped = true;
+ },
+ /** One-shots end when the last pose is over. */
+ done() {
+ return stopped ? fx.done() : t >= span.to && stop <= 0;
+ },
+ };
+ poseNow();
+ return out;
+}
+
+/**
+ * An act as plain data, for a game with its own character: how long the wind-up and recovery are, when to freeze and shake,
+ * what a target should do, and the poses themselves. Times are in the effect's own seconds: start the effect at 0.
+ */
+export function actTiming(mod) {
+ const a = mod.act;
+ if (!a) return null;
+ const { from, to } = actSpan(mod), D = mod.meta?.duration ?? 1;
+ return {
+ windup: -from,
+ recovery: mod.meta?.loop ? 0 : Math.max(0, to - D),
+ onBody: !!a.onBody,
+ targets: (a.targets ?? (a.target ? [a.target] : [])).map((g) => g.x ?? 66),
+ hits: (a.hits ?? []).map((h) => ({ t: h.t, freeze: h.stop ?? 0, shake: h.shake ?? 0, amp: h.amp ?? 0, push: h.target === false ? 0 : h.push ?? 1.2, skin: h.skin, at: h.at })),
+ poses: (a.poses ?? []).map(([t, pose, how]) => ({ t, how: how ?? "smooth", pose })),
+ };
+}
+
+/** The box an act needs in local space, so nothing gets cut off: { x0, y0, x1, y1 }, sampled over its poses. */
+export function actBounds(mod) {
+ const a = mod.act, [w, h] = mod.meta.size, [ox, oy] = mod.meta.origin;
+ let x0 = -ox, y0 = -oy, x1 = w - ox, y1 = h - oy;
+ const see = (p) => {
+ const r = posed(p), X = Math.round(p.x ?? 0), Y = Math.round(p.y ?? 0), a = r.x0, b = r.x1;
+ x0 = Math.min(x0, a + X - 1); x1 = Math.max(x1, b + X + 1); y0 = Math.min(y0, r.y0 + Y - 1); y1 = Math.max(y1, r.y1 + Y + 1);
+ };
+ const k = a?.poses;
+ if (k) {
+ for (let t = k[0][0]; t <= k[k.length - 1][0]; t += 1 / 12) see(poseAt(k, t));
+ for (const key of k) see(key[1]);
+ } else see(STAND);
+ for (const g of a?.targets ?? (a?.target ? [a.target] : [])) {
+ const tx = g.x ?? 66;
+ x0 = Math.min(x0, tx - 30); x1 = Math.max(x1, tx + 36); y0 = Math.min(y0, -56);
+ }
+ return { x0, y0, x1, y1 };
+}
diff --git a/src/core/actor.js b/src/core/actor.js
index d91eb97..d6824ac 100644
--- a/src/core/actor.js
+++ b/src/core/actor.js
@@ -27,48 +27,54 @@ const HERO_PAL = {
k: "#17121f", h: "#7a4128", s: "#f3c49d", S: "#c98b6c", e: "#17121f",
t: "#5f6f94", T: "#46536f", b: "#8a5a32", p: "#38334a", o: "#6a4030",
// the 2x character's extra detail
- H: "#a35d34", w: "#ffffff", m: "#a3564a", g: "#e8c060", L: "#7f90b6", O: "#8f5a3f",
+ H: "#a35d34", w: "#ffffff", m: "#a3564a", g: "#e8c060", L: "#7f90b6", O: "#8f5a3f", P: "#4b4560",
+ // the scarf
+ c: "#f53cd1", C: "#ff8fe6", D: "#a31f8a",
};
-// The same character at twice the size (24 x 38): Scale2x of HERO, outline thinned back to 1 px, detail added.
+// the dummy: a neutral shell that lets any effect's colors do the talking, near and far limbs, dark bands at the joints, a small mark
+const DUMMY_PAL = {
+ k: "#0e0c14", A: "#e4e6ec", B: "#b6b9c3", C: "#868995", D: "#5c5e6a", E: "#6e707c", F: "#4b4d58", G: "#34353f", J: "#2a2b33", m: "#f53cd1",
+};
+// The same character at twice the size (24 x 38), standing easy: the rest pose of src/core/rig.js, baked.
const HERO2 = [
- ".........kkkkkkkk.......",
- ".......kkhhhhhhhhkk.....",
- ".....kkhhhHHhhhhhhk.....",
- "...kkhhHHHhhhhhhhhhkk...",
- "...khhHHhhhhhhhhhhhhk...",
- "..khhHHhhhhhhhhhhhhhhkk.",
- "..khhhhhhhhhhhhhhhhhhhk.",
- "..khhhhhhhhhhhhhhhhhhhhk",
- "..khhhhSSssssssSShhhhhhk",
- "..khhhhsssssssssssshhhhk",
- "..khhhhswessssewssshhhhk",
- "..khhhsseesssseesssshhhk",
- "..khhhsseesssseesssshhhk",
- "...khhsseesssseesssshhk.",
- "...kkhsssssmmssssssshkk.",
- ".....kssssssssssssssk...",
- "......ksssSSSSSSssskk...",
- "......kttSSSSSSSSkkk....",
- ".....ktttttttttttttk....",
- "...kktLLttttttttttttk...",
- "...ktLLtTTttttTTttttk...",
- "..kttLttTTTttTTTtttttk..",
- "..kssttttTTTTTTtttsssk..",
- "..ksssttttTTTTttttsssk..",
- "..kssstttttttttttttttk..",
- "...kssttttttttttttttk...",
- "...kksbbbbbggbbbbbtkk...",
- "....kbbbbbbggbbbbbbk....",
- "....kpppppbbbbpppppk....",
- "....kppppppkkkppppppk...",
- "....kppppppk..kpppppk...",
- "....kppppppk..kppppppk..",
- "....kppppppk..kppppppk..",
- "....kppppppk...kpppppok.",
- "....koOOooook...kpOOook.",
- "....kkoooooook..kkoooook",
- "....kkkoooookk..kkkoookk",
- ".....kkkkkkkk....kkkkkk.",
+ "...........kkk..........",
+ "..........kAABk.........",
+ ".........kAAABJk........",
+ ".........kABBJJk........",
+ ".........kBBBJCDk.......",
+ ".........kBCJDDDk.......",
+ ".........kkJJJDk........",
+ ".......kkkkABBJCkk......",
+ "......kAABCJBCCCkDk.....",
+ "......kABBCJCCCmDkDk....",
+ "......kBBCDDJCDDDkDk....",
+ "......kABCDJDDDDDkk.....",
+ ".....kAABDkDDDDJkk......",
+ ".....kABCDkDDJJGkk......",
+ ".....kABCkJJJGGGkk......",
+ "....kJJCDkFFFGGGk.......",
+ "....kAJJDkJJJGGGk.......",
+ "....kJCJJkABBJGGk.......",
+ ".....kJCCkBBCDJJJk......",
+ ".....kCCCJBBCDJJDk......",
+ ".....kCCCDJCCDkJDDk.....",
+ "......kCDDJBCDkDDDk.....",
+ ".......kDJJJCDkDDDkk....",
+ ".......kJBCJCDkDDDkk....",
+ ".......kBDJBCDkCDDkk....",
+ "........kJJBCDkCDDk.....",
+ "........kBBBCDkCCDDk....",
+ "........kBBBCDkCCDDk....",
+ ".........kBBCDkJDDDk....",
+ "........kBJJJJkCJJJk....",
+ "........kBBCCDkCCDDk....",
+ "........kBBCDDkCDDk.....",
+ "........kBBCDkCCDDk.....",
+ "........kBCCDkCCDDk.....",
+ "........kBCDDkCDDDk.....",
+ ".......kJBCJkkkDJkkkk...",
+ ".......kAJJAAAAkCCCCCk..",
+ "........kkkkkkkkkkkkk...",
];
@@ -84,12 +90,12 @@ function maskOf(rows, k = 1) {
const MASKS = { 1: maskOf(HERO, 1), 2: maskOf(HERO2, 1) };
const SPRITES = { 1: HERO, 2: HERO2 };
// the character's own colors, row by row (0 where empty), for effects that recolor it: frozen, poisoned, stone
-function pixelsOf(rows) {
+function pixelsOf(rows, pal) {
const w = rows[0].length, data = new Uint32Array(w * rows.length);
- rows.forEach((r, y) => [...r].forEach((ch, x) => (data[y * w + x] = ch === "." ? 0 : hex(HERO_PAL[ch]))));
+ rows.forEach((r, y) => [...r].forEach((ch, x) => (data[y * w + x] = ch === "." ? 0 : hex(pal[ch]))));
return data;
}
-const PIXELS = { 1: pixelsOf(HERO), 2: pixelsOf(HERO2) };
+const PIXELS = { 1: pixelsOf(HERO, HERO_PAL), 2: pixelsOf(HERO2, DUMMY_PAL) };
/**
* The stock actor at scale k (1: 12 x 19 px, 2: 24 x 38 px), in local space with its feet at (0, 0):
@@ -98,14 +104,14 @@ const PIXELS = { 1: pixelsOf(HERO), 2: pixelsOf(HERO2) };
export function stockActor(k = 1) {
k = k === 2 ? 2 : 1;
const m = MASKS[k], x = -Math.floor(m.w / 2), y = -m.h;
- return { mask: m, pixels: PIXELS[k], x, y, w: m.w, h: m.h, k, head: [0, y], chest: [0, y + 11 * k] };
+ return { mask: m, pixels: PIXELS[k], x, y, w: m.w, h: m.h, k, head: [0, y], chest: [0, k === 2 ? -26 : y + 11], ...(k === 2 ? { eyes: [[13, 3], [15, 3]] } : {}) };
}
/** Draw the stock actor with its feet at the painter's origin, at alpha a (dithered). */
export function drawActor(p, actor = stockActor(), a = 1) {
- if (a > 0) p.sprite(SPRITES[actor.k === 2 ? 2 : 1], HERO_PAL, actor.x, actor.y, { a });
+ if (a > 0) p.sprite(SPRITES[actor.k === 2 ? 2 : 1], actor.k === 2 ? DUMMY_PAL : HERO_PAL, actor.x, actor.y, { a });
}
/** How visible an effect wants the stand-in character at time t (effects may export actorAlpha). */
export const actorAlphaOf = (mod, t, o) => (typeof mod.actorAlpha === "function" ? mod.actorAlpha(t, o) : 1);
-export { HERO, HERO2, HERO_PAL };
+export { HERO, HERO2, HERO_PAL, DUMMY_PAL };
diff --git a/src/core/chain.js b/src/core/chain.js
new file mode 100644
index 0000000..c816e89
--- /dev/null
+++ b/src/core/chain.js
@@ -0,0 +1,46 @@
+// Moves: several effects played as one. A cue says which effect, when, where and for how long; a projectile is just an
+// effect whose x is a function of time. It's an ordinary effect from the outside: it plays, recolors and exports.
+
+import { createFx } from "./fx.js";
+
+/**
+ * create(o) for a list of cues: { fx (an effect module), t (when it starts), until (cut it off here), x, y (numbers, or
+ * functions of the move's time, local space), flip, ...any of that effect's options }.
+ */
+export function chain(cues) {
+ return (o) => {
+ const list = cues.map(({ fx, t, until, x, y, flip, ...opts }, i) => ({ fx, t: t ?? 0, until: until ?? Infinity, x: x ?? 0, y: y ?? 0, flip: !!flip, opts: { ...opts, seed: (o.seed ?? 1) + i }, inst: null, over: false }));
+ let t = 0;
+ const at = (v) => (typeof v === "function" ? v(t) : v);
+ const each = (p, layer) => {
+ const { frame, tx, ty, fx: sign, cs, sn, fade, lightK } = p;
+ for (const c of list) {
+ if (!c.inst || c.over) continue;
+ c.inst.options.x = tx + sign * at(c.x);
+ c.inst.options.y = ty + at(c.y);
+ c.inst.options.flip = sign < 0 !== c.flip;
+ c.inst.draw(frame, layer);
+ }
+ // each one places the painter for itself: put it back for whoever draws next
+ Object.assign(p, { tx, ty, fx: sign, cs, sn, fade, lightK });
+ };
+ return {
+ update(dt) {
+ t += dt;
+ for (const c of list) {
+ if (c.over || t < c.t) continue;
+ if (!c.inst) c.inst = createFx(c.fx, c.opts);
+ else c.inst.update(dt);
+ if (t >= c.until || (c.inst.done() && !c.fx.meta?.loop)) c.over = true;
+ }
+ },
+ drawBack: (p) => each(p, "back"),
+ draw: (p) => each(p, "front"),
+ };
+ };
+}
+
+/** Reuse an act's keys in a longer move: later by dt, moved along by dx, with anything else laid over each pose. */
+export const shiftKeys = (keys, dt, { dx = 0, ...over } = {}) => keys.map(([t, pose, how]) => [t + dt, { ...pose, ...over, x: (pose.x ?? 0) + dx }, how]);
+/** The same for hits. */
+export const shiftHits = (hits, dt) => hits.map((h) => ({ ...h, t: h.t + dt }));
diff --git a/src/core/index.js b/src/core/index.js
index dd662a0..14b3144 100644
--- a/src/core/index.js
+++ b/src/core/index.js
@@ -8,5 +8,9 @@ export { Particles, Bits, Lights, Blazes, P, PF, B, GRAVITY, FIRE_RAMP, SMOKE_RA
export { Painter } from "./painter.js";
export { FONTS, textWidth } from "./font.js";
export { createFrame, clearFrame, createFx, composite, painterFor, resolveOptions } from "./fx.js";
-export { stockActor, drawActor, actorAlphaOf, HERO, HERO2, HERO_PAL } from "./actor.js";
+export { stockActor, drawActor, actorAlphaOf, HERO, HERO2, HERO_PAL, DUMMY_PAL } from "./actor.js";
export { backdrop, BACKDROPS } from "./scene.js";
+export { createAct, actBounds, actSpan, actTiming, poseAt, lerpPose, Target, STAND, SKINS, posed } from "./act.js";
+export { skeleton, posedParts } from "./rig.js";
+export { READY } from "./poses.js";
+export { chain, shiftKeys, shiftHits } from "./chain.js";
diff --git a/src/core/poses.js b/src/core/poses.js
new file mode 100644
index 0000000..c6a9daa
--- /dev/null
+++ b/src/core/poses.js
@@ -0,0 +1,24 @@
+// The stance acts start from. A pose only says what differs from standing easy (STAND in rig.js), in screen terms, px from
+// the feet, y negative up. Give the hands and feet; the skeleton works out the rest.
+// x, y where the feet are, from the effect's origin
+// crouch hips lowered; lean the spine bent forward (+) or back (-); hx, hy the head rolled, nodded
+// fx, fy, fz the near (right) hand; bx, by, bz the far (left) hand; ffx, ffy the near foot; fbx, fby the far foot
+// turn how far the chest faces us, in radians (it follows the hands if you leave it out); yaw the whole body turned
+// about its feet (0 faces right, pi faces left, in between towards us; a spin is really a spin)
+// twist extra chest turn; armsFront the far hand comes round in front of the chest
+// weapon, sa what the near hand holds and its angle on screen (radians, 0 points forward); two both hands on it
+// wl, wz foreshorten the weapon towards (or, wz -1, away from) the viewer: wl is its length on screen, 1 is full
+// pull, nocked a bow drawn to the far hand, an arrow on the string
+// offWeapon, sb a weapon in the far hand and its angle
+// toeF, toeB up on the toes; ghost leave after-images
+//
+// How the body works. He faces right, three-quarters towards us, so his near shoulder is on the LEFT of the chest on screen and
+// his far shoulder on the right: for arms raised or open to us, the near hand goes left (fx < 0) and the far hand right (bx > 0). A hand
+// driving forward closes the chest and brings its shoulder round; a hand drawn back opens him up. Bones have fixed lengths: an arm reaches
+// about 15 px from its shoulder (shoulders are near y = -29), a leg 17 px. Arms don't stretch, so step the body in rather than ask too much.
+//
+// How to hold things. Keep a little bend in the elbow. The blade lags the hand on a swing, so the wrist breaks and it whips. Long weapons
+// rest in one hand with the butt on the floor and take the second hand to swing. Everything is in depth, so a weapon can swing round the front
+// of him: turn the body (yaw) and the weapon goes with it.
+
+export const READY = { crouch: 3, fx: 11, fy: -21, bx: 9, by: -21, ffx: 7, fbx: -7 };
diff --git a/src/core/rig.js b/src/core/rig.js
new file mode 100644
index 0000000..525b714
--- /dev/null
+++ b/src/core/rig.js
@@ -0,0 +1,516 @@
+// The character who acts: a real skeleton in 3D, drawn down to pixels the way Dead Cells makes its sprites. Bones have
+// fixed lengths and hang from each other, pelvis to spine to chest to shoulders, so the body can twist, bend and turn round,
+// and depth decides what's in front. A pose only says where the hands and feet should be and how the body is carrying
+// itself; the solver works out every joint, and the renderer shades it into a few flat tones with one clean ink line.
+//
+// Coordinates: x right, y up, z towards the viewer, in pixels, the feet at the origin. Poses are in screen terms (y negative
+// is up), as effects are. The character faces +x with his right side towards the viewer, so the right hand is the near one.
+//
+// A rendered pose also knows, for each of its pixels, which pixel of the standing character it came from (`src`). That
+// is what lets an effect drawn on the standing body (frost, poison, a scan line) follow the body wherever it goes.
+
+import { hex } from "./color.js";
+import { DUMMY_PAL } from "./actor.js";
+
+const PAL = Object.fromEntries(Object.entries(DUMMY_PAL).map(([k, v]) => [k, hex(v) >>> 0]));
+const INK = PAL.k, SEAM = PAL.J, MARK = PAL.m;
+// plates and joints: lit to dark
+const SHELL = [PAL.A, PAL.B, PAL.C, PAL.D], CORE = [PAL.E, PAL.F, PAL.G, PAL.G];
+const DEG = Math.PI / 180, W0 = 24, H0 = 38;
+
+// ---- vectors and turns
+const add = (a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
+const sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
+const mul = (a, s) => [a[0] * s, a[1] * s, a[2] * s];
+const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
+const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
+const len = (a) => Math.hypot(a[0], a[1], a[2]);
+const unit = (a) => mul(a, 1 / (len(a) || 1e-6));
+const rotY = (t) => { const c = Math.cos(t), s = Math.sin(t); return [c, 0, s, 0, 1, 0, -s, 0, c]; };
+const rotZ = (t) => { const c = Math.cos(t), s = Math.sin(t); return [c, -s, 0, s, c, 0, 0, 0, 1]; };
+const mm = (A, B) => { const o = new Array(9); for (let r = 0; r < 3; r++) for (let c = 0; c < 3; c++) o[r * 3 + c] = A[r * 3] * B[c] + A[r * 3 + 1] * B[3 + c] + A[r * 3 + 2] * B[6 + c]; return o; };
+const mv = (M, v) => [M[0] * v[0] + M[1] * v[1] + M[2] * v[2], M[3] * v[0] + M[4] * v[1] + M[5] * v[2], M[6] * v[0] + M[7] * v[1] + M[8] * v[2]];
+const tv = (M, v) => [M[0] * v[0] + M[3] * v[1] + M[6] * v[2], M[1] * v[0] + M[4] * v[1] + M[7] * v[2], M[2] * v[0] + M[5] * v[1] + M[8] * v[2]];
+const clamp01 = (v) => Math.max(0, Math.min(1, v));
+
+// ---- the body's measurements, in pixels
+const M = {
+ pelvis: 19.7, spine1: 2.8, spine2: 4.6, shoulderUp: 2.5, shoulderOut: 5.9, neckUp: 4.0, headUp: 3.1,
+ hipDown: 1.1, hipOut: 2.8, thigh: 8.6, shin: 8.3, upper: 7.6, fore: 7.4, turn: 36 * DEG,
+};
+/** Standing easy, in screen terms: hands and feet are where they should end up, y negative is up. */
+export const STAND = { lean: 0, crouch: 0, yaw: 0, fx: -3, fy: -15, bx: 5, by: -15, ffx: -2, ffy: -4, fbx: 3, fby: -4 };
+
+// ---- solving a pose: from where the hands and feet should be, to every joint
+function ik(a, target, L1, L2, pole) {
+ let to = sub(target, a), d = len(to);
+ const reach = L1 + L2 - 0.02;
+ if (d > reach) { to = mul(to, reach / d); d = reach; }
+ const u = unit(to), along = (L1 * L1 - L2 * L2 + d * d) / (2 * d), h = Math.sqrt(Math.max(0, L1 * L1 - along * along));
+ let v = sub(pole, mul(u, dot(pole, u)));
+ v = len(v) < 1e-4 ? unit(cross(u, [0, 0, 1])) : unit(v);
+ return { joint: add(a, add(mul(u, along), mul(v, h))), end: add(a, to), u, v };
+}
+function frame(t, R) {
+ return { t, R };
+}
+// a frame along a bone: its local x runs down the bone
+function boneFrame(a, b, pole) {
+ const x = unit(sub(b, a));
+ let y = sub(pole, mul(x, dot(pole, x)));
+ y = len(y) < 1e-4 ? unit(cross(x, [0, 0, 1])) : unit(y);
+ const z = cross(x, y);
+ return frame(a, [x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2]]);
+}
+const weaponOf = (name) => WEAPONS[name];
+
+function solve(pose) {
+ const q = { ...STAND, ...pose }, lean = q.lean, W = q.weapon && weaponOf(q.weapon), OW = q.offWeapon && weaponOf(q.offWeapon);
+ const sa = q.sa ?? 0, wl = q.wl ?? 1, axisZ = Math.sqrt(Math.max(0, 1 - wl * wl)) * (q.wz ?? 1);
+ const axis = [Math.cos(sa) * wl, -Math.sin(sa) * wl, axisZ], side = [-Math.sin(sa), -Math.cos(sa), 0];
+ const two = !!(q.two && W), nearZ = q.fz ?? (two ? 3 : 4.5);
+ // how the chest is turned follows the hands: a hand driving forward brings its shoulder round; one drawn back opens him up
+ const fwd = (q.fx - STAND.fx) / 24, farFwd = two ? 0 : (q.bx - STAND.bx) / 22;
+ let turn = M.turn + (fwd >= 0 ? -44 * DEG * Math.min(1, fwd) : 28 * DEG * Math.min(1, -fwd * 1.8));
+ turn += (farFwd > 0 ? 34 * DEG * Math.min(1, farFwd) : 0) + (q.twist ?? 0) * 4 * DEG;
+ if (q.turn !== undefined) turn = q.turn;
+ const hipTurn = M.turn + (turn - M.turn) * 0.45, tilt = Math.atan2(lean, 13);
+ const Rp = mm(rotZ(-tilt * 0.25), rotY(-hipTurn)), Rc = mm(rotZ(-tilt), rotY(-turn));
+ // feet first: the pelvis sinks if that's what it takes for both legs to reach them
+ const ankleN = [q.ffx, -q.ffy - 1.8, q.fzz ?? 2.4], ankleF = [q.fbx, -q.fby - 1.8, q.bzz ?? -2.4];
+ let pelvis = [lean * 0.2, M.pelvis - q.crouch, 0];
+ const hipAt = (s) => add(pelvis, mv(Rp, [0, -M.hipDown, s * M.hipOut]));
+ const maxLeg = (M.thigh + M.shin) * 0.995;
+ for (const [s, a] of [[1, ankleN], [-1, ankleF]]) {
+ const h = hipAt(s), dx = h[0] - a[0], dz = h[2] - a[2], flat = dx * dx + dz * dz;
+ if (flat < maxLeg * maxLeg) {
+ const top = a[1] + Math.sqrt(maxLeg * maxLeg - flat);
+ if (h[1] > top) pelvis = [pelvis[0], pelvis[1] - (h[1] - top), pelvis[2]];
+ }
+ }
+ const waist = add(pelvis, [Math.sin(tilt * 0.45) * M.spine1, Math.cos(tilt * 0.45) * M.spine1, 0]);
+ const chest = add(waist, [Math.sin(tilt) * M.spine2, Math.cos(tilt) * M.spine2, 0]);
+ const neck = add(chest, mv(Rc, [0, M.neckUp, 0]));
+ // the head keeps looking where he's going: it takes only part of the lean and part of the turn
+ const headTurn = M.turn * 0.9 + (turn - M.turn) * 0.35, nod = tilt * 0.35 + (q.hy ?? 0) * 7 * DEG, roll = (q.hx ?? 0) * 7 * DEG;
+ const Rh = mm(rotZ(-nod - roll), rotY(-headTurn));
+ const head = add(neck, mv(Rh, [0.15, M.headUp, 0]));
+ // the arms: shoulders reach a little towards a far hand
+ const pick = (s, target) => {
+ const base = add(chest, mv(Rc, [0, M.shoulderUp, s * M.shoulderOut])), to = sub(target, base), d = len(to);
+ return add(base, mul(unit(to), Math.min(1.8, Math.max(0, d - 11) * 0.35)));
+ };
+ const nearT = [q.fx, -q.fy, nearZ];
+ const farT = two ? [q.fx + axis[0] * W.two, -q.fy + axis[1] * W.two, nearZ + axis[2] * W.two] : [q.bx, -q.by, q.bz ?? (q.armsFront ? 5.5 : -4.5)];
+ const sN = pick(1, nearT), sF = pick(-1, farT);
+ const pole = (s, T, shoulder, hold) => {
+ // elbows hang down and back; overhead they go out and forward
+ const up = clamp01((T[1] - shoulder[1] + 2) / 10);
+ const base = [-0.55 + up * 1.1, -1 + up * 0.9, s * (0.45 + up * 0.5)];
+ if (!hold) return base;
+ // holding something, the forearm wants to meet the handle side on: try round the circle, keep the best
+ const u = unit(sub(T, shoulder));
+ let best = base, score = Infinity;
+ for (let i = 0; i < 16; i++) {
+ const a = (i / 16) * Math.PI * 2, x = unit(cross(u, [0.3, 1, 0.2])), y = cross(u, x), v = add(mul(x, Math.cos(a)), mul(y, Math.sin(a)));
+ const A = ik(shoulder, T, M.upper, M.fore, v), f = unit(sub(A.end, A.joint));
+ const cost = Math.abs(dot(f, hold)) * 0.7 + (1 - dot(unit(base), v)) * 0.55;
+ if (cost < score) { score = cost; best = v; }
+ }
+ return best;
+ };
+ const holdN = W ? (W.across ? side : axis) : null, holdF = two ? (W.across ? side : axis) : OW ? [Math.cos(q.sb ?? Math.PI), -Math.sin(q.sb ?? Math.PI), 0] : null;
+ const armN = ik(sN, nearT, M.upper, M.fore, pole(1, nearT, sN, holdN)), armF = ik(sF, farT, M.upper, M.fore, pole(-1, farT, sF, holdF));
+ // the legs: knees forward, a little out
+ const kneePole = (s) => mv(Rp, [1, 0, s * 0.35]);
+ const hipN = hipAt(1), hipF = hipAt(-1);
+ const legN = ik(hipN, ankleN, M.thigh, M.shin, kneePole(1)), legF = ik(hipF, ankleF, M.thigh, M.shin, kneePole(-1));
+ const footDir = (s) => { const t = hipTurn * 0.6 + s * 8 * DEG; return [Math.cos(t), 0, Math.sin(t)]; };
+ const B = {
+ pelvis: frame(pelvis, Rp), waist: frame(waist, mm(rotZ(-tilt * 0.6), rotY(-(turn + hipTurn) / 2))), chest: frame(chest, Rc), head: frame(head, Rh), neck: frame(neck, Rh),
+ upperN: boneFrame(sN, armN.joint, armN.v), foreN: boneFrame(armN.joint, armN.end, armN.v), upperF: boneFrame(sF, armF.joint, armF.v), foreF: boneFrame(armF.joint, armF.end, armF.v),
+ thighN: boneFrame(hipN, legN.joint, legN.v), shinN: boneFrame(legN.joint, legN.end, legN.v), thighF: boneFrame(hipF, legF.joint, legF.v), shinF: boneFrame(legF.joint, legF.end, legF.v),
+ };
+ B.footN = frame(legN.end, mm(rotY(-Math.atan2(footDir(1)[2], footDir(1)[0])), rotZ(q.toeF ? -55 * DEG : 0)));
+ B.footF = frame(legF.end, mm(rotY(-Math.atan2(footDir(-1)[2], footDir(-1)[0])), rotZ(q.toeB ? -55 * DEG : 0)));
+ return { B, W, OW, q, axis, side, armN, armF, legN, legF, sN, sF, hipN, hipF, turn };
+}
+
+// ---- drawing: every part goes through one depth buffer
+const BW = 300, BH = 240, OX = 150, OY = 180; // the scratch grid, big enough for a raised scythe; feet at (OX, OY)
+const Zb = new Float32Array(BW * BH), Tone = new Float32Array(BW * BH), Part = new Int8Array(BW * BH), Mat = new Int8Array(BW * BH), Fr = new Int8Array(BW * BH), LX = new Float32Array(BW * BH), LY = new Float32Array(BW * BH), Col = new Uint32Array(BW * BH);
+const touched = [];
+const LIGHT = unit([-0.55, 0.72, 0.5]);
+let clipBody = false, clipWeapon = false, curFrameIndex = 0, curDim = 0, onlyPart = 0;
+const FRAME_IDS = ["pelvis", "waist", "chest", "head", "neck", "upperN", "foreN", "upperF", "foreF", "thighN", "shinN", "thighF", "shinF", "footN", "footF"];
+function plot(i, z, tone, part, mat, wx, wy, color) {
+ if (onlyPart && part !== onlyPart) return;
+ if (Part[i] === 0) touched.push(i);
+ else if (z <= Zb[i]) return;
+ Zb[i] = z;
+ Tone[i] = tone;
+ Part[i] = part;
+ Mat[i] = mat;
+ Fr[i] = curFrameIndex;
+ LX[i] = wx;
+ LY[i] = wy;
+ Col[i] = color;
+}
+function sphere(c, r, part, mat) {
+ const x0 = Math.floor(c[0] - r), x1 = Math.ceil(c[0] + r), y0 = Math.floor(c[1] - r), y1 = Math.ceil(c[1] + r);
+ for (let wy = y0; wy <= y1; wy++)
+ for (let wx = x0; wx <= x1; wx++) {
+ const dx = wx - c[0], dy = wy - c[1], d2 = dx * dx + dy * dy;
+ if (d2 > r * r || (clipBody && wy < 1.5)) continue;
+ const dz = Math.sqrt(r * r - d2), n = [dx / r, dy / r, dz / r], i = (OY - wy) * BW + (OX + wx);
+ plot(i, c[2] + dz, dot(n, LIGHT), part, mat, wx, wy, 0);
+ }
+}
+function sweep(a, b, ra, rb, part, mat, bulge = 0) {
+ const n = Math.max(2, Math.ceil(len(sub(b, a)) / 0.4));
+ for (let k = 0; k <= n; k++) {
+ const u = k / n;
+ sphere(add(a, mul(sub(b, a), u)), ra + (rb - ra) * u + bulge * Math.sin(u * Math.PI), part, mat);
+ }
+}
+// an ellipsoid with radii r along the axes of frame R, seen along z
+function ellipsoid(c, R, r, part, mat) {
+ const big = Math.max(r[0], r[1], r[2]), x0 = Math.floor(c[0] - big), x1 = Math.ceil(c[0] + big), y0 = Math.floor(c[1] - big), y1 = Math.ceil(c[1] + big);
+ const Rt = [R[0], R[3], R[6], R[1], R[4], R[7], R[2], R[5], R[8]], D = [1 / (r[0] * r[0]), 1 / (r[1] * r[1]), 1 / (r[2] * r[2])];
+ // A = R diag(D) R^T
+ const A = new Array(9);
+ for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) A[i * 3 + j] = R[i * 3] * D[0] * R[j * 3] + R[i * 3 + 1] * D[1] * R[j * 3 + 1] + R[i * 3 + 2] * D[2] * R[j * 3 + 2];
+ void Rt;
+ for (let wy = y0; wy <= y1; wy++)
+ for (let wx = x0; wx <= x1; wx++) {
+ if (clipBody && wy < 1.5) continue;
+ const dx = wx - c[0], dy = wy - c[1];
+ const qa = A[8], qb = 2 * (A[2] * dx + A[5] * dy), qc = A[0] * dx * dx + 2 * A[1] * dx * dy + A[4] * dy * dy - 1, disc = qb * qb - 4 * qa * qc;
+ if (disc < 0) continue;
+ const dz = (-qb + Math.sqrt(disc)) / (2 * qa);
+ const n = unit([A[0] * dx + A[1] * dy + A[2] * dz, A[3] * dx + A[4] * dy + A[5] * dz, A[6] * dx + A[7] * dy + A[8] * dz]);
+ plot((OY - wy) * BW + (OX + wx), c[2] + dz, dot(n, LIGHT), part, mat, wx, wy, 0);
+ }
+}
+// parts: each has its own number, so edges between them can be seen
+const PART = { pelvis: 1, waist: 2, chest: 3, neck: 4, head: 5, face: 6, upperN: 7, elbowN: 8, foreN: 9, handN: 10, upperF: 11, elbowF: 12, foreF: 13, handF: 14, thighN: 15, kneeN: 16, shinN: 17, footN: 18, thighF: 19, kneeF: 20, shinF: 21, footF: 22, weapon: 23, offWeapon: 24 };
+const useFrame = (name) => { curFrameIndex = FRAME_IDS.indexOf(name); };
+
+function drawBody(S) {
+ const { B, armN, armF, legN, legF, sN, sF, hipN, hipF, turn } = S, F_ = (name) => B[name];
+ useFrame("pelvis");
+ ellipsoid(add(F_("pelvis").t, mv(F_("pelvis").R, [0, -0.2, 0])), F_("pelvis").R, [2.9, 2.6, 4.2], PART.pelvis, 0);
+ useFrame("waist");
+ sweep(F_("pelvis").t, F_("chest").t, 3, 3.3, PART.waist, 1);
+ useFrame("chest");
+ ellipsoid(add(F_("chest").t, mv(F_("chest").R, [0.2, 0.9, 0])), F_("chest").R, [3.4, 4.2, 5.5], PART.chest, 0);
+ useFrame("neck");
+ sweep(F_("neck").t, add(F_("neck").t, mv(F_("head").R, [0, 1.6, 0])), 1.25, 1.15, PART.neck, 1);
+ useFrame("head");
+ ellipsoid(F_("head").t, F_("head").R, [3, 3.3, 2.8], PART.head, 0);
+ ellipsoid(add(F_("head").t, mv(F_("head").R, [0.85, -0.45, 0])), F_("head").R, [2.4, 2.7, 2.35], PART.face, 0);
+ const arm = (far, A, sh, up, el, fo, ha, nameU, nameF) => {
+ curDim = far ? 1 : 0;
+ useFrame(nameU);
+ sphere(sh, 2.5, up, 0);
+ sweep(sh, A.joint, 2.1, 1.6, up, 0);
+ sphere(A.joint, 1.45, el, 1);
+ useFrame(nameF);
+ sweep(A.joint, A.end, 1.6, 1.2, fo, 0, 0.15);
+ sphere(A.end, 1.9, ha, 0);
+ curDim = 0;
+ };
+ arm(false, armN, sN, PART.upperN, PART.elbowN, PART.foreN, PART.handN, "upperN", "foreN");
+ arm(true, armF, sF, PART.upperF, PART.elbowF, PART.foreF, PART.handF, "upperF", "foreF");
+ const leg = (far, L, hip, th, kn, sh, fo, nameT, nameS, nameFt) => {
+ useFrame(nameT);
+ sweep(hip, L.joint, 3.2, 2.2, th, 0);
+ sphere(L.joint, 1.9, kn, 1);
+ useFrame(nameS);
+ sweep(L.joint, L.end, 2.15, 1.4, sh, 0, 0.4);
+ useFrame(nameFt);
+ const R = F_(nameFt).R, a = F_(nameFt).t;
+ sweep(add(a, mv(R, [-1.5, -0.6, 0])), add(a, mv(R, [4.6, -1.1, 0])), 1.7, 1.25, fo, 0);
+ };
+ leg(false, legN, hipN, PART.thighN, PART.kneeN, PART.shinN, PART.footN, "thighN", "shinN", "footN");
+ leg(true, legF, hipF, PART.thighF, PART.kneeF, PART.shinF, PART.footF, "thighF", "shinF", "footF");
+ void turn;
+}
+
+// ---- what they hold: drawn along the handle from the fist, through the same depth buffer
+function along(H, axis, side, part) {
+ const n = cross(axis, side);
+ const T = (i, k, c, lift = 0) => {
+ const x = H[0] + axis[0] * i + side[0] * k + n[0] * lift, y = H[1] + axis[1] * i + side[1] * k + n[1] * lift, z = H[2] + axis[2] * i + side[2] * k + n[2] * lift;
+ const wx = Math.round(x), wy = Math.round(y);
+ if (clipWeapon && wy < 0) return;
+ const idx = (OY - wy) * BW + (OX + wx);
+ if (idx < 0 || idx >= BW * BH) return;
+ curFrameIndex = -1;
+ plot(idx, z + 0.05, 2, part, 2, wx, wy, c);
+ };
+ T.at = (i, k) => [H[0] + axis[0] * i + side[0] * k, H[1] + axis[1] * i + side[1] * k, H[2] + axis[2] * i + side[2] * k];
+ return T;
+}
+const STEEL = Object.fromEntries(Object.entries({ hi: "#ffffff", a: "#e8edf6", b: "#a4afc6", d: "#68748f", gold: "#ffd84a", goldD: "#b8862a", grip: "#7a3a2a", gripD: "#4a2018", wood: "#8a5a32", woodD: "#5a3820", dark: "#3a3448", darkD: "#262033", olive: "#58663f", oliveA: "#7d8c58", oliveD: "#3a4529" }).map(([k, v]) => [k, hex(v) >>> 0]));
+function blade(T, from, length, w) {
+ for (let i = from; i <= from + length + 0.01; i += 0.4) {
+ const r = i - from, wd = r > length - 5 ? Math.max(0, ((length - r) / 5) * w) : w;
+ for (let k = -wd; k <= wd + 0.01; k += 0.4) T(i, k, k < -w * 0.4 ? STEEL.hi : k > w * 0.4 ? STEEL.d : STEEL.a);
+ }
+}
+const haft = (T, from, to, a, d, r = 0.8) => {
+ for (let i = from; i <= to; i += 0.4) for (let k = -r; k <= r + 0.01; k += 0.4) T(i, k, k > 0.1 ? d : a);
+};
+export const WEAPONS = {
+ // the fist is at i = 0; `two` is where the other hand goes; `across`: the handle lies across the weapon's length
+ sword: { two: -4.4, draw(T, q) {
+ const end = q.two ? -6.5 : -2.6;
+ haft(T, end, 2.2, STEEL.grip, STEEL.gripD);
+ for (let k = -1.4; k <= 1.4; k += 0.4) T(end - 0.4, k, STEEL.gold);
+ for (let k = -4.6; k <= 4.6; k += 0.4) (T(2.6, k, Math.abs(k) > 3.8 ? STEEL.goldD : STEEL.gold), T(3, k, STEEL.goldD));
+ blade(T, 3.2, 25, 2.2);
+ } },
+ greatsword: { two: -4.8, draw(T) {
+ haft(T, -7.2, 2.2, STEEL.grip, STEEL.gripD);
+ for (let k = -1.8; k <= 1.8; k += 0.4) T(-7.6, k, STEEL.gold);
+ for (let k = -6.6; k <= 6.6; k += 0.4) (T(2.6, k, Math.abs(k) > 5.6 ? STEEL.goldD : STEEL.gold), T(3, k, STEEL.goldD));
+ blade(T, 3.2, 31, 3);
+ for (let i = 4; i <= 28; i += 0.4) T(i, 0, STEEL.b);
+ } },
+ dagger: { draw(T) {
+ haft(T, -2.4, 1.8, STEEL.grip, STEEL.gripD);
+ for (let k = -2.6; k <= 2.6; k += 0.4) T(2.2, k, STEEL.goldD);
+ blade(T, 2.6, 10, 1.3);
+ } },
+ spear: { two: -12, draw(T) {
+ haft(T, -18, 36, STEEL.wood, STEEL.woodD, 0.5);
+ blade(T, 36, 11, 2);
+ for (let k = -2.4; k <= 2.4; k += 0.4) T(36, k, STEEL.goldD);
+ } },
+ hammer: { two: -7, draw(T) {
+ for (const lift of [-0.8, 0, 0.8]) for (let i = -10; i <= 18; i += 0.4) for (let k = -0.8; k <= 0.81; k += 0.4) T(i, k, k > 0.1 ? STEEL.woodD : STEEL.wood, lift);
+ // the head is a block: its two faces, and the steel between them
+ for (let i = 18; i <= 28; i += 0.4) for (let k = -9; k <= 9; k += 0.4) {
+ const face = Math.abs(k) > 7.4 ? (k < 0 ? STEEL.a : STEEL.d) : i < 20 ? STEEL.hi : i > 26.4 ? STEEL.d : Math.abs(k) < 2 ? STEEL.gold : STEEL.b;
+ T(i, k, face, 4.5);
+ T(i, k, face, -4.5);
+ if (i < 18.4 || i > 27.6 || Math.abs(k) > 8.6) for (let l = -4; l <= 4; l += 0.4) T(i, k, k < 0 ? STEEL.a : i > 27.6 ? STEEL.d : STEEL.b, l);
+ }
+ } },
+ scythe: { two: -11, draw(T) {
+ haft(T, -16, 31, STEEL.dark, STEEL.darkD, 0.5);
+ for (let j = 0; j <= 28; j += 0.4) {
+ const u = j / 28, w = 3.2 * (1 - u) + 0.3, b = 31.5 - u * u * 12;
+ for (let k = -w; k <= w; k += 0.4) T(b + k, j + 0.8, k > w * 0.3 ? STEEL.hi : k < -w * 0.4 ? STEEL.d : STEEL.b);
+ }
+ } },
+ claw: { draw(T) {
+ for (const q0 of [-2.4, 0, 2.4])
+ for (let i = 2; i <= 9.5; i += 0.4) {
+ const u = (i - 2) / 7.5, k = q0 + u * u * 1.8;
+ T(i, k, u > 0.55 ? STEEL.hi : STEEL.a);
+ if (u < 0.6) T(i, k + 0.8, STEEL.d);
+ }
+ } },
+ bow: { across: true, draw(T, q, off) {
+ for (let u = -1; u <= 1.001; u += 0.025) {
+ const k = u * 17, i = 6 * (1 - u * u) - 1;
+ T(i, k, Math.abs(u) > 0.85 ? STEEL.goldD : STEEL.wood);
+ T(i + 0.8, k, STEEL.woodD);
+ }
+ const tipA = T.at(-1, -17), tipB = T.at(-1, 17), mid = q.pull ? off : T.at(-1, 0);
+ const line = (A, B, c) => {
+ const n = Math.max(2, Math.ceil(len(sub(B, A)) / 0.4)), Z = STEEL.a;
+ for (let k = 0; k <= n; k++) {
+ const P = add(A, mul(sub(B, A), k / n)), wx = Math.round(P[0]), wy = Math.round(P[1]), idx = (OY - wy) * BW + (OX + wx);
+ curFrameIndex = -1;
+ plot(idx, P[2] + 0.05, 2, PART.weapon, 2, wx, wy, c ?? Z);
+ }
+ };
+ line(tipA, mid);
+ line(tipB, mid);
+ if (q.nocked) {
+ const nock = mid, tip = T.at(13, 0);
+ line(nock, tip, STEEL.wood);
+ for (let i = 9; i <= 13; i += 0.4) for (let k = -(13 - i) * 0.45; k <= (13 - i) * 0.45; k += 0.4) T(i, k, STEEL.hi);
+ }
+ } },
+ pistol: { across: true, draw(T) {
+ for (let i = -1; i <= 9.5; i += 0.4) for (let k = -4.2; k <= -2.4; k += 0.4) T(i, k, k < -3.6 ? STEEL.a : k > -2.9 ? STEEL.d : STEEL.b);
+ for (let i = -1.2; i <= 1.2; i += 0.4) for (let k = -2.4; k <= 2.4; k += 0.4) T(i, k, STEEL.gripD);
+ T(9, -4.6, STEEL.hi);
+ } },
+ launcher: { two: -9, draw(T) {
+ for (let i = -14; i <= 22; i += 0.4) for (let k = -6; k <= -1; k += 0.4) T(i, k, k < -4.8 ? STEEL.oliveA : k > -2.2 ? STEEL.oliveD : Math.abs(i - 3) < 1.4 ? STEEL.gold : STEEL.olive);
+ for (let k = -6.8; k <= -0.2; k += 0.4) (T(22.4, k, STEEL.b), T(-14.4, k, STEEL.d));
+ } },
+ handle: { draw(T) {
+ haft(T, -2.6, 6, STEEL.grip, STEEL.gripD);
+ for (let k = -1.6; k <= 1.6; k += 0.4) (T(-3, k, STEEL.gold), T(6.4, k, STEEL.gold));
+ } },
+};
+
+// ---- flat tones, seams, and one clean ink line
+function finish(S, restFrames) {
+ const dim = (part) => part >= PART.upperF && part <= PART.handF ? 1 : part >= PART.thighF && part <= PART.footF ? 1 : 0;
+ const toneOf = (v, part) => {
+ let t = v > 0.8 ? 0 : v > 0.42 ? 1 : v > 0.08 ? 2 : 3;
+ t = Math.min(3, t + dim(part));
+ return t;
+ };
+ const tones = new Map();
+ for (const i of touched) tones.set(i, toneOf(Tone[i], Part[i]));
+ // a lone pixel of a tone, with no neighbour like it on the same part, takes its neighbours' tone
+ for (const i of touched) {
+ if (Mat[i] === 2) continue;
+ const t = tones.get(i), votes = [0, 0, 0, 0];
+ let same = false;
+ for (const d of [-1, 1, -BW, BW]) {
+ const j = i + d;
+ if (Part[j] !== Part[i] || !tones.has(j)) continue;
+ const u = tones.get(j);
+ votes[u]++;
+ if (u === t) same = true;
+ }
+ if (!same && votes.some((v) => v > 0)) tones.set(i, votes.indexOf(Math.max(...votes)));
+ }
+ for (const i of touched) {
+ if (Mat[i] === 2) continue;
+ Col[i] = (Mat[i] === 1 ? CORE : SHELL)[tones.get(i)];
+ }
+ // where two parts meet: a soft seam if they touch, ink if one stands in front of the other
+ const marks = new Map();
+ for (const i of touched) {
+ for (const d of [1, BW]) {
+ const j = i + d;
+ if (Part[j] === 0 || Part[j] === Part[i]) continue;
+ const far = Zb[i] < Zb[j] ? i : j, dz = Math.abs(Zb[i] - Zb[j]), steel = Mat[i] === 2 || Mat[j] === 2;
+ if (Mat[far] === 2 && dz < 1) continue;
+ const ink = steel || dz > 2.2;
+ if (ink) marks.set(far, INK);
+ else if (!marks.has(far)) marks.set(far, SEAM);
+ }
+ }
+ for (const [i, c] of marks) Col[i] = c;
+ // the mark on his chest, when it's facing us
+ const { B } = S, chestAt = add(B.chest.t, mv(B.chest.R, [3, 1.6, -1.8]));
+ if (mv(B.chest.R, [1, 0, 0])[2] > 0.15) {
+ const i = (OY - Math.round(chestAt[1])) * BW + (OX + Math.round(chestAt[0]));
+ if (Part[i] === PART.chest) Col[i] = MARK;
+ }
+ // the outline, and everything into a small list of pixels
+ const list = touched.slice(), ring = new Map();
+ for (const i of list) for (const d of [-1, 1, -BW, BW]) { const j = i + d; if (Part[j] === 0 && !ring.has(j)) ring.set(j, i); }
+ const n = list.length + ring.size, out = { n, xs: new Int16Array(n), ys: new Int16Array(n), color: new Uint32Array(n), src: new Int16Array(n), ink: new Uint8Array(n), x0: 0, y0: 0, x1: 0, y1: 0 };
+ const srcFor = (i) => {
+ const f = Fr[i];
+ if (f < 0 || !restFrames) return -1;
+ const name = FRAME_IDS[f], A = B[name], R0 = restFrames[name], wx = (i % BW) - OX, wy = OY - ((i / BW) | 0), P = [wx, wy, Zb[i]];
+ const lp = tv(A.R, sub(P, A.t)), rp = add(R0.t, mv(R0.R, lp)), c = Math.round(rp[0]) + 12, r = 38 - Math.round(rp[1]);
+ return c < 0 || r < 0 || c >= W0 || r >= H0 ? -1 : r * W0 + c;
+ };
+ let k = 0, x0 = 1e9, y0 = 1e9, x1 = -1e9, y1 = -1e9;
+ const push = (i, c, s, isInk) => {
+ const x = (i % BW) - OX, y = ((i / BW) | 0) - OY;
+ out.xs[k] = x; out.ys[k] = y; out.color[k] = c; out.src[k] = s; out.ink[k] = isInk ? 1 : 0;
+ if (x < x0) x0 = x; if (x > x1) x1 = x; if (y < y0) y0 = y; if (y > y1) y1 = y;
+ k++;
+ };
+ for (const i of list) push(i, Col[i], srcFor(i), Col[i] === INK);
+ for (const [j, i] of ring) push(j, INK, srcFor(i), true);
+ let zs = 0;
+ for (const i of list) zs += Zb[i];
+ Object.assign(out, { x0, y0, x1, y1, z: list.length ? zs / list.length : 0 });
+ for (const i of list) Part[i] = 0;
+ touched.length = 0;
+ return out;
+}
+
+const turnAll = (S, a) => {
+ // the whole figure turned about the vertical through the feet
+ const R = rotY(-a), P = (v) => mv(R, v);
+ for (const f of Object.values(S.B)) { f.t = P(f.t); f.R = mm(R, f.R); }
+ for (const A of [S.armN, S.armF, S.legN, S.legF]) { A.joint = P(A.joint); A.end = P(A.end); }
+ S.sN = P(S.sN); S.sF = P(S.sF); S.hipN = P(S.hipN); S.hipF = P(S.hipF);
+ S.axis = P(S.axis); S.side = P(S.side);
+};
+let REST_FRAMES = null;
+function render(pose) {
+ const S = solve(pose), q = S.q, whole = (q.yaw ?? 0) + (q.face === -1 ? Math.PI : 0);
+ if (whole) turnAll(S, whole);
+ const air = (q.y ?? 0) < -0.5;
+ clipBody = !air;
+ clipWeapon = !air;
+ drawBody(S);
+ clipBody = false;
+ if (S.W) S.W.draw(along(S.armN.end, S.axis, S.side, PART.weapon), q, S.armF.end);
+ if (S.OW) {
+ const sb = q.sb ?? Math.PI;
+ let ax = [Math.cos(sb), -Math.sin(sb), 0], sd = [-Math.sin(sb), -Math.cos(sb), 0];
+ if (whole) { const R = rotY(-whole); ax = mv(R, ax); sd = mv(R, sd); }
+ S.OW.draw(along(S.armF.end, ax, sd, PART.offWeapon), q, S.armF.end);
+ }
+ clipWeapon = false;
+ return finish(S, REST_FRAMES);
+}
+REST_FRAMES = solve({}).B;
+
+const CACHE = new Map();
+const keyOf = (p) => {
+ let s = (p.y ?? 0) < -0.5 ? "air," : "";
+ for (const k of Object.keys(p).sort()) {
+ const v = p[k];
+ if (v === undefined || k === "x" || k === "y" || k === "ghost") continue;
+ s += k + (typeof v === "number" ? (k === "sa" || k === "sb" || k === "wl" || k === "yaw" || k === "turn" ? Math.round(v * 20) : Math.round(v)) : v) + ",";
+ }
+ return s;
+};
+/** How far short of where the pose wants them the hands fall, in px: arms don't stretch. */
+export function shortfall(pose) {
+ const S = solve(pose), q = S.q, near = len(sub(S.armN.end, [q.fx, -q.fy, S.armN.end[2]])), far = q.two ? 0 : len(sub(S.armF.end, [q.bx, -q.by, S.armF.end[2]]));
+ return Math.max(near, far);
+}
+/** The pixels of a pose: { n, xs, ys, color, src, ink, x0, y0, x1, y1 }, in local space with the feet at (0, 0). */
+export function posed(pose) {
+ const key = keyOf(pose);
+ let r = CACHE.get(key);
+ if (!r) {
+ if (CACHE.size > 6000) CACHE.clear();
+ CACHE.set(key, (r = render(pose)));
+ }
+ return r;
+}
+
+/**
+ * The skeleton of a pose, in the same local space as posed(): x right, y down, feet at (0, 0), z toward the viewer, whole
+ * figure turned by its yaw. { joints: { name: [x, y, z] }, bones: [[from, to], ...], handles: [name, ...] }: the handles
+ * are what a pose moves (hands and feet); everything else is solved from them.
+ */
+export function skeleton(pose) {
+ const S = solve(pose), q = S.q, whole = (q.yaw ?? 0) + (q.face === -1 ? Math.PI : 0);
+ if (whole) turnAll(S, whole);
+ const { B, armN, armF, legN, legF, sN, sF, hipN, hipF } = S, at = (f, v) => add(f.t, mv(f.R, v));
+ const J = {
+ pelvis: B.pelvis.t, waist: B.waist.t, chest: B.chest.t, neck: B.neck.t, head: B.head.t, crown: at(B.head, [0, 3.3, 0]),
+ shoulderN: sN, elbowN: armN.joint, handN: armN.end, shoulderF: sF, elbowF: armF.joint, handF: armF.end,
+ hipN, kneeN: legN.joint, ankleN: legN.end, toeN: at(B.footN, [4.6, -1.1, 0]), hipF, kneeF: legF.joint, ankleF: legF.end, toeF: at(B.footF, [4.6, -1.1, 0]),
+ };
+ const joints = Object.fromEntries(Object.entries(J).map(([k, v]) => [k, [v[0], -v[1], v[2]]]));
+ const bones = [["pelvis", "waist"], ["waist", "chest"], ["chest", "neck"], ["neck", "head"], ["head", "crown"], ["chest", "shoulderN"], ["shoulderN", "elbowN"], ["elbowN", "handN"], ["chest", "shoulderF"], ["shoulderF", "elbowF"], ["elbowF", "handF"], ["pelvis", "hipN"], ["hipN", "kneeN"], ["kneeN", "ankleN"], ["ankleN", "toeN"], ["pelvis", "hipF"], ["hipF", "kneeF"], ["kneeF", "ankleF"], ["ankleF", "toeF"]];
+ return { joints, bones, handles: ["handN", "handF", "ankleN", "ankleF"] };
+}
+/** The figure taken apart: each part drawn alone, with its own outline, and where its middle is. For exploded views. */
+export function posedParts(pose) {
+ const out = [];
+ for (const [name, part] of Object.entries(PART)) {
+ onlyPart = part;
+ const r = render(pose);
+ onlyPart = 0;
+ if (!r.n) continue;
+ let cx = 0, cy = 0;
+ for (let i = 0; i < r.n; i++) { cx += r.xs[i]; cy += r.ys[i]; }
+ out.push({ name, part, n: r.n, xs: r.xs, ys: r.ys, color: r.color, cx: cx / r.n, cy: cy / r.n, z: r.z });
+ }
+ return out;
+}
diff --git a/src/fx/arcane/arcane-beam.js b/src/fx/arcane/arcane-beam.js
index 47891f0..7ac65ff 100644
--- a/src/fx/arcane/arcane-beam.js
+++ b/src/fx/arcane/arcane-beam.js
@@ -1,7 +1,7 @@
// The beam (banded across, pulses running down it, sine strands that brighten in front, a source flare with
// spinning rays, an end flare spraying rays and sparks) is adapted from Sprite Fusion's open-source energy beam
// (https://www.spritefusion.com/pixel-art-vfx/energy), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { PAL, fit, cycle, fly, flyV, loopNoise, fract, ease, sparkle, TAU, WHITE } from "../../core/index.js";
+import { PAL, fit, cycle, fly, flyV, loopNoise, fract, ease, sparkle, TAU, WHITE, READY } from "../../core/index.js";
import { bayer, mote } from "./_lib.js";
const D = 1.2, HX = 15, HY = -24, L = 168, W = 6;
@@ -20,6 +20,24 @@ export const meta = {
options: { palette: PAL.arcane, seed: 10 },
};
+const AIM = { ...READY, x: -3, crouch: 4, lean: 4, fx: 18, fy: -24, bx: 13, by: -20, ffx: 11, fbx: -9, toeB: true };
+const PULL = { ...READY, x: -3, crouch: 4, lean: -3, fx: 1, fy: -20, bx: 4, by: -22, ffx: 9, fbx: -7 };
+export const act = {
+ target: { x: 186 },
+ poses: [
+ [-0.62, { ...READY, x: -3 }],
+ [-0.3, PULL],
+ [-0.04, { ...PULL, crouch: 5, lean: -4 }],
+ [0, { ...AIM, crouch: 3 }, "snap"],
+ [0.3, AIM],
+ [0.6, { ...AIM, crouch: 5, lean: 3 }],
+ [0.9, AIM],
+ [1.2, { ...AIM, crouch: 3 }],
+ ],
+ hits: [{ t: 0.1, push: 0.5, straw: 3, flash: 0.02, y: -24 }, { t: 0.7, push: 0.5, straw: 3, flash: 0.02, y: -24 }],
+ dust: [{ t: 0, x: -10, n: 5, dir: -1 }],
+};
+
export function draw(p, t, o) {
const C = fit(o.palette, 8), ph = t / D, S = o.seed, EX = HX + L;
// the body, built across from a white core out to a dithered violet edge, wobbling and pulsing as it goes
diff --git a/src/fx/arcane/arcane-missiles.js b/src/fx/arcane/arcane-missiles.js
index 50ddf44..e992bce 100644
--- a/src/fx/arcane/arcane-missiles.js
+++ b/src/fx/arcane/arcane-missiles.js
@@ -1,7 +1,7 @@
// The bolt and its pop (a layered head with spinning rays, a flash disc, a cross, a ring, plasma sparks and stars)
// are adapted from Sprite Fusion's open-source energy bolt (https://www.spritefusion.com/pixel-art-vfx/energy),
// MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, PAL, fit, sparkle, clamp, smooth, ease, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, PAL, fit, sparkle, clamp, smooth, ease, TAU, WHITE, READY } from "../../core/index.js";
const HX = 15, HY = -24, TX = 152, TY = -22, N = 5, TRAIL = 18;
@@ -19,6 +19,37 @@ export const meta = {
options: { palette: PAL.arcane, seed: 3 },
};
+const OPEN = { ...READY, x: -3, crouch: 4, lean: 4, fx: 18, fy: -24, bx: -6, by: -22, ffx: 11, fbx: -9 };
+const KICK = { ...OPEN, fx: 15, fy: -26, lean: 2 };
+const GATHER = { ...READY, x: -3, crouch: 4, lean: -2, fx: 6, fy: -24, bx: 8, by: -24, ffx: 9, fbx: -7 };
+export const act = {
+ target: { x: 152 },
+ poses: [
+ [-0.52, { ...READY, x: -3 }],
+ [-0.24, GATHER],
+ [0, { ...GATHER, crouch: 5 }],
+ [0.05, KICK, "snap"],
+ [0.1, OPEN, "snap"],
+ [0.15, KICK, "snap"],
+ [0.2, OPEN, "snap"],
+ [0.25, KICK, "snap"],
+ [0.29, OPEN, "snap"],
+ [0.33, KICK, "snap"],
+ [0.38, OPEN, "snap"],
+ [0.43, KICK, "snap"],
+ [0.48, OPEN, "snap"],
+ [1.2, { ...OPEN, crouch: 3 }],
+ [1.7, { ...READY, x: -3 }],
+ ],
+ hits: [
+ { t: 0.77, stop: 0.02, push: 0.7, straw: 4, y: -24, flash: 0.03 },
+ { t: 0.85, stop: 0.02, push: 0.7, straw: 4, y: -24, flash: 0.03 },
+ { t: 0.95, stop: 0.02, push: 0.7, straw: 4, y: -24, flash: 0.03 },
+ { t: 1.08, stop: 0.02, push: 0.7, straw: 4, y: -24, flash: 0.03 },
+ { t: 1.2, stop: 0.07, shake: 0.14, amp: 1, push: 1.4, straw: 9, y: -24 },
+ ],
+};
+
export function create(o) {
const C = fit(o.palette, 8), R = new Rng(o.seed);
const ps = new Particles({ rng: R, ground: () => 0, sparks: [WHITE, C[6], C[5], C[4]] }), lights = new Lights();
diff --git a/src/fx/arcane/blink-in.js b/src/fx/arcane/blink-in.js
index f2def8d..ae7ec50 100644
--- a/src/fx/arcane/blink-in.js
+++ b/src/fx/arcane/blink-in.js
@@ -1,7 +1,7 @@
// The arrival (bits converging, a line of light that opens into the silhouette, a ring on the floor, a burst of
// stars) is adapted from Sprite Fusion's open-source blink (https://www.spritefusion.com/pixel-art-vfx/movement),
// MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, PAL, fit, band, flare, sparkle, clamp, ease, rand, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, PAL, fit, band, flare, sparkle, clamp, ease, rand, TAU, WHITE, READY } from "../../core/index.js";
import { shades, squeezed } from "./_lib.js";
const LINE = 0.26, GROW = 0.1, OPEN = 0.12, ARRIVE = LINE + GROW + OPEN;
@@ -20,6 +20,20 @@ export const meta = {
options: { palette: PAL.arcane, seed: 12 },
};
+const LANDED = { crouch: 7, lean: 3, fx: 9, fy: -12, bx: 12, by: -12, ffx: 8, fbx: -6 };
+export const act = {
+ onBody: true,
+ poses: [
+ [0, LANDED],
+ [0.48, LANDED],
+ [0.56, { ...LANDED, crouch: 6 }, "snap"],
+ [0.95, READY],
+ [1.4, READY],
+ ],
+ hits: [{ t: 0.48, stop: 0.03, shake: 0.1, amp: 1 }],
+ dust: [{ t: 0.48, x: 0, n: 7 }],
+};
+
/** The stand-in character appears once the silhouette has opened. */
export const actorAlpha = (t) => (t < ARRIVE ? 0 : 1);
diff --git a/src/fx/arcane/blink-out.js b/src/fx/arcane/blink-out.js
index 4de94bd..d905aa3 100644
--- a/src/fx/arcane/blink-out.js
+++ b/src/fx/arcane/blink-out.js
@@ -1,7 +1,7 @@
// The blink (a crackling outline as it gathers, a white flash, the silhouette squeezed into a line, a ring on the
// floor, a fading afterimage) is adapted from Sprite Fusion's open-source blink
// (https://www.spritefusion.com/pixel-art-vfx/movement), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, PAL, fit, band, flare, sparkle, clamp, ease, rand, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, PAL, fit, band, flare, sparkle, clamp, ease, rand, TAU, WHITE, READY } from "../../core/index.js";
import { shades, squeezed } from "./_lib.js";
const OUT = 0.32, SQUEEZE = 0.12, COLLAPSE = 0.08, POP = OUT + SQUEEZE + COLLAPSE;
@@ -20,6 +20,18 @@ export const meta = {
options: { palette: PAL.arcane, seed: 11 },
};
+const IN = { turn: 1, crouch: 4, fx: -2, fy: -25, bx: 2, by: -25, armsFront: true, ffx: 0, fbx: 2 };
+export const act = {
+ onBody: true,
+ poses: [
+ [-0.36, READY],
+ [-0.1, IN],
+ [0.2, { ...IN, crouch: 5 }],
+ [0.32, { ...IN, crouch: 0 }, "snap"],
+ [1.6, { ...IN, crouch: 0 }],
+ ],
+};
+
/** The stand-in character is hidden from the flash on: the effect draws it from then. */
export const actorAlpha = (t) => (t < OUT ? 1 : 0);
diff --git a/src/fx/arcane/spell-charge.js b/src/fx/arcane/spell-charge.js
index ce223cf..c59d187 100644
--- a/src/fx/arcane/spell-charge.js
+++ b/src/fx/arcane/spell-charge.js
@@ -1,7 +1,7 @@
// The charge recipe (motes spiralling in, pulse rings collapsing onto a layered ball with flickering rays, short
// crackling sparks) is adapted from Sprite Fusion's open-source energy charge
// (https://www.spritefusion.com/pixel-art-vfx/energy), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { PAL, fit, cycle, rng, loopNoise, smooth, ease, sparkle, TAU, WHITE } from "../../core/index.js";
+import { PAL, fit, cycle, rng, loopNoise, smooth, ease, sparkle, TAU, WHITE, READY } from "../../core/index.js";
import { mote, streak, arc, drawArc } from "./_lib.js";
const D = 1.6, HX = 15, HY = -22, RINGS = 4, RT = 0.5;
@@ -20,6 +20,19 @@ export const meta = {
options: { palette: PAL.arcane, seed: 5 },
};
+const HOLD = { ...READY, x: -3, crouch: 4, lean: 2, fx: 18, fy: -22, bx: 11, by: -17, ffx: 10, fbx: -8 };
+export const act = {
+ poses: [
+ [-0.46, { ...READY, x: -3 }],
+ [-0.12, { ...HOLD, crouch: 3 }],
+ [0, HOLD],
+ [0.4, { ...HOLD, crouch: 5 }],
+ [0.8, { ...HOLD, lean: 3 }],
+ [1.2, { ...HOLD, crouch: 5 }],
+ [1.6, HOLD],
+ ],
+};
+
// each ring is born at k * D / RINGS and lands RT later; the times it lands, wrapped into the loop
const landings = Array.from({ length: RINGS }, (_, k) => (k * D) / RINGS + RT);
const sinceLast = (t) => Math.min(...landings.map((l) => ((((t - l) % D) + D) % D)));
diff --git a/src/fx/categories.js b/src/fx/categories.js
index 14a3adc..4721e65 100644
--- a/src/fx/categories.js
+++ b/src/fx/categories.js
@@ -1,6 +1,7 @@
// The categories, in gallery order, with a line for each.
export const categories = [
+ { id: "moves", name: "moves", blurb: "whole attacks, wind-up to recovery, chained from the effects below" },
{ id: "fire", name: "fire", blurb: "torches, breath, pillars, walls of flame" },
{ id: "explosions", name: "explosions", blurb: "blasts, smoke, fireworks, mushroom clouds" },
{ id: "water", name: "water", blurb: "splashes, falls, fountains, waves" },
diff --git a/src/fx/fire/fire-ring.js b/src/fx/fire/fire-ring.js
index 2f9f9c3..94591ea 100644
--- a/src/fx/fire/fire-ring.js
+++ b/src/fx/fire/fire-ring.js
@@ -1,7 +1,7 @@
// The flame-puff, smoke and spark recipe and the floor ring are adapted from Sprite Fusion's open-source explosion
// (https://www.spritefusion.com/pixel-art-vfx/explosion), and the tongue from its fire
// (https://www.spritefusion.com/pixel-art-vfx/fire), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, PF, Rng, fit, band, clamp, smooth, ease, noise, rand, TAU, WHITE, hex, mix, rgb } from "../../core/index.js";
+import { Particles, Lights, P, PF, Rng, fit, band, clamp, smooth, ease, noise, rand, TAU, WHITE, hex, mix, rgb, READY } from "../../core/index.js";
import { hotFirst, flameTongue, simDraw, LAYERS, BACK_LAYERS } from "./_lib.js";
export const meta = {
@@ -22,6 +22,29 @@ export const meta = {
},
};
+const HIGH = { turn: 1.15, crouch: 0, fx: -7, fy: -44, bx: 8, by: -44, ffx: -5, fbx: 6 };
+const SLAM = { turn: 1.15, crouch: 8, lean: 3, fx: -9, fy: -8, bx: 11, by: -8, ffx: -8, fbx: 9 };
+const EASE = { turn: 1, crouch: 2, fx: -8, fy: -17, bx: 9, by: -17, ffx: -4, fbx: 5 };
+export const act = {
+ target: { x: 70 },
+ poses: [
+ [-0.32, READY],
+ [0.02, HIGH],
+ [0.27, { ...HIGH, y: -1 }],
+ [0.32, SLAM, "snap"],
+ [0.85, { ...SLAM, crouch: 7 }],
+ [1.5, EASE],
+ [2.4, READY],
+ [3.9, READY],
+ ],
+ hits: [
+ { t: 0.32, stop: 0.1, shake: 0.28, amp: 3, target: false },
+ { t: 0.6, push: 1.2, straw: 10, y: -8, skin: "char" },
+ { t: 3.5, push: 0, straw: 0, flash: 0, skin: null },
+ ],
+ dust: [{ t: 0.32, x: 10, n: 6, dir: 1 }, { t: 0.32, x: -10, n: 6, dir: -1 }],
+};
+
const SY = 0.2, CHARGE = 0.32, SPREAD = 0.75, SOOT = hex("#0d0a12"), SOOT2 = hex("#17121d"), WARM = rgb(255, 176, 96);
// the dying flames: deep orange and red, no white heart
const EMBER_LAYERS = [[1, 1, 7], [0.7, 0.8, 6], [0.4, 0.55, 5]];
diff --git a/src/fx/holy/blessing.js b/src/fx/holy/blessing.js
index fe56527..e3e0ed7 100644
--- a/src/fx/holy/blessing.js
+++ b/src/fx/holy/blessing.js
@@ -15,6 +15,18 @@ export const meta = {
options: { palette: GOLD, seed: 7 },
};
+const OPEN = { turn: 1.15, fx: -13, fy: -31, bx: 14, by: -31, hy: -1, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [
+ [0, OPEN],
+ [0.75, { ...OPEN, fy: -33, by: -33 }],
+ [1.5, { ...OPEN, crouch: -1, fy: -35, by: -35 }],
+ [2.25, { ...OPEN, fy: -33, by: -33 }],
+ [3, OPEN],
+ ],
+};
+
const TOP = -108, T = 3;
const halfW = (y) => lerp(5, 20, (y - TOP) / -TOP);
// the rays in the cone, each shimmering a whole number of times a loop so it closes
diff --git a/src/fx/holy/divine-shield.js b/src/fx/holy/divine-shield.js
index 5f8e505..0fb54d6 100644
--- a/src/fx/holy/divine-shield.js
+++ b/src/fx/holy/divine-shield.js
@@ -15,6 +15,18 @@ export const meta = {
options: { palette: GOLD, radius: 29, seed: 8 },
};
+const BRACE = { turn: 0.7, crouch: 3, lean: 1, fx: 5, fy: -33, bx: 10, by: -20, ffx: 4, fbx: -2 };
+export const act = {
+ onBody: true,
+ poses: [
+ [0, BRACE],
+ [0.6, { ...BRACE, crouch: 4 }],
+ [1.2, { ...BRACE, fy: -35, crouch: 3 }],
+ [1.8, { ...BRACE, crouch: 4 }],
+ [2.4, BRACE],
+ ],
+};
+
const CY = -22, TILT = 0.34, N = 4, FLOOR_SY = 0.26;
// a point of the sphere (lat, lon) seen from a little above: screen x, y and depth z (> 0 faces us)
diff --git a/src/fx/holy/halo.js b/src/fx/holy/halo.js
index 7b12065..cd89a1b 100644
--- a/src/fx/holy/halo.js
+++ b/src/fx/holy/halo.js
@@ -3,7 +3,7 @@ import { GOLD } from "./_lib.js";
export const meta = {
name: "Halo",
- desc: "A ring of gold light floats over the head with a glint running round it; fine dust sifts down from it and the hair catches its light.",
+ desc: "A ring of gold light floats over the head with a glint running round it; fine dust sifts down from it and the head catches its light.",
tags: ["holy", "halo", "saint", "buff", "glow", "character", "loop"],
size: [56, 80],
origin: [28, 70],
@@ -15,6 +15,12 @@ export const meta = {
options: { palette: GOLD, seed: 5 },
};
+const PRAY = { turn: 1.1, fx: -1, fy: -26, bx: 2, by: -26, armsFront: true, hy: 1, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [[0, PRAY], [0.5, { ...PRAY, crouch: 1 }], [1, { ...PRAY, crouch: 1, hy: 2 }], [1.5, { ...PRAY, crouch: 1 }], [2, PRAY]],
+};
+
const HY = -46, RX = 9.5, RY = 2.6;
// how far apart two angles are (0..π)
const apart = (a, b) => Math.abs(((a - b + Math.PI) % TAU + TAU) % TAU - Math.PI);
diff --git a/src/fx/holy/heal.js b/src/fx/holy/heal.js
index d570bc8..b6640ae 100644
--- a/src/fx/holy/heal.js
+++ b/src/fx/holy/heal.js
@@ -1,4 +1,4 @@
-import { Particles, Lights, P, Rng, fit, sparkle, clamp, smooth, seg, lerp, ease, TAU, WHITE, mix, luma, rgb } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, sparkle, clamp, smooth, seg, lerp, ease, TAU, WHITE, mix, luma, rgb, READY } from "../../core/index.js";
import { shapeOf, recolor, oval } from "./_lib.js";
export const meta = {
@@ -15,6 +15,20 @@ export const meta = {
options: { palette: ["#3d2027", "#7d3f35", "#c97a4a", "#f2b46a", "#ffd994", "#fff0cf", "#fffaf2", "#ffffff"], seed: 2 },
};
+const HURT = { turn: 0.8, crouch: 5, lean: 3, hy: 1, fx: 1, fy: -21, bx: 7, by: -15, ffx: 4, fbx: -3 };
+const UP = { turn: 1.15, crouch: -1, fx: -13, fy: -36, bx: 14, by: -36, hy: -1, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [
+ [-0.3, HURT],
+ [0.16, { ...HURT, crouch: 6 }],
+ [0.5, { ...HURT, crouch: 3, lean: 1, hy: 0 }],
+ [0.78, UP],
+ [1.2, { ...UP, crouch: 0, fy: -30, by: -30, hy: 0 }],
+ [1.9, READY],
+ ],
+};
+
const SY = 0.3, NP = 8, PR = 16, LIFT0 = 0.16, LIFT1 = 0.74, TOPY = -43;
const HEART = [".#.#.", "#####", ".###.", "..#.."];
diff --git a/src/fx/holy/resurrection.js b/src/fx/holy/resurrection.js
index dec7bd8..3e58ca3 100644
--- a/src/fx/holy/resurrection.js
+++ b/src/fx/holy/resurrection.js
@@ -1,6 +1,6 @@
// The lit floor line is adapted from Sprite Fusion's open-source heal (https://www.spritefusion.com/pixel-art-vfx/heal),
// MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, sparkle, flare, band, clamp, smooth, seg, lerp, ease, TAU, WHITE, mix } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, sparkle, flare, band, clamp, smooth, seg, lerp, ease, TAU, WHITE, mix, READY } from "../../core/index.js";
import { GOLD, ASH, shapeOf, recolor, toneOf, feather, Feathers, oval, FAR, NEAR } from "./_lib.js";
export const meta = {
@@ -17,6 +17,28 @@ export const meta = {
options: { palette: GOLD, ash: ASH, seed: 5 },
};
+const DOWN = { turn: 0.9, crouch: 8, lean: 6, hy: 2, fx: -4, fy: -10, bx: 9, by: -10, ffx: 8, fbx: -7 };
+const RISEN = { turn: 1.15, crouch: -1, fx: -15, fy: -33, bx: 16, by: -33, hy: -1, ffx: -3, ffy: -5, fbx: 4, fby: -5 };
+export const act = {
+ onBody: true,
+ follow: 0.6,
+ poses: [
+ [0, DOWN],
+ [0.5, DOWN],
+ [0.85, { ...DOWN, crouch: 6, lean: 4, hy: 1 }],
+ [1.15, { turn: 1, crouch: 2, fx: -8, fy: -17, bx: 9, by: -17 }],
+ [1.5, { ...RISEN, y: -2 }],
+ [1.95, { ...RISEN, y: -3 }],
+ [2.1, { ...RISEN, y: -2, crouch: 1, fy: -37, by: -37 }],
+ [2.3, { ...RISEN, y: -9, fx: -15, fy: -38, bx: 16, by: -38 }],
+ [2.95, { ...RISEN, y: -6 }],
+ [3.8, { turn: 1, y: 0, crouch: 2, fx: -8, fy: -17, bx: 9, by: -17 }],
+ [4.3, READY],
+ [4.8, READY],
+ ],
+ dust: [{ t: 3.8, x: 0, n: 5 }],
+};
+
const TOP = -140;
// the story: the light pours, life climbs the body, wings and halo, the beat, the wings come apart
const POUR = 0.34, CL0 = 0.5, CL1 = 1.15, W0 = 1.1, H0 = 1.24, H1 = 1.5, B0 = 1.95, B1 = 2.25, B2 = 2.37, B3 = 2.8, SC = 2.95, GONE = 3.85;
diff --git a/src/fx/ice/freeze.js b/src/fx/ice/freeze.js
index 401d23d..471f08c 100644
--- a/src/fx/ice/freeze.js
+++ b/src/fx/ice/freeze.js
@@ -1,7 +1,7 @@
// The crack-and-burst recipe (cracks walking out from a point, a white frame, the ice flung apart as shards
// with ice dust and glints) is adapted from Sprite Fusion's open-source ice
// (https://www.spritefusion.com/pixel-art-vfx/ice), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Bits, Lights, P, B, Rng, fit, flare, sparkle, clamp, smooth, seg, ease, rand, mix, TAU, WHITE } from "../../core/index.js";
+import { Particles, Bits, Lights, P, B, Rng, fit, flare, sparkle, clamp, smooth, seg, ease, rand, mix, TAU, WHITE, READY } from "../../core/index.js";
import { Panes, endBy, inPoly, centroid, splitPoly, iceOf, fractures, drawFractures } from "./_lib.js";
export const meta = {
@@ -18,6 +18,27 @@ export const meta = {
options: { palette: ["#151a3d", "#212f6b", "#2c58aa", "#3a8bd8", "#62c8f4", "#a6ecff", "#dcfbff", "#ffffff"], seed: 5 },
};
+const FEAR = { turn: 0.9, lean: -2, crouch: 2, fx: -8, fy: -31, bx: 9, by: -31, ffx: -3, fbx: 4 };
+const FREE = { turn: 1, crouch: 5, fx: -12, fy: -18, bx: 12, by: -18, ffx: -5, fbx: 6 };
+export const act = {
+ onBody: true,
+ poses: [
+ [-0.2, READY],
+ [0.05, READY],
+ [0.16, FEAR, "snap"],
+ [0.3, { ...FEAR, lean: -1, fx: -10, fy: -34 }],
+ [0.45, { ...FEAR, lean: -3, bx: 11, by: -34, fx: -7, fy: -29 }],
+ [0.62, FEAR],
+ [2.52, FEAR],
+ [2.54, FREE, "snap"],
+ [2.9, { ...FREE, crouch: 4 }],
+ [3.1, { ...FREE, crouch: 3, lean: 1 }],
+ [3.3, { ...FREE, crouch: 3, lean: -1 }],
+ [4, READY],
+ ],
+ hits: [{ t: 0.62, stop: 0.03, shake: 0.08, amp: 1 }, { t: 2.52, stop: 0.05, shake: 0.2, amp: 2 }],
+};
+
const SNAP = 0.16; // frost lines race in along the floor to the feet
const CLIMB = [0.14, 0.62]; // and climb the character
const SEAL = 0.6; // the block crystallizes, pane by pane
diff --git a/src/fx/ice/frost-nova.js b/src/fx/ice/frost-nova.js
index 9f38ea6..ed3ad0e 100644
--- a/src/fx/ice/frost-nova.js
+++ b/src/fx/ice/frost-nova.js
@@ -1,4 +1,4 @@
-import { Particles, Bits, Lights, P, B, Rng, fit, crystal, band, flare, clamp, smooth, ease, rand, TAU, WHITE } from "../../core/index.js";
+import { Particles, Bits, Lights, P, B, Rng, fit, crystal, band, flare, clamp, smooth, ease, rand, TAU, WHITE, READY } from "../../core/index.js";
export const meta = {
name: "Frost nova",
@@ -14,6 +14,29 @@ export const meta = {
options: { palette: ["#151a3d", "#212f6b", "#2c58aa", "#3a8bd8", "#62c8f4", "#a6ecff", "#dcfbff", "#ffffff"], reach: 104, seed: 4 },
};
+const HIGH = { turn: 1.15, crouch: 0, fx: -7, fy: -44, bx: 8, by: -44, ffx: -5, fbx: 6 };
+const SLAM = { turn: 1.15, crouch: 8, lean: 3, fx: -9, fy: -8, bx: 11, by: -8, ffx: -8, fbx: 9 };
+const EASE = { turn: 1, crouch: 2, fx: -8, fy: -17, bx: 9, by: -17, ffx: -4, fbx: 5 };
+export const act = {
+ target: { x: 76 },
+ poses: [
+ [-0.34, READY],
+ [-0.04, { ...HIGH, crouch: 2, fy: -36, by: -36 }],
+ [0.36, HIGH],
+ [0.42, SLAM, "snap"],
+ [0.9, { ...SLAM, crouch: 7 }],
+ [1.9, { ...SLAM, crouch: 6 }],
+ [2.6, EASE],
+ [3.4, READY],
+ ],
+ hits: [
+ { t: 0.42, stop: 0.1, shake: 0.26, amp: 2, target: false },
+ { t: 0.66, push: 0.9, straw: 6, y: -10, skin: "ice", shiver: 1.7 },
+ { t: 2.9, push: 0.2, straw: 0, flash: 0, skin: null },
+ ],
+ dust: [{ t: 0.42, x: 10, n: 5, dir: 1, c: "#d8f2ff" }, { t: 0.42, x: -10, n: 5, dir: -1, c: "#d8f2ff" }],
+};
+
const CHARGE = 0.42, SPREAD = 0.62, HOLD = 1.95, MELT = 0.7, CORE_Y = -24;
// three rings of crystals: tall ones hugging the caster, smaller ones further out
const RINGS = [
diff --git a/src/fx/impacts/heavy-landing.js b/src/fx/impacts/heavy-landing.js
index 8636f49..673802d 100644
--- a/src/fx/impacts/heavy-landing.js
+++ b/src/fx/impacts/heavy-landing.js
@@ -1,6 +1,6 @@
// The rocks, grit and dust are adapted from Sprite Fusion's open-source explosion
// (https://www.spritefusion.com/pixel-art-vfx/explosion), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Bits, P, B, Rng, fit, band, clamp, smooth, ease, TAU, WHITE, mix, hex } from "../../core/index.js";
+import { Particles, Bits, P, B, Rng, fit, band, clamp, smooth, ease, TAU, WHITE, mix, hex, READY } from "../../core/index.js";
import { stone, makeCracks, drawCracks, dustRing, rock, rockShape, SOOT } from "./_lib.js";
export const meta = {
@@ -17,6 +17,21 @@ export const meta = {
options: { palette: ["#1c1a24", "#2f2a3a", "#4a4258", "#6b6280", "#9088a4", "#bdb6cc", "#e6e1ee"], stone: "#4a3f69", seed: 14 },
};
+const FALL = { turn: 0.8, y: -46, crouch: -1, lean: -1, fx: -9, fy: -42, bx: 10, by: -42, ffx: 6, ffy: -8, fbx: -3, fby: -3, toeB: true, ghost: 1 };
+const HERO_ = { y: 0, crouch: 8, lean: 5, fx: 13, fy: -8, bx: -6, by: -23, ffx: 11, fbx: -10 };
+export const act = {
+ poses: [
+ [-0.26, FALL],
+ [-0.01, { ...FALL, y: -6 }, "in"],
+ [0, HERO_, "snap"],
+ [0.55, { ...HERO_, crouch: 7 }],
+ [0.95, { ...HERO_, crouch: 5, lean: 3, fx: 13, fy: -15, bx: -5, by: -20 }],
+ [1.3, READY],
+ [1.6, READY],
+ ],
+ hits: [{ t: 0.005, stop: 0.13, shake: 0.32, amp: 3 }],
+};
+
// the dent: the floor's edge pressed into a shallow dish, scuffed lips either side
function dent(p, st, k) {
for (let x = -10; x <= 9; x++) {
diff --git a/src/fx/impacts/hit-flash.js b/src/fx/impacts/hit-flash.js
index 309367d..60531d9 100644
--- a/src/fx/impacts/hit-flash.js
+++ b/src/fx/impacts/hit-flash.js
@@ -1,4 +1,4 @@
-import { Lights, Rng, fit, clamp, ease, TAU, WHITE, mix, luma, red, green, blue, rgb } from "../../core/index.js";
+import { Lights, Rng, fit, clamp, ease, TAU, WHITE, mix, luma, red, green, blue, rgb, READY } from "../../core/index.js";
export const meta = {
name: "Hit flash",
@@ -14,6 +14,19 @@ export const meta = {
options: { palette: ["#14040a", "#3a0a14", "#6a101c", "#a01824", "#d42a30", "#ff5a50", "#ff9a8a"], lines: 7, side: 1, seed: 17 },
};
+const BLOWN = { x: -5, crouch: 4, lean: -5, hx: -1, fx: 8, fy: -33, bx: -11, by: -27, ffx: 9, ffy: -7, fbx: -6 };
+export const act = {
+ onBody: true,
+ poses: [
+ [-0.26, { ...READY, x: 0 }],
+ [0, BLOWN, "snap"],
+ [0.16, { ...BLOWN, x: -8, crouch: 5 }],
+ [0.42, { ...BLOWN, x: -8, crouch: 5, lean: -2, fx: 9, fy: -22, bx: 6, by: -20, ffy: -4 }],
+ [0.86, { ...READY, x: 0 }],
+ ],
+ hits: [{ t: 0, stop: 0.07, shake: 0.14, amp: 2 }],
+};
+
// the beats, by frame at 30 fps: white, white, red, red, white rim, red cooling off
const BEATS = [[0.025, "white"], [0.058, "white2"], [0.125, "red"], [0.158, "rim"], [0.36, "cool"]];
diff --git a/src/fx/impacts/shield-block.js b/src/fx/impacts/shield-block.js
index b9a472c..ff7cda3 100644
--- a/src/fx/impacts/shield-block.js
+++ b/src/fx/impacts/shield-block.js
@@ -1,7 +1,7 @@
// Mapping a lattice onto a dome by longitude and latitude, the ripple measured over its surface, the rim light
// and the glancing sparks are adapted from Sprite Fusion's open-source shield
// (https://www.spritefusion.com/pixel-art-vfx/shield), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, clamp, smooth, rand, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, clamp, smooth, rand, TAU, WHITE, READY } from "../../core/index.js";
import { star, spikes } from "./_lib.js";
export const meta = {
@@ -22,6 +22,20 @@ export const meta = {
},
};
+const BRACE = { ...READY, crouch: 4, lean: 2, fx: 13, fy: -28, bx: 6, by: -21, ffx: 9, fbx: -9 };
+export const act = {
+ poses: [
+ [-0.36, READY],
+ [-0.1, BRACE],
+ [0, { ...BRACE, x: -3, crouch: 6, lean: -2, fx: 10, fy: -26 }, "snap"],
+ [0.18, { ...BRACE, x: -4, crouch: 5, lean: 0 }],
+ [0.65, { ...BRACE, x: -3 }],
+ [1.1, { ...READY, x: 0 }],
+ ],
+ hits: [{ t: 0.005, stop: 0.09, shake: 0.2, amp: 2 }],
+ dust: [{ t: 0.01, x: -10, n: 6, dir: -1 }],
+};
+
const CX = 3, RX = 28, RY = 44, GRID = 3.4; // the dome's flat face, its depth and height, lattice density
const HIT = { lon: 1.18, lat: 0.5 }, GONE = 0.5; // where the blow lands; when the dome starts to blink out
diff --git a/src/fx/index.js b/src/fx/index.js
index 126b49b..c010a77 100644
--- a/src/fx/index.js
+++ b/src/fx/index.js
@@ -1,5 +1,17 @@
// Generated by tools/index.mjs: every effect, by id. Don't edit; run `node tools/index.mjs`.
+import * as moves_arrow_shot from "./moves/arrow-shot.js";
+import * as moves_dash_strike from "./moves/dash-strike.js";
+import * as moves_earth_stomp from "./moves/earth-stomp.js";
+import * as moves_fireball_throw from "./moves/fireball-throw.js";
+import * as moves_ground_pound from "./moves/ground-pound.js";
+import * as moves_holy_smite from "./moves/holy-smite.js";
+import * as moves_ice_lance_throw from "./moves/ice-lance-throw.js";
+import * as moves_lightning_call from "./moves/lightning-call.js";
+import * as moves_meteor_call from "./moves/meteor-call.js";
+import * as moves_pistol_shots from "./moves/pistol-shots.js";
+import * as moves_rocket_launcher from "./moves/rocket-launcher.js";
+import * as moves_sword_combo from "./moves/sword-combo.js";
import * as fire_brazier from "./fire/brazier.js";
import * as fire_campfire from "./fire/campfire.js";
import * as fire_candle from "./fire/candle.js";
@@ -236,6 +248,18 @@ import * as critters_wisp from "./critters/wisp.js";
export { categories } from "./categories.js";
export const effects = {
+ "moves/arrow-shot": moves_arrow_shot,
+ "moves/dash-strike": moves_dash_strike,
+ "moves/earth-stomp": moves_earth_stomp,
+ "moves/fireball-throw": moves_fireball_throw,
+ "moves/ground-pound": moves_ground_pound,
+ "moves/holy-smite": moves_holy_smite,
+ "moves/ice-lance-throw": moves_ice_lance_throw,
+ "moves/lightning-call": moves_lightning_call,
+ "moves/meteor-call": moves_meteor_call,
+ "moves/pistol-shots": moves_pistol_shots,
+ "moves/rocket-launcher": moves_rocket_launcher,
+ "moves/sword-combo": moves_sword_combo,
"fire/brazier": fire_brazier,
"fire/campfire": fire_campfire,
"fire/candle": fire_candle,
diff --git a/src/fx/lightning/chain-lightning.js b/src/fx/lightning/chain-lightning.js
index b9c1132..3600eb2 100644
--- a/src/fx/lightning/chain-lightning.js
+++ b/src/fx/lightning/chain-lightning.js
@@ -1,7 +1,7 @@
// The hop timing, the link shapes that re-strike every other frame, the glowing nodes and the crawling arcs
// follow Sprite Fusion's open-source lightning (https://www.spritefusion.com/pixel-art-vfx/lightning),
// MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, sparkle, clamp, smooth, ease, rng, lerp, TAU, WHITE, hex, mix } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, sparkle, clamp, smooth, ease, rng, lerp, TAU, WHITE, hex, mix, READY } from "../../core/index.js";
import { VOLT, PLASMA, zigzag, bowed, stroke, crackle, trace, scorch } from "./_lib.js";
export const meta = {
@@ -18,6 +18,28 @@ export const meta = {
options: { palette: VOLT, sparks: PLASMA, seed: 3 },
};
+const AIM = { ...READY, x: -6, crouch: 4, lean: 4, fx: 16, fy: -16, bx: -6, by: -23, ffx: 11, fbx: -9 };
+const BACK = { ...READY, x: -6, crouch: 4, lean: -3, fx: -5, fy: -32, bx: 8, by: -24, armsFront: true, ffx: 9, fbx: -7 };
+const zap = (at, t, stop = 0.03) => ({ t, at, stop, push: 1.2, straw: 6, skin: "shock", shiver: 0.7, y: -22 });
+export const act = {
+ targets: [{ x: 58 }, { x: 104 }, { x: 150 }],
+ poses: [
+ [-0.46, { ...READY, x: -6 }],
+ [-0.22, BACK],
+ [0, { ...BACK, crouch: 5 }],
+ [0.04, AIM, "snap"],
+ [0.7, { ...AIM, crouch: 3 }],
+ [1.35, { ...AIM, crouch: 3, fy: -18 }],
+ [1.8, { ...READY, x: -6 }],
+ ],
+ hits: [
+ zap(0, 0.05),
+ zap(1, 0.14),
+ { ...zap(2, 0.23, 0.07), shake: 0.14, amp: 1 },
+ { t: 1.35, push: 0, straw: 0, flash: 0, skin: null },
+ ],
+};
+
const HAND = [10, -16], HOPS = [[58, -22], [104, -30], [150, -19]];
const WIND = 0.12, LEAP = 0.05, GAP = 0.075, HOLD = 0.78, BREAK = 0.16, ASH = hex("#5b5566");
const on = (i) => WIND + i * GAP + LEAP; // when link i lands on its target
diff --git a/src/fx/lightning/charge-up.js b/src/fx/lightning/charge-up.js
index 5c59fe0..ef7c520 100644
--- a/src/fx/lightning/charge-up.js
+++ b/src/fx/lightning/charge-up.js
@@ -1,7 +1,7 @@
// The charge (streaks spiralling in, a core that swells with an accelerating pulse, little arcs spitting off
// it) and the release (flash, rings, a spray of motes and stars) follow Sprite Fusion's open-source energy charge
// (https://www.spritefusion.com/pixel-art-vfx/energy), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, flare, sparkle, clamp, smooth, ease, rng, TAU, WHITE, hex, mix } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, flare, sparkle, clamp, smooth, ease, rng, TAU, WHITE, hex, mix, READY } from "../../core/index.js";
import { VOLT, PLASMA, zigzag, stroke, crackle } from "./_lib.js";
export const meta = {
@@ -18,6 +18,25 @@ export const meta = {
options: { palette: VOLT, sparks: PLASMA, charge: 1.6, seed: 4 },
};
+const HOLD = { ...READY, crouch: 3, lean: -2, fx: 15, fy: -21, bx: 9, by: -17, ffx: 9, fbx: -7 };
+const BURST = { turn: 1.15, y: -2, crouch: 0, lean: -2, fx: -13, fy: -37, bx: 14, by: -36, ffx: -2, ffy: -6, fbx: 3, fby: -6 };
+export const act = {
+ onBody: true,
+ follow: 0,
+ poses: [
+ [-0.36, READY],
+ [0, HOLD],
+ [0.8, { ...HOLD, crouch: 4 }],
+ [1.4, { ...HOLD, crouch: 6, lean: 0 }],
+ [1.59, { ...HOLD, crouch: 7, lean: 0 }],
+ [1.6, BURST, "snap"],
+ [1.95, { ...BURST, y: 0, crouch: 2, fy: -30, by: -30, ffy: -4, fby: -4 }],
+ [2.7, READY],
+ ],
+ hits: [{ t: 1.6, stop: 0.14, shake: 0.3, amp: 3 }],
+ dust: [{ t: 1.6, x: 10, n: 6, dir: 1 }, { t: 1.6, x: -10, n: 6, dir: -1 }],
+};
+
const CX = 15, CY = -21, BK = [1, 0.7, 0.95, 0.5, 0.8, 0.35], ASH = hex("#5b5566");
const edges = new WeakMap();
function edgeOf(A) {
diff --git a/src/fx/lightning/electrified.js b/src/fx/lightning/electrified.js
index 33530d5..e79222e 100644
--- a/src/fx/lightning/electrified.js
+++ b/src/fx/lightning/electrified.js
@@ -18,6 +18,28 @@ export const meta = {
options: { palette: VOLT, sparks: PLASMA, seed: 5 },
};
+const TENSE = { turn: 0.9, crouch: 3, fx: -8, fy: -17, bx: 9, by: -17, ffx: -3, fbx: 4 };
+const JOLT_A = { turn: 1.1, crouch: 0, y: -1, fx: -13, fy: -36, bx: 13, by: -17, ffx: -4, fbx: 5 };
+const JOLT_B = { turn: 0.7, crouch: 1, y: -1, fx: -13, fy: -16, bx: 13, by: -36, ffx: -4, fbx: 5 };
+export const act = {
+ onBody: true,
+ poses: [
+ [0, TENSE],
+ [0.1, JOLT_A, "snap"],
+ [0.17, JOLT_B, "snap"],
+ [0.3, TENSE, "snap"],
+ [0.733, TENSE],
+ [0.733, JOLT_B, "snap"],
+ [0.8, JOLT_A, "snap"],
+ [0.93, TENSE, "snap"],
+ [1.367, TENSE],
+ [1.367, JOLT_A, "snap"],
+ [1.45, JOLT_B, "snap"],
+ [1.58, TENSE, "snap"],
+ [2, TENSE],
+ ],
+};
+
const FPS = 30, N = 60, P = 2, JOLTS = [[3, 1], [22, 0.7], [41, 0.9]];
const edges = new WeakMap();
// the silhouette's edge pixels, in local space
diff --git a/src/fx/lightning/thunderclap.js b/src/fx/lightning/thunderclap.js
index 1f6d9ad..6fac4bb 100644
--- a/src/fx/lightning/thunderclap.js
+++ b/src/fx/lightning/thunderclap.js
@@ -1,7 +1,7 @@
// The flash and flare, the bolts and their flicker, the plasma spray, the scorch where bolts land and the dust
// thrown along the floor follow Sprite Fusion's open-source lightning and explosion
// (https://www.spritefusion.com/pixel-art-vfx/lightning), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, PF, Rng, fit, band, flare, sparkle, clamp, smooth, ease, rng, TAU, WHITE, hex, mix } from "../../core/index.js";
+import { Particles, Lights, P, PF, Rng, fit, band, flare, sparkle, clamp, smooth, ease, rng, TAU, WHITE, hex, mix, READY } from "../../core/index.js";
import { VOLT, PLASMA, zigzag, stroke, crackle, scorch } from "./_lib.js";
export const meta = {
@@ -18,6 +18,28 @@ export const meta = {
options: { palette: VOLT, sparks: PLASMA, reach: 104, seed: 6 },
};
+const WIDE = { turn: 1.15, crouch: 5, lean: -1, fx: -15, fy: -33, bx: 15, by: -33, ffx: -7, fbx: 8 };
+const CLAP_ = { turn: 1.15, y: -2, crouch: 0, fx: -1, fy: -45, bx: 1, by: -45, ffx: -3, ffy: -5, fbx: 4, fby: -5 };
+export const act = {
+ onBody: true,
+ follow: 0,
+ target: { x: 104 },
+ poses: [
+ [-0.46, READY],
+ [-0.18, WIDE],
+ [0.08, { ...WIDE, crouch: 6 }],
+ [0.12, CLAP_, "snap"],
+ [0.55, { ...CLAP_, y: 0, ffy: -4, fby: -4, crouch: 1 }],
+ [1.05, { turn: 1, crouch: 3, fx: -10, fy: -28, bx: 11, by: -28, ffx: -4, fbx: 5 }],
+ [1.7, READY],
+ ],
+ hits: [
+ { t: 0.12, stop: 0.13, shake: 0.3, amp: 3, target: false },
+ { t: 0.42, push: 2, straw: 14, y: -8, skin: "shock", shiver: 0.5 },
+ { t: 1.2, push: 0, straw: 0, flash: 0, skin: null },
+ ],
+};
+
const CLAP = 0.12, CY = -22, BK = [1, 0.7, 0.95, 0.5, 0.8, 0.3];
const DUST = hex("#6e6382"), STONE = ["#655b7a", "#4a4263", "#342d45"].map(hex), ASH = hex("#5b5566");
diff --git a/src/fx/melee/claw-swipe.js b/src/fx/melee/claw-swipe.js
index 587052c..5db5500 100644
--- a/src/fx/melee/claw-swipe.js
+++ b/src/fx/melee/claw-swipe.js
@@ -1,6 +1,6 @@
// The shaded smear, its light and the dotted trace follow Sprite Fusion's open-source slash
// (https://www.spritefusion.com/pixel-art-vfx/slash), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Bits, Lights, P, B, Rng, fit, sparkle, clamp, smooth, ease } from "../../core/index.js";
+import { Particles, Bits, Lights, P, B, Rng, fit, sparkle, clamp, smooth, ease, READY } from "../../core/index.js";
import { through, onSwing, travel, smear, trace, glowAlong } from "./_lib.js";
export const meta = {
@@ -21,6 +21,28 @@ export const meta = {
},
};
+const READY_ = { ...READY, weapon: "claw", offWeapon: "claw", sa: -0.4, sb: -0.9, crouch: 5, lean: 3, fx: 14, fy: -21, bx: 8, by: -25, ffx: 9, fbx: -8 };
+const HIGH = { ...READY_, x: -6, crouch: 4, lean: -3, fx: 3, fy: -41, sa: -1.4, bx: 7, by: -18, sb: -0.3, ffx: 10 };
+export const act = {
+ target: { x: 58 },
+ poses: [
+ [-0.46, { ...READY_, x: -6 }],
+ [-0.2, HIGH],
+ [-0.05, { ...HIGH, crouch: 5 }],
+ [0, { ...READY_, x: 0, crouch: 3, lean: 4, fx: 19, fy: -36, sa: -0.9, bx: -7, by: -24, ghost: 1 }, "snap"],
+ [0.05, { ...READY_, x: 2, crouch: 5, lean: 6, fx: 23, fy: -24, sa: 0.5, bx: -7, by: -24, ffx: 13, fbx: -10, toeB: true }, "snap"],
+ [0.1, { ...READY_, x: 3, crouch: 7, lean: 7, fx: 22, fy: -12, sa: 1.2, bx: -7, by: -24, ffx: 13, fbx: -10, toeB: true }, "snap"],
+ [0.42, { ...READY_, x: 3, crouch: 6, lean: 5, fx: 21, fy: -13, sa: 1.1, bx: -6, by: -22, ffx: 13, fbx: -10 }],
+ [0.9, { ...READY_, x: -6 }],
+ ],
+ hits: [
+ { t: 0.04, stop: 0.03, push: 0.9, straw: 5, y: -30, flash: 0.03 },
+ { t: 0.08, stop: 0.03, push: 0.9, straw: 5, y: -26, flash: 0.03 },
+ { t: 0.12, stop: 0.08, shake: 0.14, amp: 2, push: 1.4, straw: 9, y: -18 },
+ ],
+ dust: [{ t: 0.1, x: 12, n: 6, dir: 1 }],
+};
+
const RAKE = 0.05; // each mark tears open
const STAGGER = 0.04;
const CLOSE0 = 0.16, CLOSE = 0.3; // then closes up from both ends
diff --git a/src/fx/melee/dagger-flurry.js b/src/fx/melee/dagger-flurry.js
index 3710ffe..03a5906 100644
--- a/src/fx/melee/dagger-flurry.js
+++ b/src/fx/melee/dagger-flurry.js
@@ -1,6 +1,6 @@
// The crescent, trace, glint and spark recipe is adapted from Sprite Fusion's open-source slash
// (https://www.spritefusion.com/pixel-art-vfx/slash), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, sparkle, clamp, ease, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, sparkle, clamp, ease, WHITE, READY } from "../../core/index.js";
import { swing, slash, slashEnd, shavings, sliver } from "./_lib.js";
export const meta = {
@@ -21,6 +21,40 @@ export const meta = {
},
};
+const BASE = { ...READY, weapon: "dagger", offWeapon: "dagger", sa: -0.5, sb: -0.9, crouch: 4, lean: 3, ffx: 11, fbx: -9, fx: 12, fy: -24, bx: 9, by: -24 };
+// a stab with one hand while the other comes back to the chest; the shoulders turn into each one
+const near = (fx, fy, sa, o = {}) => ({ ...BASE, fx, fy, sa, bx: 4, by: -24, sb: -1, ...o });
+const far = (bx, by, sb, o = {}) => ({ ...BASE, bx, by, sb, fx: 1, fy: -23, sa: -1, ...o });
+export const act = {
+ target: { x: 60 },
+ poses: [
+ [-0.4, { ...BASE, x: -4 }],
+ [-0.14, { ...BASE, x: -6, lean: -2, crouch: 5, fx: 2, fy: -22, sa: -1.2, bx: 2, by: -26, sb: -1.5 }],
+ [-0.03, { ...BASE, x: -6, lean: -3, crouch: 6, fx: 1, fy: -21, sa: -1.2, bx: 1, by: -25, sb: -1.5 }],
+ [0, near(20, -31, -0.5, { x: 2, ghost: 1 }), "snap"],
+ [0.055, far(21, -23, 0.5, { x: 3 }), "snap"],
+ [0.11, near(18, -36, -1, { x: 4 }), "snap"],
+ [0.165, far(22, -31, -0.6, { x: 5 }), "snap"],
+ [0.22, near(20, -22, 0.2, { x: 5 }), "snap"],
+ [0.275, far(21, -27, 0.05, { x: 6 }), "snap"],
+ [0.33, { ...BASE, x: 4, lean: -3, crouch: 5, fx: -1, fy: -33, sa: -2.5, bx: 2, by: -23, sb: -1.2 }, "snap"],
+ [0.37, { ...BASE, x: 7, lean: 2, crouch: 4, fx: 16, fy: -34, sa: -1, bx: -7, by: -24, sb: -2.4, ghost: 1 }, "snap"],
+ [0.43, { ...BASE, x: 9, lean: 6, crouch: 6, fx: 22, fy: -23, sa: 0.15, bx: -9, by: -24, sb: -2.6, ffx: 13, fbx: -10, toeB: true }, "snap"],
+ [0.68, { ...BASE, x: 9, lean: 5, crouch: 5, fx: 21, fy: -22, sa: 0.2, bx: -8, by: -24, sb: -2.6 }],
+ [1.05, { ...BASE, x: -4 }],
+ ],
+ hits: [
+ { t: 0.05, stop: 0.015, push: 0.5, straw: 3, flash: 0.02 },
+ { t: 0.105, stop: 0.015, push: -0.3, straw: 3, flash: 0.02 },
+ { t: 0.16, stop: 0.015, push: 0.5, straw: 3, flash: 0.02 },
+ { t: 0.215, stop: 0.015, push: -0.3, straw: 3, flash: 0.02 },
+ { t: 0.27, stop: 0.015, push: 0.5, straw: 3, flash: 0.02 },
+ { t: 0.325, stop: 0.015, push: -0.3, straw: 3, flash: 0.02 },
+ { t: 0.42, stop: 0.12, shake: 0.18, amp: 2, push: 2.6, straw: 16 },
+ ],
+ dust: [{ t: 0.43, x: 20, n: 7, dir: 1 }, { t: 0, x: -6, n: 3, dir: -1 }],
+};
+
const EVERY = 0.055;
// small cuts: where, how they're turned, which way they go
const CUTS = [
diff --git a/src/fx/melee/double-slash.js b/src/fx/melee/double-slash.js
index 5a1b239..2aa6e6e 100644
--- a/src/fx/melee/double-slash.js
+++ b/src/fx/melee/double-slash.js
@@ -1,6 +1,6 @@
// The crescent, trace, glint and spark recipe is adapted from Sprite Fusion's open-source slash
// (https://www.spritefusion.com/pixel-art-vfx/slash), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, sparkle, flare, clamp, ease, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, sparkle, flare, clamp, ease, WHITE, READY } from "../../core/index.js";
import { through, slash, slashEnd, shavings, sliver } from "./_lib.js";
export const meta = {
@@ -21,6 +21,30 @@ export const meta = {
},
};
+const STANCE = { ...READY, weapon: "sword", fx: 12, fy: -21, sa: -0.85 };
+const HIGH = { ...STANCE, x: -7, crouch: 4, lean: -4, fx: -7, fy: -35, sa: -2.65, bx: 9, by: -25, armsFront: true, ffx: 9, fbx: -8 };
+const LOW = { ...STANCE, x: 3, crouch: 6, lean: 6, fx: 22, fy: -20, sa: 0.62, bx: -8, by: -24, ffx: 13, fbx: -10, toeB: true };
+export const act = {
+ target: { x: 62 },
+ poses: [
+ [-0.42, { ...STANCE, x: -7 }],
+ [-0.18, HIGH],
+ [-0.04, { ...HIGH, crouch: 5 }],
+ [0, { ...STANCE, x: 0, crouch: 2, lean: 3, fx: 16, fy: -37, sa: -1.45, bx: -7, by: -24, ffx: 11, fbx: -9, ghost: 1 }, "snap"],
+ [0.06, LOW, "snap"],
+ [0.14, { ...LOW, x: 4, crouch: 6, lean: 5, fx: 20, fy: -17, sa: 0.85, ghost: 1 }],
+ [0.17, { ...LOW, x: 5, crouch: 3, lean: 5, fx: 22, fy: -28, sa: 0.1, by: -18, toeB: true, ghost: 1 }, "snap"],
+ [0.21, { ...LOW, x: 6, crouch: 1, lean: 6, fx: 19, fy: -37, sa: -0.95, by: -18, ffx: 13, fby: -6 }, "snap"],
+ [0.5, { ...LOW, x: 6, crouch: 3, lean: 3, fx: 18, fy: -36, sa: -1.05, by: -19, ffx: 12 }],
+ [0.92, { ...STANCE, x: -7 }],
+ ],
+ hits: [
+ { t: 0.06, stop: 0.05, shake: 0.08, amp: 1, push: 1.4, straw: 8 },
+ { t: 0.16, stop: 0.14, shake: 0.2, amp: 2, push: 2.8, straw: 18, y: -28 },
+ ],
+ dust: [{ t: 0.06, x: 16, n: 5, dir: 1 }, { t: 0.17, x: -8, n: 4, dir: -1 }],
+};
+
const UP = 0.14; // the second cut starts
const R0 = 62;
diff --git a/src/fx/melee/hammer-smash.js b/src/fx/melee/hammer-smash.js
index 355e33f..3b3ecf8 100644
--- a/src/fx/melee/hammer-smash.js
+++ b/src/fx/melee/hammer-smash.js
@@ -1,6 +1,6 @@
// The rocks, grit, rolling dust and floor ring are adapted from Sprite Fusion's open-source explosion, and the
// dome from his ice nova (https://www.spritefusion.com/pixel-art-vfx), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Bits, Lights, P, PF, B, Rng, fit, band, clamp, smooth, ease, rand, hex, TAU, WHITE } from "../../core/index.js";
+import { Particles, Bits, Lights, P, PF, B, Rng, fit, band, clamp, smooth, ease, rand, hex, TAU, WHITE, READY } from "../../core/index.js";
import { swing, onSwing, smear, stone, rock, cracks, along } from "./_lib.js";
export const meta = {
@@ -21,6 +21,28 @@ export const meta = {
},
};
+// both hands low on the shaft, the head resting on the floor in front; it comes up, over and down
+const REST_ = { ...READY, weapon: "hammer", two: true, sa: 0.62, fx: 11, fy: -21, crouch: 3 };
+const TOP = { ...REST_, x: -3, crouch: 0, lean: -3, fx: 3, fy: -41, sa: -2.1, ffx: 8, ffy: -8, fbx: -5, toeB: true };
+const SLAM = { ...REST_, x: -1, crouch: 7, lean: 6, fx: 14, fy: -19, sa: 0.62, ffx: 11, fbx: -10 };
+export const act = {
+ target: { x: 66 },
+ poses: [
+ [-0.72, { ...REST_, x: -3 }],
+ [-0.44, { ...REST_, x: -3, crouch: 5, lean: -1, fx: 16, fy: -28, sa: -0.9 }],
+ [-0.2, TOP],
+ [-0.03, { ...TOP, y: -2 }],
+ [0.06, { ...REST_, x: 0, y: -3, crouch: -1, lean: 2, fx: 13, fy: -41, sa: -1.2, ffx: 11, ffy: -8, ghost: 1 }, "snap"],
+ [0.11, { ...REST_, x: 0, y: -1, crouch: 3, lean: 5, fx: 19, fy: -30, sa: -0.15, ffx: 13, ghost: 1 }, "snap"],
+ [0.15, SLAM, "snap"],
+ [0.62, { ...SLAM, crouch: 6, lean: 5 }],
+ [1.02, { ...REST_, x: -2, crouch: 5, lean: 2, fx: 14, fy: -24, sa: 0.3 }],
+ [1.4, { ...REST_, x: -3 }],
+ ],
+ hits: [{ t: 0.15, stop: 0.2, shake: 0.34, amp: 3, push: 3, straw: 26, y: -8 }],
+ dust: [{ t: 0.15, x: 10, n: 8 }, { t: 0.15, x: -12, n: 5, dir: -1 }],
+};
+
const SOOT = hex("#0d0a12"), HOT = ["#fff3a6", "#ffc23d", "#ff8a2a", "#c9281f"].map(hex);
const DROP = 0.15; // the hammer comes over and down, gathering speed
const head = (t) => {
diff --git a/src/fx/melee/heavy-cleave.js b/src/fx/melee/heavy-cleave.js
index 9ecd07b..5dc5a39 100644
--- a/src/fx/melee/heavy-cleave.js
+++ b/src/fx/melee/heavy-cleave.js
@@ -1,7 +1,7 @@
// The crescent and its cooling ramp are adapted from Sprite Fusion's open-source slash
// (https://www.spritefusion.com/pixel-art-vfx/slash), and the impact star, dust, grit and embers from his
// impact and explosion (https://www.spritefusion.com/pixel-art-vfx), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Bits, Lights, P, PF, B, Rng, fit, sparkle, band, clamp, smooth, ease, rand, TAU, WHITE } from "../../core/index.js";
+import { Particles, Bits, Lights, P, PF, B, Rng, fit, sparkle, band, clamp, smooth, ease, rand, TAU, WHITE, READY } from "../../core/index.js";
import { swing, onSwing, smear, trace, glowAlong, stone, rock, cracks, star, sliver, along } from "./_lib.js";
export const meta = {
@@ -22,6 +22,27 @@ export const meta = {
},
};
+const REST_ = { ...READY, weapon: "greatsword", two: true, sa: -1, fx: 11, fy: -21 };
+const OVER = { ...REST_, x: -4, crouch: 2, lean: -2, fx: 1, fy: -42, sa: -2.45, ffx: 8, fbx: -7 };
+const FLOOR = { ...REST_, x: 0, crouch: 7, lean: 6, fx: 17, fy: -21, sa: 0.72, ffx: 11, fbx: -10, toeB: true };
+export const act = {
+ target: { x: 66 },
+ poses: [
+ [-0.42, { ...REST_, x: -4 }],
+ [-0.3, { ...REST_, x: -3, crouch: 4, fx: 13, fy: -29, sa: -1.3 }],
+ [-0.12, { ...OVER, crouch: 4 }],
+ [0.2, { ...OVER, crouch: 3 }],
+ [0.27, { ...REST_, x: -1, y: -2, crouch: 0, lean: 2, fx: 11, fy: -42, sa: -1.45, ffx: 10, ghost: 1 }, "snap"],
+ [0.31, { ...REST_, x: 0, y: -1, crouch: 3, lean: 4, fx: 18, fy: -33, sa: -0.45, ffx: 12, ghost: 1 }, "snap"],
+ [0.335, FLOOR, "snap"],
+ [0.85, { ...FLOOR, crouch: 6, lean: 5 }],
+ [1.3, { ...REST_, x: -2, crouch: 4, lean: 2, fx: 15, fy: -23, sa: 0.1 }],
+ [1.7, { ...REST_, x: -4 }],
+ ],
+ hits: [{ t: 0.335, stop: 0.2, shake: 0.34, amp: 3, push: 3.2, straw: 28, y: -8 }],
+ dust: [{ t: 0.335, x: 18, n: 8, dir: 1 }, { t: 0.335, x: -12, n: 5, dir: -1 }],
+};
+
const RAISE = 0.2; // the glint over the head
const SWING = 0.135; // the arc accelerates over the top
const HIT = RAISE + SWING;
diff --git a/src/fx/melee/scythe-reap.js b/src/fx/melee/scythe-reap.js
index 4c88095..9757b43 100644
--- a/src/fx/melee/scythe-reap.js
+++ b/src/fx/melee/scythe-reap.js
@@ -1,6 +1,6 @@
// The crescent and trace recipe is adapted from Sprite Fusion's open-source slash, and the vapour from his
// ice and poison (https://www.spritefusion.com/pixel-art-vfx), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, PF, Rng, fit, sparkle, clamp, smooth, ease, rand, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, PF, Rng, fit, sparkle, clamp, smooth, ease, rand, WHITE, READY } from "../../core/index.js";
import { swing, onSwing, travel, smear, glowAlong } from "./_lib.js";
export const meta = {
@@ -20,6 +20,27 @@ export const meta = {
},
};
+// the butt rests on the floor in one hand; both hands take it out to the right, and he turns with it round the front
+const REST_ = { ...READY, weapon: "scythe", x: 2, sa: -1.5, fx: 11, fy: -22, bx: 7, by: -16 };
+const OUT_ = { ...REST_, two: true, crouch: 4, lean: 4, fx: 17, fy: -27, sa: -0.45, ffx: 11, fbx: -8 };
+const END = { ...REST_, two: true, x: 0, yaw: 3.14, crouch: 6, lean: 4, fx: 15, fy: -24, sa: 0.3, ffx: 11, fbx: -10, toeB: true };
+export const act = {
+ target: { x: 66 },
+ poses: [
+ [-0.56, REST_],
+ [-0.26, OUT_],
+ [0.08, { ...OUT_, crouch: 5 }],
+ [0.2, { ...OUT_, yaw: 0.8, crouch: 5, lean: 3, fx: 16, fy: -23, sa: 0.1, ghost: 1 }],
+ [0.3, { ...OUT_, x: 1, yaw: 1.9, crouch: 6, lean: 3, fx: 15, fy: -23, sa: 0.2, ghost: 1 }],
+ [0.42, END],
+ [0.92, { ...END, crouch: 5 }],
+ [1.3, { ...REST_, x: 1, yaw: 1.4, crouch: 4 }],
+ [1.7, REST_],
+ ],
+ hits: [{ t: 0.14, stop: 0.12, shake: 0.16, amp: 2, push: 2.4, straw: 20, skin: "shadow" }],
+ dust: [{ t: 0.3, x: 2, n: 6 }],
+};
+
const WIND = 0.08, SWEEP = 0.34, HANG = 0.14, TEAR = 0.55;
const T0 = WIND, T1 = WIND + SWEEP, T2 = T1 + HANG, T3 = T2 + TEAR;
const head = (t) => ease.inOutSine(clamp((t - T0) / SWEEP));
diff --git a/src/fx/melee/spear-sweep.js b/src/fx/melee/spear-sweep.js
index b31f17b..6197935 100644
--- a/src/fx/melee/spear-sweep.js
+++ b/src/fx/melee/spear-sweep.js
@@ -1,6 +1,6 @@
// The crescent, trace and glint recipe is adapted from Sprite Fusion's open-source slash, and the rolling dust and
// grit from his explosion (https://www.spritefusion.com/pixel-art-vfx), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, PF, Rng, fit, sparkle, clamp, ease } from "../../core/index.js";
+import { Particles, Lights, P, PF, Rng, fit, sparkle, clamp, ease, READY } from "../../core/index.js";
import { swing, onSwing, travel, slash, slashEnd, stone } from "./_lib.js";
export const meta = {
@@ -22,6 +22,28 @@ export const meta = {
},
};
+// upright in one hand; two hands take it low across the belt, he winds right round, and it whips through the front
+const REST_ = { ...READY, weapon: "spear", sa: -1.42, fx: 11, fy: -21, bx: 7, by: -16 };
+const COCK = { ...REST_, two: true, yaw: 2.5, crouch: 6, lean: 2, fx: 15, fy: -17, sa: 0.05, ffx: 9, fbx: -8 };
+const OUT_ = { ...REST_, two: true, x: 2, crouch: 6, lean: 6, fx: 20, fy: -15, sa: 0.04, ffx: 12, fbx: -10, toeB: true };
+export const act = {
+ target: { x: 62 },
+ poses: [
+ [-0.56, REST_],
+ [-0.34, { ...REST_, two: true, crouch: 4, fx: 14, fy: -22, sa: -0.7 }],
+ [-0.14, COCK],
+ [-0.02, { ...COCK, crouch: 7, yaw: 2.7 }],
+ [0.045, { ...OUT_, x: 1, yaw: 1.3, ghost: 1 }, "snap"],
+ [0.09, { ...OUT_, ghost: 1 }, "snap"],
+ [0.14, OUT_, "snap"],
+ [0.62, { ...OUT_, crouch: 5, lean: 5 }],
+ [1.12, { ...REST_, two: true, crouch: 4, sa: -0.7, fx: 14, fy: -22 }],
+ [1.5, REST_],
+ ],
+ hits: [{ t: 0.1, stop: 0.12, shake: 0.18, amp: 2, push: 2.6, straw: 18, y: -12 }],
+ dust: [{ t: 0.09, x: 14, n: 6, dir: 1 }, { t: 0.09, x: -10, n: 5, dir: -1 }],
+};
+
export function create(o) {
const C = fit(o.palette, 7), Rg = new Rng(o.seed), st = stone(o.stone), ps = new Particles({ rng: Rg, ground: () => 0, sparks: o.sparks }), lights = new Lights();
// from behind the left leg, round the front, out to the right; the far part is behind the fighter
diff --git a/src/fx/melee/spin-slash.js b/src/fx/melee/spin-slash.js
index 3a87daf..59ccca7 100644
--- a/src/fx/melee/spin-slash.js
+++ b/src/fx/melee/spin-slash.js
@@ -1,6 +1,6 @@
// The crescent shading, cooling ramp, dotted trace, glint and spark recipe is adapted from Sprite Fusion's
// open-source slash (https://www.spritefusion.com/pixel-art-vfx/slash), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, PF, Rng, fit, sparkle, clamp, smooth, ease, rand, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, PF, Rng, fit, sparkle, clamp, smooth, ease, rand, TAU, WHITE, READY } from "../../core/index.js";
import { swing, onSwing, travel, smear, trace, glowAlong } from "./_lib.js";
export const meta = {
@@ -22,6 +22,28 @@ export const meta = {
},
};
+const STANCE = { ...READY, weapon: "sword", fx: 12, fy: -21, sa: -0.85 };
+// he really turns: forward, away from us, facing back, towards us, and round to the front
+const WOUND = { ...STANCE, crouch: 6, lean: -2, yaw: 1.1, fx: 13, fy: -20, sa: 0.3, bx: 6, by: -24, ffx: 8, fbx: -8 };
+const WIDE = { ...STANCE, crouch: 5, lean: 3, fx: 21, fy: -21, sa: 0.05, bx: -9, by: -23, ffx: 11, fbx: -11 };
+export const act = {
+ target: { x: 60 },
+ poses: [
+ [-0.46, STANCE],
+ [-0.2, WOUND],
+ [-0.02, { ...WOUND, crouch: 7, yaw: 1.3 }],
+ [0, { ...WIDE, sa: -0.1, ghost: 1 }, "snap"],
+ [0.05, { ...WIDE, yaw: -1.57, ghost: 1 }, "snap"],
+ [0.09, { ...WIDE, yaw: -3.14, ghost: 1 }, "snap"],
+ [0.13, { ...WIDE, yaw: -4.71, ghost: 1 }, "snap"],
+ [0.17, WIDE, "snap"],
+ [0.56, { ...WIDE, crouch: 4, lean: 2 }],
+ [0.92, STANCE],
+ ],
+ hits: [{ t: 0.17, stop: 0.12, shake: 0.16, amp: 2, push: 2.4, straw: 16 }],
+ dust: [{ t: 0, x: 0, n: 6 }, { t: 0.17, x: 12, n: 6, dir: 1 }],
+};
+
const SW = 0.17; // the edge goes once round
const FLARE = 0.3; // the closed ring flares and dissolves
const turn = (t) => 1 - Math.pow(1 - clamp(t / SW), 1.6); // fraction of the turn the edge has made
diff --git a/src/fx/melee/sword-slash.js b/src/fx/melee/sword-slash.js
index b0850e2..8e9258f 100644
--- a/src/fx/melee/sword-slash.js
+++ b/src/fx/melee/sword-slash.js
@@ -1,6 +1,6 @@
// The crescent, echo, trail, glint and spark recipe is adapted from Sprite Fusion's open-source slash
// (https://www.spritefusion.com/pixel-art-vfx/slash), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, P, Rng, fit, sparkle, clamp, smooth, ease, TAU } from "../../core/index.js";
+import { Particles, P, Rng, fit, sparkle, clamp, smooth, ease, TAU, READY } from "../../core/index.js";
export const meta = {
name: "Sword slash",
@@ -21,6 +21,27 @@ export const meta = {
},
};
+const GUARD = { ...READY, weapon: "sword", fx: 12, fy: -21, sa: -0.85 };
+// the blade goes back past his head, then lags behind the hand on the way through, so the wrist breaks and it whips
+const WIND = { ...GUARD, x: -8, crouch: 4, lean: -4, fx: -7, fy: -35, sa: -2.65, bx: 9, by: -25, armsFront: true, ffx: 9, fbx: -8 };
+const CUT = { ...GUARD, x: 0, crouch: 2, lean: 3, fx: 16, fy: -37, sa: -1.45, bx: -7, by: -24, ffx: 11, fbx: -10, ghost: 1 };
+const DOWN = { ...GUARD, x: 2, crouch: 5, lean: 5, fx: 20, fy: -21, sa: 0.62, bx: -9, by: -24, ffx: 13, fbx: -10, toeB: true };
+export const act = {
+ target: { x: 58 },
+ poses: [
+ [-0.55, { ...GUARD, x: -8 }],
+ [-0.3, WIND],
+ [-0.08, { ...WIND, crouch: 5, lean: -5 }],
+ [0, CUT, "snap"],
+ [0.06, DOWN, "snap"],
+ [0.3, { ...DOWN, x: 3, crouch: 6 }],
+ [0.58, { ...GUARD, x: 1, crouch: 3, fx: 15, fy: -21, sa: 0.1, bx: -5, by: -21, ffx: 9, fbx: -7 }],
+ [0.86, { ...GUARD, x: -8 }],
+ ],
+ hits: [{ t: 0.06, stop: 0.14, shake: 0.18, amp: 2, push: 2.8, straw: 18 }],
+ dust: [{ t: 0.06, x: 16, n: 7, dir: 1 }, { t: 0.06, x: -11, n: 4, dir: -1 }],
+};
+
// a point on the slash's tilted ellipse
function onArc(s, r, a) {
const lx = Math.cos(a) * r, ly = Math.sin(a) * r * s.sy, c = Math.cos(s.rot), n = Math.sin(s.rot);
diff --git a/src/fx/melee/thrust.js b/src/fx/melee/thrust.js
index 5604b1c..9714b58 100644
--- a/src/fx/melee/thrust.js
+++ b/src/fx/melee/thrust.js
@@ -1,6 +1,6 @@
// The speed lines are adapted from Sprite Fusion's open-source dash and the ray star from his sparkle
// (https://www.spritefusion.com/pixel-art-vfx), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, sparkle, clamp, smooth, ease, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, sparkle, clamp, smooth, ease, TAU, WHITE, READY } from "../../core/index.js";
export const meta = {
name: "Thrust",
@@ -21,6 +21,25 @@ export const meta = {
},
};
+const STANCE = { ...READY, weapon: "sword", x: -14, fx: 12, fy: -21, sa: -0.3 };
+// the hand comes back to the hip with the point forward, then the whole arm goes out along the blade
+const BACK = { ...STANCE, crouch: 5, lean: -3, fx: -3, fy: -19, sa: -0.05, bx: 8, by: -30, armsFront: true, ffx: 10, fbx: -8 };
+const LUNGE = { ...STANCE, crouch: 6, lean: 6, fx: 23, fy: -20, sa: 0, bx: -8, by: -24, ffx: 15, fbx: -11, toeB: true };
+export const act = {
+ target: { x: 80 },
+ poses: [
+ [-0.46, STANCE],
+ [-0.24, BACK],
+ [-0.05, { ...BACK, crouch: 6, fx: -5 }],
+ [0, { ...LUNGE, ghost: 1 }, "snap"],
+ [0.07, LUNGE, "snap"],
+ [0.3, { ...LUNGE, crouch: 5, lean: 5 }],
+ [0.7, STANCE],
+ ],
+ hits: [{ t: 0.07, stop: 0.12, shake: 0.14, amp: 2, push: 2.8, straw: 16, y: -26 }],
+ dust: [{ t: 0, x: -24, n: 6, dir: -1 }, { t: 0.07, x: 1, n: 6, dir: 1 }],
+};
+
const OUT = 0.07; // the point arrives
const HOLD = 0.06, PULL = 0.2;
diff --git a/src/fx/melee/uppercut.js b/src/fx/melee/uppercut.js
index 18119db..70c7199 100644
--- a/src/fx/melee/uppercut.js
+++ b/src/fx/melee/uppercut.js
@@ -1,6 +1,6 @@
// The crescent recipe is adapted from Sprite Fusion's open-source slash, and the star from his impact
// (https://www.spritefusion.com/pixel-art-vfx), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, hex, clamp, smooth, ease, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, hex, clamp, smooth, ease, TAU, WHITE, READY } from "../../core/index.js";
import { swing, onSwing, slash, slashEnd, star } from "./_lib.js";
export const meta = {
@@ -22,6 +22,26 @@ export const meta = {
},
};
+const FISTS = { ...READY, fx: 12, fy: -25, bx: 9, by: -27, crouch: 3, lean: 1 };
+const COIL = { ...FISTS, crouch: 7, lean: 3, fx: 8, fy: -11, bx: 8, by: -27, ffx: 10, fbx: -9 };
+const TOP = { ...FISTS, x: 1, y: -11, crouch: -1, lean: 2, fx: 12, fy: -42, bx: -6, by: -21, ffx: 8, ffy: -8, fbx: -3, fby: -2, toeB: true, ghost: 1 };
+export const act = {
+ target: { x: 44 },
+ poses: [
+ [-0.42, FISTS],
+ [-0.16, COIL],
+ [0, { ...COIL, crouch: 8 }],
+ [0.03, { ...FISTS, y: -4, crouch: 1, lean: 4, fx: 18, fy: -27, bx: -5, by: -23, ffx: 9, fbx: -7, toeB: true, ghost: 1 }, "snap"],
+ [0.076, TOP, "snap"],
+ [0.3, { ...TOP, y: -13, ghost: undefined }],
+ [0.56, { ...TOP, y: 0, crouch: 2, fx: 13, fy: -31, ffx: 7, ffy: -6, fbx: -5, fby: -5, ghost: undefined }, "in"],
+ [0.6, { ...FISTS, y: 0, crouch: 7, lean: 3, fx: 12, fy: -14, bx: -6, by: -16, ffx: 10, fbx: -9 }, "snap"],
+ [0.98, FISTS],
+ ],
+ hits: [{ t: 0.076, stop: 0.13, shake: 0.18, amp: 2, push: -2.6, straw: 18, y: -34 }],
+ dust: [{ t: 0.03, x: 8, n: 6 }, { t: 0.6, x: 0, n: 6 }],
+};
+
export function create(o) {
const C = fit(o.palette, 7), INK = hex(o.outline), Rg = new Rng(o.seed), ps = new Particles({ rng: Rg, ground: () => 0, sparks: o.sparks }), lights = new Lights();
// up from the floor in front, bowing forward past the face, to the top
diff --git a/src/fx/melee/whip-crack.js b/src/fx/melee/whip-crack.js
index 2284fb8..92794f2 100644
--- a/src/fx/melee/whip-crack.js
+++ b/src/fx/melee/whip-crack.js
@@ -1,6 +1,6 @@
// The pop's star and slivers follow Sprite Fusion's open-source impact, and the sparks his slash
// (https://www.spritefusion.com/pixel-art-vfx), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, clamp, smooth, ease, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, clamp, smooth, ease, TAU, WHITE, READY } from "../../core/index.js";
import { star, sliver } from "./_lib.js";
export const meta = {
@@ -22,6 +22,26 @@ export const meta = {
},
};
+const STANCE = { ...READY, weapon: "handle", x: -7, sa: -0.3, fx: 13, fy: -21, bx: 7, by: -18 };
+const COCK = { ...STANCE, crouch: 4, lean: -3, fx: -6, fy: -38, sa: -2.2, bx: 9, by: -23, armsFront: true, ffx: 9, fbx: -7 };
+const CRACK_ = { ...STANCE, crouch: 4, lean: 5, fx: 18, fy: -21, sa: 0, bx: -8, by: -23, ffx: 12, fbx: -10, toeB: true };
+export const act = {
+ target: { x: 94 },
+ poses: [
+ [-0.46, STANCE],
+ [-0.22, COCK],
+ [0.02, { ...COCK, lean: -4 }],
+ [0.06, { ...CRACK_, fx: 15, fy: -34, sa: -0.7, lean: 2, ghost: 1 }, "snap"],
+ [0.12, CRACK_, "snap"],
+ [0.21, CRACK_],
+ [0.26, { ...CRACK_, fx: 15, fy: -27, sa: -0.3, lean: 2, crouch: 3 }, "snap"],
+ [0.44, { ...CRACK_, fx: 17, fy: -22, sa: 0.1, lean: 3, crouch: 3 }],
+ [0.92, STANCE],
+ ],
+ hits: [{ t: 0.21, stop: 0.1, shake: 0.14, amp: 2, push: 2.4, straw: 14, y: -28 }],
+ dust: [{ t: 0.06, x: 2, n: 4, dir: 1 }],
+};
+
const ROLL0 = 0.02, ROLL = 0.19, CRACK = ROLL0 + ROLL; // the loop runs out; the tip cracks when it gets there
const RECOIL = 0.16;
diff --git a/src/fx/moves/arrow-shot.js b/src/fx/moves/arrow-shot.js
new file mode 100644
index 0000000..e1c4ae1
--- /dev/null
+++ b/src/fx/moves/arrow-shot.js
@@ -0,0 +1,43 @@
+import { chain, READY } from "../../core/index.js";
+import * as arrow from "../projectiles/arrow.js";
+import * as spark from "../impacts/hit-spark.js";
+
+const LOOSE = 0.56, FLY = 0.24, HIT = LOOSE + FLY, TX = 180, SPEED = (TX - 30) / FLY;
+
+export const meta = {
+ name: "Arrow shot",
+ desc: "He raises the bow, draws to his cheek, holds his breath and looses: the string snaps forward, the arrow crosses the floor and thuds home.",
+ tags: ["move", "bow", "arrow", "projectile", "ranged", "one-shot"],
+ size: [300, 74],
+ origin: [38, 66],
+ duration: 1.9,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const REST_ = { ...READY, weapon: "bow", sa: -0.4, fx: 12, fy: -20, bx: 6, by: -17 };
+const AIM = { ...REST_, crouch: 3, lean: 1, fx: 18, fy: -28, sa: 0, bx: 10, by: -27, nocked: true, ffx: 11, fbx: -9 };
+const DRAWN = { ...AIM, crouch: 4, lean: -2, fx: 18, bx: -3, by: -29, pull: true };
+const LOOSED = { ...AIM, crouch: 3, lean: 2, fx: 19, fy: -28, bx: -9, by: -32, nocked: false, pull: false };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [-0.44, REST_],
+ [-0.14, AIM],
+ [0.16, DRAWN],
+ [LOOSE, { ...DRAWN, crouch: 4 }],
+ [LOOSE + 0.002, LOOSED, "snap"],
+ [1.1, { ...LOOSED, bx: -6, by: -25 }],
+ [1.6, REST_],
+ [1.9, REST_],
+ ],
+ hits: [{ t: HIT, stop: 0.07, shake: 0.12, amp: 2, push: 2.2, straw: 14, y: -28 }],
+};
+
+export const create = chain([
+ { fx: arrow, t: LOOSE, until: HIT, x: (t) => 30 + (t - LOOSE) * SPEED, y: -28 },
+ { fx: spark, t: HIT, x: TX - 10, height: 30 },
+]);
diff --git a/src/fx/moves/dash-strike.js b/src/fx/moves/dash-strike.js
new file mode 100644
index 0000000..9d2c7d8
--- /dev/null
+++ b/src/fx/moves/dash-strike.js
@@ -0,0 +1,53 @@
+import { chain, READY } from "../../core/index.js";
+import * as slash from "../melee/sword-slash.js";
+import * as crit from "../impacts/crit-hit.js";
+
+const CUT = 0.16, HIT = CUT + 0.06, AT = 116, TX = 176;
+
+export const meta = {
+ name: "Dash strike",
+ desc: "A crouch, then he's across the floor in a blur of after-images and already cutting: a critical hit, a beat, and he hops back to where he started.",
+ tags: ["move", "melee", "sword", "dash", "crit", "one-shot"],
+ size: [372, 156],
+ origin: [66, 136],
+ duration: 2.3,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const GUARD = { ...READY, weapon: "sword", fx: 12, fy: -21, sa: -0.85 };
+const LOW = { ...GUARD, crouch: 6, lean: 6, fx: -3, fy: -17, sa: 3.05, bx: 9, by: -23, ffx: 11, fbx: -10 };
+const COCK = { ...GUARD, x: AT - 4, crouch: 3, lean: -2, fx: -7, fy: -35, sa: -2.65, bx: 9, by: -25, armsFront: true, ffx: 9, fbx: -7 };
+const CUT_ = { ...GUARD, x: AT, crouch: 2, lean: 3, fx: 16, fy: -37, sa: -1.45, bx: -7, by: -24, ffx: 11, fbx: -10 };
+const DOWN = { ...GUARD, x: AT + 2, crouch: 5, lean: 5, fx: 20, fy: -21, sa: 0.62, bx: -9, by: -24, ffx: 13, fbx: -10, toeB: true };
+const HOP = { ...GUARD, y: -14, crouch: 0, lean: -3, fx: 13, fy: -31, sa: -0.9, bx: -8, by: -28, ffx: 6, ffy: -8, fbx: -6, fby: -6, ghost: 1 };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [-0.5, { ...GUARD, x: 0 }],
+ [-0.16, { ...LOW, x: -2 }],
+ [-0.01, { ...LOW, x: -3, crouch: 6 }],
+ [0, { ...LOW, x: 8, ghost: 1 }, "snap"],
+ [0.14, { ...LOW, x: AT - 6, ghost: 1 }, "line"],
+ [0.145, COCK, "snap"],
+ [CUT, CUT_, "snap"],
+ [HIT, DOWN, "snap"],
+ [0.75, { ...DOWN, crouch: 4, lean: 4 }],
+ [1.25, { ...GUARD, x: AT + 2 }],
+ [1.32, { ...GUARD, x: AT + 2, crouch: 5, lean: -2 }, "snap"],
+ [1.4, { ...HOP, x: AT - 28 }, "snap"],
+ [1.6, { ...HOP, x: 22, y: -18 }, "line"],
+ [1.74, { ...GUARD, x: 0, y: 0, crouch: 5 }, "line"],
+ [2.2, { ...GUARD, x: 0 }],
+ ],
+ hits: [{ t: HIT, stop: 0.17, shake: 0.26, amp: 3, push: 3.4, straw: 32 }],
+ dust: [{ t: 0, x: 0, n: 8, dir: -1 }, { t: 0.14, x: AT - 6, n: 7 }, { t: 1.74, x: 0, n: 6 }],
+};
+
+export const create = chain([
+ { fx: slash, t: CUT, x: AT },
+ { fx: crit, t: HIT, x: TX - 10, height: 28 },
+]);
diff --git a/src/fx/moves/earth-stomp.js b/src/fx/moves/earth-stomp.js
new file mode 100644
index 0000000..a4353ca
--- /dev/null
+++ b/src/fx/moves/earth-stomp.js
@@ -0,0 +1,40 @@
+import { chain, READY } from "../../core/index.js";
+import * as spike from "../nature/earth-spike.js";
+
+const STOMP = 0.06, RAM = STOMP + 0.43, TX = 112;
+
+export const meta = {
+ name: "Earth stomp",
+ desc: "A knee comes up, the boot slams down, the floor heaves under the target and a stone spike rams up through it.",
+ tags: ["move", "earth", "spell", "stomp", "one-shot"],
+ size: [290, 142],
+ origin: [50, 128],
+ duration: STOMP + 3.4,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const KNEE = { ...READY, crouch: 1, lean: -3, fx: 3, fy: -34, bx: 11, by: -30, ffx: 9, ffy: -15, fbx: -5 };
+const SLAM = { ...READY, crouch: 7, lean: 3, fx: 14, fy: -14, bx: -5, by: -18, ffx: 11, fbx: -9 };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [-0.5, READY],
+ [-0.14, KNEE],
+ [STOMP - 0.005, { ...KNEE, ffy: -17 }],
+ [STOMP, SLAM, "snap"],
+ [RAM + 0.5, { ...SLAM, crouch: 5 }],
+ [RAM + 1.1, READY],
+ [STOMP + 3.4, READY],
+ ],
+ hits: [
+ { t: STOMP, stop: 0.1, shake: 0.2, amp: 3, target: false },
+ { t: RAM, stop: 0.14, shake: 0.28, amp: 3, push: -3.2, straw: 30, y: -10 },
+ ],
+ dust: [{ t: STOMP, x: 11, n: 9 }],
+};
+
+export const create = chain([{ fx: spike, t: STOMP, x: TX }]);
diff --git a/src/fx/moves/fireball-throw.js b/src/fx/moves/fireball-throw.js
new file mode 100644
index 0000000..d65a620
--- /dev/null
+++ b/src/fx/moves/fireball-throw.js
@@ -0,0 +1,51 @@
+import { chain, READY, PAL } from "../../core/index.js";
+import * as charge from "../arcane/spell-charge.js";
+import * as fireball from "../fire/fireball.js";
+import * as blast from "../explosions/small-explosion.js";
+
+const THROW = 0.95, FLY = 0.46, HIT = THROW + FLY, SPEED = 340, TX = 190;
+
+export const meta = {
+ name: "Fireball throw",
+ desc: "He gathers fire in his hand, leans back and hurls it: the ball flies, the target takes it in a blast and comes out charred.",
+ tags: ["move", "fire", "spell", "projectile", "explosion", "one-shot"],
+ size: [356, 244],
+ origin: [64, 198],
+ duration: HIT + 5.4,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const HOLD = { ...READY, x: -3, crouch: 4, lean: 2, fx: 18, fy: -22, bx: 11, by: -17, ffx: 10, fbx: -8 };
+const THROWN = { ...READY, x: 9, crouch: 4, lean: 6, fx: 19, fy: -22, bx: -6, by: -24, ffx: 13, fbx: -10, toeB: true };
+const FLINCH = { turn: 0.9, x: 7, crouch: 5, lean: -3, fx: -4, fy: -36, bx: 5, by: -33, ffx: 4, fbx: -4 };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [-0.42, { ...READY, x: -3 }],
+ [0.08, { ...HOLD }],
+ [0.5, HOLD],
+ [THROW - 0.03, { ...HOLD, crouch: 5, lean: -2, fx: 17, bx: 5, by: -20 }],
+ [THROW, THROWN, "snap"],
+ [HIT - 0.02, { ...THROWN, crouch: 3, lean: 4 }],
+ [HIT, FLINCH, "snap"],
+ [HIT + 0.7, { ...FLINCH, crouch: 3, lean: -2 }],
+ [HIT + 1.4, { ...READY, x: 4 }],
+ [HIT + 2.1, { ...READY, x: -3 }],
+ [HIT + 5.4, { ...READY, x: -3 }],
+ ],
+ hits: [
+ { t: HIT, stop: 0.18, shake: 0.38, amp: 3, push: 3.4, straw: 34, skin: "char" },
+ { t: HIT + 4.8, push: 0, straw: 0, flash: 0, skin: null },
+ ],
+ dust: [{ t: THROW, x: 13, n: 7, dir: 1 }],
+};
+
+export const create = chain([
+ { fx: charge, t: 0.08, until: THROW, palette: PAL.fire },
+ { fx: fireball, t: THROW, until: HIT, x: (t) => 28 + (t - THROW) * SPEED, y: -22 },
+ { fx: blast, t: HIT, x: TX },
+]);
diff --git a/src/fx/moves/ground-pound.js b/src/fx/moves/ground-pound.js
new file mode 100644
index 0000000..5b8414e
--- /dev/null
+++ b/src/fx/moves/ground-pound.js
@@ -0,0 +1,49 @@
+import { chain, READY } from "../../core/index.js";
+import * as slam from "../impacts/ground-slam.js";
+
+const LAND = 0.62, TX = 80;
+
+export const meta = {
+ name: "Ground pound",
+ desc: "He coils, leaps out of frame height, hangs, and comes down like a rock: the floor cracks, shock waves race out and throw the target about as they pass.",
+ tags: ["move", "impact", "jump", "landing", "shockwave", "one-shot"],
+ size: [304, 204],
+ origin: [152, 168],
+ duration: LAND + 3.2,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const COIL = { ...READY, crouch: 8, lean: 4, fx: -6, fy: -14, bx: 3, by: -14, ffx: 8, fbx: -8 };
+const AIR = { turn: 0.8, crouch: -1, fx: -9, fy: -44, bx: 10, by: -44, ffx: 6, ffy: -8, fbx: -3, fby: -3, toeB: true };
+const TOP = { ...AIR, y: -62, fx: -10, fy: -20, bx: 11, by: -20, ffx: 7, ffy: -10, fbx: -4, fby: -10 };
+const DOWN = { turn: 0.8, y: -8, crouch: 0, fx: -5, fy: -40, bx: 6, by: -40, ffx: 3, ffy: -3, fbx: -3, fby: -3, ghost: 1 };
+const HERO_ = { y: 0, crouch: 8, lean: 5, fx: 13, fy: -8, bx: -6, by: -23, ffx: 11, fbx: -10 };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [-0.5, READY],
+ [-0.16, COIL],
+ [0, { ...COIL, crouch: 7 }],
+ [0.03, { ...AIR, y: -10, ghost: 1 }, "snap"],
+ [0.26, { ...TOP, y: -60 }, "out"],
+ [0.42, TOP],
+ [LAND - 0.005, { ...DOWN, y: -4 }, "in"],
+ [LAND, HERO_, "snap"],
+ [LAND + 0.8, { ...HERO_, crouch: 6 }],
+ [LAND + 1.3, { ...HERO_, crouch: 5, lean: 3, fx: 13, fy: -15, bx: -5, by: -20 }],
+ [LAND + 1.8, READY],
+ [LAND + 3.2, READY],
+ ],
+ hits: [
+ { t: LAND, stop: 0.2, shake: 0.5, amp: 4, target: false },
+ { t: LAND + 0.14, stop: 0.04, push: 3, straw: 26, y: -8 },
+ { t: LAND + 0.44, push: -1.6, straw: 8, y: -8, flash: 0 },
+ ],
+ dust: [{ t: 0.03, x: 0, n: 8 }],
+};
+
+export const create = chain([{ fx: slam, t: LAND }]);
diff --git a/src/fx/moves/holy-smite.js b/src/fx/moves/holy-smite.js
new file mode 100644
index 0000000..8afbf29
--- /dev/null
+++ b/src/fx/moves/holy-smite.js
@@ -0,0 +1,40 @@
+import { chain, READY } from "../../core/index.js";
+import * as smite from "../holy/smite.js";
+
+const BOLT = 0.47, TX = 118;
+
+export const meta = {
+ name: "Holy smite",
+ desc: "Both hands go up and a glint marks the target; he brings them down and a bolt of light drops like a hammer, leaving the target blanched.",
+ tags: ["move", "holy", "spell", "strike", "one-shot"],
+ size: [252, 182],
+ origin: [42, 151],
+ duration: 2.8,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const UP = { turn: 1.15, crouch: -1, fx: -7, fy: -44, bx: 8, by: -44, ffx: -3, fbx: 4 };
+const DOWN = { ...READY, crouch: 5, lean: 5, fx: 17, fy: -29, bx: 13, by: -25, ffx: 12, fbx: -10, toeB: true };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [-0.42, READY],
+ [-0.04, UP],
+ [BOLT - 0.01, { ...UP, y: -1 }],
+ [BOLT, DOWN, "snap"],
+ [1.1, { ...DOWN, crouch: 3, lean: 3 }],
+ [1.7, READY],
+ [2.8, READY],
+ ],
+ hits: [
+ { t: BOLT, stop: 0.14, shake: 0.32, amp: 3, push: 2.8, straw: 24, skin: "holy", y: -30 },
+ { t: 2.3, push: 0, straw: 0, flash: 0, skin: null },
+ ],
+ dust: [{ t: BOLT, x: 14, n: 6, dir: 1 }],
+};
+
+export const create = chain([{ fx: smite, t: 0, x: TX }]);
diff --git a/src/fx/moves/ice-lance-throw.js b/src/fx/moves/ice-lance-throw.js
new file mode 100644
index 0000000..08361a8
--- /dev/null
+++ b/src/fx/moves/ice-lance-throw.js
@@ -0,0 +1,47 @@
+import { chain, READY, PAL } from "../../core/index.js";
+import * as charge from "../arcane/spell-charge.js";
+import * as lance from "../ice/ice-lance.js";
+import * as burst from "../ice/snowflake-burst.js";
+
+const THROW = 0.8, FLY = 0.34, HIT = THROW + FLY, TX = 170, SPEED = (TX - 34) / FLY;
+
+export const meta = {
+ name: "Ice lance throw",
+ desc: "Frost gathers into a spear in his hand, he throws it like a javelin, and the target ices over in a burst of snowflakes and shivers.",
+ tags: ["move", "ice", "spell", "projectile", "one-shot"],
+ size: [310, 136],
+ origin: [86, 134],
+ duration: HIT + 3.2,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const HOLD = { ...READY, x: -3, crouch: 4, lean: 2, fx: 18, fy: -22, bx: 11, by: -17, ffx: 10, fbx: -8 };
+const THROWN = { ...READY, x: 9, crouch: 4, lean: 6, fx: 19, fy: -24, bx: -6, by: -24, ffx: 13, fbx: -10, toeB: true };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [-0.4, { ...READY, x: -3 }],
+ [0.06, { ...HOLD }],
+ [THROW - 0.2, HOLD],
+ [THROW - 0.03, { ...HOLD, crouch: 5, lean: -2, fx: 17, bx: 5, by: -20 }],
+ [THROW, THROWN, "snap"],
+ [HIT + 0.3, { ...THROWN, crouch: 3, lean: 4 }],
+ [HIT + 0.9, { ...READY, x: -3 }],
+ [HIT + 3.2, { ...READY, x: -3 }],
+ ],
+ hits: [
+ { t: HIT, stop: 0.13, shake: 0.2, amp: 2, push: 2.4, straw: 12, skin: "ice", shiver: 1.4, y: -26 },
+ { t: 2.75, push: 0.3, straw: 0, flash: 0, skin: null },
+ ],
+ dust: [{ t: THROW, x: 13, n: 6, dir: 1, c: "#d8f2ff" }],
+};
+
+export const create = chain([
+ { fx: charge, t: 0.06, until: THROW, palette: PAL.ice },
+ { fx: lance, t: THROW, until: HIT, x: (t) => 34 + (t - THROW) * SPEED, y: -24 },
+ { fx: burst, t: HIT, x: TX, y: -26 },
+]);
diff --git a/src/fx/moves/lightning-call.js b/src/fx/moves/lightning-call.js
new file mode 100644
index 0000000..c931c21
--- /dev/null
+++ b/src/fx/moves/lightning-call.js
@@ -0,0 +1,42 @@
+import { chain, READY } from "../../core/index.js";
+import * as strike from "../lightning/lightning-strike.js";
+
+const BOLT = 0.76, TX = 130;
+
+export const meta = {
+ name: "Lightning call",
+ desc: "An arm goes up, a sigil lights under the target, and on the downswing a thick bolt comes down on it; the target jolts through the aftershocks.",
+ tags: ["move", "lightning", "spell", "strike", "one-shot"],
+ size: [290, 266],
+ origin: [42, 231],
+ duration: 3,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const UP = { ...READY, crouch: 1, lean: -2, fx: 2, fy: -44, bx: 8, by: -19, ffx: 7, fbx: -5 };
+const DOWN = { ...READY, crouch: 5, lean: 5, fx: 18, fy: -27, bx: -7, by: -24, ffx: 12, fbx: -10, toeB: true };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [0, READY],
+ [0.26, UP],
+ [BOLT - 0.04, { ...UP, y: -1, crouch: -1 }],
+ [BOLT, DOWN, "snap"],
+ [1.4, { ...DOWN, crouch: 3, lean: 4 }],
+ [2, READY],
+ [3, READY],
+ ],
+ hits: [
+ { t: BOLT, stop: 0.14, shake: 0.32, amp: 3, push: 2.8, straw: 24, skin: "shock", shiver: 1.2 },
+ { t: 1.04, stop: 0.03, push: 1.2, straw: 8 },
+ { t: 1.26, stop: 0.03, push: -1, straw: 6 },
+ { t: 2.5, push: 0, straw: 0, flash: 0, skin: null },
+ ],
+ dust: [{ t: BOLT, x: 14, n: 6, dir: 1 }],
+};
+
+export const create = chain([{ fx: strike, t: 0, x: TX }]);
diff --git a/src/fx/moves/meteor-call.js b/src/fx/moves/meteor-call.js
new file mode 100644
index 0000000..434a9b5
--- /dev/null
+++ b/src/fx/moves/meteor-call.js
@@ -0,0 +1,50 @@
+import { chain, READY } from "../../core/index.js";
+import * as circle from "../arcane/magic-circle-cast.js";
+import * as meteor from "../fire/meteor.js";
+
+const BOLT = 1.52, HIT = 2.05, TX = 170;
+
+export const meta = {
+ name: "Meteor call",
+ desc: "A long chant: a circle draws itself round him, it flares, he points, and a burning rock comes down on the target and flattens the scene.",
+ tags: ["move", "fire", "spell", "meteor", "ultimate", "one-shot"],
+ size: [380, 240],
+ origin: [92, 212],
+ duration: HIT - 0.62 + 5,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const CHANT = { turn: 1.1, crouch: 1, fx: -1, fy: -26, bx: 2, by: -26, armsFront: true, hy: 1, ffx: -3, fbx: 4 };
+const UP = { turn: 1.15, crouch: -1, fx: -7, fy: -44, bx: 8, by: -44, ffx: -3, fbx: 4 };
+const POINT = { ...READY, crouch: 3, lean: 5, fx: 17, fy: -37, bx: -6, by: -24, ffx: 12, fbx: -9, toeB: true };
+const FLINCH = { turn: 0.9, x: -3, crouch: 6, lean: -4, fx: -4, fy: -36, bx: 5, by: -33, ffx: 4, fbx: -4 };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [-0.34, READY],
+ [0, CHANT],
+ [0.75, { ...CHANT, crouch: 2 }],
+ [1.4, UP],
+ [BOLT - 0.02, { ...UP, y: -1 }],
+ [BOLT, POINT, "snap"],
+ [HIT - 0.02, { ...POINT, crouch: 3 }],
+ [HIT, FLINCH, "snap"],
+ [HIT + 0.9, { ...FLINCH, crouch: 3, lean: -2 }],
+ [HIT + 1.7, { ...READY, x: 0 }],
+ [HIT + 4.3, READY],
+ ],
+ hits: [
+ { t: BOLT, stop: 0.06, shake: 0.16, amp: 2, target: false },
+ { t: HIT, stop: 0.22, shake: 0.55, amp: 4, push: 3.8, straw: 44, skin: "char" },
+ { t: HIT + 3.9, push: 0, straw: 0, flash: 0, skin: null },
+ ],
+};
+
+export const create = chain([
+ { fx: circle, t: 0 },
+ { fx: meteor, t: HIT - 0.62, x: TX },
+]);
diff --git a/src/fx/moves/pistol-shots.js b/src/fx/moves/pistol-shots.js
new file mode 100644
index 0000000..c735d97
--- /dev/null
+++ b/src/fx/moves/pistol-shots.js
@@ -0,0 +1,38 @@
+import { chain, READY } from "../../core/index.js";
+import * as muzzle from "../projectiles/muzzle-pistol.js";
+import * as tracer from "../projectiles/bullet-tracer.js";
+import * as spark from "../impacts/hit-spark.js";
+
+const SHOTS = [0.14, 0.42, 0.7], FLY = 0.12, TX = 180, BY = -32, MX = 28;
+
+export const meta = {
+ name: "Pistol shots",
+ desc: "Three aimed shots: the gun kicks up each time and settles, tracers cross the floor, and the target staggers under each hit.",
+ tags: ["move", "gun", "pistol", "projectile", "ranged", "one-shot"],
+ size: [378, 76],
+ origin: [111, 72],
+ duration: 2.6,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const REST_ = { ...READY, weapon: "pistol", sa: 0.9, fx: 10, fy: -17, bx: 7, by: -16 };
+const AIM = { ...REST_, crouch: 3, lean: 2, fx: 18, fy: -28, sa: 0, bx: 12, by: -25, ffx: 11, fbx: -9 };
+const KICK = { ...AIM, lean: 0, fx: 16, fy: -33, sa: -0.45, by: -28 };
+const keys = SHOTS.flatMap((t) => [[t, AIM], [t + 0.001, KICK, "snap"], [t + 0.14, AIM]]);
+export const act = {
+ target: { x: TX },
+ poses: [[-0.36, REST_], [-0.06, AIM], ...keys, [1.2, { ...AIM, crouch: 1 }], [1.7, REST_], [2.6, REST_]],
+ hits: SHOTS.map((t, i) => ({ t: t + FLY, stop: i === 2 ? 0.08 : 0.04, shake: 0.1, amp: 1 + (i === 2 ? 1 : 0), push: i % 2 ? -1.8 : 2, straw: 10, y: -30, kick: 1 })),
+};
+
+export const create = chain([
+ ...SHOTS.flatMap((t) => [
+ { fx: muzzle, t, x: MX, height: -BY },
+ { fx: tracer, t, until: t + FLY, x: (u) => MX + 4 + (u - t) * ((TX - MX - 14) / FLY), y: BY },
+ { fx: spark, t: t + FLY, x: TX - 10, height: 28 },
+ ]),
+]);
diff --git a/src/fx/moves/rocket-launcher.js b/src/fx/moves/rocket-launcher.js
new file mode 100644
index 0000000..2ac031c
--- /dev/null
+++ b/src/fx/moves/rocket-launcher.js
@@ -0,0 +1,50 @@
+import { chain, READY } from "../../core/index.js";
+import * as muzzle from "../projectiles/muzzle-shotgun.js";
+import * as rocket from "../projectiles/rocket.js";
+import * as blast from "../explosions/small-explosion.js";
+
+const FIRE = 0.6, FLY = 0.56, HIT = FIRE + FLY, TX = 200, MY = -21, MX = 34;
+
+export const meta = {
+ name: "Rocket launcher",
+ desc: "He drops to one knee, shoulders the tube and fires: the kick shoves him back along the floor, the rocket crawls out on its jet and the target goes up.",
+ tags: ["move", "gun", "rocket", "projectile", "explosion", "one-shot"],
+ size: [480, 244],
+ origin: [178, 198],
+ duration: HIT + 5.4,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const REST_ = { ...READY, weapon: "launcher", two: true, sa: -1, fx: 9, fy: -19 };
+const KNEEL = { ...READY, weapon: "launcher", two: true, sa: 0, fx: 9, fy: -17, crouch: 6, lean: 2, ffx: 12, fbx: -9 };
+const KICKED = { ...KNEEL, x: -6, sa: -0.12, fx: 4, fy: -19, lean: -4, crouch: 5 };
+export const act = {
+ target: { x: TX },
+ poses: [
+ [-0.52, REST_],
+ [-0.18, KNEEL],
+ [FIRE - 0.001, { ...KNEEL, crouch: 7 }],
+ [FIRE, KICKED, "snap"],
+ [FIRE + 0.36, { ...KNEEL, x: -6 }],
+ [HIT + 0.9, { ...KNEEL, x: -6, crouch: 5, lean: 1 }],
+ [HIT + 1.5, { ...REST_, x: -3 }],
+ [HIT + 2.2, { ...REST_, x: 0 }],
+ [HIT + 5.4, REST_],
+ ],
+ hits: [
+ { t: FIRE, stop: 0.06, shake: 0.22, amp: 2, target: false },
+ { t: HIT, stop: 0.2, shake: 0.45, amp: 4, push: 3.8, straw: 44, skin: "char" },
+ { t: HIT + 4.8, push: 0, straw: 0, flash: 0, skin: null },
+ ],
+ dust: [{ t: FIRE, x: -16, n: 10, dir: -1 }],
+};
+
+export const create = chain([
+ { fx: muzzle, t: FIRE, x: MX, height: -MY },
+ { fx: rocket, t: FIRE, until: HIT, x: (t) => MX + 10 + (t - FIRE) ** 1.5 * ((TX - MX - 16) / FLY ** 1.5), y: MY },
+ { fx: blast, t: HIT, x: TX },
+]);
diff --git a/src/fx/moves/sword-combo.js b/src/fx/moves/sword-combo.js
new file mode 100644
index 0000000..4a0fbb1
--- /dev/null
+++ b/src/fx/moves/sword-combo.js
@@ -0,0 +1,40 @@
+import { chain, shiftKeys, shiftHits, READY } from "../../core/index.js";
+import * as slash from "../melee/sword-slash.js";
+import * as double from "../melee/double-slash.js";
+import * as cleave from "../melee/heavy-cleave.js";
+
+const A = 0, B = 0.5, C = 1.04, STEP = 10, FINISH = C + 0.335;
+
+export const meta = {
+ name: "Sword combo",
+ desc: "Three strokes walking forward: a slash, a crossing double cut, and a two-handed cleave into the floor that throws the target about.",
+ tags: ["move", "melee", "sword", "combo", "one-shot"],
+ size: [264, 150],
+ origin: [72, 130],
+ duration: FINISH + 1.6,
+ loop: false,
+ fps: 30,
+ bg: "ground",
+ actor: 2,
+ options: { seed: 1 },
+};
+
+const until = (keys, t) => keys.filter((k) => k[0] <= t);
+const STAND_ = { ...READY, weapon: "sword", fx: 11, fy: -15, sa: 0.38 };
+export const act = {
+ target: { x: 118 },
+ poses: [
+ ...shiftKeys(until(slash.act.poses, 0.3), A),
+ ...shiftKeys(until(double.act.poses, 0.27).filter((k) => k[0] >= -0.14), B, { dx: STEP }),
+ ...shiftKeys(cleave.act.poses.filter((k) => k[0] >= -0.3), C, { dx: STEP * 2, weapon: "sword" }),
+ [FINISH + 1.6, { ...STAND_, x: STEP * 2 - 4 }],
+ ],
+ hits: [...shiftHits(slash.act.hits, A), ...shiftHits(double.act.hits, B), ...shiftHits(cleave.act.hits, C)],
+ dust: [...shiftHits(slash.act.dust, A).map((d) => ({ ...d })), ...shiftHits(cleave.act.dust, C).map((d) => ({ ...d, x: d.x + STEP * 2 }))],
+};
+
+export const create = chain([
+ { fx: slash, t: A },
+ { fx: double, t: B, x: STEP },
+ { fx: cleave, t: C, x: STEP * 2 },
+]);
diff --git a/src/fx/nature/leaf-storm.js b/src/fx/nature/leaf-storm.js
index 65f4cf8..1921a4a 100644
--- a/src/fx/nature/leaf-storm.js
+++ b/src/fx/nature/leaf-storm.js
@@ -1,7 +1,7 @@
// The leaves' tumble (turning as they go, flipping over through edge-on, palettes of autumn and green) is adapted
// from Sprite Fusion's open-source falling leaves (https://www.spritefusion.com/pixel-art-vfx/falling-leaves),
// MIT License, Copyright (c) 2026 Hugo Duprez.
-import { cycle, fit, rng, smooth, clamp, lerp, TAU, WHITE } from "../../core/index.js";
+import { cycle, fit, rng, smooth, clamp, lerp, TAU, WHITE, READY } from "../../core/index.js";
import { drawLeaf } from "./_lib.js";
export const meta = {
@@ -22,6 +22,17 @@ export const meta = {
},
};
+const UP = { turn: 1.1, crouch: 0, fx: -13, fy: -37, bx: 13, by: -37, ffx: -3, fbx: 4 };
+export const act = {
+ poses: [
+ [0, UP],
+ [0.6, { ...UP, lean: 2, fy: -40, by: -33 }],
+ [1.2, { ...UP, crouch: -1 }],
+ [1.8, { ...UP, lean: -2, fy: -33, by: -40 }],
+ [2.4, UP],
+ ],
+};
+
const SY = 0.3, TOP = 64;
const ringR = (y) => 15 + 9 * clamp(-y / TOP);
diff --git a/src/fx/nature/root-snare.js b/src/fx/nature/root-snare.js
index be3ef65..e5516f8 100644
--- a/src/fx/nature/root-snare.js
+++ b/src/fx/nature/root-snare.js
@@ -1,7 +1,7 @@
// The hold-then-break (it closes round the character, holds with glints, cracks, then bursts into tumbling
// pieces, mist and light) is adapted from Sprite Fusion's open-source ice freeze (https://www.spritefusion.com/pixel-art-vfx/ice),
// MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, sparkle, clamp, smooth, ease, lerp, rand, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, sparkle, clamp, smooth, ease, lerp, rand, TAU, WHITE, READY } from "../../core/index.js";
import { drawRock, stoneShape, drawLeaf, floorCrack } from "./_lib.js";
export const meta = {
@@ -22,6 +22,24 @@ export const meta = {
},
};
+const GRAB = { turn: 0.9, crouch: 3, fx: -12, fy: -34, bx: 12, by: -28, ffx: -2, fbx: 3 };
+export const act = {
+ poses: [
+ [-0.24, { ...READY, ffx: -2, fbx: 3 }],
+ [0.3, { turn: 0.9, lean: -1, crouch: 2, fx: -10, fy: -24, bx: 11, by: -24, ffx: -2, fbx: 3 }],
+ [0.62, GRAB, "snap"],
+ [0.86, { ...GRAB, lean: -3, fy: -37, by: -27 }],
+ [1.1, { ...GRAB, lean: 3, fy: -27, by: -37 }],
+ [1.34, { ...GRAB, lean: -3, fy: -37, by: -27 }],
+ [1.58, { ...GRAB, lean: 3, fy: -27, by: -37 }],
+ [1.75, { ...GRAB, crouch: 6 }],
+ [1.8, { turn: 1.1, crouch: -1, y: -3, fx: -14, fy: -36, bx: 15, by: -36, ffx: -3, ffy: -6, fbx: 4, fby: -6 }, "snap"],
+ [2.05, { ...READY, y: 0, crouch: 5 }],
+ [2.7, { ...READY, ffx: -2, fbx: 3 }],
+ ],
+ hits: [{ t: 0.62, stop: 0.05, shake: 0.1, amp: 1 }, { t: 1.75, stop: 0.04, shake: 0.14, amp: 2 }],
+};
+
const SY = 0.34, CINCH = 0.62, BREAK = 1.75, NP = 48;
// one root: from the floor outside the feet it spirals in round the legs and climbs, thinning to its tip
diff --git a/src/fx/scifi/force-field.js b/src/fx/scifi/force-field.js
index f09eb8a..2297fe0 100644
--- a/src/fx/scifi/force-field.js
+++ b/src/fx/scifi/force-field.js
@@ -1,7 +1,7 @@
// The hit recipe (a tracer from the right, a flash and a ripple over a hex shell mapped by longitude and
// latitude, sparks glancing off) is adapted from Sprite Fusion's open-source shield
// (https://www.spritefusion.com/pixel-art-vfx/shield), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { P, Rng, fit, sparkle, band, bolt, forks, clamp, smooth, rand, hex, TAU, WHITE } from "../../core/index.js";
+import { P, Rng, fit, sparkle, band, bolt, forks, clamp, smooth, rand, hex, TAU, WHITE, READY } from "../../core/index.js";
import { Ghosts, flash, since } from "./_lib.js";
export const meta = {
@@ -23,6 +23,23 @@ export const meta = {
},
};
+const HOLD = { turn: 1, crouch: 3, lean: 1, fx: -9, fy: -38, bx: 10, by: -38, ffx: -5, fbx: 6 };
+const HIT_ = { ...HOLD, x: -2, crouch: 5, lean: -3 };
+export const act = {
+ poses: [
+ [0, HOLD],
+ [0.42, HOLD],
+ [0.42, HIT_, "snap"],
+ [0.7, { ...HOLD, x: -1 }],
+ [1.1, HOLD],
+ [1.5, HOLD],
+ [1.5, { ...HIT_, crouch: 4, lean: -2 }, "snap"],
+ [1.75, HOLD],
+ [2.4, HOLD],
+ ],
+ hits: [{ t: 0.42, stop: 0.07, shake: 0.16, amp: 2 }, { t: 1.5, stop: 0.03, shake: 0.08, amp: 1 }],
+};
+
const S3 = Math.sqrt(3), SA = 0.13, CA = Math.sqrt(1 - SA * SA); // we look down on the dome a little
const G = 6.3, KY = 1.12; // hex plates per radian of longitude, and their stretch in latitude
// the shots, once a loop: a heavy one that cracks the shell, a lighter one lower down that it shrugs off
diff --git a/src/fx/scifi/glitch.js b/src/fx/scifi/glitch.js
index 8453a00..55da934 100644
--- a/src/fx/scifi/glitch.js
+++ b/src/fx/scifi/glitch.js
@@ -14,6 +14,28 @@ export const meta = {
options: { palette: ["#14101f", "#3b1f5c", "#ff2e63", "#ff7aa8", "#2ef2ff", "#b4fbff", "#ffffff"], seed: 7 },
};
+const TWITCH_A = { turn: 0.3, lean: 3, crouch: 1, fx: 13, fy: -31, bx: 6, by: -14, hx: 1 };
+const TWITCH_B = { turn: 1.2, lean: -3, crouch: 0, fx: -9, fy: -14, bx: 14, by: -31, hx: -1 };
+const FINE = {};
+export const act = {
+ onBody: true,
+ poses: [
+ [0, FINE],
+ [0.3, TWITCH_A, "snap"],
+ [0.37, TWITCH_B, "snap"],
+ [0.44, TWITCH_A, "snap"],
+ [0.53, FINE, "snap"],
+ [1.1, TWITCH_B, "snap"],
+ [1.23, FINE, "snap"],
+ [1.7, TWITCH_A, "snap"],
+ [1.8, { ...TWITCH_B, crouch: 3 }, "snap"],
+ [1.9, TWITCH_A, "snap"],
+ [2, TWITCH_B, "snap"],
+ [2.07, FINE, "snap"],
+ [2.4, FINE],
+ ],
+};
+
const FPS = 30, NF = Math.round(meta.duration * FPS);
// the bursts: [first frame, last frame, how hard]
const BURSTS = [[9, 16, 0.8], [33, 37, 0.5], [51, 62, 1]];
diff --git a/src/fx/scifi/scanner.js b/src/fx/scifi/scanner.js
index 3c9f98d..84d1d0e 100644
--- a/src/fx/scifi/scanner.js
+++ b/src/fx/scifi/scanner.js
@@ -15,6 +15,21 @@ export const meta = {
options: { palette: ["#03140a", "#06301a", "#0c5a2c", "#16893e", "#2cc256", "#7cf08c", "#d0ffd4", "#ffffff"], seed: 22 },
};
+const STIFF = { turn: 0.9, crouch: -1, fx: -7, fy: -14, bx: 8, by: -14, ffx: -3, fbx: 4 };
+const OK_ = { turn: 0.9, fx: -9, fy: -37, bx: 8, by: -15, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [
+ [0, {}],
+ [0.3, STIFF, "snap"],
+ [1.75, STIFF],
+ [1.85, OK_, "snap"],
+ [2.5, OK_],
+ [2.8, {}],
+ [3.2, {}],
+ ],
+};
+
const D = meta.duration, LOCK = 0.3, SCAN0 = 0.42, SCAN1 = 1.6, DONE = 1.75, LET = 2.5;
// the body: its outline pixels by row, and each row's extent, worked out once per actor
diff --git a/src/fx/scifi/warp-in.js b/src/fx/scifi/warp-in.js
index 46b6b48..5c9ed18 100644
--- a/src/fx/scifi/warp-in.js
+++ b/src/fx/scifi/warp-in.js
@@ -1,7 +1,7 @@
// The column (bands of the ramp across it, strands, pulses scrolling along it, a guide thread before it lands,
// rings riding it) is adapted from Sprite Fusion's open-source holy light
// (https://www.spritefusion.com/pixel-art-vfx/holy-light), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, band, sparkle, clamp, smooth, lerp, ease, rand, mix, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, band, sparkle, clamp, smooth, lerp, ease, rand, mix, TAU, WHITE, READY } from "../../core/index.js";
export const meta = {
name: "Warp in",
@@ -17,6 +17,19 @@ export const meta = {
options: { palette: ["#0b1030", "#152a63", "#1d4f9e", "#2582d2", "#36b9ee", "#8ae8ff", "#d4fbff", "#ffffff"], width: 15, seed: 3 },
};
+const IN = { crouch: 7, lean: 3, fx: 9, fy: -12, bx: 12, by: -12, ffx: 8, fbx: -6 };
+export const act = {
+ onBody: true,
+ follow: 0,
+ poses: [
+ [0, IN],
+ [1.82, IN],
+ [2.05, { crouch: 3, fx: 8, fy: -19, bx: 8, by: -18, ffx: 4, fbx: -3 }],
+ [2.5, READY],
+ [3, READY],
+ ],
+};
+
// the beats: the guide thread, the slam, the tube opens, the scan, the cooling, the beam narrows, it snaps shut
const SLAM = 0.34, OPEN = 0.52, SCAN0 = 0.62, SCAN1 = 1.4, COOL = 0.42, DONE = SCAN1 + COOL, CLOSE = 1.9, SNAP = 2.16;
const TOP = -meta.origin[1];
diff --git a/src/fx/scifi/warp-out.js b/src/fx/scifi/warp-out.js
index d92043a..11d867a 100644
--- a/src/fx/scifi/warp-out.js
+++ b/src/fx/scifi/warp-out.js
@@ -1,7 +1,7 @@
// The breakup (the outline flickering on, a white hero frame, the body bursting into bits of light) follows
// Sprite Fusion's open-source blink (https://www.spritefusion.com/pixel-art-vfx/movement), MIT License,
// Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, band, sparkle, clamp, smooth, lerp, ease, rand, mix, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, band, sparkle, clamp, smooth, lerp, ease, rand, mix, TAU, WHITE, READY } from "../../core/index.js";
export const meta = {
name: "Warp out",
@@ -17,6 +17,19 @@ export const meta = {
options: { palette: ["#0b1030", "#152a63", "#1d4f9e", "#2582d2", "#36b9ee", "#8ae8ff", "#d4fbff", "#ffffff"], seed: 4 },
};
+const SET = { turn: 1, crouch: 3, fx: -9, fy: -15, bx: 10, by: -15, ffx: -3, fbx: 4 };
+const RAISED = { ...SET, crouch: 0, fx: -11, fy: -29, bx: 12, by: -29 };
+export const act = {
+ onBody: true,
+ follow: 0,
+ poses: [
+ [-0.3, READY],
+ [0.1, SET],
+ [0.42, RAISED, "snap"],
+ [2.6, RAISED],
+ ],
+};
+
// the beats: it charges, flashes white, breaks up into the beam, the beam lifts away
const FLASH = 0.42, BREAK0 = 0.5, BREAK1 = 1.1, LIFT = 1.3, GONE = 1.62, TOP = -meta.origin[1];
diff --git a/src/fx/shadow/curse.js b/src/fx/shadow/curse.js
index 989f6a0..882315b 100644
--- a/src/fx/shadow/curse.js
+++ b/src/fx/shadow/curse.js
@@ -1,6 +1,6 @@
// The tint that floods the character and the gas round it are adapted from Sprite Fusion's open-source poison
// aura (https://www.spritefusion.com/pixel-art-vfx/poison), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Bits, P, B, Rng, fit, sparkle, smooth, ease, noise, TAU, WHITE, mix, luma } from "../../core/index.js";
+import { Particles, Bits, P, B, Rng, fit, sparkle, smooth, ease, noise, TAU, WHITE, mix, luma, READY } from "../../core/index.js";
import { VOID, Puffs, PK, attract, ringFast, unlight } from "./_lib.js";
export const meta = {
@@ -17,6 +17,23 @@ export const meta = {
options: { palette: VOID, bone: ["#170f26", "#4a3a6e", "#7f6ea6", "#b3a4d4", "#e2d8f6"], seed: 9 },
};
+const COWER = { turn: 1, crouch: 6, lean: 2, hy: 1, fx: -6, fy: -38, bx: 7, by: -38, ffx: -4, fbx: 5 };
+export const act = {
+ onBody: true,
+ poses: [
+ [-0.2, READY],
+ [0.3, { turn: 0.9, hy: -1, fx: -9, fy: -19, bx: 10, by: -19, ffx: -3, fbx: 4 }],
+ [0.55, COWER, "snap"],
+ [0.8, { ...COWER, crouch: 7 }],
+ [1.2, { ...COWER, crouch: 6, lean: 3 }],
+ [1.72, { ...COWER, crouch: 7, lean: 2 }],
+ [2.1, { turn: 1, crouch: 4, lean: 3, hy: 2, fx: -8, fy: -15, bx: 9, by: -15, ffx: -4, fbx: 5 }],
+ [2.9, { turn: 1, crouch: 3, lean: 1, fx: -8, fy: -16, bx: 9, by: -16, ffx: -3, fbx: 4 }],
+ [3.4, READY],
+ ],
+ hits: [{ t: 0.55, stop: 0.09, shake: 0.2, amp: 2 }],
+};
+
// where the skull hangs, and the beats: it stamps in, burns, cracks, breaks
const SY = -60, STAMP = 0.55, CRACK = 1.72, BREAK = 1.98;
diff --git a/src/fx/shadow/life-steal.js b/src/fx/shadow/life-steal.js
index e8ca1a0..939c177 100644
--- a/src/fx/shadow/life-steal.js
+++ b/src/fx/shadow/life-steal.js
@@ -1,4 +1,4 @@
-import { Particles, P, Rng, fit, sparkle, clamp, smooth, ease, TAU, WHITE, mix, luma } from "../../core/index.js";
+import { Particles, P, Rng, fit, sparkle, clamp, smooth, ease, TAU, WHITE, mix, luma, READY } from "../../core/index.js";
import { ringFast, Drops } from "./_lib.js";
export const meta = {
@@ -15,6 +15,29 @@ export const meta = {
options: { palette: ["#14040a", "#3a0a14", "#6a101c", "#a01824", "#d42a30", "#ff5a50", "#ff9a8a", "#ffe6de"], dark: "#2a1040", seed: 11 },
};
+const GRASP = { ...READY, crouch: 3, lean: 3, fx: 17, fy: -28, bx: -6, by: -21, ffx: 10, fbx: -9 };
+const FED = { turn: 1.15, crouch: 0, lean: -3, hy: -1, fx: -13, fy: -37, bx: 14, by: -37, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ follow: 0,
+ target: { x: 104 },
+ poses: [
+ [-0.46, READY],
+ [-0.2, { ...READY, crouch: 4, lean: -2, fx: 3, fy: -27, bx: 8, by: -20 }],
+ [0, GRASP, "snap"],
+ [0.4, GRASP],
+ [0.7, { ...GRASP, fx: 13, fy: -26, lean: 1 }],
+ [0.8, { ...FED, crouch: 2 }, "snap"],
+ [1.22, FED],
+ [1.7, { turn: 1, crouch: 2, fx: -11, fy: -26, bx: 12, by: -26, ffx: -3, fbx: 4 }],
+ [2.2, READY],
+ ],
+ hits: [
+ { t: 0.01, stop: 0.07, shake: 0.12, amp: 1, push: 1.6, straw: 12, skin: "red", y: -24 },
+ { t: 1.6, push: 0, straw: 0, flash: 0, skin: null },
+ ],
+};
+
// the target point on the right, the caster's heart; when the orbs turn for home
const TX = 104, TY = -24, HX = 1, HY = -20, N = 7;
diff --git a/src/fx/spawn/disintegrate.js b/src/fx/spawn/disintegrate.js
index 15b7216..adaf697 100644
--- a/src/fx/spawn/disintegrate.js
+++ b/src/fx/spawn/disintegrate.js
@@ -1,7 +1,7 @@
// The flickering outline, the white silhouette flash and the body's own pixels flying off as bits of light are
// adapted from Sprite Fusion's open-source movement (https://www.spritefusion.com/pixel-art-vfx/movement),
// MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, band, sparkle, clamp, smooth, ease, rand, noise, noise2, TAU, WHITE, mix, scale } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, band, sparkle, clamp, smooth, ease, rand, noise, noise2, TAU, WHITE, mix, scale, READY } from "../../core/index.js";
import { bodyOf, rimOf } from "./_lib.js";
export const meta = {
@@ -23,6 +23,17 @@ export const meta = {
},
};
+const AGONY = { turn: 1.15, crouch: 0, hy: -1, fx: -14, fy: -36, bx: 15, by: -36, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [
+ [-0.2, READY],
+ [0.05, { turn: 1, crouch: 3, fx: -9, fy: -16, bx: 10, by: -16, ffx: -3, fbx: 4 }],
+ [0.3, AGONY],
+ [3.4, AGONY],
+ ],
+};
+
const FLASH = 0.42, WHITE_T = 0.07, P0 = FLASH + WHITE_T, PEEL = 1.2, CORE_Y = -20;
export const actorAlpha = (t) => (t < FLASH - 0.1 ? 1 : 0);
diff --git a/src/fx/spawn/dissolve-burn.js b/src/fx/spawn/dissolve-burn.js
index c65882b..22b5774 100644
--- a/src/fx/spawn/dissolve-burn.js
+++ b/src/fx/spawn/dissolve-burn.js
@@ -1,6 +1,6 @@
// The flames that cool into smoke, the embers and the smouldering glow are adapted from Sprite Fusion's
// open-source fire (https://www.spritefusion.com/pixel-art-vfx/fire), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, PF, Rng, fit, clamp, smooth, ease, rand, noise, WHITE, hex, mix } from "../../core/index.js";
+import { Particles, Lights, P, PF, Rng, fit, clamp, smooth, ease, rand, noise, WHITE, hex, mix, READY } from "../../core/index.js";
import { bodyOf } from "./_lib.js";
export const meta = {
@@ -21,6 +21,20 @@ export const meta = {
},
};
+const WRITHE = { turn: 1, crouch: 2, fx: -13, fy: -35, bx: 13, by: -26, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [
+ [-0.16, READY],
+ [0.4, { turn: 1, crouch: 2, fx: -9, fy: -22, bx: 10, by: -22, ffx: -3, fbx: 4 }],
+ [0.8, WRITHE],
+ [1.2, { ...WRITHE, lean: 2, fy: -26, by: -36 }],
+ [1.6, { ...WRITHE, lean: -2, fy: -36, by: -26 }],
+ [2.1, { ...WRITHE, crouch: 5, lean: 2, fx: -8, fy: -38, bx: 9, by: -38 }],
+ [3.6, { ...WRITHE, crouch: 6, lean: 2, fx: -8, fy: -36, bx: 9, by: -36 }],
+ ],
+};
+
const IGNITE = 0.15, BURN = 1.9, CHAR = [hex("#100908"), hex("#22130e"), hex("#3a2016")];
export const actorAlpha = () => 0;
diff --git a/src/fx/spawn/respawn-beam.js b/src/fx/spawn/respawn-beam.js
index 102e4d2..038aa83 100644
--- a/src/fx/spawn/respawn-beam.js
+++ b/src/fx/spawn/respawn-beam.js
@@ -1,6 +1,6 @@
// The beam's slam, strands, rings and the sparks thrown along the floor are adapted from Sprite Fusion's
// open-source holy-light (https://www.spritefusion.com/pixel-art-vfx/holy-light), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, band, sparkle, clamp, smooth, ease, rand, TAU, WHITE, mix } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, band, sparkle, clamp, smooth, ease, rand, TAU, WHITE, mix, READY } from "../../core/index.js";
import { bodyOf, rimOf } from "./_lib.js";
export const meta = {
@@ -21,6 +21,19 @@ export const meta = {
},
};
+const SET = { turn: 1, crouch: 4, fx: -9, fy: -14, bx: 10, by: -14, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ follow: 0,
+ poses: [
+ [0, SET],
+ [1.4, SET],
+ [1.72, { turn: 1.15, crouch: -1, fx: -13, fy: -36, bx: 14, by: -36, hy: -1, ffx: -3, fbx: 4 }],
+ [2.1, READY],
+ [2.5, READY],
+ ],
+};
+
const SLAM = 0.32, WRITE0 = SLAM + 0.08, WRITE = 0.95, DONE = WRITE0 + WRITE, LIFT = DONE + 0.12;
export const actorAlpha = (t) => (t < DONE + 0.04 ? 0 : 1);
diff --git a/src/fx/spawn/shatter-death.js b/src/fx/spawn/shatter-death.js
index 9c72ee0..6009732 100644
--- a/src/fx/spawn/shatter-death.js
+++ b/src/fx/spawn/shatter-death.js
@@ -1,13 +1,13 @@
// The faceted ice shell, the cracks, and the shards, mist and glints of the burst are adapted from Sprite
// Fusion's open-source ice (https://www.spritefusion.com/pixel-art-vfx/ice), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Bits, Lights, P, B, Rng, fit, crystal, sparkle, clamp, smooth, ease, rand, TAU, WHITE, mix } from "../../core/index.js";
+import { Particles, Bits, Lights, P, B, Rng, fit, crystal, sparkle, clamp, smooth, ease, rand, TAU, WHITE, mix, READY } from "../../core/index.js";
import { bodyOf } from "./_lib.js";
export const meta = {
name: "Shatter death",
desc: "Frost races up the body and seals it in faceted ice, a glint sweeps it, cracks spread from the chest, then it bursts into its own facets that tumble, bounce and melt.",
tags: ["spawn", "death", "ice", "freeze", "shatter", "shards", "one-shot"],
- size: [168, 96],
+ size: [172, 96],
origin: [84, 84],
duration: 3.3,
loop: false,
@@ -20,6 +20,13 @@ export const meta = {
},
};
+const FEAR = { turn: 0.9, lean: -2, crouch: 2, fx: -9, fy: -31, bx: 9, by: -31, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [[-0.2, READY], [0.08, FEAR, "snap"], [0.3, { ...FEAR, lean: -3, fy: -34 }], [0.5, FEAR], [3.3, FEAR]],
+ hits: [{ t: 0.5, stop: 0.02, shake: 0.06, amp: 1 }, { t: 1.4, stop: 0.09, shake: 0.26, amp: 3 }],
+};
+
const LOCK = 0.5, CRACK = 1.05, BURST = 1.4;
export const actorAlpha = (t) => (t < BURST ? 1 : 0);
diff --git a/src/fx/spawn/soul-rise.js b/src/fx/spawn/soul-rise.js
index 71e4e5e..9521e75 100644
--- a/src/fx/spawn/soul-rise.js
+++ b/src/fx/spawn/soul-rise.js
@@ -1,6 +1,6 @@
// The pale ghost of the body and the motes it sheds follow Sprite Fusion's open-source movement and heal
// (https://www.spritefusion.com/pixel-art-vfx/movement), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, Rng, fit, band, clamp, smooth, ease, rand, WHITE, hex, luma } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, band, clamp, smooth, ease, rand, WHITE, hex, luma, READY } from "../../core/index.js";
import { bodyOf, rimOf } from "./_lib.js";
export const meta = {
@@ -21,6 +21,21 @@ export const meta = {
},
};
+const SLUMP = { crouch: 8, lean: 6, hy: 2, fx: 7, fy: -9, bx: 11, by: -9, ffx: 9, fbx: -8 };
+export const act = {
+ onBody: true,
+ follow: 0,
+ poses: [
+ [-0.2, READY],
+ [0.3, { turn: 1, crouch: 2, hy: -1, fx: -10, fy: -24, bx: 11, by: -24, ffx: -3, fbx: 4 }],
+ [0.7, { turn: 0.7, crouch: 4, lean: 3, hy: 1, fx: 2, fy: -14, bx: 8, by: -14, ffx: 4, fbx: -3 }],
+ [1.1, SLUMP],
+ [2.7, SLUMP],
+ [3.2, { ...SLUMP, crouch: 7 }],
+ ],
+ dust: [{ t: 1.1, x: 0, n: 5 }],
+};
+
const LEAVE = 0.35, TOP = 2.05, GONE = 2.55, SHADOW = hex("#0c0f1e");
export function create(o) {
diff --git a/src/fx/status/_lib.js b/src/fx/status/_lib.js
index bc624f2..107093a 100644
--- a/src/fx/status/_lib.js
+++ b/src/fx/status/_lib.js
@@ -219,6 +219,12 @@ const EYES = new WeakMap();
export function eyes(a) {
let list = EYES.get(a.mask);
if (list) return list;
+ // a body that says where its eyes would go: a blank head still needs somewhere to go pink, burn or shut
+ if (a.eyes) {
+ list = a.eyes.map(([x, y]) => ({ x0: x, x1: x, y0: y, y1: y + 1, px: [[x, y], [x, y + 1]], skin: colorAt(a, x, y) }));
+ EYES.set(a.mask, list);
+ return list;
+ }
const S = shape(a), W = S.w, col = (x, y) => (S.on(x, y) ? colorAt(a, x, y) : 0);
const dark = (x, y) => S.on(x, y) && y < S.h * 0.4 && luma(col(x, y)) < 0.15 && S.on(x - 1, y) && S.on(x + 1, y) && S.on(x, y - 1) && S.on(x, y + 1);
const seen = new Set();
diff --git a/src/fx/status/bleeding.js b/src/fx/status/bleeding.js
index 18cbe68..5c01160 100644
--- a/src/fx/status/bleeding.js
+++ b/src/fx/status/bleeding.js
@@ -18,6 +18,13 @@ export const meta = {
options: { palette: ["#350711", "#5e0c1b", "#931327", "#c71e33", "#f2384a", "#ff8a7a"], seed: 5 },
};
+const CLUTCH = { turn: 0.7, crouch: 3, lean: 2, fx: 2, fy: -21, bx: 8, by: -14, ffx: 3, fbx: -3 };
+const BEAT_ = { ...CLUTCH, crouch: 5, lean: 4, hy: 1 };
+export const act = {
+ onBody: true,
+ poses: [[0, BEAT_], [0.18, CLUTCH], [1.2, CLUTCH], [1.2, BEAT_, "snap"], [1.38, CLUTCH], [2.4, CLUTCH], [2.4, BEAT_, "snap"]],
+};
+
const D = meta.duration, BEAT = D / 2, G = 900;
// the wounds: two on the edges of the arms and one on the front of the body. Blood runs down the body from each
diff --git a/src/fx/status/burning.js b/src/fx/status/burning.js
index d2e526f..d28f251 100644
--- a/src/fx/status/burning.js
+++ b/src/fx/status/burning.js
@@ -24,6 +24,13 @@ export const meta = {
},
};
+const A_ = { turn: 1, crouch: 2, lean: 2, fx: -13, fy: -38, bx: 12, by: -17, ffx: -3, ffy: -7, fbx: 5 };
+const B_ = { turn: 0.9, crouch: 3, lean: -2, fx: -12, fy: -17, bx: 13, by: -38, ffx: -4, fbx: 4, fby: -7 };
+export const act = {
+ onBody: true,
+ poses: [[0, A_], [0.15, B_, "snap"], [0.3, A_, "snap"], [0.45, B_, "snap"], [0.6, A_, "snap"], [0.75, B_, "snap"], [0.9, A_, "snap"], [1.05, B_, "snap"], [1.2, A_, "snap"]],
+};
+
const D = meta.duration, TICK = 0.6, WIND = -14;
const since = (t) => (((t % TICK) + TICK) % TICK);
const flare = (t) => Math.exp(-since(t) / 0.12);
diff --git a/src/fx/status/charmed.js b/src/fx/status/charmed.js
index ddafc78..4b49304 100644
--- a/src/fx/status/charmed.js
+++ b/src/fx/status/charmed.js
@@ -18,6 +18,12 @@ export const meta = {
options: { palette: ["#3a0a1e", "#7a1238", "#c4245a", "#f04e86", "#ff8ab0", "#ffc8da", "#ffffff"], seed: 8 },
};
+const SWOON = { turn: 1.1, fx: -2, fy: -28, bx: 2, by: -28, armsFront: true, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [[0, { ...SWOON, lean: -2 }], [0.6, { ...SWOON, lean: 0, crouch: 1 }], [1.2, { ...SWOON, lean: 2 }], [1.8, { ...SWOON, lean: 0, crouch: 1 }], [2.4, { ...SWOON, lean: -2 }]],
+};
+
const D = meta.duration, BEAT = D / 2;
const HEART5 = bitmap([".#.#.", "#####", "#####", ".###.", "..#.."]);
const HEART7 = bitmap([".##.##.", "#######", "#######", ".#####.", "..###..", "...#..."]);
diff --git a/src/fx/status/confused.js b/src/fx/status/confused.js
index b8d414e..1279745 100644
--- a/src/fx/status/confused.js
+++ b/src/fx/status/confused.js
@@ -22,6 +22,18 @@ export const meta = {
},
};
+const SHRUG = { turn: 1, fx: -13, fy: -26, bx: 14, by: -26, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [
+ [0, { ...SHRUG, x: 0, lean: -2 }],
+ [0.6, { ...SHRUG, x: 1, lean: 1, crouch: 1, fy: -23, by: -29, fbx: 5, fby: -6 }],
+ [1.2, { ...SHRUG, x: 2, lean: 2 }],
+ [1.8, { ...SHRUG, x: 1, lean: -1, crouch: 1, fy: -29, by: -23, ffx: -4, ffy: -6 }],
+ [2.4, { ...SHRUG, x: 0, lean: -2 }],
+ ],
+};
+
const D = meta.duration;
const QS = [
[".###.", "#...#", "....#", "...#.", "..#..", ".....", "..#.."],
diff --git a/src/fx/status/cursed.js b/src/fx/status/cursed.js
index 8d9bfdb..00358c5 100644
--- a/src/fx/status/cursed.js
+++ b/src/fx/status/cursed.js
@@ -18,6 +18,12 @@ export const meta = {
options: { palette: ["#0c0612", "#1f0f2e", "#3a1a55", "#5e2a85", "#8a3fc0", "#b86ef0", "#e0b0ff", "#ffffff"], seed: 9 },
};
+const HUNCH = { turn: 1, crouch: 4, lean: 3, hy: 1, fx: -7, fy: -33, bx: 8, by: -33, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [[0, HUNCH], [0.6, { ...HUNCH, crouch: 5 }], [1.2, { ...HUNCH, lean: 2 }], [1.8, { ...HUNCH, crouch: 5 }], [2.4, HUNCH]],
+};
+
const D = meta.duration;
const SKULL = bitmap([
"...#####...",
diff --git a/src/fx/status/frozen.js b/src/fx/status/frozen.js
index c5e2c83..7ef8ece 100644
--- a/src/fx/status/frozen.js
+++ b/src/fx/status/frozen.js
@@ -3,7 +3,7 @@ import { shape, colorAt, eyes, travel } from "./_lib.js";
export const meta = {
name: "Frozen",
- desc: "Chilled to the bone: frost ferns creep over the body, icicles hang from chin, hands and hair and drip, breath steams, snow settles, a shiver every second, frost spreads underfoot.",
+ desc: "Chilled to the bone: frost ferns creep over the body, icicles hang from chin and hands and drip, breath steams, snow settles, a shiver every second, frost spreads underfoot.",
tags: ["status", "ice", "freeze", "frozen", "cold", "chill", "debuff", "loop"],
size: [72, 64],
origin: [36, 54],
@@ -15,6 +15,12 @@ export const meta = {
options: { palette: ["#151a3d", "#212f6b", "#2c58aa", "#3a8bd8", "#62c8f4", "#a6ecff", "#dcfbff", "#ffffff"], seed: 4 },
};
+const STIFF = { turn: 0.9, crouch: 1, fx: -6, fy: -15, bx: 7, by: -15, ffx: -2, fbx: 3 };
+export const act = {
+ onBody: true,
+ poses: [[0, { ...STIFF, crouch: 2 }], [0.22, STIFF], [1, STIFF], [1, { ...STIFF, crouch: 2 }, "snap"], [1.22, STIFF], [2, { ...STIFF, crouch: 2 }]],
+};
+
const D = meta.duration, SHIVER = 1;
const since = (t) => (((t % SHIVER) + SHIVER) % SHIVER);
/** The effect draws the whole (chilled, shivering) body, so the stand-in is hidden throughout. */
diff --git a/src/fx/status/haste.js b/src/fx/status/haste.js
index b819f07..d2aed91 100644
--- a/src/fx/status/haste.js
+++ b/src/fx/status/haste.js
@@ -18,6 +18,17 @@ export const meta = {
options: { palette: ["#4c25ab", "#773ae4", "#5b6cff", "#5eb0ff", "#a3dcff", "#ccf6ff", "#ffffff"], dust: "#8a8090", seed: 4 },
};
+const RUN = { turn: 0.25, lean: 4 };
+const R1 = { ...RUN, crouch: 3, ffx: 12, ffy: -5, fbx: -10, fby: -8, toeB: true, fx: -7, fy: -19, bx: 12, by: -27 };
+const R2 = { ...RUN, crouch: 1, ffx: 4, ffy: -8, fbx: -1, fby: -5, fx: 3, fy: -18, bx: 5, by: -19 };
+const R3 = { ...RUN, crouch: 3, ffx: -10, ffy: -8, toeF: true, fbx: 12, fby: -5, fx: 14, fy: -27, bx: -5, by: -19 };
+const R4 = { ...RUN, crouch: 1, ffx: -1, ffy: -5, fbx: 4, fby: -8, fx: 5, fy: -19, bx: 3, by: -18 };
+export const act = {
+ onBody: true,
+ follow: 0,
+ poses: [[0, R1], [0.1, R2, "snap"], [0.2, R3, "snap"], [0.3, R4, "snap"], [0.4, R1, "snap"], [0.5, R2, "snap"], [0.6, R3, "snap"], [0.7, R4, "snap"], [0.8, R1, "snap"], [0.9, R2, "snap"], [1, R3, "snap"], [1.1, R4, "snap"], [1.2, R1, "snap"]],
+};
+
const D = meta.duration;
// the character's shading in three levels (dark outline, mid, light), for the after-images
diff --git a/src/fx/status/petrified.js b/src/fx/status/petrified.js
index fb44f87..5f7d760 100644
--- a/src/fx/status/petrified.js
+++ b/src/fx/status/petrified.js
@@ -1,7 +1,7 @@
// The creeping front, the branching cracks and the burst of the body into chunks, grit and dust are
// adapted from Sprite Fusion's open-source ice freeze and shatter (https://www.spritefusion.com/pixel-art-vfx/ice),
// MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Bits, Lights, P, B, Rng, fit, rand, clamp, luma, smooth, tileFbm, TAU, WHITE } from "../../core/index.js";
+import { Particles, Bits, Lights, P, B, Rng, fit, rand, clamp, luma, smooth, tileFbm, TAU, WHITE, READY } from "../../core/index.js";
import { shape, colorAt } from "./_lib.js";
export const meta = {
@@ -18,6 +18,13 @@ export const meta = {
options: { palette: ["#16141c", "#2a2733", "#433f4d", "#5f5a6a", "#7d7889", "#a29dab", "#cdc8d2", "#f0edf3"], seed: 3 },
};
+const REACH_ = { lean: 3, crouch: 2, fx: 14, fy: -29, bx: -4, by: -22, ffx: 8, fbx: -7, toeB: true };
+export const act = {
+ onBody: true,
+ poses: [[-0.16, READY], [0.08, { turn: 0.9, lean: -1, crouch: 2, fx: -8, fy: -24, bx: 9, by: -24 }, "snap"], [0.5, REACH_], [0.95, REACH_], [3.8, REACH_]],
+ hits: [{ t: 2.2, stop: 0.08, shake: 0.24, amp: 2 }],
+};
+
const CREEP = 0.95, CRACK = 1.75, SHATTER = 2.2;
/** The stand-in character is gone once the stone covers it (the statue is drawn in its place). */
diff --git a/src/fx/status/poisoned.js b/src/fx/status/poisoned.js
index 1356304..8ea6920 100644
--- a/src/fx/status/poisoned.js
+++ b/src/fx/status/poisoned.js
@@ -15,6 +15,12 @@ export const meta = {
options: { palette: ["#0e1d14", "#173320", "#23552e", "#318232", "#55b92f", "#8eea3f", "#cfff63", "#f6ffc2"], veins: "#2c1a3a", seed: 5 },
};
+const SICK = { turn: 0.8, crouch: 4, lean: 4, hy: 1, fx: 2, fy: -20, bx: 8, by: -14, ffx: 3, fbx: -3 };
+export const act = {
+ onBody: true,
+ poses: [[0, { ...SICK, x: -1, crouch: 5, lean: 5 }], [0.2, { ...SICK, x: 0 }], [0.5, { ...SICK, x: 1 }], [0.8, { ...SICK, x: 1, crouch: 5, lean: 5 }], [1, { ...SICK, x: 0 }], [1.3, { ...SICK, x: -1 }], [1.6, { ...SICK, x: -1, crouch: 5, lean: 5 }]],
+};
+
const D = meta.duration, TICK = 0.8, G = 760;
const since = (t) => (((t % TICK) + TICK) % TICK);
/** The effect draws the whole (sick, swaying) body, so the stand-in is hidden throughout. */
diff --git a/src/fx/status/rage.js b/src/fx/status/rage.js
index 3eb934a..171b95c 100644
--- a/src/fx/status/rage.js
+++ b/src/fx/status/rage.js
@@ -23,6 +23,13 @@ export const meta = {
},
};
+const SEETHE = { turn: 1, crouch: 4, fx: -13, fy: -19, bx: 13, by: -19, ffx: -8, fbx: 9 };
+const THUD = { ...SEETHE, crouch: 6, fy: -23, by: -23 };
+export const act = {
+ onBody: true,
+ poses: [[0, SEETHE], [0.05, THUD, "snap"], [0.17, SEETHE, "snap"], [0.29, { ...THUD, crouch: 5 }, "snap"], [0.4, SEETHE, "snap"], [1.2, SEETHE]],
+};
+
const D = meta.duration, LUB = 0.05, DUB = 0.29, G = 760;
const pulse = (t, at, w = 0.06) => Math.exp(-((((((t - at) % D) + D + D / 2) % D - D / 2) / w) ** 2));
const beat = (t) => pulse(t, LUB) + 0.65 * pulse(t, DUB);
diff --git a/src/fx/status/sleep.js b/src/fx/status/sleep.js
index e439757..c0048fc 100644
--- a/src/fx/status/sleep.js
+++ b/src/fx/status/sleep.js
@@ -18,6 +18,12 @@ export const meta = {
options: { palette: ["#1a1636", "#3c3a7a", "#6f78c8", "#a9b8f0", "#dfe6ff", "#ffffff"], seed: 3 },
};
+const NOD = { turn: 0.9, crouch: 1, lean: 1, hy: 2, fx: -6, fy: -14, bx: 7, by: -14, ffx: -2, fbx: 3 };
+export const act = {
+ onBody: true,
+ poses: [[0, NOD], [1.2, { ...NOD, crouch: 2, lean: 2, hy: 3 }], [2.4, NOD]],
+};
+
const D = meta.duration, NZ = 3;
// the letter at four sizes: it grows a step at a time as it rises
const ZS = [
diff --git a/src/fx/status/slowed.js b/src/fx/status/slowed.js
index 2fadb2c..6ca80b7 100644
--- a/src/fx/status/slowed.js
+++ b/src/fx/status/slowed.js
@@ -15,6 +15,13 @@ export const meta = {
options: { palette: ["#081a24", "#0e3446", "#165a6e", "#2a8a9a", "#52bcc4", "#9ee6e0", "#e2fff8", "#ffffff"], seed: 7 },
};
+const S1 = { turn: 0.3, lean: 3, crouch: 3, ffx: 11, ffy: -5, fbx: -9, fby: -5, toeB: true, fx: -5, fy: -19, bx: 11, by: -26 };
+const S2 = { turn: 0.3, lean: 3, crouch: 3, ffx: -9, ffy: -5, toeF: true, fbx: 11, fby: -5, fx: 13, fy: -26, bx: -4, by: -19 };
+export const act = {
+ onBody: true,
+ poses: [[0, S1], [1.2, S2], [2.4, S1]],
+};
+
const D = meta.duration, TICKS = 4, STEP = D / TICKS, R = 18;
// the hand's angle: it waits, pulls back a little, snaps a quarter turn, overshoots and settles
diff --git a/src/fx/status/stunned.js b/src/fx/status/stunned.js
index bfb71aa..a780fbc 100644
--- a/src/fx/status/stunned.js
+++ b/src/fx/status/stunned.js
@@ -23,6 +23,18 @@ export const meta = {
},
};
+const DAZE = { turn: 1, fx: -7, fy: -15, bx: 8, by: -15, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ poses: [
+ [0, { ...DAZE, x: -1, lean: -3, hx: -1 }],
+ [0.5, { ...DAZE, x: 0, lean: 0, crouch: 2, hy: 1, ffx: -2 }],
+ [1, { ...DAZE, x: 1, lean: 3, hx: 1 }],
+ [1.5, { ...DAZE, x: 0, lean: 0, crouch: 2, hy: 1, fbx: 3 }],
+ [2, { ...DAZE, x: -1, lean: -3, hx: -1 }],
+ ],
+};
+
const D = meta.duration, TURNS = 2, N = 5;
const STAR7 = ["...#...", "..###..", "#######", ".#####.", "..###..", ".##.##.", ".#...#."];
// a little bird facing right: body, head, eye, beak, tail, a wing that beats
diff --git a/src/fx/ui/exclamation.js b/src/fx/ui/exclamation.js
index fcf5fee..d5dd3a8 100644
--- a/src/fx/ui/exclamation.js
+++ b/src/fx/ui/exclamation.js
@@ -1,4 +1,4 @@
-import { Particles, Lights, P, Rng, fit, sparkle, clamp, seg, ease, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, Rng, fit, sparkle, clamp, seg, ease, TAU, WHITE, READY } from "../../core/index.js";
export const meta = {
name: "Exclamation",
@@ -14,6 +14,19 @@ export const meta = {
options: { palette: ["#2a1405", "#6a2e06", "#b85a0a", "#f08c14", "#ffc23a", "#ffe580", "#fff6c8", "#ffffff"], seed: 3 },
};
+const STARTLED = { turn: 1, y: -5, crouch: -1, fx: -14, fy: -34, bx: 15, by: -34, ffx: -3, ffy: -6, fbx: 4, fby: -6 };
+export const act = {
+ poses: [
+ [-0.08, READY],
+ [0, STARTLED, "snap"],
+ [0.14, { ...STARTLED, y: 0, crouch: 4, ffy: -4, fby: -4, fy: -26, by: -26 }, "in"],
+ [0.3, { turn: 1, fx: -10, fy: -23, bx: 11, by: -23, ffx: -3, fbx: 4 }],
+ [1.1, { turn: 1, fx: -10, fy: -23, bx: 11, by: -23, ffx: -3, fbx: 4 }],
+ [1.4, READY],
+ ],
+ dust: [{ t: 0.14, x: 0, n: 4 }],
+};
+
const HEAD = -40, REST = -45, POP = 1.1;
// the mark: a bar that tapers to its foot and a round dot, with a dark outline, lit down its left side,
diff --git a/src/fx/ui/level-up.js b/src/fx/ui/level-up.js
index 4d4d23a..073eb75 100644
--- a/src/fx/ui/level-up.js
+++ b/src/fx/ui/level-up.js
@@ -1,7 +1,7 @@
// The pillar's strands of light and the rings climbing it adapt Sprite Fusion's open-source holy light
// (https://www.spritefusion.com/pixel-art-vfx/holy-light), and the streaks rushing in its power-up
// (https://www.spritefusion.com/pixel-art-vfx/power-up), MIT License, Copyright (c) 2026 Hugo Duprez.
-import { Particles, Lights, P, PF, Rng, fit, band, flare, sparkle, clamp, seg, smooth, ease, noise2, fract, rand, scale, TAU, WHITE } from "../../core/index.js";
+import { Particles, Lights, P, PF, Rng, fit, band, flare, sparkle, clamp, seg, smooth, ease, noise2, fract, rand, scale, TAU, WHITE, READY } from "../../core/index.js";
import { spell, drawWord, tintActor, lightActor, haloActor } from "./_lib.js";
export const meta = {
@@ -18,6 +18,30 @@ export const meta = {
options: { palette: ["#2a1405", "#5c3008", "#9a5a0e", "#d48e18", "#f5b92c", "#ffde5e", "#fff4bc", "#ffffff"], text: "LEVEL UP!", seed: 5 },
};
+const COIL = { turn: 0.9, crouch: 7, lean: 2, fx: -6, fy: -13, bx: 7, by: -13, ffx: -5, fbx: 6 };
+const LEAP = { turn: 1.1, y: -16, crouch: -1, fx: -6, fy: -45, bx: 7, by: -44, ffx: -2, ffy: -8, fbx: 5, fby: -3, toeB: true };
+const PUMP = { turn: 0.9, crouch: 0, fx: -6, fy: -45, bx: 9, by: -15, ffx: -3, fbx: 4 };
+export const act = {
+ onBody: true,
+ follow: 0,
+ poses: [
+ [-0.3, READY],
+ [0.28, COIL],
+ [0.3, LEAP, "snap"],
+ [0.46, { ...LEAP, y: -19 }],
+ [0.72, { ...LEAP, y: 0, ffy: -4, fby: -4 }, "in"],
+ [0.74, { ...COIL, crouch: 5 }, "snap"],
+ [0.95, PUMP, "out"],
+ [1.2, { ...PUMP, crouch: 1, fy: -43 }],
+ [1.45, PUMP],
+ [2.3, { ...PUMP, fy: -41 }],
+ [2.8, READY],
+ [3.2, READY],
+ ],
+ hits: [{ t: 0.28, stop: 0.05, shake: 0.14, amp: 2 }],
+ dust: [{ t: 0.3, x: 0, n: 7 }, { t: 0.74, x: 0, n: 6 }],
+};
+
// release, pillar lifts off, pillar gone, pillar height, text top, first letter, stagger, shine, letters pop
const REL = 0.28, RET = 1.02, GONE = 1.34, TOP = 100, TY = -68, DROP = 0.5, STAG = 0.05, LANDED = 1.06, SHINE = 1.24, EXIT = 2.3;
// strands of light streaming up the pillar in dashes: where across it, how fast, dash period and length
diff --git a/tools/act.mjs b/tools/act.mjs
new file mode 100644
index 0000000..813f742
--- /dev/null
+++ b/tools/act.mjs
@@ -0,0 +1,58 @@
+#!/usr/bin/env node
+// See an effect acted out: the character, the target, the freeze on contact. Motion is what you are judging, so the
+// strip shows consecutive 12 fps steps, not a sample.
+//
+// node tools/act.mjs melee/sword-slash strip: records/act/melee-sword-slash.png
+// node tools/act.mjs melee/sword-slash --mp4 video: records/act/melee-sword-slash.mp4
+// node tools/act.mjs melee/sword-slash --sheet the whole act, character and all, as a transparent sprite sheet
+//
+// Options: --from S --to S (strip range) --step S (default 1/12) --cols N --zoom N --bg KIND --out FILE --no-target --seconds S
+
+import { join } from "node:path";
+import { ROOT, resolveIds, loadEffect, renderAct, spriteSheet, canvas, upscale, save, writeVideo } from "./lib/fxlib.mjs";
+
+const args = process.argv.slice(2), flags = {}, pos = [];
+for (let i = 0; i < args.length; i++) {
+ if (["--mp4", "--no-target", "--sheet"].includes(args[i])) flags[args[i].slice(2)] = true;
+ else if (args[i].startsWith("--")) flags[args[i].slice(2)] = args[++i];
+ else pos.push(args[i]);
+}
+const ids = resolveIds(pos);
+for (const id of ids) {
+ const fx = await loadEffect(id);
+ if (flags.sheet) {
+ const r = renderAct(fx, { fps: fx.meta.fps, bg: "none", target: !flags["no-target"], hold: 0 }), name = id.split("/")[1], base = join(ROOT, "records", "act", id.replace("/", "-"));
+ const s = spriteSheet(fx, r, name);
+ s.json.meta.pixelfx.pivot = r.pivot;
+ save(`${base}.sheet.png`, s.png);
+ save(`${base}.sheet.json`, JSON.stringify(s.json, null, 1));
+ console.log(`${id} ${r.n} frames of ${r.w} x ${r.h} -> ${base}.sheet.png`);
+ continue;
+ }
+ const r = renderAct(fx, { fps: 60, bg: flags.bg, target: !flags["no-target"], seconds: flags.seconds ? +flags.seconds : undefined });
+ const base = join(ROOT, "records", "act", id.replace("/", "-"));
+ if (flags.mp4) {
+ const k = +(flags.zoom ?? Math.max(2, Math.min(8, Math.floor(960 / Math.max(r.w, r.h)))));
+ const file = flags.out ?? base + ".mp4";
+ writeVideo(file, r, k);
+ console.log(`${id} ${r.frames.length} frames ${(r.frames.length / r.fps).toFixed(2)} s -> ${file}`);
+ } else {
+ const from = +(flags.from ?? r.frames[0].t), to = +(flags.to ?? r.frames[r.frames.length - 1].t), step = +(flags.step ?? 1 / 12), list = [];
+ let held = 0;
+ for (const f of r.frames) {
+ if (f.t < from - 1e-6 || f.t > to + 1e-6) continue;
+ if (f.t + 1e-6 >= from + list.length * step) list.push(f);
+ else if (f.frozen) held++;
+ }
+ const k = +(flags.zoom ?? 3), cols = +(flags.cols ?? 8), rows = Math.ceil(list.length / cols);
+ const img = canvas(cols * (r.w * k + 4), rows * (r.h * k + 18));
+ list.forEach((f, j) => {
+ const x = (j % cols) * (r.w * k + 4), y = Math.floor(j / cols) * (r.h * k + 18);
+ img.text(f.t.toFixed(2), x + 2, y + 3, 2);
+ img.paste(upscale(f.color, r.w, r.h, k), r.w * k, r.h * k, x, y + 16);
+ });
+ const file = flags.out ?? base + ".png";
+ save(file, img.png());
+ console.log(`${id} ${list.length} steps -> ${file}`);
+ }
+}
diff --git a/tools/check.mjs b/tools/check.mjs
index 9662381..2fbcfdc 100644
--- a/tools/check.mjs
+++ b/tools/check.mjs
@@ -6,8 +6,9 @@
// node tools/check.mjs fire ui/level-up
import { readFileSync } from "node:fs";
+import { shortfall } from "../src/core/rig.js";
import { resolveIds, allIds, loadEffect } from "./lib/fxlib.mjs";
-import { createFrame, clearFrame, painterFor, createFx, stockActor, resolveOptions, Painter, BACKDROPS } from "../src/core/index.js";
+import { createFrame, clearFrame, painterFor, createFx, createAct, poseAt, stockActor, resolveOptions, Painter, BACKDROPS } from "../src/core/index.js";
const ids = process.argv.slice(2).length ? resolveIds(process.argv.slice(2)) : allIds();
const M = 24; // margin around the canvas, to catch pixels drawn outside it
@@ -19,6 +20,54 @@ function drawAt(fx, t, frame, opts) {
if (mod.drawBack) mod.drawBack(p, t, opts);
mod.draw(p, t, opts);
}
+// an act: its data makes sense, and the body doesn't teleport when no key asked it to
+const POSE_KEYS = new Set("x y crouch lean twist turn yaw hx hy fx fy fz bx by bz ffx ffy fbx fby fzz bzz weapon sa two offWeapon sb armsFront toeF toeB face ghost wl wz pull nocked".split(" "));
+const hands = (q) => [q.fx ?? 7, q.fy ?? -14, q.bx ?? -8, q.by ?? -14];
+function checkAct(fx, errs, notes) {
+ const { mod, meta } = fx, a = mod.act, k = a.poses;
+ if (!Array.isArray(k) || !k.length) return errs.push("act.poses is empty");
+ k.forEach(([t, pose], i) => {
+ if (typeof t !== "number") errs.push(`act key ${i}: no time`);
+ if (i && t < k[i - 1][0]) errs.push(`act keys out of order at ${t}`);
+ for (const n of Object.keys(pose)) if (!POSE_KEYS.has(n)) errs.push(`act key at ${t}: unknown pose field "${n}"`);
+ });
+ // arms don't stretch: a hand asked to go further than it can falls short of where the effect needs it
+ for (const [t, pose] of k) {
+ const short = shortfall(pose);
+ if (short > 3.5) { notes.push(`act: at t = ${t} a hand falls ${short.toFixed(0)} px short of where the pose wants it: step the body in`); break; }
+ }
+ const first = k[0][0], last = k[k.length - 1][0], D = meta.duration;
+ for (const h of a.hits ?? []) {
+ if (!(h.t >= first && h.t <= Math.max(last, D))) errs.push(`act hit at ${h.t} is outside the act`);
+ if (h.stop > 0.3) notes.push(`act hit at ${h.t} freezes for ${h.stop} s: past 0.3 s it reads as a stall`);
+ }
+ if (meta.loop) {
+ if (last !== D) errs.push(`a loop's poses end at its duration (${D}), not ${last}`);
+ const from = k.findIndex(([t]) => t >= 0);
+ if (k[from]?.[0] !== 0) errs.push("a loop's poses need a key at t = 0");
+ else {
+ const A = poseAt(k, 0), B = poseAt(k, D);
+ const seam = Math.max(...hands(A).map((v, i) => Math.abs(v - hands(B)[i])), Math.abs((A.crouch ?? 0) - (B.crouch ?? 0)), Math.abs((A.x ?? 0) - (B.x ?? 0)));
+ if (seam > 2) notes.push(`act's loop has a seam: the body jumps ${seam.toFixed(0)} px from its last pose to its first`);
+ }
+ } else if (last < D - 1e-3 && last < 0) errs.push("an act's poses end before the effect starts");
+ // the smooth stretches: a hand moving more than this in one 12 fps step is a pop nobody asked for
+ for (let i = 1; i < k.length; i++) {
+ const [t0, , ] = k[i - 1], [t1, , how] = k[i];
+ if (how === "snap" || t1 - t0 < 1 / 12) continue;
+ for (let t = t0; t < t1 - 1 / 12; t += 1 / 12) {
+ const p = hands(poseAt(k, t)), q = hands(poseAt(k, t + 1 / 12)), d = Math.max(Math.hypot(p[0] - q[0], p[1] - q[1]), Math.hypot(p[2] - q[2], p[3] - q[3]));
+ if (d > 30) { notes.push(`act: a hand jumps ${d.toFixed(0)} px in one step at t = ${t.toFixed(2)}: add a key or mark it "snap"`); break; }
+ }
+ }
+ // it runs, ends and doesn't throw
+ const inst = createAct(mod, { x: 100, y: 100 }), f = createFrame(400, 300);
+ for (let i = 0; i < 900 && !inst.done(); i++) {
+ inst.update(1 / 30);
+ if (i % 3 === 0) inst.draw(clearFrame(f));
+ }
+ if (!meta.loop && !inst.done()) errs.push("the act never ends");
+}
const count = (buf, test) => {
let n = 0;
for (let i = 0; i < buf.length; i++) if (test(buf[i], i)) n++;
@@ -35,13 +84,14 @@ for (const id of ids) {
if (typeof meta.desc !== "string" || meta.desc.length < 12) errs.push("meta.desc missing or too short");
if (meta.desc?.length > 180) notes.push(`desc is ${meta.desc.length} chars (keep it under 180)`);
if (!Array.isArray(meta.tags) || !meta.tags.length) errs.push("meta.tags missing");
- if (!Array.isArray(meta.size) || meta.size.some((v) => !Number.isInteger(v) || v < 8 || v > 400)) errs.push("meta.size must be [w, h], whole pixels 8..400");
+ if (!Array.isArray(meta.size) || meta.size.some((v) => !Number.isInteger(v) || v < 8 || v > 480)) errs.push("meta.size must be [w, h], whole pixels 8..480");
if (!Array.isArray(meta.origin) || meta.origin.length !== 2) errs.push("meta.origin must be [x, y]");
if (!(meta.duration > 0 && meta.duration <= 12)) errs.push("meta.duration must be 0..12 s");
if (!BACKDROPS.includes(meta.bg)) errs.push(`meta.bg must be one of ${BACKDROPS.join(", ")}`);
const taken = Object.keys(meta.options ?? {}).filter((k) => ["x", "y", "flip", "angle", "light"].includes(k));
if (taken.length) errs.push(`option ${taken.join(", ")} is reserved for placement and glow: rename it`);
if (/Math\.random/.test(src)) errs.push("uses Math.random: use rng/rand/burst/cycle so frames repeat");
+ if (mod.act) checkAct(fx, errs, notes);
if (errs.length) throw new Error(errs.join("; "));
const [W, H] = meta.size, frame = createFrame(W + M * 2, H + M * 2, -M, -M);
diff --git a/tools/index.mjs b/tools/index.mjs
index 7f7cb7a..9b377ae 100644
--- a/tools/index.mjs
+++ b/tools/index.mjs
@@ -49,7 +49,7 @@ for (const c of categories) {
if (!list.length) continue;
md.push(`## ${c.name}`, "", `${c.blurb}.`, "", "| effect | id | | size | what it does |", "|---|---|---|---|---|");
for (const m of list)
- md.push(`| ${m.name} | \`${m.id}\` | ${m.loop ? "loop" : "one-shot"} ${m.duration}s | ${m.size[0]}×${m.size[1]} | ${m.desc.replace(/\|/g, "\\|")} |`);
+ md.push(`| ${m.name} | \`${m.id}\` | ${m.loop ? "loop" : "one-shot"} ${+m.duration.toFixed(2)}s | ${m.size[0]}×${m.size[1]} | ${m.desc.replace(/\|/g, "\\|")} |`);
md.push("");
}
writeFileSync(join(ROOT, "docs", "CATALOG.md"), md.join("\n"));
diff --git a/tools/lib/fxlib.mjs b/tools/lib/fxlib.mjs
index 6a8f1a6..5c62316 100644
--- a/tools/lib/fxlib.mjs
+++ b/tools/lib/fxlib.mjs
@@ -4,7 +4,7 @@ import { readdirSync, existsSync, statSync, writeFileSync, mkdirSync } from "nod
import { join, dirname, relative, sep } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { spawnSync } from "node:child_process";
-import { createFrame, clearFrame, createFx, composite, painterFor, drawActor, stockActor, backdrop, actorAlphaOf } from "../../src/core/index.js";
+import { createFrame, clearFrame, createFx, createAct, actBounds, actTiming, composite, painterFor, drawActor, stockActor, backdrop, actorAlphaOf } from "../../src/core/index.js";
import { rasterText, textWidth } from "../../src/core/font.js";
import { encodePNG } from "./png.mjs";
@@ -82,6 +82,44 @@ export function renderFrames(fx, opts = {}) {
return { w, h, fps, n, frames, margin: m };
}
+/**
+ * An effect acted out: the character, the target, the freeze, the shake, on a canvas big enough for all of it.
+ * Returns { w, h, fps, n, frames: [{ t (effect time, negative before it starts), frozen, color }] }.
+ */
+export function renderAct(fx, opts = {}) {
+ const { meta } = fx, fps = opts.fps ?? 60, b = actBounds(fx.mod), pad = opts.pad ?? 6;
+ const w = b.x1 - b.x0 + pad * 2, h = b.y1 - b.y0 + pad * 2, X = pad - b.x0, Y = pad - b.y0;
+ const frame = createFrame(w, h), bgKind = opts.bg ?? meta.bg, bg = bgKind === "none" ? null : backdrop(bgKind, w, h, Y);
+ const act = createAct(fx.mod, { x: X, y: Y, ...(opts.seed !== undefined ? { seed: opts.seed } : {}), ...(opts.options ?? {}) });
+ const frames = [], max = Math.round((opts.seconds ?? (meta.loop ? meta.duration * 2 - act.t : 8)) * fps);
+ const show = () => {
+ clearFrame(frame);
+ act.draw(frame, { body: opts.actor !== false, target: opts.target !== false });
+ const rgba = composite(frame, new Uint8ClampedArray(w * h * 4), bg), [sx, sy] = act.shake;
+ frames.push({ t: act.t, frozen: act.frozen, color: sx || sy ? shifted(rgba, w, h, sx, sy) : rgba, clear: rgba });
+ };
+ show();
+ for (let i = 0; i < max && !act.done(); i++) {
+ act.update(1 / fps);
+ show();
+ }
+ // a beat on the end, so a video doesn't cut off the last pose
+ if (!meta.loop) for (let i = 0; i < fps * (opts.hold ?? 0.3); i++) {
+ act.update(1 / fps);
+ show();
+ }
+ return { w, h, fps, n: frames.length, frames, pivot: [X, Y] };
+}
+function shifted(rgba, w, h, sx, sy) {
+ const out = new Uint8ClampedArray(w * h * 4);
+ for (let y = 0; y < h; y++)
+ for (let x = 0; x < w; x++) {
+ const X = Math.max(0, Math.min(w - 1, x - sx)), Y = Math.max(0, Math.min(h - 1, y - sy)), d = (y * w + x) * 4, s = (Y * w + X) * 4;
+ out[d] = rgba[s]; out[d + 1] = rgba[s + 1]; out[d + 2] = rgba[s + 2]; out[d + 3] = rgba[s + 3];
+ }
+ return out;
+}
+
/** Full-screen effects (transitions, weather, impact frames): 16:9 and at least 320 wide. They fill the screen. */
export const isScreen = (meta) => meta.size[0] >= 320 && Math.abs(meta.size[0] / meta.size[1] - 16 / 9) < 0.05;
@@ -198,7 +236,7 @@ export function spriteSheet(fx, r, name) {
app: "https://github.com/patch-gg/pixelfx", version: "1", image: `${name}.png`, format: "RGBA8888",
size: { w: cols * w, h: rows * h }, scale: "1",
frameTags: [{ name: name, from: 0, to: n - 1, direction: "forward" }],
- pixelfx: { id: fx.id, name: m.name, fps, loop: m.loop, frames: n, frameSize: [w, h], pivot: m.origin, columns: cols },
+ pixelfx: { id: fx.id, name: m.name, fps, loop: m.loop, frames: n, frameSize: [w, h], pivot: m.origin, columns: cols, ...(fx.mod.act ? { act: actTiming(fx.mod) } : {}) },
};
return { png: img.png(), json };
}
diff --git a/tools/montage.mjs b/tools/montage.mjs
index 4b030d4..7d2d2a2 100644
--- a/tools/montage.mjs
+++ b/tools/montage.mjs
@@ -10,7 +10,7 @@
import { join } from "node:path";
import { allIds, loadEffect, writeVideo, save } from "./lib/fxlib.mjs";
-import { createFrame, clearFrame, createFx, composite, backdrop, drawActor, painterFor, stockActor, rand, actorAlphaOf } from "../src/core/index.js";
+import { createFrame, clearFrame, createFx, composite, backdrop, drawActor, painterFor, stockActor, rand, actorAlphaOf, createAct, actBounds } from "../src/core/index.js";
import { categories } from "../src/fx/categories.js";
import { encodePNG } from "./lib/png.mjs";
@@ -39,7 +39,7 @@ else {
ids = ids.slice(0, cols * rows);
const W = cols * CW + (cols + 1) * gap, H = rows * CH + (rows + 1) * gap;
-const cells = [];
+const cells = [], cellPlace = {};
for (const [i, id] of ids.entries()) {
const fx = await loadEffect(id), m = fx.meta, frame = createFrame(CW, CH);
// a canvas that fits is centred; a bigger one is cropped round its anchor, keeping a strip of floor in view
@@ -47,7 +47,13 @@ for (const [i, id] of ids.entries()) {
const x = w <= CW ? Math.floor((CW - w) / 2) + ox : Math.round(CW / 2 + ox - w / 2);
const y = h <= CH ? Math.floor((CH - h) / 2) + oy : CH - Math.min(h - oy, Math.round(CH * 0.16));
const bg = backdrop(flags.bg ?? m.bg, CW, CH, y);
- cells.push({ id, fx, m, frame, x, y, bg, cx: gap + (i % cols) * (CW + gap), cy: gap + Math.floor(i / cols) * (CH + gap), delay: m.loop ? 0 : rand(i, 7) * stagger, inst: null, born: 0 });
+ if (fx.mod.act) {
+ // an act stands on the floor near the bottom of its cell, with the whole performance in view if it fits
+ const b = actBounds(fx.mod), bw = b.x1 - b.x0;
+ Object.assign(cellPlace, { x: bw <= CW ? Math.floor((CW - bw) / 2) - b.x0 : Math.round(CW / 2 + (-b.x0 - bw / 2)), y: CH - 16 });
+ }
+ const acted = !!fx.mod.act, X = acted ? cellPlace.x : x, Y = acted ? cellPlace.y : y;
+ cells.push({ id, fx, m, acted, frame, x: X, y: Y, bg: acted ? backdrop(flags.bg ?? m.bg, CW, CH, Y) : bg, cx: gap + (i % cols) * (CW + gap), cy: gap + Math.floor(i / cols) * (CH + gap), delay: m.loop ? 0 : rand(i, 7) * stagger, inst: null, born: 0 });
}
const n = Math.round(seconds * fps), frames = [], buf = new Uint8ClampedArray(CW * CH * 4);
for (let f = 0; f < n; f++) {
@@ -55,6 +61,28 @@ for (let f = 0; f < n; f++) {
for (let i = 0; i < W * H; i++) out.set([0, 0, 0, 255], i * 4);
for (const c of cells) {
const local = t - c.delay;
+ if (c.acted) {
+ if (!c.act || (c.act.done() && t - c.ended > rest)) {
+ c.act = createAct(c.fx.mod, { x: c.x, y: c.y });
+ c.ended = Infinity;
+ }
+ clearFrame(c.frame);
+ if (local >= 0) {
+ c.act.draw(c.frame);
+ c.act.update(1 / fps);
+ if (c.act.done() && c.ended === Infinity) c.ended = t;
+ }
+ composite(c.frame, buf, c.bg);
+ const [sx, sy] = local >= 0 ? c.act.shake : [0, 0];
+ for (let yy = 0; yy < CH; yy++) {
+ const from = Math.max(0, Math.min(CH - 1, yy - sy));
+ for (let xx = 0; xx < CW; xx++) {
+ const a = (from * CW + Math.max(0, Math.min(CW - 1, xx - sx))) * 4, d = ((c.cy + yy) * W + c.cx + xx) * 4;
+ out[d] = buf[a]; out[d + 1] = buf[a + 1]; out[d + 2] = buf[a + 2];
+ }
+ }
+ continue;
+ }
if (!c.inst || (!c.m.loop && local - c.born > c.m.duration + rest)) {
c.inst = createFx(c.fx.mod, { x: c.x, y: c.y });
c.born = Math.max(0, local);
diff --git a/tools/new.mjs b/tools/new.mjs
index 5b6fbe7..459e5b9 100644
--- a/tools/new.mjs
+++ b/tools/new.mjs
@@ -58,4 +58,4 @@ ${body}
`;
mkdirSync(dirname(file), { recursive: true });
writeFileSync(file, src);
-console.log(`wrote ${file}\nnext: node tools/render.mjs ${id} then look at records/${id}/contact.png`);
+console.log(`wrote ${file}\nnext: node tools/render.mjs ${id} then look at records/${id}/contact.png\na character in it? give it an act: see "Acts" in docs/AUTHORING.md, then node tools/act.mjs ${id}`);
diff --git a/tools/render.mjs b/tools/render.mjs
index bfb2034..3170397 100644
--- a/tools/render.mjs
+++ b/tools/render.mjs
@@ -10,6 +10,8 @@
// Options: --gif --mp4 --sheet (transparent PNG + JSON) --all --max N (frames in the contact sheet)
// --zoom N (contact sheet scale) --scale N (GIF/MP4) --bg dark|ground|sky|light|black|none --seed N --fps N --opts JSON --out DIR
// --no-actor --loops N (repeat a loop in the GIF/MP4)
+//
+// This shows the effect by itself, with the character standing by. tools/act.mjs shows it acted out.
import { join } from "node:path";
import { ROOT, resolveIds, loadEffect, renderFrames, contactSheet, spriteSheet, writeVideo, save } from "./lib/fxlib.mjs";
diff --git a/tools/sheets.mjs b/tools/sheets.mjs
index 6263e86..63ac79e 100644
--- a/tools/sheets.mjs
+++ b/tools/sheets.mjs
@@ -7,6 +7,7 @@
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { ROOT, allIds, resolveIds, loadEffect, renderFrames, spriteSheet, save } from "./lib/fxlib.mjs";
+import { actTiming } from "../src/core/index.js";
const ids = process.argv.length > 2 ? resolveIds(process.argv.slice(2)) : allIds();
const out = join(ROOT, "sheets"), index = [];
@@ -16,7 +17,7 @@ for (const id of ids) {
save(join(out, id + ".png"), s.png);
save(join(out, id + ".json"), JSON.stringify(s.json, null, 1));
const m = fx.meta;
- index.push({ id, name: m.name, desc: m.desc, tags: m.tags, loop: m.loop, fps: r.fps, frames: r.n, frameSize: m.size, pivot: m.origin, columns: s.json.meta.pixelfx.columns, image: `${id}.png` });
+ index.push({ id, name: m.name, desc: m.desc, tags: m.tags, loop: m.loop, fps: r.fps, frames: r.n, frameSize: m.size, pivot: m.origin, columns: s.json.meta.pixelfx.columns, image: `${id}.png`, ...(fx.mod.act ? { act: actTiming(fx.mod) } : {}) });
process.stdout.write(".");
}
if (process.argv.length <= 2) writeFileSync(join(out, "index.json"), JSON.stringify(index, null, 1));