@korial29/tiny-fps 0.11.0 → 0.13.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,60 +0,0 @@
1
- import type { Bullet, Monster, PlayerState } from '../shared/types';
2
- import type { Vec3 } from './mesh';
3
- /** Seconds a walker's blow takes. */
4
- export declare const SWING = 0.3;
5
- /** Limb phase per metre walked: a full stride every 1.75 m. */
6
- export declare const GAIT = 3.6;
7
- /** Flat colours, shared with the gibs. Eyes are the unlit layer: they glow in the dark. */
8
- export declare const COLOR: {
9
- body: number[];
10
- arm: number[];
11
- leg: number[];
12
- head: number[];
13
- shell: number[];
14
- fin: number[];
15
- gore: number[];
16
- calm: number[];
17
- chase: number[];
18
- blob: number[];
19
- core: number[];
20
- };
21
- /** What a monster of each MONSTER kind bursts into. */
22
- export declare const CHUNKS: number[][][];
23
- /** What the client keeps of each body it draws: the limbs follow the distance, the pace the speed. */
24
- export interface Gait {
25
- x: number;
26
- z: number;
27
- /** Distance covered, metres. */
28
- walked: number;
29
- /** Eased velocity on x and z, m/s. */
30
- vx: number;
31
- vz: number;
32
- }
33
- /** Moves the gait of `id` to (x, z) after dt seconds. A jump of metres (a respawn) is not a walk. */
34
- export declare const follow: (book: Map<number, Gait>, id: number, x: number, z: number, dt: number) => Gait;
35
- /** 0 standing to 1 striding: the limbs swing less when slow. */
36
- export declare const pace: (g: Gait) => number;
37
- /** Arm angle during a blow, `s` in (0, 1] the share of SWING elapsed: raised overhead, slammed down, back. */
38
- export declare const strike: (s: number) => number;
39
- /**
40
- * Appends a walker: `walked` is the distance it has covered (the limbs swing with it), `pace` how
41
- * fast it goes (0 stands), `blow` the share of SWING elapsed, 0 when not swinging.
42
- */
43
- export declare const walker: (out: number[], m: Monster, walked: number, blow: number, pace?: number) => void;
44
- /**
45
- * Appends another player as a soldier: `color` (r, g, b) for the body, darker for the legs, the
46
- * helmet and the gloves, a visor that glows in it. The legs stride with `walked` and `pace` as a
47
- * walker's do, both arms reach the `gun` parts (gun-space vertices, drawn forward at the chest and
48
- * aimed with the player's pitch).
49
- */
50
- export declare const soldier: (out: number[], p: PlayerState, color: number[], walked: number, pace: number, gun: number[][]) => void;
51
- /**
52
- * Appends a flyer at time t (seconds): it bobs on a slow sine, its membranes flap, and the pod
53
- * leans toward where it goes, (vx, vz) m/s.
54
- */
55
- export declare const flyer: (out: number[], m: Monster, t: number, vx?: number, vz?: number) => void;
56
- /**
57
- * Appends a bullet: a glowing blob with a short tail behind it when `dir` (unit, its heading) is
58
- * known.
59
- */
60
- export declare const bullet: (out: number[], b: Bullet, dir?: Vec3) => void;
@@ -1,56 +0,0 @@
1
- import type { Item, Level, MapDef, PlayerInfo, Snapshot } from '../shared/types';
2
- import type { Audio } from './audio';
3
- import type { Effects } from './effects';
4
- import type { Hud } from './hud';
5
- /** Ticks as m:ss.s, the tenth cut, not rounded. */
6
- export declare const clock: (ticks: number) => string;
7
- export interface Progress {
8
- /** The level of the latest snapshot. */
9
- readonly lvl: Level;
10
- /** The pickups lying in it. */
11
- readonly items: Item[];
12
- /** The own player has no health left. */
13
- readonly dead: boolean;
14
- /** The own health: 0 when dead or unknown. */
15
- readonly hp: number;
16
- /** The level's number, name and mode, for the title screen. */
17
- readonly name: string;
18
- /** The level is in its RETURN phase: the team runs back to the exit. */
19
- readonly returning: boolean;
20
- /** False for a player the latest snapshot shows without health: not drawn. */
21
- alive(id: number): boolean;
22
- /** A snapshot, before the predictor sees it: a new level or `hard` switches everything. */
23
- snapshot(s: Snapshot): void;
24
- /** The run is won: the end screen with its time and the players' kills and deaths. */
25
- end(ticks: number, hard: boolean, stats: {
26
- id: number;
27
- kills: number;
28
- deaths: number;
29
- }[]): void;
30
- }
31
- export interface Deps {
32
- /** The level the predictor, renderer and effects were built with. */
33
- lvl: Level;
34
- /** The own player id, -1 while unknown. */
35
- you(): number;
36
- /** Everyone in the room. */
37
- roster(): PlayerInfo[];
38
- predictor: {
39
- level(lvl: Level): void;
40
- };
41
- /** Absent without WebGL. */
42
- rd?: {
43
- level(lvl: Level): void;
44
- };
45
- /** What the old level left waiting: shots and events. */
46
- delays: {
47
- clear(): void;
48
- }[];
49
- fx: Effects;
50
- hud: Hud;
51
- /** Plays COLLECT when the own player takes an item. */
52
- audio?: Pick<Audio, 'play'>;
53
- }
54
- /** The yaw of the spawn nearest (x, z): where a player put back at the start should look. */
55
- export declare const facing: ({ spawns }: MapDef, x: number, z: number) => number;
56
- export declare const createProgress: ({ lvl, you, roster, predictor, rd, delays, fx, hud, audio, }: Deps) => Progress;
@@ -1,15 +0,0 @@
1
- import type { Level, MapDef, Sector } from './types';
2
- /** Joins every edge a→b with the sector that has b→a, if any: that edge is a portal. */
3
- export declare const compile: (map: MapDef) => Level;
4
- /** Bars the gates whose key is not in `keys` (bits 1 << ITEM.KEY_*), and the exit before RETURN. */
5
- export declare const bar: ({ map, barred }: Level, keys: number, phase: number) => void;
6
- /** Whether (x, z) is inside the sector, its edges included. */
7
- export declare const inside: ({ pts }: Sector, x: number, z: number) => boolean;
8
- /** Index of the first sector holding (x, z), -1 outside the map. */
9
- export declare const sectorAt: ({ map }: Level, x: number, z: number) => number;
10
- /**
11
- * Whether a wall, a step or a ceiling hides b from a (both inside the map). Between two edge
12
- * crossings the segment stays in one sector, and each crossing is checked against the opening of
13
- * its portal, so floors and ceilings need no test of their own.
14
- */
15
- export declare const blocked: ({ map, edges }: Level, [ax, ay, az]: [number, number, number], [bx, by, bz]: [number, number, number]) => boolean;
@@ -1,2 +0,0 @@
1
- import type { MapDef } from './types';
2
- export declare const LEVELS: MapDef[];
@@ -1,23 +0,0 @@
1
- import type { Bullet, GameEvent, Level, Monster, PlayerState } from './types';
2
- /** Mulberry32: a small seeded generator, uniform in [0, 1). */
3
- export declare const mulberry32: (seed: number) => (() => number);
4
- export interface Horde {
5
- /** The living monsters, copied. */
6
- monsters(): Monster[];
7
- /** The bullets in flight, copied. */
8
- bullets(): Bullet[];
9
- /** What happened since the owner last emptied it: the owner takes events off the front. */
10
- events: GameEvent[];
11
- /** One host tick, with the players' states. */
12
- step(players: PlayerState[]): void;
13
- /**
14
- * A player's shot killed monster `id`: it dies at once, and the monsters that see it hunt `by`.
15
- * Returns the monster, undefined when `id` is not alive.
16
- */
17
- kill(id: number, by: number): Monster | undefined;
18
- }
19
- /**
20
- * The monsters of the level's map, from the first spawn. In hard mode they move HARD_SPEED faster
21
- * and swing and shoot HARD_RATE as often.
22
- */
23
- export declare const createHorde: (lvl: Level, rand: () => number, hard?: boolean) => Horde;
@@ -1,33 +0,0 @@
1
- import type { Body, Level, Monster, PlayerState, Shot } from './types';
2
- type Vec3 = [number, number, number];
3
- /**
4
- * Unit direction of a shot: the view direction at yaw and pitch (yaw 0, pitch 0 is -z; pitch > 0
5
- * looks up), turned by at most SPREAD in a direction hashed from seq, so the host and the
6
- * shooter's client agree on it.
7
- */
8
- export declare const aim: (yaw: number, pitch: number, seq: number) => Vec3;
9
- /**
10
- * Distance along the ray from o (inside the map) in the unit direction d to the first wall, step
11
- * face, floor or ceiling, at most max.
12
- *
13
- * Walks the sectors: in the current convex one the ray leaves through the edge with the least
14
- * crossing distance among the edges it goes outward through, or ends earlier on the floor or the
15
- * ceiling. A solid edge, or a portal whose opening does not hold the crossing height, ends it.
16
- */
17
- export declare const trace: (lvl: Level, o: Vec3, d: Vec3, max: number) => number;
18
- /**
19
- * Distance at which the ray enters the upright cylinder of t (sides and caps), Infinity on a miss:
20
- * the span of the ray inside the infinite cylinder, cut to the span between the cap planes.
21
- */
22
- export declare const hit: (o: Vec3, d: Vec3, t: Body) => number;
23
- /** The body a shot sees of a player. */
24
- export declare const body: ({ id, x, y, z }: PlayerState) => Body;
25
- /** The body a shot sees of a monster. */
26
- export declare const monsterBody: ({ id, kind, x, y, z }: Monster) => Body;
27
- /**
28
- * Resolves one shot of `shooter` (state after the step that fired) from its eye (feet + EYE)
29
- * along aim(yaw, pitch, seq): the nearest of the level (trace) and the upright cylinders
30
- * of `targets` (bodies: players, monsters) other than the shooter, within RANGE.
31
- */
32
- export declare const fire: (lvl: Level, shooter: PlayerState, seq: number, targets: Body[]) => Shot;
33
- export {};