rng(seed: number) → void
A deterministic random generator: returns a function giving numbers in [0, 1). Same seed, same sequence, on every peer.
| arg | type | description |
|---|
| seed | number | |
num(v: any, default: number) → number
| arg | type | description |
|---|
| v | any | |
| default | number | |
int(v: any, default: number, lo: number) → number
| arg | type | description |
|---|
| v | any | |
| default | number | |
| lo | number | |
push(out: { Shot }, angle: number, speed: number, delay: number) → Shot
| arg | type | description |
|---|
| out | { Shot } | |
| angle | number | |
| speed | number | |
| delay | number | |
aimed(o: ?, out: ?) → void
aimed: one bullet, or a stream of `count` along the aim with `interval` between them
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
spread(o: ?, out: ?) → void
spread: a fan of `count` bullets spread evenly over `arc`, centred on the aim
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
ring(o: ?, out: ?) → void
ring: `count` bullets evenly around a full circle, starting at the aim
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
spiral(o: ?, out: ?) → void
spiral: `count` arms evenly around the circle, the whole star turned by `spin` rad/s times t
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
doubleSpiral(o: ?, out: ?) → void
doubleSpiral: two spirals turning opposite ways, `count` shots in all (half each way)
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
flower(o: ?, out: ?) → void
flower: a ring whose speed swells into `petals` petals, `depth` deep (fraction of speed)
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
wave(o: ?, out: ?) → void
wave: a stream of `count` bullets whose angle sweeps as a sine (`amplitude` rad, `frequency` Hz)
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
shotgun(o: ?, out: ?) → void
shotgun: `count` pellets at random angles inside `arc` and speeds within `speedJitter`, seeded
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
cross(o: ?, out: ?) → void
cross: `arms` arms (4 = plus, 8 = star) of `perArm` bullets each at stepped speeds, turning with `spin`
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
wall(o: ?, out: ?) → void
wall: a line of `count` bullets across the aim, `spacing` metres apart, all flying along the
aim, with a gap of `gap` bullets left out (0 = none) at a seeded place (or `gapAt`, 0..1)
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
burstRing(o: ?, out: ?) → void
burstRing: `rings` rings of `count` bullets, `ringDelay` s apart, each turned half a step
and a little faster (`speedStep`) so they stack into a lattice
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
sunburst(o: ?, out: ?) → void
sunburst: a ring of `count` bullets alternating fast and slow (`slowRatio` of speed)
| arg | type | description |
|---|
| o | ? | |
| out | ? | |
catalog( ) → void
Every pattern's catalog entry, in catalog order: { name, title, description, tags, defaults }. A copy: changing it changes nothing here.
names( ) → void
Every pattern name, in catalog order.
has(name: string) → boolean
Whether a pattern of this name exists.
| arg | type | description |
|---|
| name | string | |
count(pattern: string, opts: any?) → number
How many shots `shots(pattern, opts)` returns, without building them.
| arg | type | description |
|---|
| pattern | string | |
| opts | any? | |
shots(pattern: string, opts: any?) → void
The shots of one volley of `pattern`: { { angle (radians, XZ, 0 = +X, pi/2 = +Z), speed (m/s), delay (s), ox?, oz? (start offset m) } }. Opts not given take the pattern's catalog defaults; `angle` is the aim (default 0), `t` the time (spirals turn with it), `seed` the random seed. Pure and deterministic.
| arg | type | description |
|---|
| pattern | string | |
| opts | any? | |
dir(angle: number) → void
The direction of an angle as x, z (cos, sin).
| arg | type | description |
|---|
| angle | number | |
angleTo(x1: number, z1: number, x2: number, z2: number) → number
The angle from (x1, z1) to (x2, z2) in this kit's convention (0 = +X, pi/2 = +Z).
| arg | type | description |
|---|
| x1 | number | |
| z1 | number | |
| x2 | number | |
| z2 | number | |