@korial29/tiny-fps 0.53.1 → 0.54.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 -2
- package/dist/index.js +15 -15
- package/dist/local.js +1 -1
- package/dist/server.js +104 -30
- package/dist/types/client/beams.d.ts +2 -0
- package/dist/types/client/combat.d.ts +2 -2
- package/dist/types/client/flag.d.ts +2 -0
- package/dist/types/client/gun.d.ts +33 -10
- package/dist/types/client/hud.d.ts +3 -2
- package/dist/types/client/input.d.ts +7 -6
- package/dist/types/client/props.d.ts +4 -4
- package/dist/types/client/sfx.d.ts +2 -0
- package/dist/types/shared/constants.d.ts +14 -0
- package/dist/types/shared/gun.d.ts +4 -1
- package/dist/types/shared/physics.d.ts +4 -0
- package/dist/types/shared/protocol.d.ts +1 -1
- package/dist/types/shared/rail.d.ts +13 -3
- package/dist/types/shared/room.d.ts +3 -1
- package/dist/types/shared/types.d.ts +10 -0
- package/dist/types/shared/world.d.ts +2 -0
- package/package.json +1 -1
|
@@ -27,9 +27,10 @@ export interface Hud {
|
|
|
27
27
|
* (charge(), 99 full) with the gun glyph in violet when `railed`. -1 ammo is no gun, `blade` is a
|
|
28
28
|
* katana carried, `rail` the rail gun's lightning (-1 none); two or more carried show their slots (1 gun, 2 katana, 3 rail gun)
|
|
29
29
|
* over the glyph, none hides it. `loaded` is what the battery or the capsule of the gun in hand
|
|
30
|
-
* holds, in the same count: big, with the rest after it; faded while `swapping` it.
|
|
30
|
+
* holds, in the same count: big, with the rest after it; faded while `swapping` it. `rifle` is the
|
|
31
|
+
* laser rifle's rounds (-1 none), shown with the glyph in red when `rifled` (slot 4).
|
|
31
32
|
*/
|
|
32
|
-
vitals(hp: number, ammo: number, blade?: boolean, wield?: boolean, rail?: number, railed?: boolean, loaded?: number, swapping?: boolean): void;
|
|
33
|
+
vitals(hp: number, ammo: number, blade?: boolean, wield?: boolean, rail?: number, railed?: boolean, loaded?: number, swapping?: boolean, rifle?: number, rifled?: boolean): void;
|
|
33
34
|
/** A hit marker on the crosshair for a moment: a ball or a cut of the own player hit. */
|
|
34
35
|
hit(): void;
|
|
35
36
|
/**
|
|
@@ -9,25 +9,26 @@ export declare const keyBit: (code: string) => number;
|
|
|
9
9
|
export declare const DOUBLE_CLICK_MS = 300;
|
|
10
10
|
/** The wheel swaps the weapon at most this often (ms): a trackpad's flick is a hundred events, one swap. */
|
|
11
11
|
export declare const WHEEL_MS = 250;
|
|
12
|
-
/** The weapon chosen: 1, 2 and
|
|
12
|
+
/** The weapon chosen: 1, 2, 3 and 4 on the keyboard. */
|
|
13
13
|
export declare const WEAPON: {
|
|
14
14
|
readonly GUN: 0;
|
|
15
15
|
readonly BLADE: 1;
|
|
16
16
|
readonly RAIL: 2;
|
|
17
|
+
readonly RIFLE: 3;
|
|
17
18
|
};
|
|
18
|
-
/** The choice after a key: 1 the gun, 2 the katana, 3 the rail gun, any other key keeps it. */
|
|
19
|
+
/** The choice after a key: 1 the gun, 2 the katana, 3 the rail gun, 4 the laser rifle, any other key keeps it. */
|
|
19
20
|
export declare const picked: (weapon: number, code: string) => number;
|
|
20
|
-
/** Which of the gun, the katana
|
|
21
|
+
/** Which of the gun, the katana, the rail gun and the laser rifle a player has; all of them when there is no state yet. */
|
|
21
22
|
export declare const owned: (p?: PlayerState) => boolean[];
|
|
22
23
|
/**
|
|
23
|
-
* The choice after a step of the own player. Picking the katana
|
|
24
|
+
* The choice after a step of the own player. Picking the katana, the rail gun or the rifle up switches to
|
|
24
25
|
* it, once; losing every weapon (going down) goes back to the gun; anything else, the gun picked
|
|
25
26
|
* up included, keeps it.
|
|
26
27
|
*/
|
|
27
28
|
export declare const chosen: (weapon: number, was?: PlayerState, now?: PlayerState) => number;
|
|
28
|
-
/** The keys of a step with KEY.BLADE set while the katana is the choice, KEY.RAIL while the rail gun is. */
|
|
29
|
+
/** The keys of a step with KEY.BLADE set while the katana is the choice, KEY.RAIL while the rail gun is, KEY.RIFLE while the rifle is. */
|
|
29
30
|
export declare const withWeapon: (keys: number, weapon: number) => number;
|
|
30
|
-
/** The choice the wheel turns to, `dir` 1 or -1: the next weapon he has, round the
|
|
31
|
+
/** The choice the wheel turns to, `dir` 1 or -1: the next weapon he has, round the four. */
|
|
31
32
|
export declare const turned: (weapon: number, dir: number, have: boolean[]) => number;
|
|
32
33
|
/** Live look angles and held keys; the loop reads them once per step and per frame. */
|
|
33
34
|
export interface Controls {
|
|
@@ -6,12 +6,12 @@ import type { Vec3 } from './mesh';
|
|
|
6
6
|
export declare const packsOf: (all?: readonly Vec3[], mask?: number, from?: number) => Vec3[];
|
|
7
7
|
/**
|
|
8
8
|
* A rack at `at` (a point on a top): a post and a dish, a ring on the roof of the radius that gives
|
|
9
|
-
* the weapon, and the weapon over it: the gun, or by `kind` the katana (1), crackling,
|
|
10
|
-
* gun (2).
|
|
9
|
+
* the weapon, and the weapon over it: the gun, or by `kind` the katana (1), crackling, the rail
|
|
10
|
+
* gun (2) or the laser rifle (3).
|
|
11
11
|
*/
|
|
12
12
|
export declare const rack: (out: number[], at: Vec3, rgb: number[], t: number, kind?: number) => void;
|
|
13
|
-
/** Each team's gun rack, katana rack
|
|
14
|
-
export declare const racks: (out: number[], guns?: readonly (Vec3 | undefined)[], blades?: readonly (Vec3 | undefined)[], t?: number, rails?: readonly (Vec3 | undefined)[]) => void;
|
|
13
|
+
/** Each team's gun rack, katana rack, rail gun rack and laser rifle rack, where it has them. */
|
|
14
|
+
export declare const racks: (out: number[], guns?: readonly (Vec3 | undefined)[], blades?: readonly (Vec3 | undefined)[], t?: number, rails?: readonly (Vec3 | undefined)[], rifles?: readonly (Vec3 | undefined)[]) => void;
|
|
15
15
|
/** A health pack at `at`: a white box with a glowing green cross on each side. */
|
|
16
16
|
export declare const kit: (out: number[], at: Vec3, t: number) => void;
|
|
17
17
|
/** An ammo pack at `at`: a violet box with a glowing cyan cartridge on each side, the gun's colours. */
|
|
@@ -71,6 +71,8 @@ export declare const SOUND: {
|
|
|
71
71
|
readonly POP: 33;
|
|
72
72
|
readonly SCREW: 34;
|
|
73
73
|
readonly BOOT: 35;
|
|
74
|
+
/** The laser rifle's shot: a bright zip that falls, short enough for 8.6 a second. */
|
|
75
|
+
readonly LASE: 36;
|
|
74
76
|
};
|
|
75
77
|
/**
|
|
76
78
|
* The sounds of the game: one entry per sound, its voices layered, in SOUND order. A low-passed
|
|
@@ -289,6 +289,20 @@ export declare const RAIL_RANGE = 30;
|
|
|
289
289
|
export declare const RAIL_TICKS = 180;
|
|
290
290
|
export declare const RAIL_DRAIN = 60;
|
|
291
291
|
export declare const SLOW_SPEED = 3;
|
|
292
|
+
/**
|
|
293
|
+
* The laser rifle (the user, 2026-11-08), held in both hands, after Halo's assault rifle: taken at
|
|
294
|
+
* the team's fourth rack with RIFLE_MAX rounds, it fires while FIRE is held, one round each
|
|
295
|
+
* RIFLE_COOL ticks from a power cell of RIFLE_CLIP (RIFLE_RELOAD to swap). Each shot is an instant
|
|
296
|
+
* beam RIFLE_RANGE metres along the look, drifted by up to RIFLE_DRIFT radians in a pattern of the
|
|
297
|
+
* shot count, and takes RIFLE_HP from the first enemy it enters. Rounds and the cell are u8 on the wire.
|
|
298
|
+
*/
|
|
299
|
+
export declare const RIFLE_MAX = 120;
|
|
300
|
+
export declare const RIFLE_CLIP = 30;
|
|
301
|
+
export declare const RIFLE_RELOAD = 96;
|
|
302
|
+
export declare const RIFLE_COOL = 7;
|
|
303
|
+
export declare const RIFLE_RANGE = 60;
|
|
304
|
+
export declare const RIFLE_DRIFT = 0.012;
|
|
305
|
+
export declare const RIFLE_HP = 1;
|
|
292
306
|
/** Seconds a carrier who is made to drop the flag cannot take it again: he would pick it up where he stands. */
|
|
293
307
|
export declare const FLAG_LOCK = 2;
|
|
294
308
|
/** Seconds the end screen of a match stays, then a new match starts. */
|
|
@@ -3,12 +3,13 @@ import type { World } from './world';
|
|
|
3
3
|
type Vec3 = [number, number, number];
|
|
4
4
|
/** Whether the feet of `p` are within `r` of the point `at` on the floor plane and within PICK_H of its height. */
|
|
5
5
|
export declare const within: (p: PlayerState, at: Vec3, r: number) => boolean;
|
|
6
|
-
/** What a step struck, for the host to resolve: nothing, a shot (a plasma ball), the katana's cut,
|
|
6
|
+
/** What a step struck, for the host to resolve: nothing, a shot (a plasma ball), the katana's cut, a rail gun's beam, or a laser rifle's shot. */
|
|
7
7
|
export declare const STRIKE: {
|
|
8
8
|
readonly NONE: 0;
|
|
9
9
|
readonly SHOT: 1;
|
|
10
10
|
readonly CUT: 2;
|
|
11
11
|
readonly RAIL: 3;
|
|
12
|
+
readonly LASER: 4;
|
|
12
13
|
};
|
|
13
14
|
export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
|
|
14
15
|
/**
|
|
@@ -27,6 +28,8 @@ export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
|
|
|
27
28
|
* without firing, then it holds GUN_MAG (RAIL_CAP) or what is left. A switch of weapon drops it.
|
|
28
29
|
* The racks fill both.
|
|
29
30
|
* - The rail gun throws its bolt on every step FIRE is held, spending a tick of it (`zapping`).
|
|
31
|
+
* - The laser rifle (KEY.RIFLE, `rifled`), filled at its rack on arrival, fires a round from its
|
|
32
|
+
* cell (`clip`) each RIFLE_COOL ticks while FIRE is held (STRIKE.LASER).
|
|
30
33
|
* - The trigger: `cool` and `swing` run down, and at 0 a held FIRE charges the gun, with ammo, and
|
|
31
34
|
* letting it go fires a ball as strong as the charge (powerOf()), spending as many shots; or it
|
|
32
35
|
* starts the katana's swing (`cut` from the keys), unless the hands are busy (a hang, a climb).
|
|
@@ -28,7 +28,7 @@ export declare const MSG_INPUT = 1;
|
|
|
28
28
|
export declare const MSG_SNAPSHOT = 2;
|
|
29
29
|
export declare const INPUT_BYTES = 12;
|
|
30
30
|
export declare const SNAP_HEAD = 4;
|
|
31
|
-
export declare const SNAP_PLAYER =
|
|
31
|
+
export declare const SNAP_PLAYER = 60;
|
|
32
32
|
/** The match block after the players: the captures, the clock, the packs; the flags follow (2 to 16 bytes). */
|
|
33
33
|
export declare const SNAP_MATCH = 10;
|
|
34
34
|
/** Bytes of a plasma ball. */
|
|
@@ -2,10 +2,20 @@ import type { PlayerState } from './types';
|
|
|
2
2
|
import type { World } from './world';
|
|
3
3
|
type Vec3 = [number, number, number];
|
|
4
4
|
/**
|
|
5
|
-
* The beam `p` fires along his look: where it starts (his eye), its
|
|
6
|
-
* (to the first brush, or
|
|
5
|
+
* The beam `p` fires along his look, turned by `drift` (yaw, pitch): where it starts (his eye), its
|
|
6
|
+
* unit direction, how far it goes (to the first brush, or `range`) and the first of `foes` whose
|
|
7
|
+
* body it enters before that.
|
|
7
8
|
*/
|
|
8
|
-
export declare const beam: (w: World, p: PlayerState, foes?: PlayerState[]) => {
|
|
9
|
+
export declare const beam: (w: World, p: PlayerState, foes?: PlayerState[], range?: number, [dy, dp]?: [number, number]) => {
|
|
10
|
+
o: Vec3;
|
|
11
|
+
d: Vec3;
|
|
12
|
+
t: number;
|
|
13
|
+
hit?: PlayerState;
|
|
14
|
+
};
|
|
15
|
+
/** How far shot `n` of the laser rifle drifts off the look, yaw and pitch: a pattern within RIFLE_DRIFT, the same for the host and every client. */
|
|
16
|
+
export declare const drift: (n: number) => [number, number];
|
|
17
|
+
/** The laser rifle's beam of `p`, its last shot (`shots`): drifted, to RIFLE_RANGE. */
|
|
18
|
+
export declare const laser: (w: World, p: PlayerState, foes?: PlayerState[]) => {
|
|
9
19
|
o: Vec3;
|
|
10
20
|
d: Vec3;
|
|
11
21
|
t: number;
|
|
@@ -89,6 +89,8 @@ export declare class Room {
|
|
|
89
89
|
* and counts a hit.
|
|
90
90
|
*/
|
|
91
91
|
private rail;
|
|
92
|
+
/** The laser rifle's shot of `p` at the view tick `view`: RIFLE_HP to the first enemy it enters as `p` drew him, and a hit. */
|
|
93
|
+
private laser;
|
|
92
94
|
/** 1 hp of the bolt's drain to `foe`; if it puts him down he is disintegrated (`fried`). */
|
|
93
95
|
private fry;
|
|
94
96
|
/**
|
|
@@ -101,7 +103,7 @@ export declare class Room {
|
|
|
101
103
|
/**
|
|
102
104
|
* The packs, health ones first, then the ammo ones, then the rail cells: one that is gone comes
|
|
103
105
|
* back after PACK_BACK s, an ammo pack after AMMO_BACK s. A health pack goes to a hurt player standing at it, an ammo pack to one
|
|
104
|
-
* with the gun
|
|
106
|
+
* with the gun short of AMMO_MAX or the laser rifle short of RIFLE_MAX (RIFLE_CLIP more rounds), a rail cell to one with the rail gun and less than
|
|
105
107
|
* RAIL_MAX of lightning. Both change the state between two inputs, like a hit: the snapshot
|
|
106
108
|
* carries the result and the predictor replays its unacked inputs on it.
|
|
107
109
|
*/
|
|
@@ -49,6 +49,8 @@ export declare const KEY: {
|
|
|
49
49
|
readonly RAIL: 2048;
|
|
50
50
|
/** Press to swap the battery or the capsule of the gun in hand (see GUN_MAG). */
|
|
51
51
|
readonly RELOAD: 4096;
|
|
52
|
+
/** Set while the player wants the laser rifle in hand (4 or the wheel), with BLADE and RAIL clear. Ignored without it. */
|
|
53
|
+
readonly RIFLE: 8192;
|
|
52
54
|
};
|
|
53
55
|
/**
|
|
54
56
|
* The katana's cuts (PlayerState.cut, constants CUTS), chosen by the keys held when FIRE starts
|
|
@@ -194,6 +196,14 @@ export interface PlayerState {
|
|
|
194
196
|
cap?: number;
|
|
195
197
|
/** Ticks left swapping the battery or the capsule of the gun in hand, 0 when not. Absent reads 0. */
|
|
196
198
|
reload?: number;
|
|
199
|
+
/** Rounds left in the laser rifle; absent or -1 without it (taken at the team's fourth rack, lost on going down). */
|
|
200
|
+
rifle?: number;
|
|
201
|
+
/** Rounds in the laser rifle's power cell, of `rifle` (RIFLE_CLIP at most). Absent reads 0. */
|
|
202
|
+
clip?: number;
|
|
203
|
+
/** The laser rifle is in hand (see KEY.RIFLE). Absent reads false. */
|
|
204
|
+
rifled?: boolean;
|
|
205
|
+
/** Standing inside the circle of the team's rifle rack as of the last step. Absent reads false. */
|
|
206
|
+
inRifle?: boolean;
|
|
197
207
|
/** Ticks FIRE has been held with the gun, up to CHARGE_TICKS, 0 when not charging. Absent reads 0. */
|
|
198
208
|
charge?: number;
|
|
199
209
|
/** The strength of the last shot, 1 to CHARGE_MAX: the shots it spent and the health it takes. Set by the step that fires; not on the wire. */
|
|
@@ -24,6 +24,8 @@ export interface TeamDef {
|
|
|
24
24
|
blade?: Vec3;
|
|
25
25
|
/** The rail gun rack, on the other side of the gun rack: walking within RACK_R gives the rail gun with RAIL_MAX shots. */
|
|
26
26
|
rail?: Vec3;
|
|
27
|
+
/** The laser rifle rack, past the rail gun's: walking within RACK_R gives the rifle with RIFLE_MAX rounds. */
|
|
28
|
+
rifle?: Vec3;
|
|
27
29
|
}
|
|
28
30
|
export interface WorldDef {
|
|
29
31
|
/** Shown on the title screen. */
|
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.54.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|