@antha/entity-2d 0.1.0 → 0.1.2

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 -3
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -1,11 +1,55 @@
1
1
  # @antha/entity-2d
2
2
 
3
- A pre-built [Antha](https://www.npmjs.com/package/antha) mod for rendering and handling collision detection for 2D entities. This requires a mod that has setup PixiJS in a manner compatible with [@antha/graphics-2d](https://npmjs.com/package/@antha/graphics-2d)
4
-
5
- Demo: https://electrovir.github.io/antha/demo/basic-entities
3
+ This package provides a pre-built [Antha game engine](https://www.npmjs.com/package/@antha/engine) mod for creating, updating, rendering, and collision-checking 2D entities. It uses the PixiJS application supplied by [`@antha/graphics-2d`](https://npmjs.com/package/@antha/graphics-2d) to display entity views.
6
4
 
7
5
  ## Install
8
6
 
9
7
  ```sh
10
8
  npm i @antha/entity-2d
11
9
  ```
10
+
11
+ ## Usage
12
+
13
+ <!-- example-link: src/readme-examples/creating-logic-entity.example.ts -->
14
+
15
+ ```TypeScript
16
+ import {AnthaEngine, defineAnthaMod} from '@antha/engine';
17
+ import {createAnthaGraphics2dMod} from '@antha/graphics-2d';
18
+ import {type AnthaEntity2dModState, createAnthaEntityMod2d} from '@antha/entity-2d';
19
+
20
+ type GameState = AnthaEntity2dModState<{
21
+ hasCreatedScoreEntity: boolean;
22
+ }>;
23
+
24
+ const {defineLogicEntity, mod: entityMod} = createAnthaEntityMod2d<{
25
+ hasCreatedScoreEntity: boolean;
26
+ }>();
27
+
28
+ class ScoreEntity extends defineLogicEntity({
29
+ key: 'score',
30
+ paramsShape: undefined,
31
+ }) {
32
+ public override update() {}
33
+ }
34
+
35
+ const engine = new AnthaEngine<GameState>({
36
+ initState: {
37
+ hasCreatedScoreEntity: false,
38
+ },
39
+ mods: [
40
+ createAnthaGraphics2dMod(),
41
+ entityMod,
42
+ defineAnthaMod<GameState>({
43
+ modName: 'game-logic',
44
+ async execute({state}) {
45
+ if (state.entityStore && !state.hasCreatedScoreEntity) {
46
+ state.hasCreatedScoreEntity = true;
47
+ await state.entityStore.addEntity(ScoreEntity);
48
+ }
49
+ },
50
+ }),
51
+ ],
52
+ });
53
+
54
+ engine.startLoop();
55
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antha/entity-2d",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "An Antha mod for handling 2D entities.",
5
5
  "keywords": [
6
6
  "vir",
@@ -39,22 +39,22 @@
39
39
  "@augment-vir/common": "^32.2.2"
40
40
  },
41
41
  "devDependencies": {
42
- "@antha/engine": "^0.1.0",
43
- "@antha/web-test-runner-plugin-pixi": "^0.1.0",
42
+ "@antha/engine": "^0.1.2",
43
+ "@antha/web-test-runner-plugin-pixi": "^0.1.2",
44
44
  "@augment-vir/test": "^32.2.2",
45
45
  "@web/dev-server-esbuild": "^2.0.0",
46
46
  "@web/test-runner": "^1.0.0",
47
47
  "@web/test-runner-playwright": "^1.0.0",
48
48
  "detect-collisions": "^10.10.2025",
49
49
  "istanbul-smart-text-reporter": "^1.1.5",
50
- "object-shape-tester": "^6.14.1",
50
+ "object-shape-tester": "^6.15.0",
51
51
  "pixi.js": "^8.19.0",
52
52
  "typed-event-target": "^4.3.3"
53
53
  },
54
54
  "peerDependencies": {
55
- "@antha/asset": "^0.1.0",
56
- "@antha/engine": "*",
57
- "@antha/graphics-2d": "^0.1.0",
55
+ "@antha/asset": "^0.1.2",
56
+ "@antha/engine": "^0.1.2",
57
+ "@antha/graphics-2d": "^0.1.2",
58
58
  "detect-collisions": ">=10",
59
59
  "element-vir": ">=26",
60
60
  "object-shape-tester": ">=6",