@korial29/tiny-fps 0.155.0 → 0.157.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.
@@ -24,6 +24,12 @@ export interface Audio {
24
24
  * turn, two at most and each once; none before the voice is decoded, a moment after unlock.
25
25
  */
26
26
  say(id: number): void;
27
+ /**
28
+ * Says clip `id` of the players' voices (CAST): placed and fainter with distance as play() with
29
+ * `at`, centred without; over the `radio`, thin as through a headset. False, and silent, until
30
+ * the voices are decoded.
31
+ */
32
+ speak(id: number, at?: Vec3, gain?: number, rate?: number, radio?: boolean): boolean;
27
33
  /** The sound `id` (one of LOOPED) as a loop, silent until its first set; the own player's, centred. */
28
34
  loop(id: number): Loop;
29
35
  /** Mutes or unmutes everything, music included. */
@@ -37,7 +43,9 @@ export interface Audio {
37
43
  * then MP3 where the browser cannot decode the first (older Safari).
38
44
  */
39
45
  export declare const SPRITES: (() => Promise<string>)[];
40
- export declare const createAudio: (layers?: Voice[][], sprites?: (() => Promise<string>)[], song?: () => Float32Array) => Audio;
46
+ /** The players' voices (voice/cast.ts), loaded the same way after the announcer's. */
47
+ export declare const VOICED: (() => Promise<string>)[];
48
+ export declare const createAudio: (layers?: Voice[][], sprites?: (() => Promise<string>)[], song?: () => Float32Array, voiced?: (() => Promise<string>)[]) => Audio;
41
49
  /** The mute choice of the last visit. Storage throws when blocked: no memory then. */
42
50
  export declare const savedMute: () => boolean;
43
51
  /** Flips mute, remembers it, and returns the new state. */
@@ -46,11 +46,13 @@ export declare const swung: (a?: Blade, b?: Blade) => number;
46
46
  export declare const struck: (a?: Blade, b?: Blade) => boolean;
47
47
  /** The pitch of a player's voice: the woman's higher, and each a little off the next by his id. */
48
48
  export declare const voiceOf: (id: number, body?: number) => number;
49
- export declare const createCombat: (world: World, audio: Pick<Audio, "play"> & Partial<Pick<Audio, "loop">>, hud: Pick<Hud, "vitals" | "hit" | "down">, fx: Pick<Effects, "fire" | "cut" | "wound" | "lie" | "quake" | "blow" | "punch">, tracer: Pick<Tracer, "flash" | "burst" | "blast" | "orbs" | "update" | "mount" | "crackle" | "charging" | "lightning">, ctl: {
49
+ export declare const createCombat: (world: World, audio: Pick<Audio, "play"> & Partial<Pick<Audio, "loop" | "speak">>, hud: Pick<Hud, "vitals" | "hit" | "down">, fx: Pick<Effects, "fire" | "cut" | "wound" | "lie" | "quake" | "blow" | "punch">, tracer: Pick<Tracer, "flash" | "burst" | "blast" | "orbs" | "update" | "mount" | "crackle" | "charging" | "lightning">, ctl: {
50
50
  pitch: number;
51
51
  }, balls: Pick<Balls, "fire" | "frame">,
52
52
  /** The muzzle of a runner's long gun as last drawn, from his feet (Renderer.muzzle()). */
53
53
  drawn?: (id: number) => Vec3 | undefined,
54
54
  /** The pitch of a player's voice (voiceOf()). */
55
- voice?: (id: number) => number) => Combat;
55
+ voice?: (id: number) => number,
56
+ /** A player's own voice in the players' sprite (speakerOf()). */
57
+ speaker?: (id: number) => number) => Combat;
56
58
  export {};
@@ -122,6 +122,12 @@ export interface Hud {
122
122
  * colour. The newest at the bottom, FEED_MAX at most, each gone after FEED_MS.
123
123
  */
124
124
  feed(by: [string, number], who: [string, number]): void;
125
+ /**
126
+ * An ally on the radio: the small screen with `name` in `team`'s colour opens for `s` seconds
127
+ * (and COMM_TAIL more), a newer one taking its place. Returns its canvas (COMM pixels square),
128
+ * cleared, for his face.
129
+ */
130
+ comm(name: string, team: number, s: number): HTMLCanvasElement;
125
131
  /**
126
132
  * The rover: `act` is what E does now ('drive', 'ride', 'get out'; '' hides the prompt), and
127
133
  * `speed` the km/h shown at the wheel, where the gun and the crosshair then hide; undefined off it.
@@ -160,6 +166,9 @@ export declare const BANNER_MS = 2800;
160
166
  export declare const FRAG_MS = 2400;
161
167
  export declare const FEED_MS = 6000;
162
168
  export declare const FEED_MAX = 5;
169
+ /** The radio screen's canvas, pixels a side, and the seconds it stays after its line. */
170
+ export declare const COMM = 192;
171
+ export declare const COMM_TAIL = 0.5;
163
172
  export declare const HIT_MS = 140;
164
173
  /** m:ss. */
165
174
  export declare const clock: (s: number) => string;
@@ -151,7 +151,7 @@ export interface Renderer {
151
151
  * `look`, framed by `shot` (PORTRAIT, or HEAD for the head alone), into the 2D canvas `into`: a frame of him alone in the map's sky, which the next
152
152
  * frame() replaces on the screen. False when nothing could be drawn yet.
153
153
  */
154
- portrait(into: HTMLCanvasElement, p: PlayerState, build: number, color: string, look?: Choice, shot?: typeof PORTRAIT): boolean;
154
+ portrait(into: HTMLCanvasElement, p: PlayerState, build: number, color: string, look?: Choice, shot?: Shot): boolean;
155
155
  destroy(): void;
156
156
  }
157
157
  /** 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), its field of view (degrees), and how far it steps to its right (m). */
@@ -174,6 +174,12 @@ export declare const HEAD: {
174
174
  y: number;
175
175
  sun: number;
176
176
  };
177
+ /** A picture's framing, and whether he grins in it. */
178
+ export type Shot = typeof PORTRAIT & {
179
+ grin?: boolean;
180
+ };
181
+ /** An ally's face on the radio screen: the head nearly from the front, grinning. */
182
+ export declare const FACE: Shot;
177
183
  /** 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. */
178
184
  export declare const MAX_PIXELS: number;
179
185
  /** The canvas size in device pixels: the CSS size times the pixel ratio (2 at most), scaled down to MAX_PIXELS. */
@@ -0,0 +1,47 @@
1
+ import type { Audio } from './audio';
2
+ import type { Vec3 } from './mesh';
3
+ /** Seconds from a frag to its taunt: the victim's cry first. */
4
+ export declare const TAUNT_DELAY = 0.6;
5
+ /** Seconds from an own frag to its taunt when the announcer has a line for it: after the line. */
6
+ export declare const TAUNT_LATE = 1.3;
7
+ /** Seconds a player keeps quiet after a taunt: a quick run of frags gets one. */
8
+ export declare const TAUNT_GAP = 4;
9
+ /** The voice of player `id` in a build (BODY): one of the man's or one of the woman's. */
10
+ export declare const speakerOf: (id: number, body?: number) => number;
11
+ /** A player's speed of speech, a little off the next's by his id, so that two in a voice differ. */
12
+ export declare const paceOf: (id: number) => number;
13
+ /**
14
+ * The clip (CAST) of what `speaker` says after his `n`th frag made `how` (FRAG): a word of his own
15
+ * for the fists and the katana, else one of the taunts, a new one each frag.
16
+ */
17
+ export declare const tauntOf: (speaker: number, how: number, n: number) => number;
18
+ /** The clip (CAST) of `speaker`'s `k`th cry as he goes down. */
19
+ export declare const deathOf: (speaker: number, k: number) => number;
20
+ /** An ally's line that began: who says it, and its seconds. */
21
+ export interface Said {
22
+ by: number;
23
+ s: number;
24
+ }
25
+ export interface Taunts {
26
+ /**
27
+ * The host's frag message `m` at `now` (s), told to the own player `me`: its author taunts
28
+ * `wait` s later, unless he taunted less than TAUNT_GAP s before.
29
+ */
30
+ frag(m: {
31
+ by: number;
32
+ who: number;
33
+ how: number;
34
+ n: number;
35
+ }, me: number, now: number, wait?: number): void;
36
+ /**
37
+ * Says the taunts due at `now` (s): the own and the one aimed at the own player centred, an
38
+ * ally's over the radio wherever he is, an enemy's from where `where` draws him (feet), unheard
39
+ * when it does not draw him. Returns the allies' lines that began.
40
+ */
41
+ frame(now: number, where: (id: number) => Vec3 | undefined): Said[];
42
+ }
43
+ export declare const createTaunts: (audio: Pick<Audio, "speak">,
44
+ /** A player's build (BODY) from the roster. */
45
+ body: (id: number) => number | undefined,
46
+ /** A player's team from the roster. */
47
+ team?: (id: number) => number | undefined) => Taunts;