@korial29/tiny-fps 0.97.0 → 0.98.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 +2 -1
- package/dist/index.js +16 -16
- package/dist/local.js +1 -1
- package/dist/server.js +619 -76
- package/dist/types/client/chase.d.ts +42 -0
- package/dist/types/client/dust.d.ts +23 -0
- package/dist/types/client/foley.d.ts +8 -1
- package/dist/types/client/gait.d.ts +33 -2
- package/dist/types/client/hud.d.ts +16 -1
- package/dist/types/client/index.d.ts +2 -1
- package/dist/types/client/input.d.ts +1 -1
- package/dist/types/client/lights.d.ts +11 -1
- package/dist/types/client/predict.d.ts +22 -2
- package/dist/types/client/render.d.ts +18 -4
- package/dist/types/client/rover.d.ts +35 -0
- package/dist/types/client/sfx.d.ts +6 -0
- package/dist/types/client/soldier.d.ts +11 -4
- package/dist/types/shared/protocol.d.ts +5 -1
- package/dist/types/shared/room.d.ts +33 -0
- package/dist/types/shared/rover.d.ts +41 -6
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Rover } from '../shared/types';
|
|
2
|
+
import type { World } from '../shared/world';
|
|
3
|
+
import type { Vec3 } from './mesh';
|
|
4
|
+
export declare const CHASE: {
|
|
5
|
+
/** The pivot above the rover's centre, the camera behind it along the look, and above that line: metres. */
|
|
6
|
+
readonly UP: 1.6;
|
|
7
|
+
readonly BACK: 6.5;
|
|
8
|
+
readonly RISE: 0.6;
|
|
9
|
+
/** The spring the pivot trails the rover on, and the one the camera backs out on after a wall pulled it in (1 / s). */
|
|
10
|
+
readonly W: 16;
|
|
11
|
+
readonly OUT: 5;
|
|
12
|
+
/** The camera is a ball of this radius for the ground and the brushes. */
|
|
13
|
+
readonly PAD: 0.3;
|
|
14
|
+
/** Seconds from the eye to the chase view, and back. */
|
|
15
|
+
readonly BLEND: 0.3;
|
|
16
|
+
/** The look's pitch at the wheel: down onto the rover, up no further than the camera stays over flat ground. */
|
|
17
|
+
readonly LO: -1;
|
|
18
|
+
readonly HI: 0.3;
|
|
19
|
+
/** Degrees of field of view added at the top speed, and how fast they come (1 / s). */
|
|
20
|
+
readonly FOV: 10;
|
|
21
|
+
readonly FOV_W: 4;
|
|
22
|
+
};
|
|
23
|
+
/** What a frame is drawn from. */
|
|
24
|
+
export interface Shot {
|
|
25
|
+
at: Vec3;
|
|
26
|
+
pitch: number;
|
|
27
|
+
/** Degrees added to the field of view, by the rover's speed. */
|
|
28
|
+
fov: number;
|
|
29
|
+
/** 0 at the eye to 1 in the chase view, eased. */
|
|
30
|
+
k: number;
|
|
31
|
+
}
|
|
32
|
+
export interface Chase {
|
|
33
|
+
/**
|
|
34
|
+
* Advances dt seconds. `seated` while the own player drives `r`; after he gets out, `r` is still
|
|
35
|
+
* the rover he left until `k` is back to 0. `eye` and `tilt` are the first-person camera and its
|
|
36
|
+
* pitch, `yaw` and `pitch` the look.
|
|
37
|
+
*/
|
|
38
|
+
frame(r: Rover | undefined, seated: boolean, eye: Vec3, tilt: number, yaw: number, pitch: number, dt: number): Shot;
|
|
39
|
+
}
|
|
40
|
+
/** The look's pitch as the chase camera takes it. */
|
|
41
|
+
export declare const chasePitch: (pitch: number) => number;
|
|
42
|
+
export declare const createChase: (world: World) => Chase;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Rover } from '../shared/types';
|
|
2
|
+
import type { World } from '../shared/world';
|
|
3
|
+
import type { Vec3 } from './mesh';
|
|
4
|
+
/** Metres a second along the ground from which the wheels raise dust, and across the nose (a slide) from which they do at any speed. */
|
|
5
|
+
export declare const DUST_SPEED = 6;
|
|
6
|
+
export declare const DUST_SLIP = 2.5;
|
|
7
|
+
/** Puffs a second a wheel throws at DUST_SPEED (more with speed, twice as many at most), puffs alive at most, and seconds one lasts at most. */
|
|
8
|
+
export declare const DUST_RATE = 28;
|
|
9
|
+
export declare const DUST_MAX = 240;
|
|
10
|
+
export declare const DUST_LIFE = 1.6;
|
|
11
|
+
/** Metres from the eye past which no dust is raised: it is too small to see. */
|
|
12
|
+
export declare const DUST_FAR = 120;
|
|
13
|
+
export interface Dust {
|
|
14
|
+
/** Moves the puffs by dt seconds, then lets the rovers' wheels throw new ones. */
|
|
15
|
+
update(rovers: Rover[], world: World, dt: number, eye?: Vec3): void;
|
|
16
|
+
/** Appends the puffs: each swells and thins as it flies. */
|
|
17
|
+
draw(out: number[]): void;
|
|
18
|
+
/** Puffs in flight. */
|
|
19
|
+
readonly count: number;
|
|
20
|
+
}
|
|
21
|
+
/** The wheels of `r` that raise dust (in the order of the model's wheels): on the ground, the rover fast or sliding. */
|
|
22
|
+
export declare const raising: (r: Rover, w: World) => boolean[];
|
|
23
|
+
export declare const createDust: () => Dust;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlayerState } from '../shared/types';
|
|
1
|
+
import type { PlayerState, Rover } from '../shared/types';
|
|
2
2
|
import type { Audio } from './audio';
|
|
3
3
|
import type { Hit } from './effects';
|
|
4
4
|
export interface Foley {
|
|
@@ -6,5 +6,12 @@ export interface Foley {
|
|
|
6
6
|
me(p: PlayerState | undefined, hit: Hit, steps: number): void;
|
|
7
7
|
/** The other players as drawn and their runners' footsteps so far: their steps and landings, at their position. */
|
|
8
8
|
others(ps: PlayerState[], steps: (id: number) => number | undefined): void;
|
|
9
|
+
/**
|
|
10
|
+
* The rover the own player sits in, as drawn (undefined on foot), `dt` seconds after the last
|
|
11
|
+
* call, and the keys he holds at its wheel (0 for the rider): the engine, the skid, the landings.
|
|
12
|
+
*/
|
|
13
|
+
rover(r: Rover | undefined, dt: number, keys?: number): void;
|
|
9
14
|
}
|
|
15
|
+
/** The rover: a sideways slide from this speed (m/s) skids, and is at its loudest this much over it. */
|
|
16
|
+
export declare const SKID_FROM = 2.5;
|
|
10
17
|
export declare const createFoley: (a: Audio) => Foley;
|
|
@@ -3,9 +3,20 @@ import type { Vec3 } from './mesh';
|
|
|
3
3
|
import type { Pose, Quat } from './rig';
|
|
4
4
|
/** The height of the ground at (x, z), for feet that stand on stairs and slopes. */
|
|
5
5
|
export type Floor = (x: number, z: number) => number;
|
|
6
|
+
/** The seat of a player in a rover (MODE.RIDE): the rover's attitude and its front wheels' angle, and the seat, 0 the driver's, 1 the rider's. */
|
|
7
|
+
export interface Seat {
|
|
8
|
+
yaw: number;
|
|
9
|
+
pitch: number;
|
|
10
|
+
roll: number;
|
|
11
|
+
steer: number;
|
|
12
|
+
s: number;
|
|
13
|
+
}
|
|
6
14
|
export interface Gait {
|
|
7
|
-
/**
|
|
8
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Moves to the state `p` after dt seconds. Without `floor` the feet stand on y = p.y. `seat` is
|
|
17
|
+
* where a player who rides sits: without it he sits level, a rider, facing his look.
|
|
18
|
+
*/
|
|
19
|
+
update(p: PlayerState, dt: number, floor?: Floor, seat?: Seat): void;
|
|
9
20
|
/** The pose now: one object, rewritten by each call. */
|
|
10
21
|
pose(): Pose;
|
|
11
22
|
/** Stride phase, in cycles: the left foot lands at 0 and the right one at a half. */
|
|
@@ -29,6 +40,26 @@ export declare const MOVE: {
|
|
|
29
40
|
readonly TUCK: 9;
|
|
30
41
|
/** Out of health: the knees give and the body topples (see `lie` in build). */
|
|
31
42
|
readonly DOWN: 10;
|
|
43
|
+
/** Seated in a rover: the rough of it, the hands and the feet are placed in `reach`. */
|
|
44
|
+
readonly RIDE: 11;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A seated body, from the seat point (the player's position, the feet of shared/rover.ts' seat())
|
|
48
|
+
* in the rover's frame: the pelvis above it and behind it (on a cushion whose top is 0.13 m up,
|
|
49
|
+
* before a back 0.3 m behind that leans away), the trunk's lean back, the ankles ahead and above,
|
|
50
|
+
* half the feet's spread, and the toes' pitch up against the footwell's slope.
|
|
51
|
+
*/
|
|
52
|
+
export declare const SIT: {
|
|
53
|
+
up: number;
|
|
54
|
+
back: number;
|
|
55
|
+
lean: number;
|
|
56
|
+
ahead: number;
|
|
57
|
+
ankle: number;
|
|
58
|
+
wide: number;
|
|
59
|
+
toes: number;
|
|
60
|
+
/** The driver sits up to the yoke: his pelvis this far ahead of a rider's, his trunk this far forward of it. */
|
|
61
|
+
reach: number;
|
|
62
|
+
hunch: number;
|
|
32
63
|
};
|
|
33
64
|
/**
|
|
34
65
|
* A move's pose, in radians (metres for the offsets): drop of the pelvis, lean forward, lean to the
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { Result } from '../shared/protocol';
|
|
2
|
-
import type { Snapshot } from '../shared/types';
|
|
2
|
+
import type { PlayerState, Rover, Snapshot } from '../shared/types';
|
|
3
3
|
import type { Mark } from './marks';
|
|
4
4
|
export declare const HUD_CSS: string;
|
|
5
|
+
/** Seconds the way out is shown after sitting down. */
|
|
6
|
+
export declare const OUT_HINT = 4;
|
|
7
|
+
/**
|
|
8
|
+
* What E does for a player on foot: 'drive' within ROVER.ENTER_R of a rover whose wheel is free,
|
|
9
|
+
* 'ride' when only the seat beside it is, or when he carries a flag (a carrier does not drive),
|
|
10
|
+
* '' with no free seat in reach, seated or down. The nearest rover with a seat for him counts.
|
|
11
|
+
*/
|
|
12
|
+
export declare const boarding: (me: Pick<PlayerState, "x" | "y" | "z" | "mode" | "down"> | undefined, rovers: readonly Rover[], carrying?: boolean) => "" | "drive" | "ride";
|
|
13
|
+
/** The speed-o-meter's reading of a rover: whole km/h over the ground. */
|
|
14
|
+
export declare const kmh: (r: Pick<Rover, "vx" | "vz">) => number;
|
|
5
15
|
/** What the end screen shows: the final captures and what each player did. */
|
|
6
16
|
export interface Summary {
|
|
7
17
|
score: [number, number];
|
|
@@ -53,6 +63,11 @@ export interface Hud {
|
|
|
53
63
|
down(level: number, left: number): void;
|
|
54
64
|
/** A line in the middle of the top of the screen in `team`'s colour, for a few seconds; a newer one replaces it. */
|
|
55
65
|
banner(text: string, team?: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* The rover: `act` is what E does now ('drive', 'ride', 'get out'; '' hides the prompt), and
|
|
68
|
+
* `speed` the km/h shown at the wheel, where the gun and the crosshair then hide; undefined off it.
|
|
69
|
+
*/
|
|
70
|
+
rover(act: string, speed?: number): void;
|
|
56
71
|
/** The end screen with the result and each player's captures and returns, `next` seconds before the next match; undefined hides it. */
|
|
57
72
|
end(sum: Summary | undefined, next: number): void;
|
|
58
73
|
}
|
|
@@ -23,7 +23,8 @@ export interface TinyFps {
|
|
|
23
23
|
/**
|
|
24
24
|
* Mounts the game in a Shadow DOM inside container: one WebGL2 canvas filling it, a click locks the
|
|
25
25
|
* pointer, the mouse looks, WASD (ZQSD on AZERTY) moves, Shift sprints, Space jumps (again in the
|
|
26
|
-
* air for a second jump), C crouches and slides, a direction key pressed twice dashes
|
|
26
|
+
* air for a second jump), C crouches and slides, a direction key pressed twice dashes, E gets in
|
|
27
|
+
* and out of a rover.
|
|
27
28
|
*
|
|
28
29
|
* The socket is this function's; the scene of one map is play()'s, behind a socket of its own.
|
|
29
30
|
* When the room plays another map, the scene goes and one of the new map takes its place on the
|
|
@@ -56,7 +56,7 @@ export interface Controls {
|
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* Click the canvas to lock the pointer; while locked the mouse looks, the keys move (WASD, Shift
|
|
59
|
-
* sprints, Space jumps, C crouches, a direction key pressed twice within DOUBLE_TAP_MS dashes that
|
|
59
|
+
* sprints, Space jumps, C crouches, E gets in and out of a rover, a direction key pressed twice within DOUBLE_TAP_MS dashes that
|
|
60
60
|
* way, the left button fires or cuts and a double click cuts the special, 1, 2 and 3 or the wheel pick
|
|
61
61
|
* the gun, the katana or the rail gun) and M calls `onMute`.
|
|
62
62
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlayerState } from '../shared/types';
|
|
1
|
+
import type { PlayerState, Rover } from '../shared/types';
|
|
2
2
|
import type { CtfScene } from './flag';
|
|
3
3
|
import type { Vec3 } from './mesh';
|
|
4
4
|
export declare const LIGHT: {
|
|
@@ -38,5 +38,15 @@ export interface Scene {
|
|
|
38
38
|
/** The bases and the flags in play: each base and each lying flag lights the roof around it. */
|
|
39
39
|
ctf?: CtfScene;
|
|
40
40
|
}
|
|
41
|
+
/** A rover's headlights: metres they reach, the cosine of the beam's half-angle, how far the beam dips under the nose (radians), and their colour. */
|
|
42
|
+
export declare const BEAM_RANGE = 45;
|
|
43
|
+
export declare const BEAM_CONE = 0.82;
|
|
44
|
+
export declare const BEAM_DIP = 0.12;
|
|
45
|
+
/**
|
|
46
|
+
* The headlights of the rovers that have a driver: one beam a rover, from between its two lenses
|
|
47
|
+
* along its nose, dipped to the ground ahead. One and not two: every pixel pays for every light.
|
|
48
|
+
* They cast no shadow of their own (a shadow map is a pass over the whole map).
|
|
49
|
+
*/
|
|
50
|
+
export declare const beams: (rovers?: Rover[]) => Light[];
|
|
41
51
|
/** The lights of this frame, most important first: the two bases, then the flags that lie on the ground. */
|
|
42
52
|
export declare const gather: (scene: Scene) => Light[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Input, PlayerState, Snapshot } from '../shared/types';
|
|
1
|
+
import type { Input, PlayerState, Rover, Snapshot } from '../shared/types';
|
|
2
2
|
import type { World } from '../shared/world';
|
|
3
3
|
export interface Predictor {
|
|
4
4
|
/**
|
|
@@ -28,10 +28,30 @@ export interface Predictor {
|
|
|
28
28
|
/**
|
|
29
29
|
* The own player, eased between the state before and after the last step by alpha in [0, 1]
|
|
30
30
|
* (the share of a step elapsed since it), so the camera moves smoothly at any frame rate.
|
|
31
|
-
* Undefined until a snapshot shows the own player.
|
|
31
|
+
* Undefined until a snapshot shows the own player. Seated, his body is on the seat of the rover
|
|
32
|
+
* as rovers() draws it on the same frame: the predicted one at the wheel, the interpolated one
|
|
33
|
+
* beside it (at the time of the last step plus alpha of a step).
|
|
32
34
|
*/
|
|
33
35
|
me(alpha: number): PlayerState | undefined;
|
|
34
36
|
/** The other players at now - INTERP_DELAY; a player missing from the latest snapshot is gone. */
|
|
35
37
|
others(now: number): PlayerState[];
|
|
38
|
+
/**
|
|
39
|
+
* The map's rovers, in the order of WorldDef.rovers: the one the own player drives predicted and
|
|
40
|
+
* eased by alpha like me(), the others at now - INTERP_DELAY. Empty on a map without rovers.
|
|
41
|
+
* The one he has just left rolls on as predicted until the snapshots' one, which rolls the same
|
|
42
|
+
* way a lag behind, has caught up with it.
|
|
43
|
+
*/
|
|
44
|
+
rovers(now: number, alpha: number): Rover[];
|
|
45
|
+
/** The rover the own player is seated in (its index) and his seat (0 the driver's), or undefined on foot. */
|
|
46
|
+
riding(): {
|
|
47
|
+
rover: number;
|
|
48
|
+
seat: 0 | 1;
|
|
49
|
+
} | undefined;
|
|
36
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* A rover the own player got out of is drawn as predicted, rolling on, until the snapshots' one is
|
|
53
|
+
* within GHOST_NEAR m of it or GHOST_MS have passed. One that will not get there (the host took
|
|
54
|
+
* him off the wheel, someone else drives it now) is eased to the snapshots' over ROVER_BLEND ms.
|
|
55
|
+
*/
|
|
56
|
+
export declare const ROVER_BLEND = 300;
|
|
37
57
|
export declare const createPredictor: (world: World) => Predictor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlayerState } from '../shared/types';
|
|
1
|
+
import type { PlayerState, Rover } from '../shared/types';
|
|
2
2
|
import type { World, WorldDef } from '../shared/world';
|
|
3
3
|
import type { Body } from './body';
|
|
4
4
|
import type { Tracer } from './beams';
|
|
@@ -10,8 +10,14 @@ import type { Vec3 } from './mesh';
|
|
|
10
10
|
export declare const MAX_TINTS = 16;
|
|
11
11
|
/** Shadow map side in texels. */
|
|
12
12
|
export declare const SHADOW = 1024;
|
|
13
|
-
/** Metres the sun's shadow window spans on a side
|
|
14
|
-
export declare const SUN_AREA =
|
|
13
|
+
/** Metres the sun's shadow window spans on a side: 9 cm a texel. */
|
|
14
|
+
export declare const SUN_AREA = 96;
|
|
15
|
+
/**
|
|
16
|
+
* Metres the window's middle is ahead of the eye, along the look on the ground: what is behind the
|
|
17
|
+
* camera needs little of it. It reaches 19 m behind the eye and 77 m ahead: a rover at 20 m/s seen
|
|
18
|
+
* from a chase camera keeps its shadow, and those of the hills it drives at, for 4 s ahead.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SUN_AHEAD = 29;
|
|
15
21
|
/** Half the depth range of the sun's window, metres: what stands this far from the eye along the sun's direction still casts. */
|
|
16
22
|
export declare const SUN_DEPTH = 100;
|
|
17
23
|
/** How far the fog colour is pulled toward the sky's horizon, 0 to 1: a fog unlike the horizon draws an edge against the sky. */
|
|
@@ -28,6 +34,8 @@ export declare const FAR = 1200;
|
|
|
28
34
|
/** The vertical field of view at rest, degrees, and the tangent of its half. */
|
|
29
35
|
export declare const FOV_DEG = 70;
|
|
30
36
|
export declare const FOV: number;
|
|
37
|
+
/** Metres within which a rover is drawn with its near level of detail (rover.ts), and within which with the middle one. */
|
|
38
|
+
export declare const ROVER_NEAR: number, ROVER_MID: number;
|
|
31
39
|
/**
|
|
32
40
|
* Blinn-Phong strength and exponent: a row per TEX id in order (brick, tile, lava, stone, metal, wood,
|
|
33
41
|
* moss, grate, concrete, glass, steel, paint), then the flat bodies, then polished metal (SHINE). Lava
|
|
@@ -66,6 +74,8 @@ export declare const pack: (lights: Light[]) => {
|
|
|
66
74
|
* shadow edge keeps its texels as the eye moves instead of crawling.
|
|
67
75
|
*/
|
|
68
76
|
export declare const sunProj: (dir: Vec3, eye: Vec3, area?: number, depth?: number) => Float32Array<ArrayBuffer>;
|
|
77
|
+
/** The middle of the sun's shadow window for an eye looking along `yaw`: SUN_AHEAD metres ahead of it on the ground. */
|
|
78
|
+
export declare const sunAt: (eye: Vec3, yaw: number) => Vec3;
|
|
69
79
|
/** The tints of a world's brushes, white first and each once: the shader's palette, MAX_TINTS at most. */
|
|
70
80
|
export declare const palette: ({ def }: World) => Vec3[];
|
|
71
81
|
/**
|
|
@@ -109,7 +119,11 @@ export interface Renderer {
|
|
|
109
119
|
/** The bases, the flags, the racks and the health packs: drawn lit, casting shadows, with the other players. */
|
|
110
120
|
ctf?: CtfScene,
|
|
111
121
|
/** The plasma balls, the flashes and the sparks: they glow and cast no shadow. */
|
|
112
|
-
tracer?: Tracer
|
|
122
|
+
tracer?: Tracer,
|
|
123
|
+
/** The map's rovers (Predictor.rovers()): drawn lit, casting shadows, with the other players. */
|
|
124
|
+
rovers?: Rover[],
|
|
125
|
+
/** The own player when the camera is not in his head (seated in a rover): drawn whole, like the others. */
|
|
126
|
+
self?: PlayerState): void;
|
|
113
127
|
/** A world point on screen as of the last frame, in [0, 1] from the top left. */
|
|
114
128
|
project(x: number, y: number, z: number): [number, number] | undefined;
|
|
115
129
|
/** The footsteps of the player `id`'s runner so far (Gait.steps), undefined before it is drawn. */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Rover } from '../shared/types';
|
|
2
|
+
import type { World } from '../shared/world';
|
|
3
|
+
import type { Vec3 } from './mesh';
|
|
4
|
+
/**
|
|
5
|
+
* How far each wheel's spring is squeezed, metres in 0..CMAX, in AT's order: the simulation's own
|
|
6
|
+
* (wheels() in shared/rover.ts), from the state and the world alone. 0 is a wheel hanging in the air.
|
|
7
|
+
*/
|
|
8
|
+
export declare const springs: (r: Rover, w: World) => number[];
|
|
9
|
+
/**
|
|
10
|
+
* The seats, driver then rider, as the simulation has them (seat()): metres right of the body's
|
|
11
|
+
* centre, above it (the feet of who sits) and ahead of it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SEATS: Vec3[];
|
|
14
|
+
/**
|
|
15
|
+
* The middles of the yoke's two grips, left then right, with the front wheels turned by `steer`:
|
|
16
|
+
* metres right of, above and ahead of the driver's seat point, in the body's frame.
|
|
17
|
+
*/
|
|
18
|
+
export declare const grips: (steer: number) => Vec3[];
|
|
19
|
+
/**
|
|
20
|
+
* Radians the wheels roll as the rover goes from (x, z) to where it is now: the distance along its
|
|
21
|
+
* nose over the wheel's radius, negative in reverse. Sliding sideways turns nothing.
|
|
22
|
+
*/
|
|
23
|
+
export declare const rolled: (x: number, z: number, r: Rover) => number;
|
|
24
|
+
/** The middle of each headlight's lens in the world, left then right: they shine along basis(yaw, pitch, roll)[2]. */
|
|
25
|
+
export declare const headlights: (r: Rover) => Vec3[];
|
|
26
|
+
/** Where each tyre meets the ground, in AT's order: under its hub. A wheel in the air (springs() gives 0) has none: this is then the bottom of its tyre. */
|
|
27
|
+
export declare const contacts: (r: Rover, w: World) => Vec3[];
|
|
28
|
+
/**
|
|
29
|
+
* Appends the rover at level of detail `lod` (0 far, 1 mid, 2 and up near: the caller picks the
|
|
30
|
+
* distances) as the state has it: the body pitched and rolled, each wheel on its spring over the
|
|
31
|
+
* world's floor, turned by `spin` radians (the distance driven over WR) and the front pair by
|
|
32
|
+
* `steer`, the wishbones and the coil-overs following, the yoke turning with the wheels. `rgb` is
|
|
33
|
+
* the team's colour (0 to 1): the fenders, the bonnet's stripe, the springs and the whip's light.
|
|
34
|
+
*/
|
|
35
|
+
export declare const rover: (out: number[], r: Rover, w: World, spin: number, rgb: number[], lod: number) => void;
|
|
@@ -79,6 +79,12 @@ export declare const SOUND: {
|
|
|
79
79
|
readonly IGNITE: 38;
|
|
80
80
|
/** The plasma gun charging, held: a whine played higher as the charge grows (combat.ts), looped. */
|
|
81
81
|
readonly CHARGE: 39;
|
|
82
|
+
/** The rover's electric turbine, looped: played higher as it goes faster. */
|
|
83
|
+
readonly ENGINE: 40;
|
|
84
|
+
/** The rover's suspension taking a landing. */
|
|
85
|
+
readonly THUD: 41;
|
|
86
|
+
/** The rover's tyres sliding sideways over the dust, looped: louder as it drifts wider. */
|
|
87
|
+
readonly SKID: 42;
|
|
82
88
|
};
|
|
83
89
|
/**
|
|
84
90
|
* The sounds of the game: one entry per sound, its voices layered, in SOUND order. A low-passed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PlayerState } from '../shared/types';
|
|
1
|
+
import type { PlayerState, Rover } from '../shared/types';
|
|
2
2
|
import type { World } from '../shared/world';
|
|
3
|
-
import type { Gait } from './gait';
|
|
3
|
+
import type { Gait, Seat } from './gait';
|
|
4
4
|
import type { Tracer } from './beams';
|
|
5
5
|
import type { Piece } from './limbs';
|
|
6
6
|
import type { Vec3 } from './mesh';
|
|
@@ -26,15 +26,22 @@ export interface Runner {
|
|
|
26
26
|
cut?: Piece;
|
|
27
27
|
/** Seconds left of the grimace a hit puts on his face. */
|
|
28
28
|
hurt: number;
|
|
29
|
+
/** The seat he rides in, when he does and his rover is known. */
|
|
30
|
+
seat?: Seat;
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The seat of a player who rides: the rover whose `driver` or `rider` he is. Nothing for one on
|
|
34
|
+
* foot, or whose rover is not among `rovers`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const seatOf: (p: PlayerState, rovers?: Rover[]) => Seat | undefined;
|
|
30
37
|
/** A runner as first seen: in the pose its state asks for, no ease. */
|
|
31
|
-
export declare const createRunner: (p: PlayerState) => Runner;
|
|
38
|
+
export declare const createRunner: (p: PlayerState, seat?: Seat) => Runner;
|
|
32
39
|
/**
|
|
33
40
|
* Moves each runner of `book` to its player in `others` after dt seconds: a new player gets a
|
|
34
41
|
* runner already in pose, one that left loses it. With a `world` the feet stand on the brushes
|
|
35
42
|
* under them. The `tracer` gets the sparks of a limb cut off.
|
|
36
43
|
*/
|
|
37
|
-
export declare const animate: (book: Map<number, Runner>, others: PlayerState[], dt: number, world?: World, tracer?: Pick<Tracer, "shock" | "spit"
|
|
44
|
+
export declare const animate: (book: Map<number, Runner>, others: PlayerState[], dt: number, world?: World, tracer?: Pick<Tracer, "shock" | "spit">, rovers?: Rover[]) => void;
|
|
38
45
|
/**
|
|
39
46
|
* The pose with the katana in both hands: carried, or in a cut, which is the first person's cut
|
|
40
47
|
* seen from the runner's eye (the share `e` of it, so that it is drawn from the carry and back to
|
|
@@ -41,7 +41,11 @@ export declare const MSG_SNAPSHOT = 2;
|
|
|
41
41
|
export declare const INPUT_BYTES = 12;
|
|
42
42
|
export declare const SNAP_HEAD = 4;
|
|
43
43
|
export declare const SNAP_PLAYER = 61;
|
|
44
|
-
/**
|
|
44
|
+
/** Bytes of a rover: thirteen float32 and the two seats. */
|
|
45
|
+
export declare const SNAP_ROVER = 54;
|
|
46
|
+
/** The rover count has three bits of the head's count byte, the players the other five. */
|
|
47
|
+
export declare const MAX_ROVERS = 7;
|
|
48
|
+
/** The match block after the players and the rovers: the captures, the clock, the packs; the flags follow (2 to 16 bytes). */
|
|
45
49
|
export declare const SNAP_MATCH = 10;
|
|
46
50
|
/** Bytes of a plasma ball. */
|
|
47
51
|
export declare const SNAP_BALL = 11;
|
|
@@ -16,6 +16,8 @@ export declare class Room {
|
|
|
16
16
|
private gone;
|
|
17
17
|
/** The plasma balls in flight, and the ones that burst since the last snapshot, which sends them once more. */
|
|
18
18
|
private balls;
|
|
19
|
+
/** The map's rovers, in the order of WorldDef.rovers. */
|
|
20
|
+
private rovers;
|
|
19
21
|
/** The key of the map being played, which the roster tells the clients. */
|
|
20
22
|
private mapName;
|
|
21
23
|
/** The map the host picked for the next match, when it is another one. */
|
|
@@ -61,6 +63,8 @@ export declare class Room {
|
|
|
61
63
|
* One the history does not hold stands where it is.
|
|
62
64
|
*/
|
|
63
65
|
rewind(id: number, view?: number): PlayerState[];
|
|
66
|
+
/** Every player as the snapshots around the view tick `view` showed him: rewind(), the asker included. */
|
|
67
|
+
private past;
|
|
64
68
|
/**
|
|
65
69
|
* After a move of `p` at the view tick `view`: a dash or a slide that overlaps an enemy carrier
|
|
66
70
|
* tackles him. The carrier is where `p` drew him (lag compensation), so a tackle that hit on
|
|
@@ -122,6 +126,35 @@ export declare class Room {
|
|
|
122
126
|
* carries the result and the predictor replays its unacked inputs on it.
|
|
123
127
|
*/
|
|
124
128
|
private heal;
|
|
129
|
+
/** The rover `p` is seated in and his seat (0 the driver's), or nothing on foot. */
|
|
130
|
+
private seatOf;
|
|
131
|
+
/** Takes `p` off his seat: in the air where he sat. */
|
|
132
|
+
private unseat;
|
|
133
|
+
/**
|
|
134
|
+
* The one place seats are kept true: a seat is held by a player who is there and rides, and who
|
|
135
|
+
* rides holds a seat. So a leaver's seat is free before his id is given again, and one put down,
|
|
136
|
+
* respawned or stumbled out is off the rover.
|
|
137
|
+
*/
|
|
138
|
+
private seats;
|
|
139
|
+
/**
|
|
140
|
+
* A press of USE on foot: the nearest rover within ROVER.ENTER_R on the floor plane with a seat
|
|
141
|
+
* for him, the wheel first; a flag carrier only rides. Not while down, stumbling or in a lock.
|
|
142
|
+
*/
|
|
143
|
+
private enter;
|
|
144
|
+
/**
|
|
145
|
+
* The rider follows the rover on his seat. Over a floor, that is his last ground: where a flag he
|
|
146
|
+
* carries lies if he is put down or falls with the rover.
|
|
147
|
+
*/
|
|
148
|
+
private carry;
|
|
149
|
+
/** The rover fell under the kill floor: who was aboard is back at a spawn, it is parked again. */
|
|
150
|
+
private sink;
|
|
151
|
+
/**
|
|
152
|
+
* After a step of the driver `p` at the view tick `view`: the rover's body (footprint()) over an
|
|
153
|
+
* enemy on foot, as `p` drew him, runs him over. Closing on him at ROVER.SPLAT_KILL or more puts
|
|
154
|
+
* him down; from ROVER.SPLAT_MIN it takes 1 hp and throws him the rover's way in a stumble. Once
|
|
155
|
+
* per SPLAT_COOLDOWN ticks a victim; a hit counts for the driver. The rover is never changed.
|
|
156
|
+
*/
|
|
157
|
+
private splat;
|
|
125
158
|
/** The first spawn point of the team with none of `others` within SPAWN_CLEAR, else the next one round-robin. */
|
|
126
159
|
private place;
|
|
127
160
|
/** The match is over: everyone gets the result and what each player did. */
|
|
@@ -23,10 +23,11 @@ export declare const ROVER: {
|
|
|
23
23
|
readonly BRAKE: 14;
|
|
24
24
|
readonly ROLL: 0.6;
|
|
25
25
|
readonly HB: 6;
|
|
26
|
-
/** Grip sideways and in traction, as shares of the load
|
|
26
|
+
/** Grip sideways and in traction, as shares of the load; under the handbrake, the share left sideways and how much faster the nose comes round. */
|
|
27
27
|
readonly MU: 1.1;
|
|
28
28
|
readonly MUL: 1.2;
|
|
29
29
|
readonly HBG: 0.35;
|
|
30
|
+
readonly HBY: 1.5;
|
|
30
31
|
/** Steering toward the driver's look: gain, the speed that halves it, the lock, its rate, and the yaw rate's cap and response. */
|
|
31
32
|
readonly SK: 2.5;
|
|
32
33
|
readonly SV: 10;
|
|
@@ -39,7 +40,11 @@ export declare const ROVER: {
|
|
|
39
40
|
readonly AC: 3;
|
|
40
41
|
readonly AD: 0.5;
|
|
41
42
|
readonly TILT: 0.9;
|
|
42
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* The body against the brushes: circles of radius RB at BODY along the nose, BODY_H tall. A wheel
|
|
45
|
+
* takes for its floor what is at most WHEEL_STEP above its hub with the spring out; the body
|
|
46
|
+
* passes over a brush no more than STEP_H above the wheels' floor, like a player.
|
|
47
|
+
*/
|
|
43
48
|
readonly RB: 1.05;
|
|
44
49
|
readonly BODY: readonly [1.15, 0, -1.15];
|
|
45
50
|
readonly BODY_H: 1.5;
|
|
@@ -49,6 +54,17 @@ export declare const ROVER: {
|
|
|
49
54
|
readonly SPLAT_MIN: 6;
|
|
50
55
|
readonly SPLAT_KILL: 12;
|
|
51
56
|
};
|
|
57
|
+
type Vec3 = [x: number, y: number, z: number];
|
|
58
|
+
/**
|
|
59
|
+
* The wheels, front left, front right, rear left, rear right: the hub, and the spring's compression
|
|
60
|
+
* (0 fully out, as in the air, to CMAX). From the state alone, for the drawing.
|
|
61
|
+
*/
|
|
62
|
+
export declare const wheels: (r: Rover, w: World) => [...Vec3, c: number][];
|
|
63
|
+
/**
|
|
64
|
+
* The body as the brushes and a run-over meet it: the centres of three circles of radius RB along
|
|
65
|
+
* the nose, front first, each at the height of its bottom, BODY_H under its top.
|
|
66
|
+
*/
|
|
67
|
+
export declare const footprint: (r: Rover) => Vec3[];
|
|
52
68
|
/** The map's rovers at rest on their spawns, nobody aboard. */
|
|
53
69
|
export declare const park: (w: World) => Rover[];
|
|
54
70
|
/**
|
|
@@ -56,16 +72,35 @@ export declare const park: (w: World) => Rover[];
|
|
|
56
72
|
* BACK the throttle, JUMP the handbrake, its yaw where the nose is steered to), or undefined with
|
|
57
73
|
* nobody at the wheel: the brake is on. Reads only the rover, the input and the world. Returns
|
|
58
74
|
* whether it fell under the world's kill floor: the caller parks it again.
|
|
75
|
+
*
|
|
76
|
+
* The body is a point with a pitch and a roll on four springs. Each wheel reads the floor under
|
|
77
|
+
* its hub; the four heights give the ground's slope, the springs push along its normal, and the
|
|
78
|
+
* tyres work on the speed along the nose and across it. Yaw is steered, not simulated: the nose
|
|
79
|
+
* turns toward the look as fast as the speed allows, and the tyres' grip decides how much of the
|
|
80
|
+
* speed follows it. The rest drifts.
|
|
59
81
|
*/
|
|
60
82
|
export declare const drive: (r: Rover, i: Input | undefined, w: World) => boolean;
|
|
61
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Puts the body of a player on seat `s` (0 the driver's, 1 the rider's) of the rover, with its
|
|
85
|
+
* speed. The seat leans with the body: on a slope he is not left in the air.
|
|
86
|
+
*/
|
|
62
87
|
export declare const seat: (p: PlayerState, r: Rover, s: 0 | 1) => void;
|
|
63
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* The player takes seat `s`: he rides (MODE.RIDE) from the next step on. What a seated body is not
|
|
90
|
+
* doing ends: a dash's burst (as in stumble()), a hang or a climb, a jump press kept for a landing.
|
|
91
|
+
*/
|
|
64
92
|
export declare const board: (p: PlayerState, r: Rover, s: 0 | 1) => void;
|
|
65
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* The player gets out of seat `s`: in the air, with the rover's speed. Beside it on the side of his
|
|
95
|
+
* seat when a standing body fits there on a floor, else on the other side, else on top of it: over
|
|
96
|
+
* a drop, between two walls, in flight. Never in a brush or under the ground. Reads only the two
|
|
97
|
+
* and the world.
|
|
98
|
+
*/
|
|
66
99
|
export declare const leave: (p: PlayerState, r: Rover, s: 0 | 1, w: World) => void;
|
|
67
100
|
/**
|
|
68
101
|
* The driver's whole step, on the host and in the predictor alike: the rover is driven by his
|
|
69
|
-
* input, he follows on his seat, and a press of USE gets him out. Returns drive()'s answer.
|
|
102
|
+
* input, he follows on his seat, and a press of USE gets him out. Returns drive()'s answer. A step
|
|
103
|
+
* that takes him off his seat (move() puts a body under the kill floor back at a spawn) frees it.
|
|
70
104
|
*/
|
|
71
105
|
export declare const ride: (p: PlayerState, r: Rover, i: Input, w: World, team: number) => boolean;
|
|
106
|
+
export {};
|
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.
|
|
5
|
+
"version": "0.98.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|