@antha/multiplayer-p2p-lock-step 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +47 -1
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,3 +1,49 @@
1
1
  # @antha/multiplayer-p2p-lock-step
2
2
 
3
- A multiplayer mod for the Antha engine that uses peer-to-peer lock-step for game state synchronization.
3
+ This package provides a pre-built [Antha game engine](https://www.npmjs.com/package/@antha/engine) mod for peer-to-peer lock-step multiplayer state synchronization. Players submit actions, and the host distributes them as ordered frames so every client advances game state in the same order.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm i @antha/multiplayer-p2p-lock-step
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ <!-- example-link: src/readme-examples/creating-lock-step-game.example.ts -->
14
+
15
+ ```TypeScript
16
+ import {AnthaEngine, defineAnthaMod} from '@antha/engine';
17
+ import {
18
+ type AnthaMultiplayerP2pLockStepState,
19
+ createAnthaMultiplayerP2pLockStepMod,
20
+ } from '@antha/multiplayer-p2p-lock-step';
21
+
22
+ type GameState = AnthaMultiplayerP2pLockStepState<string>;
23
+
24
+ const engine = new AnthaEngine<GameState>({
25
+ mods: [
26
+ createAnthaMultiplayerP2pLockStepMod<string>({
27
+ gameId: 'my-game',
28
+ }),
29
+ defineAnthaMod<GameState>({
30
+ modName: 'game-logic',
31
+ execute({state}) {
32
+ const controller = state.multiplayerP2pLockStep?.multiplayerController;
33
+
34
+ if (!controller) {
35
+ return;
36
+ }
37
+ if (!controller.isConnected()) {
38
+ controller.startSingleplayer();
39
+ controller.act('move-left');
40
+ }
41
+
42
+ return `Network FPS: ${controller.getFps()}`;
43
+ },
44
+ }),
45
+ ],
46
+ });
47
+
48
+ engine.startLoop();
49
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antha/multiplayer-p2p-lock-step",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Multiplayer mod for the Antha engine.",
5
5
  "keywords": [
6
6
  "vir",
@@ -49,7 +49,7 @@
49
49
  "istanbul-smart-text-reporter": "^1.1.5"
50
50
  },
51
51
  "peerDependencies": {
52
- "@antha/multiplayer-core": "^0.1.0"
52
+ "@antha/multiplayer-core": "^0.1.1"
53
53
  },
54
54
  "engines": {
55
55
  "node": ">=22"