@zylem/game-lib 0.6.0 → 0.6.3

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 (54) hide show
  1. package/README.md +9 -16
  2. package/dist/actions.d.ts +30 -21
  3. package/dist/actions.js +628 -145
  4. package/dist/actions.js.map +1 -1
  5. package/dist/behavior/platformer-3d.d.ts +296 -0
  6. package/dist/behavior/platformer-3d.js +518 -0
  7. package/dist/behavior/platformer-3d.js.map +1 -0
  8. package/dist/behavior/ricochet-2d.d.ts +274 -0
  9. package/dist/behavior/ricochet-2d.js +394 -0
  10. package/dist/behavior/ricochet-2d.js.map +1 -0
  11. package/dist/behavior/screen-wrap.d.ts +86 -0
  12. package/dist/behavior/screen-wrap.js +195 -0
  13. package/dist/behavior/screen-wrap.js.map +1 -0
  14. package/dist/behavior/thruster.d.ts +10 -0
  15. package/dist/behavior/thruster.js +234 -0
  16. package/dist/behavior/thruster.js.map +1 -0
  17. package/dist/behavior/world-boundary-2d.d.ts +141 -0
  18. package/dist/behavior/world-boundary-2d.js +181 -0
  19. package/dist/behavior/world-boundary-2d.js.map +1 -0
  20. package/dist/behavior-descriptor-BWNWmIjv.d.ts +142 -0
  21. package/dist/{blueprints-BOCc3Wve.d.ts → blueprints-BWGz8fII.d.ts} +2 -2
  22. package/dist/camera-B5e4c78l.d.ts +468 -0
  23. package/dist/camera.d.ts +3 -2
  24. package/dist/camera.js +962 -166
  25. package/dist/camera.js.map +1 -1
  26. package/dist/composition-DrzFrbqI.d.ts +218 -0
  27. package/dist/{core-CZhozNRH.d.ts → core-DAkskq6Y.d.ts} +97 -65
  28. package/dist/core.d.ts +12 -6
  29. package/dist/core.js +4449 -1052
  30. package/dist/core.js.map +1 -1
  31. package/dist/{entities-BAxfJOkk.d.ts → entities-DC9ce_vx.d.ts} +154 -45
  32. package/dist/entities.d.ts +5 -2
  33. package/dist/entities.js +2505 -722
  34. package/dist/entities.js.map +1 -1
  35. package/dist/entity-BpbZqg19.d.ts +1100 -0
  36. package/dist/entity-types-DAu8sGJH.d.ts +26 -0
  37. package/dist/global-change-Dc8uCKi2.d.ts +25 -0
  38. package/dist/main.d.ts +472 -29
  39. package/dist/main.js +11877 -6124
  40. package/dist/main.js.map +1 -1
  41. package/dist/{stage-types-CD21XoIU.d.ts → stage-types-BFsm3qsZ.d.ts} +255 -26
  42. package/dist/stage.d.ts +11 -6
  43. package/dist/stage.js +3462 -491
  44. package/dist/stage.js.map +1 -1
  45. package/dist/thruster-DhRaJnoL.d.ts +172 -0
  46. package/dist/world-Be5m1XC1.d.ts +31 -0
  47. package/package.json +21 -4
  48. package/dist/behaviors.d.ts +0 -106
  49. package/dist/behaviors.js +0 -398
  50. package/dist/behaviors.js.map +0 -1
  51. package/dist/camera-CpbDr4-V.d.ts +0 -116
  52. package/dist/entity-COvRtFNG.d.ts +0 -395
  53. package/dist/moveable-B_vyA6cw.d.ts +0 -67
  54. package/dist/transformable-CUhvyuYO.d.ts +0 -67
package/README.md CHANGED
@@ -39,10 +39,15 @@ npm install @zylem/game-lib
39
39
  * the ball can be controlled with the arrow keys or gamepad
40
40
  * the ball cannot go outside the boundaries
41
41
  */
42
- import { boundary2d, createGame, makeMoveable, sphere } from '@zylem/game-lib';
42
+ import { createGame, createSphere, WorldBoundary2DBehavior } from '@zylem/game-lib';
43
43
 
44
- // Creates a moveable sphere
45
- const ball = makeMoveable(await sphere());
44
+ // Creates a sphere (movement capabilities are built-in)
45
+ const ball = createSphere();
46
+
47
+ // attach boundary behavior
48
+ ball.use(WorldBoundary2DBehavior, {
49
+ boundaries: { top: 3, bottom: -3, left: -6, right: 6 },
50
+ });
46
51
 
47
52
  // when the ball is updated, move it based on the inputs
48
53
  ball.onUpdate(({ me, inputs, delta }) => {
@@ -54,20 +59,8 @@ ball.onUpdate(({ me, inputs, delta }) => {
54
59
  me.moveXY(Horizontal.value * speed, -Vertical.value * speed);
55
60
  });
56
61
 
57
- // add a boundary behavior to the ball
58
- ball.addBehavior(
59
- boundary2d({
60
- boundaries: {
61
- top: 3,
62
- bottom: -3,
63
- left: -6,
64
- right: 6,
65
- },
66
- }),
67
- );
68
-
69
62
  // start the game with the ball
70
- createGame(ball).start();
63
+ createGame(ball);
71
64
  ```
72
65
 
73
66
  ## Development
package/dist/actions.d.ts CHANGED
@@ -1,25 +1,34 @@
1
- export { m as makeMoveable } from './moveable-B_vyA6cw.js';
2
- export { m as makeRotatable, a as makeTransformable } from './transformable-CUhvyuYO.js';
1
+ import { T as TransformState } from './entity-BpbZqg19.js';
2
+ export { A as Action, c as createTransformStore, i as getPosition, H as getRotation, j as getVelocity, m as move, h as moveForwardXY, a as moveX, e as moveXY, f as moveXZ, b as moveY, d as moveZ, r as resetTransformStore, g as resetVelocity, t as rotateEuler, p as rotateInDirection, u as rotateX, v as rotateY, q as rotateYEuler, x as rotateZ, s as setPosition, k as setPositionX, l as setPositionY, n as setPositionZ, G as setRotation, C as setRotationDegrees, E as setRotationDegreesX, D as setRotationDegreesY, F as setRotationDegreesZ, z as setRotationX, y as setRotationY, B as setRotationZ, o as wrapAround3D, w as wrapAroundXY } from './entity-BpbZqg19.js';
3
+ export { c as callFunc, d as delay, m as moveBy, a as moveTo, o as onPress, b as onRelease, p as parallel, e as repeat, f as repeatForever, r as rotateBy, s as sequence, t as throttle } from './composition-DrzFrbqI.js';
4
+ import { RigidBody } from '@dimforge/rapier3d-compat';
5
+ export { g as globalChange, a as globalChanges, v as variableChange, b as variableChanges } from './global-change-Dc8uCKi2.js';
3
6
  import 'three';
4
- import '@dimforge/rapier3d-compat';
7
+ import 'bitecs';
8
+ import 'mitt';
9
+ import './behavior-descriptor-BWNWmIjv.js';
5
10
 
6
- declare function wait(delay: number, callback: Function): void;
7
- declare const actionOnPress: (isPressed: boolean, callback: Function) => void;
8
- declare const actionOnRelease: (isPressed: boolean, callback: Function) => void;
9
- type CooldownOptions = {
10
- timer: number;
11
- immediate?: boolean;
12
- };
13
- declare const actionWithCooldown: ({ timer, immediate }: CooldownOptions, callback: Function, update: Function) => void;
14
- declare const actionWithThrottle: (timer: number, callback: Function) => void;
15
-
16
- declare const actions_actionOnPress: typeof actionOnPress;
17
- declare const actions_actionOnRelease: typeof actionOnRelease;
18
- declare const actions_actionWithCooldown: typeof actionWithCooldown;
19
- declare const actions_actionWithThrottle: typeof actionWithThrottle;
20
- declare const actions_wait: typeof wait;
21
- declare namespace actions {
22
- export { actions_actionOnPress as actionOnPress, actions_actionOnRelease as actionOnRelease, actions_actionWithCooldown as actionWithCooldown, actions_actionWithThrottle as actionWithThrottle, actions_wait as wait };
11
+ /**
12
+ * Entity that can have transformations applied from a store
13
+ */
14
+ interface TransformableEntity {
15
+ body: RigidBody | null;
16
+ transformStore?: TransformState;
23
17
  }
18
+ /**
19
+ * Apply accumulated transformations from the store to the physics body.
20
+ *
21
+ * This is called automatically after onUpdate() callbacks complete,
22
+ * flushing all pending transformations to the physics engine in a single batch.
23
+ *
24
+ * Flow:
25
+ * 1. Check dirty flags to see what changed
26
+ * 2. Apply changes to RigidBody
27
+ * 3. Reset store for next frame
28
+ *
29
+ * @param entity Entity with physics body and transform store
30
+ * @param store Transform store containing pending changes
31
+ */
32
+ declare function applyTransformChanges(entity: TransformableEntity, store: TransformState): void;
24
33
 
25
- export { actions };
34
+ export { TransformState, applyTransformChanges };