littlejsengine 1.18.19 → 1.18.21
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 -1
- package/dist/littlejs.d.ts +84 -19
- package/dist/littlejs.esm.js +233 -51
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +228 -51
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +225 -51
- package/package.json +1 -1
- package/plugins/box2d.js +12 -11
- package/plugins/newgrounds.js +2 -1
- package/plugins/pluginExport.js +5 -0
- package/plugins/postProcess.js +5 -4
- package/plugins/threejs.js +155 -0
- package/plugins/tweenSystem.js +5 -1
- package/plugins/uiSystem.js +4 -3
- package/src/engine.js +6 -2
- package/src/engineAudio.js +2 -2
- package/src/engineBuild.mjs +3 -2
- package/src/engineDebug.js +3 -0
- package/src/engineDraw.js +8 -8
- package/src/engineInput.js +8 -4
- package/src/engineMath.js +2 -2
- package/src/engineParticles.js +5 -6
- package/src/engineSettings.js +1 -0
- package/src/engineTileLayer.js +10 -6
- package/src/engineUtilities.js +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ The code is very clean and well documented with many examples to get you started
|
|
|
38
38
|
- Blazing fast WebGL2 + Canvas2D hybrid rendering system
|
|
39
39
|
- Apply [Shadertoy](https://www.shadertoy.com) style shaders for post-processing effects
|
|
40
40
|
- Robust particle effect system and [effect design tool](https://killedbyapixel.github.io/LittleJS/examples/particles/)
|
|
41
|
+
- Optional 3D rendering with the [Three.js](https://threejs.org) plugin
|
|
41
42
|
|
|
42
43
|
### 🔊 Audio
|
|
43
44
|
|
|
@@ -73,6 +74,12 @@ The code is very clean and well documented with many examples to get you started
|
|
|
73
74
|
- Medal tracking system with [Newgrounds](https://www.newgrounds.com/) support
|
|
74
75
|
- Node.js build system
|
|
75
76
|
|
|
77
|
+
### 🤖 AI Friendly
|
|
78
|
+
|
|
79
|
+
- The entire API is small and well documented so LLMs can produce high quality results
|
|
80
|
+
- [LittleJS AI Tools](https://github.com/KilledByAPixel/LittleJS-AI) - Templates, examples, and prompts tuned for AI + LittleJS workflows
|
|
81
|
+
- [LittleJS GPT](https://chatgpt.com/g/g-67c7c080b5bc81919736bc8815836be6-littlejs-game-maker) - Build LittleJS games right inside ChatGPT
|
|
82
|
+
|
|
76
83
|
## How To Use LittleJS
|
|
77
84
|
|
|
78
85
|
To get started download the latest LittleJS package from GitHub or install via npm:
|
|
@@ -113,7 +120,6 @@ engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost);
|
|
|
113
120
|
- [LittleJS Quick Reference Sheet](https://github.com/KilledByAPixel/LittleJS/blob/main/REFERENCE.md) - A reference sheet to help you get started.
|
|
114
121
|
- [Little JS FAQ](https://github.com/KilledByAPixel/LittleJS/blob/main/FAQ.md) - Answers to common questions about LittleJS.
|
|
115
122
|
- [JS13k Branch](https://github.com/KilledByAPixel/LittleJS/tree/js13k) - For size coding events like JS13k there is a special branch that builds to a 7KB zip.
|
|
116
|
-
- [LittleJS AI Tools](https://github.com/KilledByAPixel/LittleJS-AI) - Experiments, games, and templates to improve LittleJS + AI workflows.
|
|
117
123
|
|
|
118
124
|
## Examples
|
|
119
125
|
|
|
@@ -126,6 +132,8 @@ LittleJS comes with several demos both for learning and using as starter project
|
|
|
126
132
|
- [Puzzle Game](https://killedbyapixel.github.io/LittleJS/examples/puzzle/) - Match 3 puzzle game with HD rendering and high score tracking
|
|
127
133
|
- [Platformer](https://killedbyapixel.github.io/LittleJS/examples/platformer/) - Platformer/shooter demo that loads level data
|
|
128
134
|
- [Box2D Demo](https://killedbyapixel.github.io/LittleJS/examples/box2d/) - Box2D plugin demonstration and testbed
|
|
135
|
+
- [Three.js Side Scroller](https://killedbyapixel.github.io/LittleJS/examples/threejs/sideScroller/) - 3D rendering with Three.js behind the 2D canvas
|
|
136
|
+
- [Three.js Platformer](https://killedbyapixel.github.io/LittleJS/examples/threejs/platformer/) - 3D platformer with LittleJS gameplay and Three.js rendering
|
|
129
137
|
- [Stress Test](https://killedbyapixel.github.io/LittleJS/examples/stress/) - Sprite rendering benchmark and music system demo
|
|
130
138
|
- [Particle System Designer](https://killedbyapixel.github.io/LittleJS/examples/particles/) - Particle system editor and visualizer
|
|
131
139
|
|
package/dist/littlejs.d.ts
CHANGED
|
@@ -606,6 +606,7 @@ declare module "littlejsengine" {
|
|
|
606
606
|
* @memberof Settings */
|
|
607
607
|
export let soundEnable: boolean;
|
|
608
608
|
/** Volume scale to apply to all sound, music and speech
|
|
609
|
+
* Use setSoundVolume to also update the audio master gain immediately
|
|
609
610
|
* @type {number}
|
|
610
611
|
* @default
|
|
611
612
|
* @memberof Settings */
|
|
@@ -1481,7 +1482,7 @@ declare module "littlejsengine" {
|
|
|
1481
1482
|
*/
|
|
1482
1483
|
export class Timer {
|
|
1483
1484
|
/** Create a timer object set time passed in
|
|
1484
|
-
* @param {number} [timeLeft] - How much time left before the timer
|
|
1485
|
+
* @param {number} [timeLeft] - How much time left before the timer is elapsed in seconds (undefined = unset)
|
|
1485
1486
|
* @param {boolean} [useRealTime] - Should the timer keep running even when the game is paused? (useful for UI) */
|
|
1486
1487
|
constructor(timeLeft?: number, useRealTime?: boolean);
|
|
1487
1488
|
useRealTime: boolean;
|
|
@@ -1691,17 +1692,17 @@ declare module "littlejsengine" {
|
|
|
1691
1692
|
*/
|
|
1692
1693
|
frame(frame: number): TileInfo;
|
|
1693
1694
|
/**
|
|
1694
|
-
*
|
|
1695
|
-
* @param {
|
|
1695
|
+
* Returns a tile info for an index using this tile as reference
|
|
1696
|
+
* @param {Vector2|number} [index=0]
|
|
1696
1697
|
* @return {TileInfo}
|
|
1697
1698
|
*/
|
|
1698
|
-
|
|
1699
|
+
index(index?: Vector2 | number): TileInfo;
|
|
1699
1700
|
/**
|
|
1700
|
-
*
|
|
1701
|
-
* @param {
|
|
1701
|
+
* Set this tile to use a full image in a texture info
|
|
1702
|
+
* @param {TextureInfo} [textureInfo]
|
|
1702
1703
|
* @return {TileInfo}
|
|
1703
1704
|
*/
|
|
1704
|
-
|
|
1705
|
+
setFullImage(textureInfo?: TextureInfo): TileInfo;
|
|
1705
1706
|
}
|
|
1706
1707
|
/**
|
|
1707
1708
|
* Tile Info - Stores info about each texture
|
|
@@ -2660,9 +2661,9 @@ declare module "littlejsengine" {
|
|
|
2660
2661
|
* @param {number} [rate] - How quickly to speak
|
|
2661
2662
|
* @param {number} [pitch] - How much to change the pitch by
|
|
2662
2663
|
* @param {string} [language] - The language/accent to use (examples: en, it, ru, ja, zh)
|
|
2663
|
-
* @return {SpeechSynthesisUtterance} - The utterance that was spoken
|
|
2664
|
+
* @return {SpeechSynthesisUtterance|undefined} - The utterance that was spoken, or undefined if speech is unavailable
|
|
2664
2665
|
* @memberof Audio */
|
|
2665
|
-
export function speak(text: string, volume?: number, rate?: number, pitch?: number, language?: string): SpeechSynthesisUtterance;
|
|
2666
|
+
export function speak(text: string, volume?: number, rate?: number, pitch?: number, language?: string): SpeechSynthesisUtterance | undefined;
|
|
2666
2667
|
/** Stop all queued speech
|
|
2667
2668
|
* @memberof Audio */
|
|
2668
2669
|
export function speakStop(): void;
|
|
@@ -2684,7 +2685,7 @@ declare module "littlejsengine" {
|
|
|
2684
2685
|
* @param {number} [pan] - How much to apply stereo panning
|
|
2685
2686
|
* @param {boolean} [loop] - True if the sound should loop when it reaches the end
|
|
2686
2687
|
* @param {number} [sampleRate=44100] - Sample rate for the sound
|
|
2687
|
-
* @param {GainNode} [gainNode] - Optional gain node for volume control while playing
|
|
2688
|
+
* @param {GainNode} [gainNode] - Optional gain node for volume control while playing (disconnected when the sound ends)
|
|
2688
2689
|
* @param {number} [offset] - Offset in seconds to start playback from
|
|
2689
2690
|
* @param {AudioEndedCallback} [onended] - Callback for when the sound ends
|
|
2690
2691
|
* @return {AudioBufferSourceNode} - The source node of the sound played, may be undefined if play fails
|
|
@@ -3068,7 +3069,7 @@ declare module "littlejsengine" {
|
|
|
3068
3069
|
* @param {boolean} [useWebGL] - Should this layer use WebGL for rendering
|
|
3069
3070
|
*/
|
|
3070
3071
|
constructor(pos: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number, useWebGL?: boolean);
|
|
3071
|
-
/** @property {Array<TileLayerData>} -
|
|
3072
|
+
/** @property {Array<TileLayerData>} - Array of tile data for the layer */
|
|
3072
3073
|
data: TileLayerData[];
|
|
3073
3074
|
/** @property {boolean} - Is this layer using a webgl texture? */
|
|
3074
3075
|
isUsingWebGL: boolean;
|
|
@@ -3225,8 +3226,8 @@ declare module "littlejsengine" {
|
|
|
3225
3226
|
* rgb(1,1,1,1), rgb(0,0,0,1), // colorStartA, colorStartB
|
|
3226
3227
|
* rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
|
|
3227
3228
|
* 1, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
3228
|
-
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate
|
|
3229
|
-
* .5, 1 // randomness, collide
|
|
3229
|
+
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate
|
|
3230
|
+
* .5, 1 // randomness, collide
|
|
3230
3231
|
* );
|
|
3231
3232
|
*/
|
|
3232
3233
|
export class ParticleEmitter extends EngineObject {
|
|
@@ -3572,7 +3573,7 @@ declare module "littlejsengine" {
|
|
|
3572
3573
|
* @memberof PostProcess */
|
|
3573
3574
|
export let postProcess: PostProcessPlugin;
|
|
3574
3575
|
/**
|
|
3575
|
-
*
|
|
3576
|
+
* Post Process Plugin - Applies a full screen shader to the rendered output
|
|
3576
3577
|
* @memberof PostProcess
|
|
3577
3578
|
*/
|
|
3578
3579
|
export class PostProcessPlugin {
|
|
@@ -3910,8 +3911,8 @@ declare module "littlejsengine" {
|
|
|
3910
3911
|
* @return {number} */
|
|
3911
3912
|
getNavigationDirection(): number;
|
|
3912
3913
|
/** Get other axis navigation direction from gamepad or keyboard
|
|
3913
|
-
* @return {
|
|
3914
|
-
getNavigationOtherDirection():
|
|
3914
|
+
* @return {number} */
|
|
3915
|
+
getNavigationOtherDirection(): number;
|
|
3915
3916
|
/** Get if navigation button was pressed from gamepad or keyboard
|
|
3916
3917
|
* @return {boolean} */
|
|
3917
3918
|
getNavigationWasPressed(): boolean;
|
|
@@ -4111,7 +4112,7 @@ declare module "littlejsengine" {
|
|
|
4111
4112
|
maxLength: number;
|
|
4112
4113
|
text: string;
|
|
4113
4114
|
click(): void;
|
|
4114
|
-
/** Stop editing the text
|
|
4115
|
+
/** Stop editing the text */
|
|
4115
4116
|
stopEditing(): void;
|
|
4116
4117
|
/** Key down event handler if this object is being edited
|
|
4117
4118
|
* @param {KeyboardEvent} [e] */
|
|
@@ -4170,7 +4171,7 @@ declare module "littlejsengine" {
|
|
|
4170
4171
|
* @param {Color} [color=uiSystem.defaultButtonColor]
|
|
4171
4172
|
*/
|
|
4172
4173
|
constructor(pos?: Vector2, size?: Vector2, checked?: boolean, text?: string, color?: Color);
|
|
4173
|
-
/** @property {boolean} -
|
|
4174
|
+
/** @property {boolean} - Is the checkbox currently checked? */
|
|
4174
4175
|
checked: boolean;
|
|
4175
4176
|
text: string;
|
|
4176
4177
|
click(): void;
|
|
@@ -4390,7 +4391,7 @@ declare module "littlejsengine" {
|
|
|
4390
4391
|
* @param {number} [lineWidth]
|
|
4391
4392
|
* @param {boolean} [useWebGL=glEnable]
|
|
4392
4393
|
* @param {CanvasRenderingContext2D} [context] */
|
|
4393
|
-
drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, lineColor?: Color, lineWidth?: number,
|
|
4394
|
+
drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, lineColor?: Color, lineWidth?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D): void;
|
|
4394
4395
|
/** converts a box2d vec2 to a Vector2
|
|
4395
4396
|
* @param {Object} v */
|
|
4396
4397
|
vec2From(v: any): Vector2;
|
|
@@ -5707,4 +5708,68 @@ declare module "littlejsengine" {
|
|
|
5707
5708
|
/** True if walkable and not blocked by cost. */
|
|
5708
5709
|
isClear(): boolean;
|
|
5709
5710
|
}
|
|
5711
|
+
/**
|
|
5712
|
+
* LittleJS Three.js Plugin
|
|
5713
|
+
* - Renders a three.js scene on a canvas behind the LittleJS canvases
|
|
5714
|
+
* - The three.js module is passed in by the user, nothing is bundled
|
|
5715
|
+
* - Keep canvasClearColor transparent so the 3D scene shows through
|
|
5716
|
+
* - Aligned camera mode locks the 3D camera to the LittleJS 2D camera
|
|
5717
|
+
* - ThreeJSObject lets LittleJS physics drive a three.js mesh
|
|
5718
|
+
* - Call new ThreeJSPlugin(THREE) in gameInit to set up
|
|
5719
|
+
* @namespace ThreeJS
|
|
5720
|
+
*/
|
|
5721
|
+
/** Global ThreeJS plugin object
|
|
5722
|
+
* @type {ThreeJSPlugin}
|
|
5723
|
+
* @memberof ThreeJS */
|
|
5724
|
+
export let threeJS: ThreeJSPlugin;
|
|
5725
|
+
/**
|
|
5726
|
+
* ThreeJS Plugin - Renders a three.js scene behind the LittleJS canvas
|
|
5727
|
+
* @example
|
|
5728
|
+
* // in gameInit, with three.js loaded by the user
|
|
5729
|
+
* new ThreeJSPlugin(THREE);
|
|
5730
|
+
* threeJS.scene.add(new THREE.AmbientLight);
|
|
5731
|
+
* @memberof ThreeJS
|
|
5732
|
+
*/
|
|
5733
|
+
export class ThreeJSPlugin {
|
|
5734
|
+
/** Set up the three.js rendering layer, call in gameInit
|
|
5735
|
+
* @param {Object} THREE - The three.js module, supplied by the user
|
|
5736
|
+
* @param {number} [cameraFOV] - Vertical field of view in degrees */
|
|
5737
|
+
constructor(THREE: any, cameraFOV?: number);
|
|
5738
|
+
/** @property {Object} - The three.js module passed into the constructor */
|
|
5739
|
+
THREE: any;
|
|
5740
|
+
/** @property {Object} - The three.js renderer */
|
|
5741
|
+
renderer: any;
|
|
5742
|
+
/** @property {Object} - The three.js scene, add lights and meshes here */
|
|
5743
|
+
scene: any;
|
|
5744
|
+
/** @property {Object} - The three.js perspective camera */
|
|
5745
|
+
camera: any;
|
|
5746
|
+
/** @property {boolean} - Lock the camera to the LittleJS 2D camera so the z=0 plane matches world space */
|
|
5747
|
+
cameraAlign2D: boolean;
|
|
5748
|
+
/** Position the camera so the z=0 plane exactly matches LittleJS world space,
|
|
5749
|
+
* called automatically when cameraAlign2D is set */
|
|
5750
|
+
alignCamera2D(): void;
|
|
5751
|
+
/** Sync the canvas layout and render the scene, called automatically each frame */
|
|
5752
|
+
render(): void;
|
|
5753
|
+
}
|
|
5754
|
+
/**
|
|
5755
|
+
* ThreeJS Object - EngineObject that drives a three.js mesh
|
|
5756
|
+
* - LittleJS physics moves the object and the mesh follows automatically
|
|
5757
|
+
* - Destroying the object removes the mesh from the scene
|
|
5758
|
+
* @extends EngineObject
|
|
5759
|
+
* @memberof ThreeJS
|
|
5760
|
+
*/
|
|
5761
|
+
export class ThreeJSObject extends EngineObject {
|
|
5762
|
+
/** Create an engine object that drives a three.js mesh
|
|
5763
|
+
* @param {Vector2} [pos] - World space position
|
|
5764
|
+
* @param {Vector2} [size] - World space size
|
|
5765
|
+
* @param {Object} [mesh] - The three.js object3d to drive
|
|
5766
|
+
* @param {number} [z] - Mesh height above the 2D plane */
|
|
5767
|
+
constructor(pos?: Vector2, size?: Vector2, mesh?: any, z?: number);
|
|
5768
|
+
/** @property {Object} - The three.js object3d this object drives */
|
|
5769
|
+
mesh: any;
|
|
5770
|
+
/** @property {number} - Mesh height above the 2D plane */
|
|
5771
|
+
z: number;
|
|
5772
|
+
/** Copy this object's transform to the mesh */
|
|
5773
|
+
syncMesh(): void;
|
|
5774
|
+
}
|
|
5710
5775
|
}
|