@korial29/tiny-fps 0.115.4 → 0.117.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 +3 -3
- package/dist/index.js +18 -18
- package/dist/local.js +1 -1
- package/dist/server.js +94 -10
- package/dist/types/client/doors.d.ts +25 -0
- package/dist/types/client/hud.d.ts +30 -6
- package/dist/types/client/index.d.ts +2 -1
- package/dist/types/client/input.d.ts +2 -0
- package/dist/types/client/render.d.ts +18 -1
- package/dist/types/client/sfx.d.ts +4 -0
- package/dist/types/shared/doors.d.ts +25 -0
- package/dist/types/shared/moonbase.d.ts +5 -0
- package/dist/types/shared/protocol.d.ts +4 -1
- package/dist/types/shared/types.d.ts +2 -0
- package/dist/types/shared/world.d.ts +19 -0
- package/package.json +1 -1
|
@@ -26,7 +26,8 @@ export interface TinyFps {
|
|
|
26
26
|
* Mounts the game in a Shadow DOM inside container: one WebGL2 canvas filling it, a click locks the
|
|
27
27
|
* pointer, the mouse looks, WASD (ZQSD on AZERTY) moves, Shift sprints, Space jumps (again in the
|
|
28
28
|
* air for a second jump), C crouches and slides, a direction key pressed twice dashes, E gets in
|
|
29
|
-
* and out of a rover.
|
|
29
|
+
* and out of a rover. Without the lock the title screen shows: a menu, the character to play, the
|
|
30
|
+
* mode, the map and the controls.
|
|
30
31
|
*
|
|
31
32
|
* The socket is this function's; the scene of one map is play()'s, behind a socket of its own.
|
|
32
33
|
* When the room plays another map, the scene goes and one of the new map takes its place on the
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { PlayerState } from '../shared/types';
|
|
2
|
+
/** Every KeyboardEvent.code the game reads: the title screen's controls must tell them all. */
|
|
3
|
+
export declare const CODES: readonly string[];
|
|
2
4
|
/** Two presses of the same direction key this close (ms) are a dash that way. */
|
|
3
5
|
export declare const DOUBLE_TAP_MS = 250;
|
|
4
6
|
/** The keys of the step of a dash toward `dir` (a direction bit): only that direction is held with it. */
|
|
@@ -125,7 +125,9 @@ export interface Renderer {
|
|
|
125
125
|
/** The map's rovers (Predictor.rovers()): drawn lit, casting shadows, with the other players. */
|
|
126
126
|
rovers?: Rover[],
|
|
127
127
|
/** The own player when the camera is not in his head (seated in a rover): drawn whole, like the others. */
|
|
128
|
-
self?: PlayerState
|
|
128
|
+
self?: PlayerState,
|
|
129
|
+
/** Adds what else moves in the map (the doors): drawn lit, casting shadows, with the other players. */
|
|
130
|
+
more?: (v: number[]) => void): void;
|
|
129
131
|
/** A world point on screen as of the last frame, in [0, 1] from the top left. */
|
|
130
132
|
project(x: number, y: number, z: number): [number, number] | undefined;
|
|
131
133
|
/** The footsteps of the player `id`'s runner so far (Gait.steps), undefined before it is drawn. */
|
|
@@ -136,8 +138,23 @@ export interface Renderer {
|
|
|
136
138
|
cheer(ids: number[]): void;
|
|
137
139
|
/** The body of each player (PlayerInfo.body, BODY), from the roster: the man's for one not in it. */
|
|
138
140
|
wear(builds: ReadonlyMap<number, number>): void;
|
|
141
|
+
/**
|
|
142
|
+
* A picture of the player `p` as the character `build` in `color`, into the 2D canvas `into`:
|
|
143
|
+
* a frame of him alone in the map's sky, which the next frame() replaces on the screen. False
|
|
144
|
+
* when nothing could be drawn yet.
|
|
145
|
+
*/
|
|
146
|
+
portrait(into: HTMLCanvasElement, p: PlayerState, build: number, color: string): boolean;
|
|
139
147
|
destroy(): void;
|
|
140
148
|
}
|
|
149
|
+
/** A character card's picture: how high over the map he stands (m), the camera's height over his feet and its distance (m), its angle off his front and his own off the sun (rad), and its field of view (degrees). */
|
|
150
|
+
export declare const PORTRAIT: {
|
|
151
|
+
y: number;
|
|
152
|
+
eye: number;
|
|
153
|
+
away: number;
|
|
154
|
+
turn: number;
|
|
155
|
+
sun: number;
|
|
156
|
+
fov: number;
|
|
157
|
+
};
|
|
141
158
|
/** Pixels drawn at most (1080p): every one is lit per light and shadow map, so a 4K screen at a pixel ratio of 2 would pay for 8 million. */
|
|
142
159
|
export declare const MAX_PIXELS: number;
|
|
143
160
|
/** The canvas size in device pixels: the CSS size times the pixel ratio (2 at most), scaled down to MAX_PIXELS. */
|
|
@@ -88,6 +88,10 @@ export declare const SOUND: {
|
|
|
88
88
|
/** Breathing in a space helmet (the user, 2026-11-10), in then out: air drawn through the regulator, and let out with its valve's hiss. */
|
|
89
89
|
readonly INHALE: 43;
|
|
90
90
|
readonly EXHALE: 44;
|
|
91
|
+
/** An automatic door (doors.ts) sliding open: its seals let go with a hiss and its servo whirs up. */
|
|
92
|
+
readonly DOOR: 45;
|
|
93
|
+
/** And sliding shut: the servo whirs down and the panels meet with a thump. */
|
|
94
|
+
readonly SHUT: 46;
|
|
91
95
|
};
|
|
92
96
|
/**
|
|
93
97
|
* The sounds of the game: one entry per sound, its voices layered, in SOUND order. A low-passed
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { World } from './world';
|
|
2
|
+
type Vec3 = [number, number, number];
|
|
3
|
+
export declare const DOOR: {
|
|
4
|
+
/**
|
|
5
|
+
* Metres from the doorway within which a player on foot opens it, and a driven rover. A dash
|
|
6
|
+
* from 7 m is there in 0.65 s (2.7 m of burst at 16 m/s, the rest at a sprint's 9), a rover at
|
|
7
|
+
* its 23.2 m/s from 14 m in 0.6 s: the door has been open 0.3 s and 0.25 s by then.
|
|
8
|
+
*/
|
|
9
|
+
R: number;
|
|
10
|
+
ROVER_R: number;
|
|
11
|
+
/** Ticks it takes to open (0.35 s) and to shut (0.5 s). */
|
|
12
|
+
OPEN: number;
|
|
13
|
+
SHUT: number;
|
|
14
|
+
/** Ticks it stays open after the last one has left: a second. */
|
|
15
|
+
HOLD: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* One tick of the doors of `w`: each opens while one of `feet` (the players who are up) is within
|
|
19
|
+
* DOOR.R of it or one of `rovers` (the driven ones) within DOOR.ROVER_R, stays open DOOR.HOLD ticks
|
|
20
|
+
* after the last, then shuts.
|
|
21
|
+
*/
|
|
22
|
+
export declare const swing: (w: World, feet: Vec3[], rovers?: Vec3[]) => void;
|
|
23
|
+
/** Every door shut: a new match. */
|
|
24
|
+
export declare const shut: (w: World) => void;
|
|
25
|
+
export {};
|
|
@@ -34,6 +34,11 @@ export declare const TUBES: Bx[];
|
|
|
34
34
|
export declare const HALL: number[][];
|
|
35
35
|
/** The mouths in the hall's wall (x and z of the middle from the centre, half width, height, depth): the door toward the flag, the tubes. */
|
|
36
36
|
export declare const MOUTHS: number[][];
|
|
37
|
+
/**
|
|
38
|
+
* The automatic doors of red's half (doors.ts), each the box its panels fill when shut: in the
|
|
39
|
+
* middle of the dome's door, then in the wall of each module's airlock.
|
|
40
|
+
*/
|
|
41
|
+
export declare const DOORS: Bx[];
|
|
37
42
|
/**
|
|
38
43
|
* What stands in the hall, about the dome's centre: ghosts, since client/moonbase.ts draws them
|
|
39
44
|
* with the hall (the sun's shadow map is 64 m wide, a brush across the hall would be drawn sunlit).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Input, PlayerInfo, Snapshot } from './types';
|
|
2
|
-
/** join: the first frame of a peer, `body` the character he picked (BODY, the man without it). map: the host picks the map of the next match (MAPS key). */
|
|
2
|
+
/** join: the first frame of a peer, `body` the character he picked (BODY, the man without it). map: the host picks the map of the next match (MAPS key). body: a joined player changes character (BODY), at once. */
|
|
3
3
|
export type ClientText = {
|
|
4
4
|
t: 'join';
|
|
5
5
|
name: string;
|
|
@@ -7,6 +7,9 @@ export type ClientText = {
|
|
|
7
7
|
} | {
|
|
8
8
|
t: 'map';
|
|
9
9
|
map: string;
|
|
10
|
+
} | {
|
|
11
|
+
t: 'body';
|
|
12
|
+
body: number;
|
|
10
13
|
};
|
|
11
14
|
/** What a player did in a match, for the end screen: it carries the name and the team, which a leaver takes out of the roster. */
|
|
12
15
|
export interface Result {
|
|
@@ -396,6 +396,8 @@ export interface Snapshot {
|
|
|
396
396
|
balls?: Ball[];
|
|
397
397
|
/** The map's rovers, in the order of WorldDef.rovers. Absent: none. */
|
|
398
398
|
rovers?: Rover[];
|
|
399
|
+
/** How far each of WorldDef.doors is open, 0 shut to 1, in sixteen steps on the wire. Absent: none. */
|
|
400
|
+
doors?: number[];
|
|
399
401
|
}
|
|
400
402
|
/** Room rules, set by the host. Defaults in constants.ts (RULES). */
|
|
401
403
|
export interface Rules {
|
|
@@ -30,9 +30,17 @@ export interface TeamDef {
|
|
|
30
30
|
/** The laser rifle rack, past the rail gun's: walking within RACK_R gives the rifle with RIFLE_MAX rounds. */
|
|
31
31
|
rifle?: Vec3;
|
|
32
32
|
}
|
|
33
|
+
/** A sliding door (doors.ts): the box its two panels fill when shut, in a doorway of the brushes. */
|
|
34
|
+
export interface Door {
|
|
35
|
+
min: Vec3;
|
|
36
|
+
max: Vec3;
|
|
37
|
+
}
|
|
33
38
|
export interface WorldDef {
|
|
34
39
|
/** Shown on the title screen. */
|
|
35
40
|
name?: string;
|
|
41
|
+
/** What kind of place it is, in a few words, and its story in two or three sentences: the title screen and the demo's map cards. */
|
|
42
|
+
tag?: string;
|
|
43
|
+
lore?: string;
|
|
36
44
|
brushes: Brush[];
|
|
37
45
|
/** The red team, then the blue one (TEAM). */
|
|
38
46
|
teams: [red: TeamDef, blue: TeamDef];
|
|
@@ -65,6 +73,8 @@ export interface WorldDef {
|
|
|
65
73
|
relief?: ReliefDef;
|
|
66
74
|
/** Where the rovers (rover.ts) are parked, each as a spawn: the middle of its wheels on the ground and the yaw of its nose. Absent: none. */
|
|
67
75
|
rovers?: Spawn[];
|
|
76
|
+
/** The automatic doors (doors.ts). Absent: none. */
|
|
77
|
+
doors?: Door[];
|
|
68
78
|
}
|
|
69
79
|
/** A world ready for physics and drawing: the definition and a grid of brushes on the floor plane. */
|
|
70
80
|
export interface World {
|
|
@@ -75,6 +85,15 @@ export interface World {
|
|
|
75
85
|
grid: Map<number, number[]>;
|
|
76
86
|
/** The lattice of WorldDef.relief. */
|
|
77
87
|
relief?: Relief;
|
|
88
|
+
/**
|
|
89
|
+
* The state of each of WorldDef.doors: how far it is open, 0 shut to 1, and the ticks it stays
|
|
90
|
+
* open with nobody near. The host's doors.ts moves it, the client copies it from the snapshot:
|
|
91
|
+
* ray() stops at a door less than half open, a body never does.
|
|
92
|
+
*/
|
|
93
|
+
doors?: {
|
|
94
|
+
open: number;
|
|
95
|
+
wait: number;
|
|
96
|
+
}[];
|
|
78
97
|
}
|
|
79
98
|
/** The key of the cell with integer coordinates (cx, cz). */
|
|
80
99
|
export declare const key: (cx: number, cz: number) => number;
|
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.117.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|