littlejsengine 1.9.5 → 1.9.6
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 +57 -45
- package/dist/littlejs.esm.js +277 -192
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +275 -192
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +272 -188
- package/examples/breakout/index.html +3 -3
- package/examples/breakoutTutorial/index.html +2 -2
- package/examples/electron/index.html +2 -2
- package/examples/js13k/build.js +1 -0
- package/examples/js13k/index.html +13 -13
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +1 -1
- package/examples/platformer/index.html +8 -8
- package/examples/puzzle/index.html +2 -2
- package/examples/starter/index.html +13 -13
- package/examples/stress/index.html +1 -1
- package/examples/typescript/index.html +1 -1
- package/package.json +1 -1
- package/src/engine.js +63 -40
- package/src/engineAudio.js +20 -16
- package/src/engineDebug.js +3 -4
- package/src/engineDraw.js +13 -10
- package/src/engineExport.js +2 -0
- package/src/engineInput.js +80 -64
- package/src/engineObject.js +18 -7
- package/src/engineParticles.js +14 -13
- package/src/engineSettings.js +13 -2
- package/src/engineTileLayer.js +15 -4
- package/src/engineUtilities.js +16 -14
- package/src/engineWebGL.js +20 -18
- package/LittleJS.zip +0 -0
package/dist/littlejs.d.ts
CHANGED
|
@@ -214,6 +214,11 @@ declare module "littlejsengine" {
|
|
|
214
214
|
* @default
|
|
215
215
|
* @memberof Settings */
|
|
216
216
|
export let showSplashScreen: boolean;
|
|
217
|
+
/** Disables all rendering, audio, and input for servers
|
|
218
|
+
* @type {Boolean}
|
|
219
|
+
* @default
|
|
220
|
+
* @memberof Settings */
|
|
221
|
+
export let headlessMode: boolean;
|
|
217
222
|
/** Default size of tiles in pixels
|
|
218
223
|
* @type {Vector2}
|
|
219
224
|
* @default Vector2(16,16)
|
|
@@ -389,6 +394,10 @@ declare module "littlejsengine" {
|
|
|
389
394
|
* @param {Boolean} show
|
|
390
395
|
* @memberof Settings */
|
|
391
396
|
export function setShowSplashScreen(show: boolean): void;
|
|
397
|
+
/** Set to disalbe rendering, audio, and input for servers
|
|
398
|
+
* @param {Boolean} headless
|
|
399
|
+
* @memberof Settings */
|
|
400
|
+
export function setHeadlessMode(headless: boolean): void;
|
|
392
401
|
/** Set if webgl rendering is enabled
|
|
393
402
|
* @param {Boolean} enable
|
|
394
403
|
* @memberof Settings */
|
|
@@ -888,7 +897,7 @@ declare module "littlejsengine" {
|
|
|
888
897
|
* @param {Number} [alphaAmount]
|
|
889
898
|
* @return {Color} */
|
|
890
899
|
mutate(amount?: number, alphaAmount?: number): Color;
|
|
891
|
-
/** Returns this color expressed as a
|
|
900
|
+
/** Returns this color expressed as a rgb color code
|
|
892
901
|
* @param {Boolean} [useAlpha] - if alpha should be included in result
|
|
893
902
|
* @return {String} */
|
|
894
903
|
toString(useAlpha?: boolean): string;
|
|
@@ -1103,9 +1112,9 @@ declare module "littlejsengine" {
|
|
|
1103
1112
|
* @param {Color} [additiveColor=(0,0,0,0)] - Additive color to be applied
|
|
1104
1113
|
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
1105
1114
|
* @param {Boolean} [screenSpace=false] - If true the pos and size are in screen space
|
|
1106
|
-
* @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
1115
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
1107
1116
|
* @memberof Draw */
|
|
1108
|
-
export function drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1117
|
+
export function drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1109
1118
|
/** Draw colored rect centered on pos
|
|
1110
1119
|
* @param {Vector2} pos
|
|
1111
1120
|
* @param {Vector2} [size=(1,1)]
|
|
@@ -1113,9 +1122,9 @@ declare module "littlejsengine" {
|
|
|
1113
1122
|
* @param {Number} [angle]
|
|
1114
1123
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1115
1124
|
* @param {Boolean} [screenSpace=false]
|
|
1116
|
-
* @param {CanvasRenderingContext2D} [context]
|
|
1125
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1117
1126
|
* @memberof Draw */
|
|
1118
|
-
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1127
|
+
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1119
1128
|
/** Draw colored line between two points
|
|
1120
1129
|
* @param {Vector2} posA
|
|
1121
1130
|
* @param {Vector2} posB
|
|
@@ -1123,9 +1132,9 @@ declare module "littlejsengine" {
|
|
|
1123
1132
|
* @param {Color} [color=(1,1,1,1)]
|
|
1124
1133
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1125
1134
|
* @param {Boolean} [screenSpace=false]
|
|
1126
|
-
* @param {CanvasRenderingContext2D} [context]
|
|
1135
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1127
1136
|
* @memberof Draw */
|
|
1128
|
-
export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1137
|
+
export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1129
1138
|
/** Draw directly to a 2d canvas context in world space
|
|
1130
1139
|
* @param {Vector2} pos
|
|
1131
1140
|
* @param {Vector2} size
|
|
@@ -1133,15 +1142,15 @@ declare module "littlejsengine" {
|
|
|
1133
1142
|
* @param {Boolean} mirror
|
|
1134
1143
|
* @param {Function} drawFunction
|
|
1135
1144
|
* @param {Boolean} [screenSpace=false]
|
|
1136
|
-
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1145
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=mainContext]
|
|
1137
1146
|
* @memberof Draw */
|
|
1138
|
-
export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1147
|
+
export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1139
1148
|
/** Enable normal or additive blend mode
|
|
1140
1149
|
* @param {Boolean} [additive]
|
|
1141
1150
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1142
|
-
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1151
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=mainContext]
|
|
1143
1152
|
* @memberof Draw */
|
|
1144
|
-
export function setBlendMode(additive?: boolean, useWebGL?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1153
|
+
export function setBlendMode(additive?: boolean, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1145
1154
|
/** Draw text on overlay canvas in screen space
|
|
1146
1155
|
* Automatically splits new lines into rows
|
|
1147
1156
|
* @param {String} text
|
|
@@ -1152,9 +1161,9 @@ declare module "littlejsengine" {
|
|
|
1152
1161
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1153
1162
|
* @param {CanvasTextAlign} [textAlign]
|
|
1154
1163
|
* @param {String} [font=fontDefault]
|
|
1155
|
-
* @param {CanvasRenderingContext2D} [context=overlayContext]
|
|
1164
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
1156
1165
|
* @memberof Draw */
|
|
1157
|
-
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, context?: CanvasRenderingContext2D): void;
|
|
1166
|
+
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1158
1167
|
/** Draw text on overlay canvas in world space
|
|
1159
1168
|
* Automatically splits new lines into rows
|
|
1160
1169
|
* @param {String} text
|
|
@@ -1165,9 +1174,9 @@ declare module "littlejsengine" {
|
|
|
1165
1174
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1166
1175
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1167
1176
|
* @param {String} [font=fontDefault]
|
|
1168
|
-
* @param {CanvasRenderingContext2D} [context=overlayContext]
|
|
1177
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
1169
1178
|
* @memberof Draw */
|
|
1170
|
-
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, context?: CanvasRenderingContext2D): void;
|
|
1179
|
+
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1171
1180
|
export let engineFontImage: any;
|
|
1172
1181
|
/**
|
|
1173
1182
|
* Font Image Object - Draw text on a 2D canvas by using characters in an image
|
|
@@ -1186,13 +1195,13 @@ declare module "littlejsengine" {
|
|
|
1186
1195
|
* @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
|
|
1187
1196
|
* @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
|
|
1188
1197
|
* @param {Vector2} [paddingSize=(0,1)] - How much extra space to add between characters
|
|
1189
|
-
* @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
|
|
1198
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext] - context to draw to
|
|
1190
1199
|
*/
|
|
1191
|
-
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, context?: CanvasRenderingContext2D);
|
|
1200
|
+
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D);
|
|
1192
1201
|
image: any;
|
|
1193
1202
|
tileSize: Vector2;
|
|
1194
1203
|
paddingSize: Vector2;
|
|
1195
|
-
context: CanvasRenderingContext2D;
|
|
1204
|
+
context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
1196
1205
|
/** Draw text in world space using the image font
|
|
1197
1206
|
* @param {String} text
|
|
1198
1207
|
* @param {Vector2} pos
|
|
@@ -1639,7 +1648,9 @@ declare module "littlejsengine" {
|
|
|
1639
1648
|
isSolid: boolean;
|
|
1640
1649
|
/** @property {Boolean} - Object collides with raycasts */
|
|
1641
1650
|
collideRaycast: boolean;
|
|
1642
|
-
/** Update the object transform
|
|
1651
|
+
/** Update the object transform, called automatically by engine even when paused */
|
|
1652
|
+
updateTransforms(): void;
|
|
1653
|
+
/** Update the object physics, called automatically by engine once each frame */
|
|
1643
1654
|
update(): void;
|
|
1644
1655
|
groundObject: any;
|
|
1645
1656
|
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
@@ -1785,22 +1796,13 @@ declare module "littlejsengine" {
|
|
|
1785
1796
|
constructor(position?: Vector2, size?: Vector2, tileInfo?: TileInfo, scale?: Vector2, renderOrder?: number);
|
|
1786
1797
|
/** @property {HTMLCanvasElement} - The canvas used by this tile layer */
|
|
1787
1798
|
canvas: HTMLCanvasElement;
|
|
1788
|
-
/** @property {CanvasRenderingContext2D} - The 2D canvas context used by this tile layer */
|
|
1799
|
+
/** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this tile layer */
|
|
1789
1800
|
context: CanvasRenderingContext2D;
|
|
1790
1801
|
/** @property {Vector2} - How much to scale this layer when rendered */
|
|
1791
1802
|
scale: Vector2;
|
|
1792
1803
|
/** @property {Boolean} - If true this layer will render to overlay canvas and appear above all objects */
|
|
1793
1804
|
isOverlay: boolean;
|
|
1794
1805
|
data: TileLayerData[];
|
|
1795
|
-
/** Set data at a given position in the array
|
|
1796
|
-
* @param {Vector2} layerPos - Local position in array
|
|
1797
|
-
* @param {TileLayerData} data - Data to set
|
|
1798
|
-
* @param {Boolean} [redraw] - Force the tile to redraw if true */
|
|
1799
|
-
setData(layerPos: Vector2, data: TileLayerData, redraw?: boolean): void;
|
|
1800
|
-
/** Get data at a given position in the array
|
|
1801
|
-
* @param {Vector2} layerPos - Local position in array
|
|
1802
|
-
* @return {TileLayerData} */
|
|
1803
|
-
getData(layerPos: Vector2): TileLayerData;
|
|
1804
1806
|
/** Draw all the tile data to an offscreen canvas
|
|
1805
1807
|
* - This may be slow in some browsers but only needs to be done once */
|
|
1806
1808
|
redraw(): void;
|
|
@@ -1808,8 +1810,6 @@ declare module "littlejsengine" {
|
|
|
1808
1810
|
* - This can be used to manually update small parts of the level
|
|
1809
1811
|
* @param {Boolean} [clear] - Should it clear the canvas before drawing */
|
|
1810
1812
|
redrawStart(clear?: boolean): void;
|
|
1811
|
-
/** @type {[HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number]} */
|
|
1812
|
-
savedRenderSettings: [HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number];
|
|
1813
1813
|
/** Call to end the redraw process */
|
|
1814
1814
|
redrawEnd(): void;
|
|
1815
1815
|
/** Draw the tile at a given position in the tile grid
|
|
@@ -1826,6 +1826,17 @@ declare module "littlejsengine" {
|
|
|
1826
1826
|
* @param {Boolean} mirror
|
|
1827
1827
|
* @param {Function} drawFunction */
|
|
1828
1828
|
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function): void;
|
|
1829
|
+
/** Set data at a given position in the array
|
|
1830
|
+
* @param {Vector2} layerPos - Local position in array
|
|
1831
|
+
* @param {TileLayerData} data - Data to set
|
|
1832
|
+
* @param {Boolean} [redraw] - Force the tile to redraw if true */
|
|
1833
|
+
setData(layerPos: Vector2, data: TileLayerData, redraw?: boolean): void;
|
|
1834
|
+
/** Get data at a given position in the array
|
|
1835
|
+
* @param {Vector2} layerPos - Local position in array
|
|
1836
|
+
* @return {TileLayerData} */
|
|
1837
|
+
getData(layerPos: Vector2): TileLayerData;
|
|
1838
|
+
/** @type {[HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number]} */
|
|
1839
|
+
savedRenderSettings: [HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number];
|
|
1829
1840
|
/** Draw a tile directly onto the layer canvas in world space
|
|
1830
1841
|
* @param {Vector2} pos
|
|
1831
1842
|
* @param {Vector2} [size=(1,1)]
|
|
@@ -1948,22 +1959,23 @@ declare module "littlejsengine" {
|
|
|
1948
1959
|
*/
|
|
1949
1960
|
export class Particle extends EngineObject {
|
|
1950
1961
|
/**
|
|
1951
|
-
* Create a particle with the
|
|
1952
|
-
*
|
|
1953
|
-
* @param {
|
|
1954
|
-
* @param {
|
|
1955
|
-
* @param {
|
|
1956
|
-
* @param {Color}
|
|
1957
|
-
* @param {
|
|
1958
|
-
* @param {Number}
|
|
1959
|
-
* @param {Number}
|
|
1960
|
-
* @param {Number}
|
|
1961
|
-
* @param {
|
|
1962
|
-
* @param {
|
|
1962
|
+
* Create a particle with the passed in settings
|
|
1963
|
+
* Typically this is created automatically by a ParticleEmitter
|
|
1964
|
+
* @param {Vector2} position - World space position of the particle
|
|
1965
|
+
* @param {TileInfo} tileInfo - Tile info to render particles
|
|
1966
|
+
* @param {Number} angle - Angle to rotate the particle
|
|
1967
|
+
* @param {Color} colorStart - Color at start of life
|
|
1968
|
+
* @param {Color} colorEnd - Color at end of life
|
|
1969
|
+
* @param {Number} lifeTime - How long to live for
|
|
1970
|
+
* @param {Number} sizeStart - Size at start of life
|
|
1971
|
+
* @param {Number} sizeEnd - Size at end of life
|
|
1972
|
+
* @param {Number} fadeRate - How quick to fade in/out
|
|
1973
|
+
* @param {Boolean} additive - Does it use additive blend mode
|
|
1974
|
+
* @param {Number} trailScale - If a trail, how long to make it
|
|
1963
1975
|
* @param {ParticleEmitter} [localSpaceEmitter] - Parent emitter if local space
|
|
1964
|
-
* @param {Function}
|
|
1976
|
+
* @param {Function} [destroyCallback] - Callback when particle dies
|
|
1965
1977
|
*/
|
|
1966
|
-
constructor(position: Vector2, tileInfo
|
|
1978
|
+
constructor(position: Vector2, tileInfo: TileInfo, angle: number, colorStart: Color, colorEnd: Color, lifeTime: number, sizeStart: number, sizeEnd: number, fadeRate: number, additive: boolean, trailScale: number, localSpaceEmitter?: ParticleEmitter, destroyCallback?: Function);
|
|
1967
1979
|
/** @property {Color} - Color at start of life */
|
|
1968
1980
|
colorStart: Color;
|
|
1969
1981
|
/** @property {Color} - Calculated change in color */
|