@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.
- package/LICENSE +21 -0
- 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-Cq3Ko6_G.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 +900 -211
- package/dist/camera.js.map +1 -1
- package/dist/composition-DrzFrbqI.d.ts +218 -0
- package/dist/{core-bO8TzV7u.d.ts → core-DAkskq6Y.d.ts} +60 -62
- package/dist/core.d.ts +10 -6
- package/dist/core.js +6896 -5020
- package/dist/core.js.map +1 -1
- package/dist/{entities-DvByhMGU.d.ts → entities-DC9ce_vx.d.ts} +113 -3
- package/dist/entities.d.ts +5 -3
- package/dist/entities.js +3727 -3167
- package/dist/entities.js.map +1 -1
- package/dist/entity-BpbZqg19.d.ts +1100 -0
- package/dist/global-change-Dc8uCKi2.d.ts +25 -0
- package/dist/main.d.ts +418 -15
- package/dist/main.js +11384 -8515
- package/dist/main.js.map +1 -1
- package/dist/{stage-types-Bd-KtcYT.d.ts → stage-types-BFsm3qsZ.d.ts} +205 -13
- package/dist/stage.d.ts +10 -7
- package/dist/stage.js +5311 -3880
- 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 +29 -13
- package/dist/behaviors.d.ts +0 -854
- package/dist/behaviors.js +0 -1209
- package/dist/behaviors.js.map +0 -1
- package/dist/camera-CeJPAgGg.d.ts +0 -116
- package/dist/moveable-B_vyA6cw.d.ts +0 -67
- package/dist/transformable-CUhvyuYO.d.ts +0 -67
- 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 {
|
|
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 };
|