@maco-online/paint-tanks-rules 0.3.0 → 0.4.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.
@@ -3,8 +3,8 @@ import { PaintTanksSimulation } from "../simulation.js";
3
3
  import { ENEMY_KINDS, PARTICLE_TYPES, PICKUP_TYPES, TANK_KINDS } from "./protocol.js";
4
4
  /** Effects between two states are capped, so a burst of explosions cannot make one message huge. */
5
5
  const MAX_EVENTS_PER_STATE = 300;
6
- /** The map is sent at least this often, in states, for members who joined since it last changed. */
7
- const MAP_KEYFRAME_EVERY = 20;
6
+ /** The map is sent at least this often, in states (about two-thirds of a second), for members who joined since it last changed. */
7
+ const MAP_KEYFRAME_EVERY = 40;
8
8
  /** The command a member has not yet sent anything replaces: hold still at whatever place it has. */
9
9
  const IDLE = { d: -1, f: false, x: 0, y: 0, n: 0 };
10
10
  /** Rounds a coordinate to a tenth of a pixel, which is all a browser needs to draw it. */
@@ -6,13 +6,16 @@ import type { SoundName } from '../sound-names.ts';
6
6
  import { z } from 'zod';
7
7
  /**
8
8
  * What Paint Tanks puts in the generic room protocol: a player's controls, the host's lobby settings, each
9
- * member's tank, and the state of the field, packed into short arrays because it is sent 20 times a second.
9
+ * member's tank, and the state of the field, packed into short arrays because it is sent 60 times a second.
10
10
  */
11
11
  export declare const PAINT_TANKS_ONLINE_GAME = "paint-tanks";
12
12
  export declare const PAINT_TANKS_TEAM_SIZE = 5;
13
13
  export declare const PAINT_TANKS_TICK_RATE = 60;
14
- /** A state every 2 ticks: 30 a second, so a late packet rarely leaves a visible gap. */
15
- export declare const PAINT_TANKS_STATE_EVERY = 2;
14
+ /**
15
+ * A state every tick: 60 a second. Each state is about a kilobyte, and with one per tick a browser needs only a
16
+ * tick or two of states in hand to blend between, so every tank and shot is drawn that much closer to the present.
17
+ */
18
+ export declare const PAINT_TANKS_STATE_EVERY = 1;
16
19
  /** Tanks by their number on the wire: append new tanks at the end and never reorder, so the numbers stay put. */
17
20
  export declare const TANK_KINDS: readonly ["ducky", "bunny", "robo", "dino", "bee", "crab", "firetruck", "penguin", "turtle", "frog", "unicorn", "swordfish", "octopus", "giraffe", "elephant", "mole", "cat", "bear", "piggy"];
18
21
  /** Enemies by their number on the wire; append only, as for `TANK_KINDS`. */
@@ -2,13 +2,16 @@ import { z } from 'zod';
2
2
  import { MAX_TEAM, MAXL } from "../constants.js";
3
3
  /**
4
4
  * What Paint Tanks puts in the generic room protocol: a player's controls, the host's lobby settings, each
5
- * member's tank, and the state of the field, packed into short arrays because it is sent 20 times a second.
5
+ * member's tank, and the state of the field, packed into short arrays because it is sent 60 times a second.
6
6
  */
7
7
  export const PAINT_TANKS_ONLINE_GAME = 'paint-tanks';
8
8
  export const PAINT_TANKS_TEAM_SIZE = MAX_TEAM;
9
9
  export const PAINT_TANKS_TICK_RATE = 60;
10
- /** A state every 2 ticks: 30 a second, so a late packet rarely leaves a visible gap. */
11
- export const PAINT_TANKS_STATE_EVERY = 2;
10
+ /**
11
+ * A state every tick: 60 a second. Each state is about a kilobyte, and with one per tick a browser needs only a
12
+ * tick or two of states in hand to blend between, so every tank and shot is drawn that much closer to the present.
13
+ */
14
+ export const PAINT_TANKS_STATE_EVERY = 1;
12
15
  /** Tanks by their number on the wire: append new tanks at the end and never reorder, so the numbers stay put. */
13
16
  export const TANK_KINDS = [
14
17
  'ducky',
@@ -3,7 +3,7 @@ import { PAINT_TANKS_ONLINE_GAME, PAINT_TANKS_STATE_EVERY, PAINT_TANKS_TEAM_SIZE
3
3
  /** Paint Tanks as the room server hosts it: up to five players on one team against the dust tanks. */
4
4
  export const paintTanksRoomGame = {
5
5
  id: PAINT_TANKS_ONLINE_GAME,
6
- protocolVersion: 3,
6
+ protocolVersion: 4,
7
7
  maxMembers: PAINT_TANKS_TEAM_SIZE,
8
8
  tickRate: PAINT_TANKS_TICK_RATE,
9
9
  stateEvery: PAINT_TANKS_STATE_EVERY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maco-online/paint-tanks-rules",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "The pure Paint Tanks rules (simulation, levels, AI, wire protocol, prediction) and its Maco room definition",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "sideEffects": false,
13
13
  "maco": {
14
- "protocolVersion": 3
14
+ "protocolVersion": 4
15
15
  },
16
16
  "exports": {
17
17
  ".": {