littlejsengine 1.14.19 → 1.14.23
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/dist/littlejs.d.ts +118 -18
- package/dist/littlejs.esm.js +506 -199
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +493 -199
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +468 -200
- package/examples/electron/game.js +1 -41
- package/examples/electron/index.html +2 -2
- package/examples/htmlMenu/game.js +1 -1
- package/examples/index.html +12 -6
- package/examples/module/game.js +5 -7
- package/examples/particles/index.html +6 -9
- package/examples/platformer/gameCharacter.js +1 -1
- package/examples/platformer/gameEffects.js +7 -2
- package/examples/platformer/gameObjects.js +3 -3
- package/examples/shorts/animation.js +2 -2
- package/examples/shorts/base.html +4 -1
- package/examples/shorts/cameraDrag.js +22 -0
- package/examples/shorts/debugDraw.js +38 -0
- package/examples/shorts/fps.js +90 -0
- package/examples/shorts/helloWorld.js +1 -1
- package/examples/shorts/hillGlideGame.js +1 -1
- package/examples/shorts/landerGame.js +1 -1
- package/examples/shorts/postProcess.js +1 -1
- package/examples/shorts/sequencer.js +3 -3
- package/examples/shorts/spaceGame.js +1 -1
- package/examples/shorts/spriteAtlas.js +6 -6
- package/examples/shorts/starfield.js +1 -1
- package/examples/shorts/tileRaycast.js +39 -0
- package/examples/shorts/tiles.png +0 -0
- package/examples/shorts/tiltedView.js +1 -1
- package/examples/starter/game.js +5 -7
- package/examples/starter/index.html +2 -2
- package/examples/typescript/game.js +3 -2
- package/examples/typescript/game.ts +5 -7
- package/examples/uiSystem/game.js +2 -2
- package/package.json +1 -1
- package/src/engine.js +3 -3
- package/src/engineAudio.js +13 -13
- package/src/engineDebug.js +27 -0
- package/src/engineDraw.js +68 -20
- package/src/engineExport.js +13 -0
- package/src/engineInput.js +14 -16
- package/src/engineObject.js +31 -6
- package/src/engineParticles.js +36 -15
- package/src/engineRelease.js +2 -1
- package/src/engineSettings.js +20 -1
- package/src/engineTileLayer.js +62 -59
- package/src/engineUtilities.js +206 -58
- package/src/engineWebGL.js +13 -8
- package/examples/shorts/raycasting.js +0 -79
package/dist/littlejs.d.ts
CHANGED
|
@@ -14,7 +14,11 @@ declare module "littlejsengine" {
|
|
|
14
14
|
/**
|
|
15
15
|
* - Function that processes an object
|
|
16
16
|
*/
|
|
17
|
-
export type ObjectCallbackFunction = (
|
|
17
|
+
export type ObjectCallbackFunction = (object: EngineObject) => any;
|
|
18
|
+
/**
|
|
19
|
+
* - Checks if a position is colliding
|
|
20
|
+
*/
|
|
21
|
+
export type LineTestFunction = (pos: Vector2) => any;
|
|
18
22
|
/**
|
|
19
23
|
* - A function that draws to a 2D canvas context
|
|
20
24
|
*/
|
|
@@ -143,7 +147,7 @@ declare module "littlejsengine" {
|
|
|
143
147
|
export function engineObjectsCollect(pos?: Vector2, size?: Vector2 | number, objects?: Array<EngineObject>): Array<EngineObject>;
|
|
144
148
|
/**
|
|
145
149
|
* @callback ObjectCallbackFunction - Function that processes an object
|
|
146
|
-
* @param {EngineObject}
|
|
150
|
+
* @param {EngineObject} object
|
|
147
151
|
* @memberof Engine
|
|
148
152
|
*/
|
|
149
153
|
/** Triggers a callback for each object within a given area
|
|
@@ -456,6 +460,13 @@ declare module "littlejsengine" {
|
|
|
456
460
|
* @default
|
|
457
461
|
* @memberof Settings */
|
|
458
462
|
export let touchGamepadEnable: boolean;
|
|
463
|
+
/** True if touch gamepad should have start button in the center
|
|
464
|
+
* - When the game is paused, any touch will press the button
|
|
465
|
+
* - This can function as a way to pause/unpause the game
|
|
466
|
+
* @type {boolean}
|
|
467
|
+
* @default
|
|
468
|
+
* @memberof Settings */
|
|
469
|
+
export let touchGamepadCenterButton: boolean;
|
|
459
470
|
/** True if touch gamepad should be analog stick or false to use if 8 way dpad
|
|
460
471
|
* @type {boolean}
|
|
461
472
|
* @default
|
|
@@ -637,6 +648,11 @@ declare module "littlejsengine" {
|
|
|
637
648
|
* @param {boolean} enable
|
|
638
649
|
* @memberof Settings */
|
|
639
650
|
export function setTouchGamepadEnable(enable: boolean): void;
|
|
651
|
+
/** True if touch gamepad should have start button in the center
|
|
652
|
+
* - This can function as a way to pause/unpause the game
|
|
653
|
+
* @param {boolean} enable
|
|
654
|
+
* @memberof Settings */
|
|
655
|
+
export function setTouchGamepadCenterButton(enable: boolean): void;
|
|
640
656
|
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
641
657
|
* @param {boolean} analog
|
|
642
658
|
* @memberof Settings */
|
|
@@ -702,7 +718,7 @@ declare module "littlejsengine" {
|
|
|
702
718
|
* - RandomGenerator - seeded random number generator
|
|
703
719
|
* @namespace Utilities
|
|
704
720
|
*/
|
|
705
|
-
/**
|
|
721
|
+
/** The value of PI
|
|
706
722
|
* @type {number}
|
|
707
723
|
* @default Math.PI
|
|
708
724
|
* @memberof Utilities */
|
|
@@ -711,22 +727,68 @@ declare module "littlejsengine" {
|
|
|
711
727
|
* @param {number} value
|
|
712
728
|
* @return {number}
|
|
713
729
|
* @memberof Utilities */
|
|
714
|
-
export
|
|
730
|
+
export const abs: (x: number) => number;
|
|
731
|
+
/** Returns floored value of value passed in
|
|
732
|
+
* @param {number} value
|
|
733
|
+
* @return {number}
|
|
734
|
+
* @memberof Utilities */
|
|
735
|
+
export const floor: (x: number) => number;
|
|
736
|
+
/** Returns ceiled value of value passed in
|
|
737
|
+
* @param {number} value
|
|
738
|
+
* @return {number}
|
|
739
|
+
* @memberof Utilities */
|
|
740
|
+
export const ceil: (x: number) => number;
|
|
741
|
+
/** Returns rounded value passed in
|
|
742
|
+
* @param {number} value
|
|
743
|
+
* @return {number}
|
|
744
|
+
* @memberof Utilities */
|
|
745
|
+
export const round: (x: number) => number;
|
|
715
746
|
/** Returns lowest value passed in
|
|
716
747
|
* @param {...number} values
|
|
717
748
|
* @return {number}
|
|
718
749
|
* @memberof Utilities */
|
|
719
|
-
export
|
|
750
|
+
export const min: (...values: number[]) => number;
|
|
720
751
|
/** Returns highest value passed in
|
|
721
752
|
* @param {...number} values
|
|
722
753
|
* @return {number}
|
|
723
754
|
* @memberof Utilities */
|
|
724
|
-
export
|
|
755
|
+
export const max: (...values: number[]) => number;
|
|
725
756
|
/** Returns the sign of value passed in
|
|
726
757
|
* @param {number} value
|
|
727
758
|
* @return {number}
|
|
728
759
|
* @memberof Utilities */
|
|
729
|
-
export
|
|
760
|
+
export const sign: (x: number) => number;
|
|
761
|
+
/** Returns hypotenuse of values passed in
|
|
762
|
+
* @param {...number} values
|
|
763
|
+
* @return {number}
|
|
764
|
+
* @memberof Utilities */
|
|
765
|
+
export const hypot: (...values: number[]) => number;
|
|
766
|
+
/** Returns log2 of value passed in
|
|
767
|
+
* @param {number} value
|
|
768
|
+
* @return {number}
|
|
769
|
+
* @memberof Utilities */
|
|
770
|
+
export const log2: (x: number) => number;
|
|
771
|
+
/** Returns sin of value passed in
|
|
772
|
+
* @param {number} value
|
|
773
|
+
* @return {number}
|
|
774
|
+
* @memberof Utilities */
|
|
775
|
+
export const sin: (x: number) => number;
|
|
776
|
+
/** Returns cos of value passed in
|
|
777
|
+
* @param {number} value
|
|
778
|
+
* @return {number}
|
|
779
|
+
* @memberof Utilities */
|
|
780
|
+
export const cos: (x: number) => number;
|
|
781
|
+
/** Returns tan of value passed in
|
|
782
|
+
* @param {number} value
|
|
783
|
+
* @return {number}
|
|
784
|
+
* @memberof Utilities */
|
|
785
|
+
export const tan: (x: number) => number;
|
|
786
|
+
/** Returns atan2 of values passed in
|
|
787
|
+
* @param {number} y
|
|
788
|
+
* @param {number} x
|
|
789
|
+
* @return {number}
|
|
790
|
+
* @memberof Utilities */
|
|
791
|
+
export const atan2: (y: number, x: number) => number;
|
|
730
792
|
/** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
|
|
731
793
|
* @param {number} dividend
|
|
732
794
|
* @param {number} [divisor]
|
|
@@ -911,6 +973,18 @@ declare module "littlejsengine" {
|
|
|
911
973
|
* @param {number} [valueB]
|
|
912
974
|
* @return {Vector2} */
|
|
913
975
|
vec2(valueA?: number, valueB?: number): Vector2;
|
|
976
|
+
/** Returns a random color between the two passed in colors, combine components if linear
|
|
977
|
+
* @param {Color} [colorA=(1,1,1,1)]
|
|
978
|
+
* @param {Color} [colorB=(0,0,0,1)]
|
|
979
|
+
* @param {boolean} [linear]
|
|
980
|
+
* @return {Color} */
|
|
981
|
+
randColor(colorA?: Color, colorB?: Color, linear?: boolean): Color;
|
|
982
|
+
/** Returns a new color that has each component randomly adjusted
|
|
983
|
+
* @param {Color} color
|
|
984
|
+
* @param {number} [amount]
|
|
985
|
+
* @param {number} [alphaAmount]
|
|
986
|
+
* @return {Color} */
|
|
987
|
+
mutateColor(color: Color, amount?: number, alphaAmount?: number): Color;
|
|
914
988
|
}
|
|
915
989
|
/**
|
|
916
990
|
* 2D Vector object with vector math library
|
|
@@ -1442,6 +1516,16 @@ declare module "littlejsengine" {
|
|
|
1442
1516
|
* @return {Vector2}
|
|
1443
1517
|
* @memberof Draw */
|
|
1444
1518
|
export function worldToScreen(worldPos: Vector2): Vector2;
|
|
1519
|
+
/** Convert from screen to world space coordinates for a directional vector (no translation)
|
|
1520
|
+
* @param {Vector2} screenDelta
|
|
1521
|
+
* @return {Vector2}
|
|
1522
|
+
* @memberof Draw */
|
|
1523
|
+
export function screenToWorldDelta(screenDelta: Vector2): Vector2;
|
|
1524
|
+
/** Convert from screen to world space coordinates for a directional vector (no translation)
|
|
1525
|
+
* @param {Vector2} worldDelta
|
|
1526
|
+
* @return {Vector2}
|
|
1527
|
+
* @memberof Draw */
|
|
1528
|
+
export function worldToScreenDelta(worldDelta: Vector2): Vector2;
|
|
1445
1529
|
/** Draw textured tile centered in world space, with color applied if using WebGL
|
|
1446
1530
|
* @param {Vector2} pos - Center of the tile in world space
|
|
1447
1531
|
* @param {Vector2} [size=(1,1)] - Size of the tile in world space
|
|
@@ -2325,6 +2409,14 @@ declare module "littlejsengine" {
|
|
|
2325
2409
|
* @return {boolean} - true if the collision should be resolved
|
|
2326
2410
|
*/
|
|
2327
2411
|
collideWithObject(object: EngineObject): boolean;
|
|
2412
|
+
/** Get this object's up vector
|
|
2413
|
+
* @param {number} [scale] - length of the vector
|
|
2414
|
+
* @return {Vector2} */
|
|
2415
|
+
getUp(scale?: number): Vector2;
|
|
2416
|
+
/** Get this object's right vector
|
|
2417
|
+
* @param {number} [scale] - length of the vector
|
|
2418
|
+
* @return {Vector2} */
|
|
2419
|
+
getRight(scale?: number): Vector2;
|
|
2328
2420
|
/** How long since the object was created
|
|
2329
2421
|
* @return {number} */
|
|
2330
2422
|
getAliveTime(): number;
|
|
@@ -2385,15 +2477,15 @@ declare module "littlejsengine" {
|
|
|
2385
2477
|
* @return {TileCollisionLayer}
|
|
2386
2478
|
* @memberof TileLayers */
|
|
2387
2479
|
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject, solidOnly?: boolean): TileCollisionLayer;
|
|
2388
|
-
/** Return the
|
|
2389
|
-
* This does not return the exact intersection, but the center of the tile hit.
|
|
2480
|
+
/** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
|
|
2390
2481
|
* @param {Vector2} posStart
|
|
2391
2482
|
* @param {Vector2} posEnd
|
|
2392
2483
|
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2484
|
+
* @param {Vector2} [normal] - Optional normal of the surface hit
|
|
2393
2485
|
* @param {boolean} [solidOnly=true] - Only check solid layers if true
|
|
2394
|
-
* @return {Vector2}
|
|
2486
|
+
* @return {Vector2|undefined} - position of the center of the tile hit or undefined if no hit
|
|
2395
2487
|
* @memberof TileLayers */
|
|
2396
|
-
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, solidOnly?: boolean): Vector2;
|
|
2488
|
+
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, normal?: Vector2, solidOnly?: boolean): Vector2 | undefined;
|
|
2397
2489
|
/**
|
|
2398
2490
|
* Load tile layers from exported data
|
|
2399
2491
|
* @param {Object} tileMapData - Level data from exported data
|
|
@@ -2456,6 +2548,8 @@ declare module "littlejsengine" {
|
|
|
2456
2548
|
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
2457
2549
|
context: OffscreenCanvasRenderingContext2D;
|
|
2458
2550
|
textureInfo: TextureInfo;
|
|
2551
|
+
/** @property {boolean} - True if WebGL texture needs to be refreshed */
|
|
2552
|
+
refreshWebGL: boolean;
|
|
2459
2553
|
/** Draw this canvas layer centered in world space, with color applied if using WebGL
|
|
2460
2554
|
* @param {Vector2} pos - Center in world space
|
|
2461
2555
|
* @param {Vector2} [size] - Size in world space
|
|
@@ -2494,8 +2588,10 @@ declare module "littlejsengine" {
|
|
|
2494
2588
|
* @param {number} [angle=0] */
|
|
2495
2589
|
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2496
2590
|
/** Create or update the WebGL texture for this layer
|
|
2497
|
-
* @param {boolean} [enable] - enable WebGL rendering and update the texture
|
|
2498
|
-
|
|
2591
|
+
* @param {boolean} [enable] - enable WebGL rendering and update the texture
|
|
2592
|
+
* @param {boolean} [immediate] - shoulkd the texture be updated immediately
|
|
2593
|
+
*/
|
|
2594
|
+
useWebGL(enable?: boolean, immediate?: boolean): void;
|
|
2499
2595
|
}
|
|
2500
2596
|
/**
|
|
2501
2597
|
* Tile Layer - cached rendering system for tile layers
|
|
@@ -2574,13 +2670,13 @@ declare module "littlejsengine" {
|
|
|
2574
2670
|
* @param {EngineObject} [object]
|
|
2575
2671
|
* @return {boolean} */
|
|
2576
2672
|
collisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
|
|
2577
|
-
/** Return the
|
|
2578
|
-
* This does not return the exact intersection, but the center of the tile hit.
|
|
2673
|
+
/** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
|
|
2579
2674
|
* @param {Vector2} posStart
|
|
2580
2675
|
* @param {Vector2} posEnd
|
|
2581
|
-
* @param {EngineObject} [object]
|
|
2582
|
-
* @
|
|
2583
|
-
|
|
2676
|
+
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2677
|
+
* @param {Vector2} [normal] - Optional normal of the surface hit
|
|
2678
|
+
* @return {Vector2|undefined} */
|
|
2679
|
+
collisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, normal?: Vector2): Vector2 | undefined;
|
|
2584
2680
|
}
|
|
2585
2681
|
/**
|
|
2586
2682
|
* LittleJS Particle System
|
|
@@ -2685,6 +2781,10 @@ declare module "littlejsengine" {
|
|
|
2685
2781
|
particleCreateCallback: any;
|
|
2686
2782
|
/** @property {number} - Track particle emit time */
|
|
2687
2783
|
emitTimeBuffer: number;
|
|
2784
|
+
/** @property {number} - Percentage of velocity to pass to particles (0-1) */
|
|
2785
|
+
velocityInheritance: number;
|
|
2786
|
+
previousAngle: number;
|
|
2787
|
+
previousPos: Vector2;
|
|
2688
2788
|
/** Spawn one particle
|
|
2689
2789
|
* @return {Particle} */
|
|
2690
2790
|
emitParticle(): Particle;
|