@korial29/tiny-fps 0.225.4 → 0.226.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import type { Vec3 } from './mesh';
2
- import type { Voice } from './sfx';
2
+ import type { Air, Voice } from './sfx';
3
3
  /** A sound that plays on and on, started on its first set. */
4
4
  export interface Loop {
5
5
  /** Volume (a fader, 0 silence and 1 its level) and speed (pitch) to move to, eased over a fraction of a second. */
@@ -80,7 +80,7 @@ export declare const MIMIC: {
80
80
  export declare const SPRITES: (() => Promise<string>)[];
81
81
  /** The players' voices (voice/cast.ts), loaded the same way after the announcer's. */
82
82
  export declare const VOICED: (() => Promise<string>)[];
83
- export declare const createAudio: (layers?: Voice[][], sprites?: (() => Promise<string>)[], song?: () => Float32Array, voiced?: (() => Promise<string>)[], theme?: () => Float32Array) => Audio;
83
+ export declare const createAudio: (layers?: Voice[][], sprites?: (() => Promise<string>)[], song?: () => Float32Array, voiced?: (() => Promise<string>)[], theme?: () => Float32Array, air?: Air) => Audio;
84
84
  /** The mute choice of the last visit. Storage throws when blocked: no memory then. */
85
85
  export declare const savedMute: () => boolean;
86
86
  /** Flips mute, remembers it, and returns the new state. */
@@ -0,0 +1,14 @@
1
+ import type { WorldDef } from '../shared/world';
2
+ /**
3
+ * The wreck by part, each its vertices in the renderer's format: the hull's three sections, the
4
+ * hold inside the middle one, the two wings, the debris, the camps. Read from the map at the call.
5
+ */
6
+ export declare const parts: (def: WorldDef) => {
7
+ hull: number[];
8
+ hold: number[];
9
+ wings: number[];
10
+ debris: number[];
11
+ camps: number[];
12
+ };
13
+ /** Its vertices, in the renderer's format. */
14
+ export declare const hulk: (def: WorldDef) => number[];
@@ -0,0 +1,15 @@
1
+ import type { WorldDef } from '../shared/world';
2
+ /**
3
+ * Landfall's forest and headlands by part, each its vertices in the renderer's format: the
4
+ * headlands' rocks, the first row's palms (TRUNKS and their twins), the trees behind, the
5
+ * undergrowth and the far canopy. The lists and the relief are read here, at the call.
6
+ */
7
+ export declare const parts: (def: WorldDef) => {
8
+ rocks: number[];
9
+ palms: number[];
10
+ forest: number[];
11
+ brush: number[];
12
+ canopy: number[];
13
+ };
14
+ /** Its vertices, in the renderer's format. */
15
+ export declare const jungle: (def: WorldDef) => number[];
@@ -7,6 +7,13 @@ export declare const HEAVENS: Vec3;
7
7
  * of the bound) and, at most 360 m more from a spot on the bound, inside the far clip (FAR).
8
8
  */
9
9
  export declare const SKY = 800;
10
+ /**
11
+ * A rounded stone, smooth: the sphere ICO[lod - 1] (or the triangles given) thrown onto a form from its middle (`pt` gives
12
+ * the point for a unit vector), each point's normal the mean of the faces round it, so it shades
13
+ * as one rounded mass with no facet. One tone a stone, darker at the foot (from `g` up a third of
14
+ * the way to `top`); what is wholly under the ground (`floor`, if given) is not drawn.
15
+ */
16
+ export declare const stone: (o: number[], lod: number | Vec3[][], pt: (u: Vec3) => Vec3, g: number, top: number, s: number, shade: number, floor?: (x: number, z: number) => number) => void;
10
17
  /** The pebbles' three sizes, metres across: the largest is under a step's height, a body walks through any of them. */
11
18
  export declare const PEBBLES: number[];
12
19
  /**
@@ -274,6 +274,35 @@ export declare const music: () => Float32Array;
274
274
  export declare const moon: () => Float32Array;
275
275
  /** The music of each map by its key; the others play music(). */
276
276
  export declare const SONGS: Record<string, () => Float32Array>;
277
+ /**
278
+ * A map's ambience, played by audio.ts round the listener: beds that loop, each as loud as where
279
+ * he stands makes it, and a cry now and then from afar.
280
+ */
281
+ export interface Air {
282
+ /** The beds: mono loops at MUSIC_RATE whose end joins their start. */
283
+ beds: (() => Float32Array)[];
284
+ /** Each bed's volume, 0 to 1, for a listener at `eye` at `t` seconds, written into `out`. */
285
+ mix(eye: readonly number[], t: number, out: number[]): void;
286
+ /** The cry's voices, and where one comes from, given two numbers drawn in [0, 1). */
287
+ cry: Voice[];
288
+ from(u: number, v: number): [number, number, number];
289
+ }
290
+ /**
291
+ * The surf, twelve seconds: under the far sea's rumble, two waves a loop and three weaker ones
292
+ * between them. Each swells, breaks (the noise opens up: its low-pass rises with the wave) and
293
+ * draws back down the sand as a long hiss. Every envelope is a whole number of periods a loop and
294
+ * the filters run a quarter of it unheard first, so the end joins the start.
295
+ */
296
+ export declare const surf: () => Float32Array;
297
+ export declare const breeze: () => Float32Array;
298
+ export declare const blaze: () => Float32Array;
299
+ /**
300
+ * The forest's insects, six seconds: three cicadas, each a high sine that trills and comes and
301
+ * goes. Every frequency is a whole number of periods a loop: its end joins its start.
302
+ */
303
+ export declare const chirr: () => Float32Array;
304
+ /** The ambience of each map by its key; the others have none. */
305
+ export declare const AIRS: Record<string, Air>;
277
306
  /**
278
307
  * The menus' theme, 8-bit: thirty-two bars in E minor at 105 bpm, a chord every bar or half bar.
279
308
  * The lead on the soft triangle, then on a pulse, then wide and with an echo at the climax, then
@@ -0,0 +1,37 @@
1
+ import type { WorldDef } from '../shared/world';
2
+ /** The sand's layer: lit paint (its colour in c.x, c.y, c.w) that the shader grains, ripples and wets. No other material's band holds it. */
3
+ export declare const SAND = -1.09;
4
+ /** The sea's layer: under -2.5 it casts no shadow, and the shader draws all of it. c.x is the water's depth there, metres. */
5
+ export declare const SEA = -5;
6
+ /**
7
+ * How far over FRAME.water the sea's sheet is drawn, metres. The shader moves the waterline between
8
+ * that and as much under the level (SWASH), so the sea runs up the sand and back around the level
9
+ * the map knows.
10
+ */
11
+ export declare const LIFT = 0.05;
12
+ /** The sand and the far island, in the renderer's format. */
13
+ export declare const shore: (def: WorldDef) => number[];
14
+ /** The sea, in the renderer's format: drawn after everything that stands in it, blended (render.ts). */
15
+ export declare const lagoon: (def: WorldDef) => number[];
16
+ /**
17
+ * The sky's low clouds, in K0(): `s` the sky's colour in the direction `d`. A layer seen from
18
+ * under, kept to a band over the horizon, drifting.
19
+ */
20
+ export declare const SKY = "if(d.y>0.){vec2 q=d.xz/(d.y+.1)*2.+T*.003;float f=vn(q)+.5*vn(q*2.3+5.)+.25*vn(q*5.1);\nf=smoothstep(1.05,1.4,f)*smoothstep(0.,.05,d.y)*(1.-smoothstep(.12,.4,d.y));\ns=mix(s,vec3(1.22,1.2,1.17)*(.8+.3*max(dot(d,O),0.)),f*.9);}";
21
+ /**
22
+ * The sea's pixel, in main(), given `fog`: the share of haze over it, an expression of `ds`, the
23
+ * distance to the eye. It is drawn twice, blended: with Z at 2 what the water lets through of
24
+ * what is under it (red goes first, so pale sand turns turquoise, then blue), and with Z at 1 the
25
+ * light it adds: what the water scatters, the sky mirrored on its waves (more at a grazing angle),
26
+ * the sun's glitter, the foam along the sand and the haze.
27
+ */
28
+ export declare const WATER: (fog: string) => string;
29
+ /**
30
+ * The sand's pixel, in main(), before its normal is taken: `c` its colour, `h` its height for the
31
+ * bump, `pw` the pixel's size on it. Patches, dimples the size of a footprint, wind ripples and
32
+ * grain, each faded out where a pixel no longer holds it. `bw` is how wet it is: dark and smooth
33
+ * up to where the sea last ran, with the light's net on the bed under the water.
34
+ */
35
+ export declare const GRAIN: string;
36
+ /** The wet sand's mirror, in main(), after the light: `k` the sky its normal reflects, `fr` the fresnel term. */
37
+ export declare const WET = "c+=bw*k*(.02+.3*fr);";
@@ -0,0 +1,32 @@
1
+ import type { WorldDef } from '../shared/world';
2
+ /**
3
+ * The smoke's layer: under -2.5 it casts no shadow, and the shader draws all of it. c.x is how far
4
+ * up its column a point is (0 its foot, 1 its top; up its flame for a fire), c.y a number of its
5
+ * column's own, c.w 1 on a flame.
6
+ */
7
+ export declare const SMOKE = -6;
8
+ /** A ball's bands and slices: its outline fades to nothing in the shader, so few are enough. */
9
+ export declare const BANDS: number, SLICES: number;
10
+ /**
11
+ * Where it burns: the foot of each column (x, y, z), how high it rises, and its radius at the
12
+ * foot and at the top. On the rear of each nacelle's back and on the far end of each engine in
13
+ * the lagoon, both halves; and high against each of the hull's four broken ends, thinner, so the way
14
+ * through the gaps and over the back stays in sight.
15
+ */
16
+ export declare const FIRES: number[][];
17
+ /**
18
+ * The smoke's and the fires' vertices, in the renderer's format: drawn after the sky, blended
19
+ * (render.ts). A column's balls grow as they rise and lean inland, each overlapping the last;
20
+ * three flames stand round its foot.
21
+ */
22
+ export declare const plumes: (def: WorldDef) => number[];
23
+ /**
24
+ * The smoke's and the flames' pixel, in main(), given `fog` as the sea's: the share of haze over
25
+ * it, an expression of `ds`. Blended with its colour times its alpha: a flame has none and only
26
+ * adds its light. A ball is see-through at its outline (`a`), so no edge of it shows; what shows
27
+ * is a noise in the world, the same through every ball, that climbs and drifts with the wind. The
28
+ * smoke thins as it rises, is lit on the sun's side and from under by its fire, and fades out
29
+ * within three metres of the eye. A flame is the same noise, faster, cut ever narrower up its
30
+ * height (C.x), white-yellow at its heart and bright enough to bloom.
31
+ */
32
+ export declare const PLUME: (fog: string) => string;
@@ -0,0 +1,135 @@
1
+ import type { WorldDef } from './world';
2
+ type Vec3 = [number, number, number];
3
+ /** The beach is 200 m long: a point at z has its twin at ZED - z. */
4
+ export declare const ZED = 200;
5
+ /**
6
+ * The frame every piece is laid on, metres. Across x, from the sea to the forest: the water is too
7
+ * deep at `sea`, the waterline is at `shore` (the sand is at `water` there), the first trees stand
8
+ * at `trees`, nothing is walked past `east`. Along z the headlands' rocks close the beach before
9
+ * `cape` and after ZED - `cape`.
10
+ */
11
+ export declare const FRAME: {
12
+ sea: number;
13
+ shore: number;
14
+ trees: number;
15
+ east: number;
16
+ cape: number;
17
+ water: number;
18
+ };
19
+ /**
20
+ * Feet under this have gone under: the runner is put back at a spawn (WorldDef.floor, the fall of
21
+ * Highline's roofs, no new rule). The water's surface is y 0 and the eye is 1.6 m over the feet:
22
+ * at 1.4 m of water a standing runner still looks over it.
23
+ */
24
+ export declare const DEPTH = -1.4;
25
+ /** Where nobody goes, x and z: the ghost wall behind the first palms and the one in each headland. */
26
+ export declare const EDGE: {
27
+ east: number;
28
+ cape: number;
29
+ };
30
+ /**
31
+ * The wreck, a hull along x on the centre line, broken in three: each section's x0 and x1. The
32
+ * tail is in the water, the middle on the sand, the nose in the trees; the two gaps are crossed on
33
+ * foot. `r` is the hull's radius and `sunk` how deep its axis sits under r, so its back is at
34
+ * 2 r - sunk over the sand. `axis` is the height of each section's axis: each lies level, 2 m in
35
+ * the ground it came to rest on.
36
+ */
37
+ export declare const HULL: {
38
+ r: number;
39
+ sunk: number;
40
+ sections: number[][];
41
+ axis: number[];
42
+ };
43
+ /**
44
+ * The hull's cross-section as stacked boxes: each a height over the axis and the half width from
45
+ * there up to the next. A wall under the axis, the widest at it, two shoulders and the back, flat
46
+ * and 5 m wide.
47
+ */
48
+ export declare const RINGS: number[][];
49
+ /** The middle section's hold: its floor and ceiling, the half width inside, the ends inside, the doors' x0 and x1 and their height. */
50
+ export declare const HOLD: {
51
+ floor: number;
52
+ ceil: number;
53
+ half: number;
54
+ x: number[];
55
+ door: number[];
56
+ lintel: number;
57
+ /** The two bulkheads across it (x0, x1), each with a doorway `way` wide on the centre line. */
58
+ walls: number[][];
59
+ way: number;
60
+ };
61
+ /**
62
+ * Red's wing, torn at the root and lying as a ramp from the sand up to the hull's back: its root
63
+ * on the middle section (x0, x1 at z = ZED / 2 + HULL.r) and its tip on the sand (x0, x1, z).
64
+ * Blue's is its twin.
65
+ */
66
+ export declare const WING: {
67
+ root: number[];
68
+ tip: number[];
69
+ };
70
+ /**
71
+ * Red's engines, torn off: the middle of each nacelle (x, z), its radius and length, lying along z.
72
+ * One on the sand by the wing, run through; one in the lagoon off the tail's end, stood on.
73
+ */
74
+ export declare const ENGINES: number[][];
75
+ /** Red's camp: the escape pod its flag stands by (x, z, radius). */
76
+ export declare const POD: number[];
77
+ /** The camp's ground, level. */
78
+ export declare const CAMP = 1.25;
79
+ /**
80
+ * Red's headland, the rocks that close the beach past z = ZED - FRAME.cape, from the sea to the
81
+ * trees: each x, z, radius, height and seed, a form of moon.ts rockOf(). Blue's are their twins.
82
+ * The map makes them solid and the scenery draws them, both from this list.
83
+ */
84
+ export declare const ROCKS: number[][];
85
+ /**
86
+ * Red's first row of palms, the trunks a runner can touch: each x, z and radius at the foot. The
87
+ * map makes them solid and the scenery draws a palm on each; the forest behind is drawn only.
88
+ * The first stands clear of the nose's flank.
89
+ */
90
+ export declare const TRUNKS: number[][];
91
+ /** Metres between two nodes of the lattice. */
92
+ export declare const CELL = 4;
93
+ /**
94
+ * Where the ground is level, x0, z0, x1, z1 (z in red's half) and the height: the way in to the
95
+ * hold's door through the bank, the tip of the wing, the camp. Level for 6 m round each, so that
96
+ * the lattice's triangles are, and back to the sand 6 m further; none within 12 m of the next.
97
+ */
98
+ export declare const FLATS: number[][];
99
+ /** The furrow the hull ploughed: how deep on its line, and how high the bank of sand thrown up on each side, 12 m off it. */
100
+ export declare const FURROW: number[];
101
+ /**
102
+ * The height of the ground at a lattice node. The beach: the water's surface is y 0 and the sand
103
+ * meets it at x 30, rises to 2.5 m at the trees and goes on up under them; the bed falls a metre
104
+ * in ten, 3 m down at x 0, and keeps falling. Low dunes on the upper beach. The furrow along the
105
+ * centre line from the waterline to the nose, a mound pushed up before the nose. The same on both
106
+ * sides of the centre line. Only + - * /, Math.sqrt and the integer hash.
107
+ */
108
+ export declare const at: (x: number, z: number) => number;
109
+ /** The ground as it is walked on: at()'s lattice in float32, each square two triangles, as ground() in relief.ts reads it. */
110
+ export declare const walked: (x: number, z: number) => number;
111
+ /** A piece of the wreck or of a camp for whoever draws it: what it is and its box. */
112
+ export interface Piece {
113
+ kind: string;
114
+ min: Vec3;
115
+ max: Vec3;
116
+ }
117
+ /**
118
+ * What the scenery draws on the map's boxes, both halves, blue's mirrored: the hull's sections
119
+ * (x0, x1, the axis' height), every piece of the wreck and of the camps by kind (hull, hold, heap,
120
+ * frame, raft, wing, nacelle, engine, float, pod, dais, crate, shelter, panel, container, gear), and the
121
+ * headlands' rocks where they stand.
122
+ */
123
+ export declare const LAYOUT: {
124
+ hull: number[][];
125
+ pieces: Piece[];
126
+ crags: {
127
+ at: number[];
128
+ R: number;
129
+ H: number;
130
+ s: number;
131
+ parts: number[][];
132
+ }[];
133
+ };
134
+ export declare const BEACH: WorldDef;
135
+ export {};
@@ -98,8 +98,6 @@ export type Squad = {
98
98
  export declare const squad: (team: number, players: readonly Seen[], flags: readonly FlagState[], world: World) => Squad;
99
99
  export declare class Bot {
100
100
  readonly id: number;
101
- /** The route it prefers, an index of nav.ts's ROUTES. */
102
- private prefer;
103
101
  /** Its way: the points it goes through, walking or on a leg; the last is its goal or as near as it gets. */
104
102
  private steps;
105
103
  /** The goal of the way, and the tick it was planned. */
@@ -37,8 +37,10 @@ export interface Nav {
37
37
  out: Edge[][];
38
38
  /** Cell key to the rectangles that touch the cell, PORTAL metres round included. */
39
39
  grid: Map<number, number[]>;
40
- /** The route each rectangle is a crossing of, an index of ROUTES; -1 for none. */
40
+ /** The route each rectangle is a crossing of, under `ways`; -1 for none. */
41
41
  route: Int8Array;
42
+ /** How many routes the world has for its bots to spread over: ROUTES', or Landfall's five ways. */
43
+ ways: number;
42
44
  }
43
45
  /** A point a bot goes to: walking, or flying a leg there (`edge` the link of the leg). */
44
46
  export interface Step {
@@ -46,6 +48,8 @@ export interface Step {
46
48
  leg?: Leg;
47
49
  edge?: Edge;
48
50
  }
51
+ /** Metres over the kill floor a bot keeps its feet: deeper water (Landfall's lagoon) is no floor. */
52
+ export declare const WADE = 0.3;
49
53
  /** The routes, fastest first: the Spine, Midtown, the Lowline. */
50
54
  export declare const ROUTES: import("./routes").Route[];
51
55
  /** Where a leg ends: a jump steers for its `to`, which is on the roof it lands on. */
@@ -68,7 +72,7 @@ export declare const navOf: (w: World) => Nav;
68
72
  export declare const funnel: (s: number[], ports: [number[], number[]][], t: number[]) => number[][];
69
73
  /**
70
74
  * The points a bot goes through from `a` to `b`, the last `b` or, when no way gets there, the
71
- * nearest point it can get to. The links of the routes other than `prefer` (an index of ROUTES)
75
+ * nearest point it can get to. The links of the routes other than `prefer` (a route under `ways`)
72
76
  * cost more, so bots that prefer different ones spread over the map. Off the mesh, `b` alone.
73
77
  */
74
78
  export declare const path: (nav: Nav, w: World, a: Vec3, b: Vec3, prefer?: number) => Step[];
@@ -74,3 +74,16 @@ export declare const UP: Record<'terrace' | 'viaduct' | 'plaza' | 'forecourt', {
74
74
  }>;
75
75
  /** What is left of a way up from a roof `y` high: the legs from the first ledge above it, with the run-up to it. */
76
76
  export declare const above: (legs: Leg[], y: number) => Leg[];
77
+ /**
78
+ * Landfall's way round the wreck's tail, through the lagoon where the bed is out of depth (flown
79
+ * by beach.test.ts): from `start` in red's shallows, walked west so the first jump is come at
80
+ * along its line, onto the float aground there, to the second float, up onto the engine and down
81
+ * to the raft on the centre line (`out`); and from the raft back by the same boxes to red's
82
+ * shallows (`in`). Blue's are their mirror across z = 100, so a way round is `out` then the
83
+ * mirror of `in`.
84
+ */
85
+ export declare const LAGOON: {
86
+ start: P;
87
+ out: Leg[];
88
+ in: Leg[];
89
+ };
@@ -66,8 +66,8 @@ export interface WorldDef {
66
66
  fog?: [r: number, g: number, b: number, density: number];
67
67
  /** The share of GRAVITY that pulls the players down. Absent: 1. */
68
68
  gravity?: number;
69
- /** What is drawn around the play area: the city (street, towers, parks, traffic) or the moon (crater rim, base, stars, the Earth). Absent: the city. */
70
- scenery?: 'city' | 'moon';
69
+ /** What is drawn around the play area: the city (street, towers, parks, traffic) the moon (crater rim, base, stars, the Earth) or the beach (sand, sea, forest, wreck). Absent: the city. */
70
+ scenery?: 'city' | 'moon' | 'beach';
71
71
  /** Whether the runners wear space helmets, with the pack on the back, its hose and the breath. */
72
72
  helmets?: boolean;
73
73
  /** Whether the runners wear armour over a grey suit: white with space helmets, else in the team's colour. */
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@korial29/tiny-fps",
3
3
  "description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
4
4
  "license": "Apache-2.0",
5
- "version": "0.225.4",
5
+ "version": "0.226.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"