littlejsengine 1.17.11 → 1.17.15
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/AI.md +162 -0
- package/README.md +50 -63
- package/dist/littlejs.d.ts +150 -68
- package/dist/littlejs.esm.js +323 -105
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +320 -104
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +318 -101
- package/examples/electron/{build.js → build.mjs} +26 -23
- package/examples/electron/game.js +5 -50
- package/examples/electron/index.html +2 -2
- package/examples/index.html +1 -0
- package/examples/module/{build.js → build.mjs} +22 -19
- package/examples/shorts/base.html +1 -1
- package/examples/shorts/hillGlideGame.js +1 -1
- package/examples/shorts/nineSlice.js +3 -3
- package/examples/shorts/shapes.js +1 -1
- package/examples/shorts/uiSystem.js +17 -16
- package/examples/starter/build.bat +1 -1
- package/examples/starter/{build.js → build.mjs} +25 -22
- package/examples/starter/index.html +2 -2
- package/examples/typescript/build.mjs +60 -0
- package/examples/typescript/game.js +2 -2
- package/examples/typescript/tsconfig.json +11 -2
- package/package.json +2 -2
- package/plugins/pluginExport.js +1 -0
- package/plugins/uiSystem.js +143 -20
- package/reference.md +0 -1
- package/src/engine.js +16 -14
- package/src/engineAudio.js +9 -6
- package/src/{engineBuild.js → engineBuild.mjs} +95 -78
- package/src/engineDebug.js +8 -5
- package/src/engineDraw.js +16 -14
- package/src/engineExport.js +2 -1
- package/src/engineInput.js +29 -8
- package/src/engineMath.js +46 -14
- package/src/engineMedals.js +6 -3
- package/src/engineObject.js +14 -3
- package/src/engineParticles.js +8 -3
- package/src/engineRelease.js +6 -2
- package/src/engineTileLayer.js +8 -4
- package/src/engineUtilities.js +6 -2
- package/src/engineWebGL.js +11 -8
- package/src/jsconfig.json +2 -1
- package/examples/electron/build.bat +0 -7
- package/examples/module/build.bat +0 -7
- package/examples/typescript/build.bat +0 -5
- package/examples/typescript/build.js +0 -31
package/dist/littlejs.d.ts
CHANGED
|
@@ -48,18 +48,20 @@ declare module "littlejsengine" {
|
|
|
48
48
|
* MIT License - Copyright 2021 Frank Force
|
|
49
49
|
*
|
|
50
50
|
* Engine Features
|
|
51
|
-
* - Object oriented system with base class
|
|
52
|
-
* -
|
|
53
|
-
* - Engine helper classes
|
|
54
|
-
* -
|
|
55
|
-
* -
|
|
56
|
-
* - Input
|
|
57
|
-
* - Tile layer rendering and collision
|
|
58
|
-
* - Particle effect system
|
|
59
|
-
* - Medal system
|
|
60
|
-
* -
|
|
61
|
-
* -
|
|
62
|
-
* -
|
|
51
|
+
* - Object oriented system with EngineObject base class
|
|
52
|
+
* - Automatic object lifecycle (update, physics, collision, rendering)
|
|
53
|
+
* - Engine helper classes: Vector2, Color, Timer, RandomGenerator
|
|
54
|
+
* - Hybrid rendering with WebGL batching and Canvas2D fallback
|
|
55
|
+
* - Audio system with wave, mp3, or ZzFX sound effects
|
|
56
|
+
* - Input system with keyboard, mouse, gamepad, and touch support
|
|
57
|
+
* - Tile layer rendering and collision detection
|
|
58
|
+
* - Particle effect system with emitters
|
|
59
|
+
* - Medal/achievement system with local storage
|
|
60
|
+
* - Comprehensive debug tools and visualizations
|
|
61
|
+
* - Fixed 60 FPS timestep with configurable time scale
|
|
62
|
+
* - Raycast and spatial query utilities
|
|
63
|
+
* - Plugin system for extending engine functionality
|
|
64
|
+
* - Start with engineInit() and provide your game callbacks
|
|
63
65
|
* @namespace Engine
|
|
64
66
|
*/
|
|
65
67
|
/** Name of engine
|
|
@@ -189,11 +191,14 @@ declare module "littlejsengine" {
|
|
|
189
191
|
export function engineAddPlugin(update?: PluginCallback, render?: PluginCallback, glContextLost?: PluginCallback, glContextRestored?: PluginCallback): void;
|
|
190
192
|
/**
|
|
191
193
|
* LittleJS Debug System
|
|
192
|
-
* - Press Esc to
|
|
193
|
-
* - Number keys toggle debug
|
|
194
|
-
* - +/-
|
|
195
|
-
* -
|
|
196
|
-
* -
|
|
194
|
+
* - Press Esc to toggle debug overlay with object picking
|
|
195
|
+
* - Number keys toggle debug visualizations (physics, particles, etc.)
|
|
196
|
+
* - +/- keys control time scale for slow motion/fast forward
|
|
197
|
+
* - ASSERT and LOG macros for development (removed in release builds)
|
|
198
|
+
* - Debug primitive rendering (rectangles, circles, lines, points, text)
|
|
199
|
+
* - Screenshot and video capture support
|
|
200
|
+
* - FPS counter and performance watermark
|
|
201
|
+
* - Debug overlay shows mouse position and picked objects
|
|
197
202
|
* @namespace Debug
|
|
198
203
|
*/
|
|
199
204
|
/** True if debug is enabled
|
|
@@ -733,10 +738,17 @@ declare module "littlejsengine" {
|
|
|
733
738
|
export function setDebugKey(key: string): void;
|
|
734
739
|
/**
|
|
735
740
|
* LittleJS Math Classes and Functions
|
|
736
|
-
* -
|
|
737
|
-
* -
|
|
738
|
-
* -
|
|
739
|
-
* -
|
|
741
|
+
* - Comprehensive math utilities for game development
|
|
742
|
+
* - Vector2 class for 2D positions, directions, and math operations
|
|
743
|
+
* - Color class for RGBA colors with interpolation and manipulation
|
|
744
|
+
* - RandomGenerator for seeded pseudo-random number generation
|
|
745
|
+
* - Math shortcuts (PI, abs, floor, ceil, min, max, sin, cos, etc.)
|
|
746
|
+
* - Interpolation functions (lerp, smoothStep, percent)
|
|
747
|
+
* - Clamping, wrapping, and modulo operations
|
|
748
|
+
* - Angle utilities with wrap-around support
|
|
749
|
+
* - Collision detection (overlapping, intersection, line tests)
|
|
750
|
+
* - Random number generation and seeding
|
|
751
|
+
* - Type checking utilities
|
|
740
752
|
* @namespace Math
|
|
741
753
|
*/
|
|
742
754
|
/** The value of PI
|
|
@@ -897,9 +909,10 @@ declare module "littlejsengine" {
|
|
|
897
909
|
* @param {number} [amplitude] - Amplitude (max height) of the wave
|
|
898
910
|
* @param {number} [t=time] - Value to use for time of the wave
|
|
899
911
|
* @param {number} [offset] - Value to use for time offset of the wave
|
|
912
|
+
* @param {number} [type] - Wave type: 0=sine, 1=triangle, 2=square, 3=sawtooth
|
|
900
913
|
* @return {number} - Value waving between 0 and amplitude
|
|
901
914
|
* @memberof Math */
|
|
902
|
-
export function
|
|
915
|
+
export function oscillate(frequency?: number, amplitude?: number, t?: number, offset?: number, type?: number): number;
|
|
903
916
|
/** Formats seconds to mm:ss style for display purposes
|
|
904
917
|
* @param {number} t - time in seconds
|
|
905
918
|
* @return {string}
|
|
@@ -1159,6 +1172,10 @@ declare module "littlejsengine" {
|
|
|
1159
1172
|
/** Returns a copy of this vector with each axis floored
|
|
1160
1173
|
* @return {Vector2} */
|
|
1161
1174
|
floor(): Vector2;
|
|
1175
|
+
/** Returns a copy of this vector snapped to a grid
|
|
1176
|
+
* @param {number} grid - grid size to snap to
|
|
1177
|
+
* @return {Vector2} */
|
|
1178
|
+
snap(grid: number): Vector2;
|
|
1162
1179
|
/** Returns new vec2 with modded values
|
|
1163
1180
|
* @param {number} [divisor]
|
|
1164
1181
|
* @return {Vector2} */
|
|
@@ -1283,8 +1300,12 @@ declare module "littlejsengine" {
|
|
|
1283
1300
|
}
|
|
1284
1301
|
/**
|
|
1285
1302
|
* LittleJS Utility Classes and Functions
|
|
1286
|
-
* -
|
|
1287
|
-
* -
|
|
1303
|
+
* - Timer - tracks time automatically with support for pause and real-time modes
|
|
1304
|
+
* - Time formatting helper
|
|
1305
|
+
* - JSON file fetching
|
|
1306
|
+
* - File saving (text, canvas, data URLs)
|
|
1307
|
+
* - Native share dialog support
|
|
1308
|
+
* - Local storage save data management
|
|
1288
1309
|
* @namespace Utilities
|
|
1289
1310
|
*/
|
|
1290
1311
|
/**
|
|
@@ -1547,22 +1568,23 @@ declare module "littlejsengine" {
|
|
|
1547
1568
|
}
|
|
1548
1569
|
/**
|
|
1549
1570
|
* LittleJS Drawing System
|
|
1550
|
-
* - Hybrid
|
|
1551
|
-
* -
|
|
1552
|
-
* -
|
|
1553
|
-
* -
|
|
1554
|
-
* -
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1559
|
-
*
|
|
1571
|
+
* - Hybrid rendering with both Canvas2D and WebGL support
|
|
1572
|
+
* - Optimized tile sheet sprite rendering using WebGL batching
|
|
1573
|
+
* - Primitive drawing for polygons, ellipses, and lines
|
|
1574
|
+
* - Tile-based rendering with TileInfo and TextureInfo classes
|
|
1575
|
+
* - Text rendering with custom fonts and FontImage support
|
|
1576
|
+
* - Color and additive color blending for effects
|
|
1577
|
+
* - Rotation, mirroring, and scaling transformations
|
|
1578
|
+
* - Camera system with position, scale, and rotation
|
|
1579
|
+
* - Multiple canvas support (main, WebGL, work canvases)
|
|
1580
|
+
* - Gradient fills and outlined shapes
|
|
1581
|
+
* - Image manipulation and color tinting
|
|
1560
1582
|
*
|
|
1561
|
-
*
|
|
1562
|
-
* -
|
|
1563
|
-
* -
|
|
1583
|
+
* Rendering Architecture:
|
|
1584
|
+
* - glCanvas: WebGL canvas for accelerated sprite batch rendering
|
|
1585
|
+
* - mainCanvas: Canvas2D overlay for text, UI, and custom drawing
|
|
1586
|
+
* - All draw functions default to WebGL when enabled, can force Canvas2D with useWebGL parameter
|
|
1564
1587
|
*
|
|
1565
|
-
* The LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!
|
|
1566
1588
|
* @namespace Draw
|
|
1567
1589
|
*/
|
|
1568
1590
|
/** The primary 2D canvas visible to the user
|
|
@@ -1845,14 +1867,17 @@ declare module "littlejsengine" {
|
|
|
1845
1867
|
export function getCameraSize(): Vector2;
|
|
1846
1868
|
/**
|
|
1847
1869
|
* LittleJS WebGL Interface
|
|
1848
|
-
* -
|
|
1849
|
-
* -
|
|
1850
|
-
* -
|
|
1851
|
-
* -
|
|
1852
|
-
* -
|
|
1853
|
-
* -
|
|
1854
|
-
* -
|
|
1855
|
-
* -
|
|
1870
|
+
* - WebGL2 rendering engine for high-performance graphics
|
|
1871
|
+
* - Batched sprite rendering for drawing thousands of sprites efficiently
|
|
1872
|
+
* - Instanced rendering using vertex array objects (VAOs)
|
|
1873
|
+
* - Polygon rendering with triangle strip support
|
|
1874
|
+
* - Shader system with custom vertex and fragment shaders
|
|
1875
|
+
* - Texture management with automatic atlas support
|
|
1876
|
+
* - Post-processing effects via framebuffer and shader plugins
|
|
1877
|
+
* - Automatic fallback to Canvas2D if WebGL is unavailable
|
|
1878
|
+
* - Context loss and restoration handling
|
|
1879
|
+
* - Can be disabled with glEnable setting
|
|
1880
|
+
* - Advanced users can create custom shaders and render targets
|
|
1856
1881
|
* @namespace WebGL
|
|
1857
1882
|
*/
|
|
1858
1883
|
/** The WebGL canvas which appears below the main canvas
|
|
@@ -2031,11 +2056,14 @@ declare module "littlejsengine" {
|
|
|
2031
2056
|
export function mouseWasReleased(button: number): boolean;
|
|
2032
2057
|
/**
|
|
2033
2058
|
* LittleJS Input System
|
|
2034
|
-
* -
|
|
2035
|
-
* -
|
|
2036
|
-
* -
|
|
2037
|
-
* - Touch input
|
|
2038
|
-
* - Virtual gamepad for
|
|
2059
|
+
* - Keyboard input with key down, pressed, and released states
|
|
2060
|
+
* - Mouse input with position (world and screen space), buttons, and wheel
|
|
2061
|
+
* - Gamepad support for multiple controllers with analog sticks and buttons
|
|
2062
|
+
* - Touch input mapped to mouse position and buttons
|
|
2063
|
+
* - Virtual on-screen gamepad for mobile devices
|
|
2064
|
+
* - Automatic gamepad vs keyboard/mouse detection
|
|
2065
|
+
* - Input event prevention for canvas focus
|
|
2066
|
+
* - Clipboard copy/paste support
|
|
2039
2067
|
* @namespace Input
|
|
2040
2068
|
*/
|
|
2041
2069
|
/** Mouse pos in world space
|
|
@@ -2135,12 +2163,15 @@ declare module "littlejsengine" {
|
|
|
2135
2163
|
export function pointerLockIsActive(): boolean;
|
|
2136
2164
|
/**
|
|
2137
2165
|
* LittleJS Audio System
|
|
2138
|
-
* -
|
|
2139
|
-
* - <a href=https://
|
|
2140
|
-
* -
|
|
2141
|
-
* -
|
|
2142
|
-
* -
|
|
2143
|
-
* -
|
|
2166
|
+
* - Play audio files (mp3, ogg, wave) and generate sounds with ZzFX
|
|
2167
|
+
* - ZzFX sound generator integration: <a href=https://killedbyapixel.github.io/ZzFX/>ZzFX</a>
|
|
2168
|
+
* - Sound caching for fast playback and memory efficiency
|
|
2169
|
+
* - Volume control with attenuation and stereo panning
|
|
2170
|
+
* - 2D spatial audio based on camera position with distance-based falloff
|
|
2171
|
+
* - Sound instance management (pause, resume, stop)
|
|
2172
|
+
* - Speech synthesis for text-to-speech
|
|
2173
|
+
* - Music playback with ZzFXM support
|
|
2174
|
+
* - Web Audio API integration with master gain control
|
|
2144
2175
|
* @namespace Audio
|
|
2145
2176
|
*/
|
|
2146
2177
|
/** Audio context used by the engine
|
|
@@ -2387,6 +2418,13 @@ declare module "littlejsengine" {
|
|
|
2387
2418
|
export function zzfxG(volume?: number, randomness?: number, frequency?: number, attack?: number, sustain?: number, release?: number, shape?: number, shapeCurve?: number, slide?: number, deltaSlide?: number, pitchJump?: number, pitchJumpTime?: number, repeatTime?: number, noise?: number, modulation?: number, bitCrush?: number, delay?: number, sustainVolume?: number, decay?: number, tremolo?: number, filter?: number): any[];
|
|
2388
2419
|
/**
|
|
2389
2420
|
* LittleJS Object System
|
|
2421
|
+
* - EngineObject is the base class for all game objects
|
|
2422
|
+
* - Handles automatic updating, rendering, physics, and collision
|
|
2423
|
+
* - Supports parent-child hierarchies with transform inheritance
|
|
2424
|
+
* - 2D physics with velocity, acceleration, damping, and gravity
|
|
2425
|
+
* - Collision system with tiles and other objects
|
|
2426
|
+
* - Renders sprites from tile sheets with color and rotation
|
|
2427
|
+
* - Objects sorted by renderOrder for layered rendering
|
|
2390
2428
|
*/
|
|
2391
2429
|
/**
|
|
2392
2430
|
* LittleJS Object Base Object Class
|
|
@@ -2574,10 +2612,14 @@ declare module "littlejsengine" {
|
|
|
2574
2612
|
}
|
|
2575
2613
|
/**
|
|
2576
2614
|
* LittleJS Tile Layer System
|
|
2577
|
-
* -
|
|
2578
|
-
* - Unlimited
|
|
2579
|
-
* -
|
|
2580
|
-
* -
|
|
2615
|
+
* - Renders large tile-based levels efficiently using cached canvases
|
|
2616
|
+
* - Unlimited tile layers with automatic canvas allocation
|
|
2617
|
+
* - Layers support both rendering and collision detection
|
|
2618
|
+
* - Direct canvas2d drawing access for custom tile rendering
|
|
2619
|
+
* - TileLayer for rendering, TileCollisionLayer for physics
|
|
2620
|
+
* - Collision callbacks for tile interactions with objects
|
|
2621
|
+
* - Optimized raycast support for tile-based physics
|
|
2622
|
+
* - Integration with Box2D physics via Box2DTileLayer plugin
|
|
2581
2623
|
* @namespace TileLayers
|
|
2582
2624
|
*/
|
|
2583
2625
|
/** Keep track of all tile layers with collision
|
|
@@ -2839,9 +2881,14 @@ declare module "littlejsengine" {
|
|
|
2839
2881
|
}
|
|
2840
2882
|
/**
|
|
2841
2883
|
* LittleJS Particle System
|
|
2842
|
-
* -
|
|
2843
|
-
* -
|
|
2844
|
-
* -
|
|
2884
|
+
* - Fast and flexible particle effects system
|
|
2885
|
+
* - ParticleEmitter spawns and manages lightweight Particle objects
|
|
2886
|
+
* - Particles support color gradients, fading, rotation, and scaling
|
|
2887
|
+
* - Physics simulation with velocity, gravity, and damping
|
|
2888
|
+
* - Collision detection with tile layers
|
|
2889
|
+
* - Additive blending for glowing effects
|
|
2890
|
+
* - Cone-based emission with randomization
|
|
2891
|
+
* - Particle design tool available for easy emitter creation
|
|
2845
2892
|
* @namespace Particles
|
|
2846
2893
|
*/
|
|
2847
2894
|
/**
|
|
@@ -3030,9 +3077,12 @@ declare module "littlejsengine" {
|
|
|
3030
3077
|
}
|
|
3031
3078
|
/**
|
|
3032
3079
|
* LittleJS Medal System
|
|
3033
|
-
* -
|
|
3034
|
-
* -
|
|
3035
|
-
* -
|
|
3080
|
+
* - Achievement/trophy system for games
|
|
3081
|
+
* - Medal class with name, description, icon, and unlock tracking
|
|
3082
|
+
* - Automatic saving to local storage
|
|
3083
|
+
* - Visual display queue with slide-in notifications
|
|
3084
|
+
* - Newgrounds API integration for online achievements
|
|
3085
|
+
* - Debug mode to unlock/reset medals during development
|
|
3036
3086
|
* @namespace Medals
|
|
3037
3087
|
*/
|
|
3038
3088
|
/** List of all medals
|
|
@@ -3345,6 +3395,8 @@ declare module "littlejsengine" {
|
|
|
3345
3395
|
lastHoverObject: any;
|
|
3346
3396
|
/** @property {UIObject} - Current confirm menu being shown */
|
|
3347
3397
|
confirmDialog: any;
|
|
3398
|
+
/** @property {UIObject} - Object to send keyboard input to */
|
|
3399
|
+
keyInputObject: any;
|
|
3348
3400
|
/** Draw a rectangle to the UI context
|
|
3349
3401
|
* @param {Vector2} pos
|
|
3350
3402
|
* @param {Vector2} size
|
|
@@ -3525,7 +3577,7 @@ declare module "littlejsengine" {
|
|
|
3525
3577
|
/** Destroy this object, destroy its children, detach its parent, and mark it for removal */
|
|
3526
3578
|
destroy(): void;
|
|
3527
3579
|
destroyed: number;
|
|
3528
|
-
/** Check if the mouse is overlapping
|
|
3580
|
+
/** Check if the mouse is overlapping this ui object
|
|
3529
3581
|
* @return {boolean} - True if overlapping */
|
|
3530
3582
|
isMouseOverlapping(): boolean;
|
|
3531
3583
|
/** Update the object, called automatically by plugin once each frame */
|
|
@@ -3543,6 +3595,8 @@ declare module "littlejsengine" {
|
|
|
3543
3595
|
isActiveObject(): boolean;
|
|
3544
3596
|
/** @return {boolean} - Is the gamepad or keyboard navigation object */
|
|
3545
3597
|
isNavigationObject(): boolean;
|
|
3598
|
+
/** @return {boolean} - Is this object in keyboard input mode */
|
|
3599
|
+
isKeyInputObject(): boolean;
|
|
3546
3600
|
/** @return {boolean} - Can it be interacted with */
|
|
3547
3601
|
isInteractive(): boolean;
|
|
3548
3602
|
/** Returns string containing info about this object for debugging
|
|
@@ -3551,6 +3605,9 @@ declare module "littlejsengine" {
|
|
|
3551
3605
|
/** Called if uiDebug is enabled
|
|
3552
3606
|
* @param {boolean} visible */
|
|
3553
3607
|
renderDebug(visible?: boolean): void;
|
|
3608
|
+
/** Internal function called when object is clicked
|
|
3609
|
+
* @param {boolean} [playSound] */
|
|
3610
|
+
click(playSound?: boolean): void;
|
|
3554
3611
|
/** Called each frame before object updates */
|
|
3555
3612
|
onUpdate(): void;
|
|
3556
3613
|
/** Called each frame before object renders */
|
|
@@ -3585,6 +3642,30 @@ declare module "littlejsengine" {
|
|
|
3585
3642
|
text: string;
|
|
3586
3643
|
align: string;
|
|
3587
3644
|
}
|
|
3645
|
+
/**
|
|
3646
|
+
* UITextInput - An editable text input field
|
|
3647
|
+
* - A simple text entry field that supports basic editing
|
|
3648
|
+
* - Suitable for short text input like names or numbers
|
|
3649
|
+
* @extends UIObject
|
|
3650
|
+
* @memberof UISystem
|
|
3651
|
+
*/
|
|
3652
|
+
export class UITextInput extends UIObject {
|
|
3653
|
+
/** Create a UITextInput object
|
|
3654
|
+
* @param {Vector2} [pos]
|
|
3655
|
+
* @param {Vector2} [size]
|
|
3656
|
+
* @param {string} [text]
|
|
3657
|
+
*/
|
|
3658
|
+
constructor(pos?: Vector2, size?: Vector2, text?: string);
|
|
3659
|
+
/** @property {number} - Max length of input (0 = no limit) */
|
|
3660
|
+
maxLength: number;
|
|
3661
|
+
text: string;
|
|
3662
|
+
click(): void;
|
|
3663
|
+
/** Stop editing the text edited */
|
|
3664
|
+
stopEditing(): void;
|
|
3665
|
+
/** Key down event handler if this object is being edited
|
|
3666
|
+
* @param {KeyboardEvent} [e] */
|
|
3667
|
+
onKeyDown(e?: KeyboardEvent): void;
|
|
3668
|
+
}
|
|
3588
3669
|
/**
|
|
3589
3670
|
* UITile - A UI object that displays a tile image
|
|
3590
3671
|
* @extends UIObject
|
|
@@ -3641,6 +3722,7 @@ declare module "littlejsengine" {
|
|
|
3641
3722
|
/** @property {boolean} - Current percentage value of this scrollbar 0-1 */
|
|
3642
3723
|
checked: boolean;
|
|
3643
3724
|
text: string;
|
|
3725
|
+
click(): void;
|
|
3644
3726
|
}
|
|
3645
3727
|
/**
|
|
3646
3728
|
* UIScrollbar - A UI object that acts as a scrollbar
|