@korial29/tiny-fps 0.10.0 → 0.12.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.
- package/README.md +27 -37
- package/dist/index.js +12 -13
- package/dist/local.js +1 -1
- package/dist/server.js +261 -2220
- package/dist/types/client/audio.d.ts +3 -16
- package/dist/types/client/effects.d.ts +7 -122
- package/dist/types/client/hud.d.ts +1 -25
- package/dist/types/client/input.d.ts +2 -2
- package/dist/types/client/lights.d.ts +6 -12
- package/dist/types/client/mesh.d.ts +19 -5
- package/dist/types/client/predict.d.ts +2 -27
- package/dist/types/client/render.d.ts +5 -8
- package/dist/types/client/sfx.d.ts +27 -20
- package/dist/types/client/soldier.d.ts +21 -0
- package/dist/types/shared/constants.d.ts +2 -49
- package/dist/types/shared/level.d.ts +0 -2
- package/dist/types/shared/map.d.ts +7 -2
- package/dist/types/shared/physics.d.ts +3 -19
- package/dist/types/shared/protocol.d.ts +2 -22
- package/dist/types/shared/room.d.ts +12 -53
- package/dist/types/shared/trace.d.ts +12 -0
- package/dist/types/shared/types.d.ts +2 -147
- package/package.json +2 -2
- package/dist/types/client/gun.d.ts +0 -19
- package/dist/types/client/items.d.ts +0 -19
- package/dist/types/client/monsters.d.ts +0 -36
- package/dist/types/client/progress.d.ts +0 -56
- package/dist/types/shared/levels.d.ts +0 -2
- package/dist/types/shared/monsters.d.ts +0 -23
- package/dist/types/shared/shoot.d.ts +0 -33
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Conn, Every, MapDef, Rules } from './types';
|
|
1
|
+
import type { Conn, Every, MapDef, PlayerState, Rules } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* One game, transport-agnostic. The Node server and the local host tab both drive a Room: they
|
|
4
4
|
* feed it connections and frames, the room answers through Conn.send.
|
|
@@ -7,52 +7,23 @@ import type { Conn, Every, MapDef, Rules } from './types';
|
|
|
7
7
|
* taken by another player; 'full' beyond rules.maxPlayers. Everyone gets a fresh 'roster' on
|
|
8
8
|
* every join and leave.
|
|
9
9
|
* - Each input frame moves its player at once with move(); the INPUT_BURST bank drops the excess.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* -
|
|
13
|
-
* rewinds the monsters with the players, and one that hits a monster kills it.
|
|
14
|
-
* - A player has HEALTH. A monster's blow or bullet takes 1, then HIT_COOLDOWN ticks of grace
|
|
15
|
-
* (only a hit that took health is told as a HURT event). A dead player moves, shoots and
|
|
16
|
-
* counts for nothing until PLAYER_RESPAWN ticks later, when it is back at a spawn.
|
|
17
|
-
* - The level's items lie in it, and every DROP_EVERY-th kill leaves a HEALTH pack. A key taken
|
|
18
|
-
* opens its gates for the team, a pack heals below full health.
|
|
19
|
-
* - Touching the goal turns the level from HUNT to RETURN (the exit opens); when every living
|
|
20
|
-
* player is in the exit the level is won: the next one starts, everyone respawned. After the
|
|
21
|
-
* last, every player gets { t: 'end' } with the run's kills and deaths per player, and a new
|
|
22
|
-
* run starts at level 0, hard from then on, the counts back at 0.
|
|
23
|
-
* - Every SNAP_EVERY ticks of TICK_HZ, one snapshot with every player, the shots resolved since
|
|
24
|
-
* the last one, the monsters, the bullets, the events since the last one and the items goes to
|
|
25
|
-
* every peer.
|
|
10
|
+
* rewind() answers where the others were drawn at the view tick of an input (lag compensation,
|
|
11
|
+
* at most MAX_REWIND ticks back).
|
|
12
|
+
* - Every SNAP_EVERY ticks of TICK_HZ, one snapshot with every player goes to every peer.
|
|
26
13
|
*/
|
|
27
14
|
export declare class Room {
|
|
28
15
|
/** Every connected peer; null until it joins. */
|
|
29
16
|
private peers;
|
|
30
17
|
private ticks;
|
|
31
|
-
/** The players
|
|
18
|
+
/** The players as each snapshot of the last MAX_REWIND ticks sent them. */
|
|
32
19
|
private history;
|
|
33
|
-
private maps;
|
|
34
20
|
private lvl;
|
|
35
|
-
private horde;
|
|
36
|
-
private rand;
|
|
37
|
-
private level;
|
|
38
|
-
private hard;
|
|
39
|
-
private phase;
|
|
40
|
-
/** The team's key bits (1 << ITEM.KEY_*). */
|
|
41
|
-
private keys;
|
|
42
|
-
private items;
|
|
43
|
-
private nextItem;
|
|
44
|
-
/** Monsters the team killed in this level. */
|
|
45
|
-
private kills;
|
|
46
|
-
/** Host tick the run started at. */
|
|
47
|
-
private runStart;
|
|
48
|
-
/** Shots resolved since the last snapshot. */
|
|
49
|
-
private shots;
|
|
50
21
|
private halt;
|
|
51
22
|
private rules;
|
|
52
23
|
/** Round-robin cursor over the spawn points, used once they are all taken. */
|
|
53
24
|
private rr;
|
|
54
|
-
/** Missing rules fall back to RULES.
|
|
55
|
-
constructor(rules?: Partial<Rules>,
|
|
25
|
+
/** Missing rules fall back to RULES. */
|
|
26
|
+
constructor(rules?: Partial<Rules>, map?: MapDef);
|
|
56
27
|
/** Number of joined players. */
|
|
57
28
|
get size(): number;
|
|
58
29
|
/** A peer opened. Nothing is sent until it joins. */
|
|
@@ -73,26 +44,14 @@ export declare class Room {
|
|
|
73
44
|
start(every?: Every): void;
|
|
74
45
|
stop(): void;
|
|
75
46
|
/**
|
|
76
|
-
* The
|
|
77
|
-
* fractional, read against the current tick and clamped to the
|
|
78
|
-
*
|
|
79
|
-
*
|
|
47
|
+
* The players other than `id` as player `id` drew them at `view`, the view tick of
|
|
48
|
+
* one of its inputs (a u16 tick, fractional, read against the current tick and clamped to the
|
|
49
|
+
* kept history): x, y, z interpolated between the two snapshots around it like the client does.
|
|
50
|
+
* One the history does not hold stands where it is.
|
|
80
51
|
*/
|
|
81
|
-
|
|
82
|
-
/** Resets everything a level owns, and puts every player on a spawn of it with full health. */
|
|
83
|
-
private load;
|
|
52
|
+
rewind(id: number, view?: number): PlayerState[];
|
|
84
53
|
/** The first spawn point with none of `others` within SPAWN_CLEAR, else the next one round-robin. */
|
|
85
54
|
private place;
|
|
86
|
-
/** The floor of the sector holding (x, z). */
|
|
87
|
-
private floor;
|
|
88
|
-
/** Leaves an item of `kind` on the floor at (x, z). */
|
|
89
|
-
private drop;
|
|
90
|
-
/** Takes 1 health off player `id` unless it was hurt less than HIT_COOLDOWN ticks ago. */
|
|
91
|
-
private wound;
|
|
92
|
-
/** What the living players do to the level: pick things up, touch the goal, win. */
|
|
93
|
-
private progress;
|
|
94
|
-
/** The level is won: the next one, or the end of the run and a new, hard one. */
|
|
95
|
-
private win;
|
|
96
55
|
private players;
|
|
97
56
|
private join;
|
|
98
57
|
/** Each joined peer gets the full roster with its own id. */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Level } from './types';
|
|
2
|
+
type Vec3 = [number, number, number];
|
|
3
|
+
/**
|
|
4
|
+
* Distance along the ray from o (inside the map) in the unit direction d to the first wall, step
|
|
5
|
+
* face, floor or ceiling, at most max.
|
|
6
|
+
*
|
|
7
|
+
* Walks the sectors: in the current convex one the ray leaves through the edge with the least
|
|
8
|
+
* crossing distance among the edges it goes outward through, or ends earlier on the floor or the
|
|
9
|
+
* ceiling. A solid edge, or a portal whose opening does not hold the crossing height, ends it.
|
|
10
|
+
*/
|
|
11
|
+
export declare const trace: (lvl: Level, o: Vec3, d: Vec3, max: number) => number;
|
|
12
|
+
export {};
|
|
@@ -11,8 +11,6 @@ export declare const KEY: {
|
|
|
11
11
|
readonly LEFT: 4;
|
|
12
12
|
readonly RIGHT: 8;
|
|
13
13
|
readonly JUMP: 16;
|
|
14
|
-
/** Left mouse button: the chaingun fires every FIRE_EVERY steps while held. */
|
|
15
|
-
readonly FIRE: 32;
|
|
16
14
|
};
|
|
17
15
|
/** One client step: what the player held during 1 / TICK_HZ s, and where they looked. */
|
|
18
16
|
export interface Input {
|
|
@@ -26,7 +24,7 @@ export interface Input {
|
|
|
26
24
|
pitch: number;
|
|
27
25
|
/**
|
|
28
26
|
* Host tick the client drew the others at when it sent this input, fractional (interpolation
|
|
29
|
-
* between two snapshots), in [0, 65536): the host rewinds the
|
|
27
|
+
* between two snapshots), in [0, 65536): the host rewinds the other players to it (lag
|
|
30
28
|
* compensation). The wire keeps 1/256 tick. Absent (no snapshot seen yet) goes out as 0: the host
|
|
31
29
|
* clamps it to the oldest tick it keeps.
|
|
32
30
|
*/
|
|
@@ -44,111 +42,7 @@ export interface PlayerState {
|
|
|
44
42
|
pitch: number;
|
|
45
43
|
/** Standing on a floor: a jump is allowed. */
|
|
46
44
|
ground: boolean;
|
|
47
|
-
/** Steps until the chaingun may fire again, 0 to FIRE_EVERY. */
|
|
48
|
-
cool: number;
|
|
49
45
|
}
|
|
50
|
-
/** One shot, as the host resolved it. */
|
|
51
|
-
export interface Shot {
|
|
52
|
-
/** The shooter. */
|
|
53
|
-
id: number;
|
|
54
|
-
/** Where the shot stopped: a wall, a floor, a ceiling, a target, or RANGE away. */
|
|
55
|
-
x: number;
|
|
56
|
-
y: number;
|
|
57
|
-
z: number;
|
|
58
|
-
/** Id of the player or monster hit, -1 for the level or nothing. */
|
|
59
|
-
hit: number;
|
|
60
|
-
}
|
|
61
|
-
/** Monster kinds. */
|
|
62
|
-
export declare const MONSTER: {
|
|
63
|
-
/** Walks the floors like a player, shoots bullets from afar and hits up close. */
|
|
64
|
-
readonly WALKER: 0;
|
|
65
|
-
/** Hovers above the floor, flies over steps and pits, hits up close. */
|
|
66
|
-
readonly FLYER: 1;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* A monster as the host runs it and the snapshot carries it. Ids run from MAX_PLAYERS up, so a
|
|
70
|
-
* Shot.hit or an event names a player or a monster with one u8.
|
|
71
|
-
*/
|
|
72
|
-
export interface Monster {
|
|
73
|
-
id: number;
|
|
74
|
-
/** MONSTER kind. */
|
|
75
|
-
kind: number;
|
|
76
|
-
/** Bottom of the body: the feet of a walker, the underside of a flyer. */
|
|
77
|
-
x: number;
|
|
78
|
-
y: number;
|
|
79
|
-
z: number;
|
|
80
|
-
/** Facing, as a player's yaw. */
|
|
81
|
-
yaw: number;
|
|
82
|
-
/** Hunting a player (it saw one, or was alerted), not patrolling. */
|
|
83
|
-
chase: boolean;
|
|
84
|
-
}
|
|
85
|
-
/** A monster's bullet in flight, host-simulated. Ids are a u8 counter that wraps. */
|
|
86
|
-
export interface Bullet {
|
|
87
|
-
id: number;
|
|
88
|
-
x: number;
|
|
89
|
-
y: number;
|
|
90
|
-
z: number;
|
|
91
|
-
}
|
|
92
|
-
/** What a GameEvent reports. */
|
|
93
|
-
export declare const EVENT: {
|
|
94
|
-
/** Monster `id` died, (x, y, z) the middle of its body: gibs and an explosion. */
|
|
95
|
-
readonly DIE: 0;
|
|
96
|
-
/** Player `id` was hit by a bullet or a blow at (x, y, z). Harmless until health (step 4). */
|
|
97
|
-
readonly HURT: 1;
|
|
98
|
-
/** A bullet burst on the level at (x, y, z); `id` is the bullet. */
|
|
99
|
-
readonly BOOM: 2;
|
|
100
|
-
/** Monster `id` swung at its target from (x, y, z), hit or miss. */
|
|
101
|
-
readonly SWING: 3;
|
|
102
|
-
};
|
|
103
|
-
export interface GameEvent {
|
|
104
|
-
/** EVENT type. */
|
|
105
|
-
type: number;
|
|
106
|
-
id: number;
|
|
107
|
-
x: number;
|
|
108
|
-
y: number;
|
|
109
|
-
z: number;
|
|
110
|
-
}
|
|
111
|
-
/** Something a shot can hit: an upright cylinder of radius r from y up to y + h. */
|
|
112
|
-
export interface Body {
|
|
113
|
-
id: number;
|
|
114
|
-
x: number;
|
|
115
|
-
y: number;
|
|
116
|
-
z: number;
|
|
117
|
-
r: number;
|
|
118
|
-
h: number;
|
|
119
|
-
}
|
|
120
|
-
/** Pickup kinds. A key is shared by the team: once anyone takes it, its gates open for all. */
|
|
121
|
-
export declare const ITEM: {
|
|
122
|
-
/** Gives HEAL health, up to HEALTH. Left in the level by every DROP_EVERY-th kill. */
|
|
123
|
-
readonly HEALTH: 0;
|
|
124
|
-
readonly KEY_RED: 1;
|
|
125
|
-
readonly KEY_BLUE: 2;
|
|
126
|
-
readonly KEY_YELLOW: 3;
|
|
127
|
-
};
|
|
128
|
-
/** A pickup lying in the level. Ids are unique within a level, u8. */
|
|
129
|
-
export interface Item {
|
|
130
|
-
id: number;
|
|
131
|
-
/** ITEM kind. */
|
|
132
|
-
kind: number;
|
|
133
|
-
/** Where it rests: on the floor of the sector under it. */
|
|
134
|
-
x: number;
|
|
135
|
-
y: number;
|
|
136
|
-
z: number;
|
|
137
|
-
}
|
|
138
|
-
/** A barred doorway: bodies cannot enter the sector until the team holds the key. */
|
|
139
|
-
export interface Gate {
|
|
140
|
-
/** Sector index, a thin doorway between two rooms. */
|
|
141
|
-
sector: number;
|
|
142
|
-
/** ITEM.KEY_* kind that opens it. */
|
|
143
|
-
key: number;
|
|
144
|
-
}
|
|
145
|
-
/** Where a level stands. */
|
|
146
|
-
export declare const PHASE: {
|
|
147
|
-
/** Find the goal: the exit sector is barred. */
|
|
148
|
-
readonly HUNT: 0;
|
|
149
|
-
/** The goal was touched: the exit sector is open; the level is won when every living player is in it. */
|
|
150
|
-
readonly RETURN: 1;
|
|
151
|
-
};
|
|
152
46
|
/** Procedural textures, generated by the client. A sector names one per surface. */
|
|
153
47
|
export declare const TEX: {
|
|
154
48
|
readonly BRICK: 0;
|
|
@@ -189,26 +83,13 @@ export interface Sector {
|
|
|
189
83
|
tint?: [r: number, g: number, b: number];
|
|
190
84
|
}
|
|
191
85
|
export interface MapDef {
|
|
192
|
-
/** Shown on the title screen
|
|
86
|
+
/** Shown on the title screen. */
|
|
193
87
|
name?: string;
|
|
194
88
|
/** Fog colour (linear RGB 0 to 1) and density per metre (0.02 is the default haze). Absent: the default. */
|
|
195
89
|
fog?: [r: number, g: number, b: number, density: number];
|
|
196
90
|
sectors: Sector[];
|
|
197
91
|
/** Spawn points: feet x, z (inside a sector, standing on its floor) and the yaw to face. */
|
|
198
92
|
spawns: [x: number, z: number, yaw: number][];
|
|
199
|
-
/** Monsters at the start: x, z inside a sector, the yaw they face, their MONSTER kind. Absent: none. */
|
|
200
|
-
monsters?: [x: number, z: number, yaw: number, kind: number][];
|
|
201
|
-
/** Pickups at the start: x, z inside a sector, their ITEM kind. Absent: none. */
|
|
202
|
-
items?: [x: number, z: number, kind: number][];
|
|
203
|
-
/** Barred doorways. Absent: none. */
|
|
204
|
-
gates?: Gate[];
|
|
205
|
-
/** The goal pad, far from the start: touching it (within GOAL_R) turns the level to RETURN. */
|
|
206
|
-
goal?: [x: number, z: number];
|
|
207
|
-
/**
|
|
208
|
-
* Sector index of the exit, barred until the goal is touched. Usually the start room: players
|
|
209
|
-
* spawn in it and can walk out, but not back in until RETURN.
|
|
210
|
-
*/
|
|
211
|
-
exit?: number;
|
|
212
93
|
}
|
|
213
94
|
/** One directed edge of a sector, see compile in level.ts. */
|
|
214
95
|
export interface Edge {
|
|
@@ -226,11 +107,6 @@ export interface Level {
|
|
|
226
107
|
map: MapDef;
|
|
227
108
|
/** Every edge of every sector, in sector then point order. */
|
|
228
109
|
edges: Edge[];
|
|
229
|
-
/**
|
|
230
|
-
* Sectors that bodies cannot enter now: gates without their key, the exit before RETURN.
|
|
231
|
-
* Mutable: set it with bar() in level.ts (host and client alike); sight and shots ignore it.
|
|
232
|
-
*/
|
|
233
|
-
barred: Set<number>;
|
|
234
110
|
}
|
|
235
111
|
/** One player in a snapshot. */
|
|
236
112
|
export interface SnapPlayer {
|
|
@@ -242,9 +118,6 @@ export interface SnapPlayer {
|
|
|
242
118
|
yaw: number;
|
|
243
119
|
pitch: number;
|
|
244
120
|
ground: boolean;
|
|
245
|
-
cool: number;
|
|
246
|
-
/** Health, HEALTH at most; 0 is dead, waiting PLAYER_RESPAWN ticks to respawn at the start. */
|
|
247
|
-
hp: number;
|
|
248
121
|
/** Seq of the last input of this player the host applied: the client replays the ones after. */
|
|
249
122
|
ack: number;
|
|
250
123
|
}
|
|
@@ -252,24 +125,6 @@ export interface Snapshot {
|
|
|
252
125
|
/** Host tick, u16, wraps. */
|
|
253
126
|
tick: number;
|
|
254
127
|
players: SnapPlayer[];
|
|
255
|
-
/** Shots fired since the previous snapshot, in order. */
|
|
256
|
-
shots: Shot[];
|
|
257
|
-
/** Living monsters. */
|
|
258
|
-
monsters: Monster[];
|
|
259
|
-
/** Bullets in flight. */
|
|
260
|
-
bullets: Bullet[];
|
|
261
|
-
/** Events since the previous snapshot, in order. */
|
|
262
|
-
events: GameEvent[];
|
|
263
|
-
/** Index of the level in LEVELS (levels.ts). A change means a new level: clients rebuild. */
|
|
264
|
-
level: number;
|
|
265
|
-
/** The second run and later: monsters are faster and fire more often. */
|
|
266
|
-
hard: boolean;
|
|
267
|
-
/** PHASE of the level. */
|
|
268
|
-
phase: number;
|
|
269
|
-
/** Keys the team holds: bit (1 << ITEM.KEY_*). */
|
|
270
|
-
keys: number;
|
|
271
|
-
/** Pickups lying in the level. */
|
|
272
|
-
items: Item[];
|
|
273
128
|
}
|
|
274
129
|
/** Room rules, set by the host. Defaults in constants.ts (RULES). */
|
|
275
130
|
export interface Rules {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@korial29/tiny-fps",
|
|
3
|
-
"description": "Tiny multiplayer first-person
|
|
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.
|
|
5
|
+
"version": "0.12.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
type Vec3 = [number, number, number];
|
|
2
|
-
/** Where the barrels end, on -z: the muzzle flash sits just past it. */
|
|
3
|
-
export declare const MUZZLE = 0.55;
|
|
4
|
-
/**
|
|
5
|
-
* Revolves a profile of [radius, length] points around the axis through `at` along -z: `length`
|
|
6
|
-
* runs forward from `at`. Returns triangles as x, y, z, nx, ny, nz per vertex, `sides` quads of 2
|
|
7
|
-
* triangles per profile segment. The profile goes from back to front and closes on the axis, so
|
|
8
|
-
* the normals (smooth around the ring, flat along the profile) point outward.
|
|
9
|
-
*/
|
|
10
|
-
export declare const lathe: (profile: [number, number][], sides: number, at?: Vec3) => number[];
|
|
11
|
-
/**
|
|
12
|
-
* The chaingun, built once per level of detail: `barrels` turn around the central axis (the caller
|
|
13
|
-
* spins them), the `body` stays. Vertices as in lathe.
|
|
14
|
-
*/
|
|
15
|
-
export declare const chaingun: (sides: number) => {
|
|
16
|
-
barrels: number[];
|
|
17
|
-
body: number[];
|
|
18
|
-
};
|
|
19
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Item, Level } from '../shared/types';
|
|
2
|
-
/** Colour of each ITEM kind: the pickup, the bars of its gate, the HUD mark and the pickup fade. */
|
|
3
|
-
export declare const ITEM_COLOR: number[][];
|
|
4
|
-
/** A 0 to 1 colour as CSS, with alpha a. */
|
|
5
|
-
export declare const css: (c: number[], a?: number) => string;
|
|
6
|
-
/**
|
|
7
|
-
* A pickup, bobbing and spinning above its floor: HEALTH a white box with a red cross, a key a
|
|
8
|
-
* ring (glowing), a shaft and two teeth in its colour.
|
|
9
|
-
*/
|
|
10
|
-
export declare const item: (out: number[], { id, kind, x, y, z }: Item, t: number) => void;
|
|
11
|
-
/**
|
|
12
|
-
* Every barred gate gets upright bars across the portal edges of its sector, in its key's colour:
|
|
13
|
-
* they go with the key. The exit, once open, gets a glowing frame on its portals, pulsing.
|
|
14
|
-
*/
|
|
15
|
-
export declare const gates: (out: number[], lvl: Level, t: number) => void;
|
|
16
|
-
/** The goal: a pad on the floor that swells and fades with the clock, and a crystal above it. */
|
|
17
|
-
export declare const pad: (out: number[], lvl: Level, t: number) => void;
|
|
18
|
-
/** Items, gates, the exit frame and the goal pad. */
|
|
19
|
-
export declare const props: (out: number[], lvl: Level, items: Item[], t: number) => void;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Bullet, Monster } 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
|
-
/** Arm angle during a blow, `s` in (0, 1] the share of SWING elapsed: wind up, then strike. */
|
|
24
|
-
export declare const strike: (s: number) => number;
|
|
25
|
-
/**
|
|
26
|
-
* Appends a walker: `walked` is the distance it has covered (the limbs swing with it, so a
|
|
27
|
-
* standing one is still), `blow` the share of SWING elapsed, 0 when not swinging.
|
|
28
|
-
*/
|
|
29
|
-
export declare const walker: (out: number[], m: Monster, walked: number, blow: number) => void;
|
|
30
|
-
/** Appends a flyer at time t (seconds): it bobs on a slow sine and its fins spin. */
|
|
31
|
-
export declare const flyer: (out: number[], m: Monster, t: number) => void;
|
|
32
|
-
/**
|
|
33
|
-
* Appends a bullet: a glowing blob with a short tail behind it when `dir` (unit, its heading) is
|
|
34
|
-
* known.
|
|
35
|
-
*/
|
|
36
|
-
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,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 {};
|