@zylem/game-lib 0.6.2 → 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/LICENSE +21 -0
  2. package/README.md +9 -16
  3. package/dist/actions.d.ts +30 -21
  4. package/dist/actions.js +628 -145
  5. package/dist/actions.js.map +1 -1
  6. package/dist/behavior/platformer-3d.d.ts +296 -0
  7. package/dist/behavior/platformer-3d.js +518 -0
  8. package/dist/behavior/platformer-3d.js.map +1 -0
  9. package/dist/behavior/ricochet-2d.d.ts +274 -0
  10. package/dist/behavior/ricochet-2d.js +394 -0
  11. package/dist/behavior/ricochet-2d.js.map +1 -0
  12. package/dist/behavior/screen-wrap.d.ts +86 -0
  13. package/dist/behavior/screen-wrap.js +195 -0
  14. package/dist/behavior/screen-wrap.js.map +1 -0
  15. package/dist/behavior/thruster.d.ts +10 -0
  16. package/dist/behavior/thruster.js +234 -0
  17. package/dist/behavior/thruster.js.map +1 -0
  18. package/dist/behavior/world-boundary-2d.d.ts +141 -0
  19. package/dist/behavior/world-boundary-2d.js +181 -0
  20. package/dist/behavior/world-boundary-2d.js.map +1 -0
  21. package/dist/behavior-descriptor-BWNWmIjv.d.ts +142 -0
  22. package/dist/{blueprints-Cq3Ko6_G.d.ts → blueprints-BWGz8fII.d.ts} +2 -2
  23. package/dist/camera-B5e4c78l.d.ts +468 -0
  24. package/dist/camera.d.ts +3 -2
  25. package/dist/camera.js +900 -211
  26. package/dist/camera.js.map +1 -1
  27. package/dist/composition-DrzFrbqI.d.ts +218 -0
  28. package/dist/{core-bO8TzV7u.d.ts → core-DAkskq6Y.d.ts} +60 -62
  29. package/dist/core.d.ts +10 -6
  30. package/dist/core.js +6896 -5020
  31. package/dist/core.js.map +1 -1
  32. package/dist/{entities-DvByhMGU.d.ts → entities-DC9ce_vx.d.ts} +113 -3
  33. package/dist/entities.d.ts +5 -3
  34. package/dist/entities.js +3727 -3167
  35. package/dist/entities.js.map +1 -1
  36. package/dist/entity-BpbZqg19.d.ts +1100 -0
  37. package/dist/global-change-Dc8uCKi2.d.ts +25 -0
  38. package/dist/main.d.ts +418 -15
  39. package/dist/main.js +11384 -8515
  40. package/dist/main.js.map +1 -1
  41. package/dist/{stage-types-Bd-KtcYT.d.ts → stage-types-BFsm3qsZ.d.ts} +205 -13
  42. package/dist/stage.d.ts +10 -7
  43. package/dist/stage.js +5311 -3880
  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 +29 -13
  48. package/dist/behaviors.d.ts +0 -854
  49. package/dist/behaviors.js +0 -1209
  50. package/dist/behaviors.js.map +0 -1
  51. package/dist/camera-CeJPAgGg.d.ts +0 -116
  52. package/dist/moveable-B_vyA6cw.d.ts +0 -67
  53. package/dist/transformable-CUhvyuYO.d.ts +0 -67
  54. package/dist/world-C8tQ7Plj.d.ts +0 -774
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Timothy Cool
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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 };