@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.
- package/README.md +9 -16
- package/dist/actions.d.ts +30 -21
- package/dist/actions.js +628 -145
- package/dist/actions.js.map +1 -1
- package/dist/behavior/platformer-3d.d.ts +296 -0
- package/dist/behavior/platformer-3d.js +518 -0
- package/dist/behavior/platformer-3d.js.map +1 -0
- package/dist/behavior/ricochet-2d.d.ts +274 -0
- package/dist/behavior/ricochet-2d.js +394 -0
- package/dist/behavior/ricochet-2d.js.map +1 -0
- package/dist/behavior/screen-wrap.d.ts +86 -0
- package/dist/behavior/screen-wrap.js +195 -0
- package/dist/behavior/screen-wrap.js.map +1 -0
- package/dist/behavior/thruster.d.ts +10 -0
- package/dist/behavior/thruster.js +234 -0
- package/dist/behavior/thruster.js.map +1 -0
- package/dist/behavior/world-boundary-2d.d.ts +141 -0
- package/dist/behavior/world-boundary-2d.js +181 -0
- package/dist/behavior/world-boundary-2d.js.map +1 -0
- package/dist/behavior-descriptor-BWNWmIjv.d.ts +142 -0
- package/dist/{blueprints-BOCc3Wve.d.ts → blueprints-BWGz8fII.d.ts} +2 -2
- package/dist/camera-B5e4c78l.d.ts +468 -0
- package/dist/camera.d.ts +3 -2
- package/dist/camera.js +962 -166
- package/dist/camera.js.map +1 -1
- package/dist/composition-DrzFrbqI.d.ts +218 -0
- package/dist/{core-CZhozNRH.d.ts → core-DAkskq6Y.d.ts} +97 -65
- package/dist/core.d.ts +12 -6
- package/dist/core.js +4449 -1052
- package/dist/core.js.map +1 -1
- package/dist/{entities-BAxfJOkk.d.ts → entities-DC9ce_vx.d.ts} +154 -45
- package/dist/entities.d.ts +5 -2
- package/dist/entities.js +2505 -722
- package/dist/entities.js.map +1 -1
- package/dist/entity-BpbZqg19.d.ts +1100 -0
- package/dist/entity-types-DAu8sGJH.d.ts +26 -0
- package/dist/global-change-Dc8uCKi2.d.ts +25 -0
- package/dist/main.d.ts +472 -29
- package/dist/main.js +11877 -6124
- package/dist/main.js.map +1 -1
- package/dist/{stage-types-CD21XoIU.d.ts → stage-types-BFsm3qsZ.d.ts} +255 -26
- package/dist/stage.d.ts +11 -6
- package/dist/stage.js +3462 -491
- package/dist/stage.js.map +1 -1
- package/dist/thruster-DhRaJnoL.d.ts +172 -0
- package/dist/world-Be5m1XC1.d.ts +31 -0
- package/package.json +21 -4
- package/dist/behaviors.d.ts +0 -106
- package/dist/behaviors.js +0 -398
- package/dist/behaviors.js.map +0 -1
- package/dist/camera-CpbDr4-V.d.ts +0 -116
- package/dist/entity-COvRtFNG.d.ts +0 -395
- package/dist/moveable-B_vyA6cw.d.ts +0 -67
- 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 {
|
|
42
|
+
import { createGame, createSphere, WorldBoundary2DBehavior } from '@zylem/game-lib';
|
|
43
43
|
|
|
44
|
-
// Creates a
|
|
45
|
-
const ball =
|
|
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)
|
|
63
|
+
createGame(ball);
|
|
71
64
|
```
|
|
72
65
|
|
|
73
66
|
## Development
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
export { m as
|
|
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 '
|
|
7
|
+
import 'bitecs';
|
|
8
|
+
import 'mitt';
|
|
9
|
+
import './behavior-descriptor-BWNWmIjv.js';
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 {
|
|
34
|
+
export { TransformState, applyTransformChanges };
|