littlejsengine 1.4.91 → 1.5.1

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.
Files changed (41) hide show
  1. package/README.md +1 -0
  2. package/build.bat +4 -6
  3. package/engine/engine.all.js +202 -105
  4. package/engine/engine.all.min.js +1 -1
  5. package/engine/engine.all.module.js +385 -181
  6. package/engine/engine.all.module.min.js +1 -1
  7. package/engine/engine.all.release.js +192 -100
  8. package/engine/engine.js +47 -16
  9. package/engine/engineAudio.js +14 -1
  10. package/engine/engineBuild.bat +8 -8
  11. package/engine/engineDebug.js +10 -5
  12. package/engine/engineDraw.js +25 -27
  13. package/engine/engineExport.js +183 -76
  14. package/engine/engineInput.js +6 -1
  15. package/engine/engineMedals.js +1 -0
  16. package/engine/engineObject.js +11 -9
  17. package/engine/engineParticles.js +5 -5
  18. package/engine/engineSettings.js +46 -20
  19. package/engine/engineTileLayer.js +13 -12
  20. package/engine/engineUtilities.js +13 -7
  21. package/engine/engineWebGL.js +11 -2
  22. package/engine/index.d.ts +1788 -1700
  23. package/examples/breakout/game.js +3 -1
  24. package/examples/breakout/index.html +4 -4
  25. package/examples/empty/index.html +1 -4
  26. package/examples/module/game.js +1 -4
  27. package/examples/module/index.html +2 -2
  28. package/examples/particles/index.html +2 -2
  29. package/examples/platformer/game.js +2 -0
  30. package/examples/platformer/gameObjects.js +3 -3
  31. package/examples/platformer/index.html +7 -7
  32. package/examples/puzzle/index.html +3 -3
  33. package/examples/stress/index.html +5 -5
  34. package/examples/typescript/build.bat +14 -0
  35. package/examples/typescript/game.js +89 -0
  36. package/examples/typescript/game.ts +117 -0
  37. package/examples/typescript/index.html +9 -0
  38. package/examples/typescript/tiles.png +0 -0
  39. package/examples/typescript/tsconfig.json +8 -0
  40. package/index.html +14 -14
  41. package/package.json +6 -6
package/engine/index.d.ts CHANGED
@@ -1,1700 +1,1788 @@
1
- /** Draw textured tile centered in world space, with color applied if using WebGL
2
- * @param {Vector2} pos - Center of the tile in world space
3
- * @param {Vector2} [size=new Vector2(1,1)] - Size of the tile in world space
4
- * @param {Number} [tileIndex=-1] - Tile index to use, negative is untextured
5
- * @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
6
- * @param {Color} [color=new Color(1,1,1)] - Color to modulate with
7
- * @param {Number} [angle=0] - Angle to rotate by
8
- * @param {Boolean} [mirror=0] - If true image is flipped along the Y axis
9
- * @param {Color} [additiveColor=new Color(0,0,0,0)] - Additive color to be applied
10
- * @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
11
- * @memberof Draw */
12
- declare function drawTile(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean): void;
13
- /** Draw colored rect centered on pos
14
- * @param {Vector2} pos
15
- * @param {Vector2} [size=new Vector2(1,1)]
16
- * @param {Color} [color=new Color(1,1,1)]
17
- * @param {Number} [angle=0]
18
- * @param {Boolean} [useWebGL=glEnable]
19
- * @memberof Draw */
20
- declare function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean): void;
21
- /** Draw textured tile centered on pos in screen space
22
- * @param {Vector2} pos - Center of the tile
23
- * @param {Vector2} [size=new Vector2(1,1)] - Size of the tile
24
- * @param {Number} [tileIndex=-1] - Tile index to use, negative is untextured
25
- * @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
26
- * @param {Color} [color=new Color]
27
- * @param {Number} [angle=0]
28
- * @param {Boolean} [mirror=0]
29
- * @param {Color} [additiveColor=new Color(0,0,0,0)]
30
- * @param {Boolean} [useWebGL=glEnable]
31
- * @memberof Draw */
32
- declare function drawTileScreenSpace(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean): void;
33
- /** Draw colored rectangle in screen space
34
- * @param {Vector2} pos
35
- * @param {Vector2} [size=new Vector2(1,1)]
36
- * @param {Color} [color=new Color(1,1,1)]
37
- * @param {Number} [angle=0]
38
- * @param {Boolean} [useWebGL=glEnable]
39
- * @memberof Draw */
40
- declare function drawRectScreenSpace(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean): void;
41
- /** Draw colored line between two points
42
- * @param {Vector2} posA
43
- * @param {Vector2} posB
44
- * @param {Number} [thickness=.1]
45
- * @param {Color} [color=new Color(1,1,1)]
46
- * @param {Boolean} [useWebGL=glEnable]
47
- * @memberof Draw */
48
- declare function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean): void;
49
- /** Draw directly to a 2d canvas context in world space
50
- * @param {Vector2} pos
51
- * @param {Vector2} size
52
- * @param {Number} angle
53
- * @param {Boolean} mirror
54
- * @param {Function} drawFunction
55
- * @param {CanvasRenderingContext2D} [context=mainContext]
56
- * @memberof Draw */
57
- declare function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, context?: CanvasRenderingContext2D): void;
58
- /** Enable normal or additive blend mode
59
- * @param {Boolean} [additive=0]
60
- * @param {Boolean} [useWebGL=glEnable]
61
- * @memberof Draw */
62
- declare function setBlendMode(additive?: boolean, useWebGL?: boolean): void;
63
- /** Draw text on overlay canvas in screen space
64
- * Automatically splits new lines into rows
65
- * @param {String} text
66
- * @param {Vector2} pos
67
- * @param {Number} [size=1]
68
- * @param {Color} [color=new Color(1,1,1)]
69
- * @param {Number} [lineWidth=0]
70
- * @param {Color} [lineColor=new Color(0,0,0)]
71
- * @param {String} [textAlign='center']
72
- * @memberof Draw */
73
- declare function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: string, font?: string, context?: CanvasRenderingContext2D): void;
74
- /** Draw text on overlay canvas in world space
75
- * Automatically splits new lines into rows
76
- * @param {String} text
77
- * @param {Vector2} pos
78
- * @param {Number} [size=1]
79
- * @param {Color} [color=new Color(1,1,1)]
80
- * @param {Number} [lineWidth=0]
81
- * @param {Color} [lineColor=new Color(0,0,0)]
82
- * @param {String} [textAlign='center']
83
- * @memberof Draw */
84
- declare function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: string, font: any): void;
85
- /** Toggle fullsceen mode
86
- * @memberof Draw */
87
- declare function toggleFullscreen(): void;
88
- declare function inputUpdate(): void;
89
- declare function inputUpdatePost(): void;
90
- declare function gamepadsUpdate(): void;
91
- declare function touchGamepadCreate(): void;
92
- declare function touchGamepadRender(): void;
93
- /** Play an mp3 or wav audio from a local file or url
94
- * @param {String} url - Location of sound file to play
95
- * @param {Number} [volume=1] - How much to scale volume by
96
- * @param {Boolean} [loop=1] - True if the music should loop when it reaches the end
97
- * @return {HTMLAudioElement} - The audio element for this sound
98
- * @memberof Audio */
99
- declare function playAudioFile(url: string, volume?: number, loop?: boolean): HTMLAudioElement;
100
- /** Speak text with passed in settings
101
- * @param {String} text - The text to speak
102
- * @param {String} [language] - The language/accent to use (examples: en, it, ru, ja, zh)
103
- * @param {Number} [volume=1] - How much to scale volume by
104
- * @param {Number} [rate=1] - How quickly to speak
105
- * @param {Number} [pitch=1] - How much to change the pitch by
106
- * @return {SpeechSynthesisUtterance} - The utterance that was spoken
107
- * @memberof Audio */
108
- declare function speak(text: string, language?: string, volume?: number, rate?: number, pitch?: number): SpeechSynthesisUtterance;
109
- /** Play cached audio samples with given settings
110
- * @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
111
- * @param {Number} [volume=1] - How much to scale volume by
112
- * @param {Number} [rate=1] - The playback rate to use
113
- * @param {Number} [pan=0] - How much to apply stereo panning
114
- * @param {Boolean} [loop=0] - True if the sound should loop when it reaches the end
115
- * @return {AudioBufferSourceNode} - The audio node of the sound played
116
- * @memberof Audio */
117
- declare function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean): AudioBufferSourceNode;
118
- /** Generate samples for a ZzFX sound
119
- * @memberof Audio */
120
- declare 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): number[];
121
- /** Generate samples for a ZzFM song with given parameters
122
- * @param {Array} instruments - Array of ZzFX sound paramaters
123
- * @param {Array} patterns - Array of pattern data
124
- * @param {Array} sequence - Array of pattern indexes
125
- * @param {Number} [BPM=125] - Playback speed of the song in BPM
126
- * @returns {Array} - Left and right channel sample data
127
- * @memberof Audio */
128
- declare function zzfxM(instruments: any[], patterns: any[], sequence: any[], BPM?: number): any[];
129
- /** Clear and initialize tile collision
130
- * @param {Vector2} size
131
- * @memberof TileCollision */
132
- declare function initTileCollision(size: Vector2): void;
133
- /** Check if collision with another object should occur
134
- * @param {Vector2} pos
135
- * @param {Vector2} [size=new Vector2(1,1)]
136
- * @param {EngineObject} [object]
137
- * @return {Boolean}
138
- * @memberof TileCollision */
139
- declare function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
140
- /** Return the center of tile if any that is hit (this does not return the exact hit point)
141
- * @param {Vector2} posStart
142
- * @param {Vector2} posEnd
143
- * @param {EngineObject} [object]
144
- * @return {Vector2}
145
- * @memberof TileCollision */
146
- declare function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject): Vector2;
147
- /** Initialize medals with a save name used for storage
148
- * <br> - Call this after creating all medals
149
- * <br> - Checks if medals are unlocked
150
- * @param {String} saveName
151
- * @memberof Medals */
152
- declare function medalsInit(saveName: string): void;
153
- declare function medalsRender(): void;
154
- /** This can used to enable Newgrounds functionality
155
- * @param {Number} app_id - The newgrounds App ID
156
- * @param {String} [cipher] - The encryption Key (AES-128/Base64)
157
- * @memberof Medals */
158
- declare function newgroundsInit(app_id: number, cipher?: string): void;
159
- declare function glInit(): void;
160
- /** Set the WebGl blend mode, normally you should call setBlendMode instead
161
- * @param {Boolean} [additive=0]
162
- * @memberof WebGL */
163
- declare function glSetBlendMode(additive?: boolean): void;
164
- /** Set the WebGl texture, not normally necessary unless multiple tile sheets are used
165
- * <br> - This may also flush the gl buffer resulting in more draw calls and worse performance
166
- * @param {WebGLTexture} [texture=glTileTexture]
167
- * @memberof WebGL */
168
- declare function glSetTexture(texture?: WebGLTexture): void;
169
- /** Compile WebGL shader of the given type, will throw errors if in debug mode
170
- * @param {String} source
171
- * @param type
172
- * @return {WebGLShader}
173
- * @memberof WebGL */
174
- declare function glCompileShader(source: string, type: any): WebGLShader;
175
- /** Create WebGL program with given shaders
176
- * @param {WebGLShader} vsSource
177
- * @param {WebGLShader} fsSource
178
- * @return {WebGLProgram}
179
- * @memberof WebGL */
180
- declare function glCreateProgram(vsSource: WebGLShader, fsSource: WebGLShader): WebGLProgram;
181
- /** Create WebGL texture from an image and set the texture settings
182
- * @param {Image} image
183
- * @return {WebGLTexture}
184
- * @memberof WebGL */
185
- declare function glCreateTexture(image: new (width?: number, height?: number) => HTMLImageElement): WebGLTexture;
186
- declare function glPreRender(): void;
187
- /** Draw all sprites and clear out the buffer, called automatically by the system whenever necessary
188
- * @memberof WebGL */
189
- declare function glFlush(): void;
190
- /** Draw any sprites still in the buffer, copy to main canvas and clear
191
- * @param {CanvasRenderingContext2D} context
192
- * @param {Boolean} [forceDraw=0]
193
- * @memberof WebGL */
194
- declare function glCopyToContext(context: CanvasRenderingContext2D, forceDraw?: boolean): void;
195
- /** Add a sprite to the gl draw list, used by all gl draw functions
196
- * @param x
197
- * @param y
198
- * @param sizeX
199
- * @param sizeY
200
- * @param angle
201
- * @param uv0X
202
- * @param uv0Y
203
- * @param uv1X
204
- * @param uv1Y
205
- * @param rgba
206
- * @param [rgbaAdditive=0]
207
- * @memberof WebGL */
208
- declare function glDraw(x: any, y: any, sizeX: any, sizeY: any, angle: any, uv0X: any, uv0Y: any, uv1X: any, uv1Y: any, rgba: any, rgbaAdditive?: number): void;
209
- /** Set up a post processing shader
210
- * @param {String} shaderCode
211
- * @memberof WebGL */
212
- declare function glInitPostProcess(shaderCode: string): void;
213
- declare function glRenderPostProcess(): void;
214
- /** Set if game is paused
215
- * @param {Boolean} paused
216
- */
217
- declare function setPaused(_paused: any): void;
218
- /** Start up LittleJS engine with your callback functions
219
- * @param {Function} gameInit - Called once after the engine starts up, setup the game
220
- * @param {Function} gameUpdate - Called every frame at 60 frames per second, handle input and update the game state
221
- * @param {Function} gameUpdatePost - Called after physics and objects are updated, setup camera and prepare for render
222
- * @param {Function} gameRender - Called before objects are rendered, draw any background effects that appear behind objects
223
- * @param {Function} gameRenderPost - Called after objects are rendered, draw effects or hud that appear above all objects
224
- * @param {String} [tileImageSource] - Tile image to use, everything starts when the image is finished loading
225
- */
226
- declare function engineInit(gameInit: Function, gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, tileImageSource?: string): void;
227
- declare function enginePreRender(): void;
228
- /** Update each engine object, remove destroyed objects, and update time */
229
- declare function engineObjectsUpdate(): void;
230
- /** Destroy and remove all objects */
231
- declare function engineObjectsDestroy(): void;
232
- /** Triggers a callback for each object within a given area
233
- * @param {Vector2} [pos] - Center of test area
234
- * @param {Number} [size] - Radius of circle if float, rectangle size if Vector2
235
- * @param {Function} [callbackFunction] - Calls this function on every object that passes the test
236
- * @param {Array} [objects=engineObjects] - List of objects to check */
237
- declare function engineObjectsCallback(pos?: Vector2, size?: number, callbackFunction?: Function, objects?: any[]): void;
238
- /** True if debug is enabled
239
- * @default
240
- * @memberof Debug */
241
- declare const debug: 1;
242
- /** True if asserts are enaled
243
- * @default
244
- * @memberof Debug */
245
- declare const enableAsserts: 1;
246
- /** Size to render debug points by default
247
- * @default
248
- * @memberof Debug */
249
- declare const debugPointSize: 0.5;
250
- /** True if watermark with FPS should be down, false in release builds
251
- * @default
252
- * @memberof Debug */
253
- declare let showWatermark: number;
254
- /** True if god mode is enabled, handle this however you want
255
- * @default
256
- * @memberof Debug */
257
- declare let godMode: number;
258
- declare let debugPrimitives: any[];
259
- declare let debugOverlay: number;
260
- declare let debugPhysics: number;
261
- declare let debugRaycast: number;
262
- declare let debugParticles: number;
263
- declare let debugGamepads: number;
264
- declare let debugMedals: number;
265
- declare let debugTakeScreenshot: any;
266
- declare let downloadLink: any;
267
- declare function ASSERT(...assert: any[]): void;
268
- /** Draw a debug rectangle in world space
269
- * @param {Vector2} pos
270
- * @param {Vector2} [size=new Vector2()]
271
- * @param {String} [color='#fff']
272
- * @param {Number} [time=0]
273
- * @param {Number} [angle=0]
274
- * @param {Boolean} [fill=0]
275
- * @memberof Debug */
276
- declare function debugRect(pos: Vector2, size?: Vector2, color?: string, time?: number, angle?: number, fill?: boolean): void;
277
- /** Draw a debug circle in world space
278
- * @param {Vector2} pos
279
- * @param {Number} [radius=0]
280
- * @param {String} [color='#fff']
281
- * @param {Number} [time=0]
282
- * @param {Boolean} [fill=0]
283
- * @memberof Debug */
284
- declare function debugCircle(pos: Vector2, radius?: number, color?: string, time?: number, fill?: boolean): void;
285
- /** Draw a debug point in world space
286
- * @param {Vector2} pos
287
- * @param {String} [color='#fff']
288
- * @param {Number} [time=0]
289
- * @param {Number} [angle=0]
290
- * @memberof Debug */
291
- declare function debugPoint(pos: Vector2, color?: string, time?: number, angle?: number): void;
292
- /** Draw a debug line in world space
293
- * @param {Vector2} posA
294
- * @param {Vector2} posB
295
- * @param {String} [color='#fff']
296
- * @param {Number} [thickness=.1]
297
- * @param {Number} [time=0]
298
- * @memberof Debug */
299
- declare function debugLine(posA: Vector2, posB: Vector2, color?: string, thickness?: number, time?: number): void;
300
- /** Draw a debug axis aligned bounding box in world space
301
- * @param {Vector2} posA
302
- * @param {Vector2} sizeA
303
- * @param {Vector2} posB
304
- * @param {Vector2} sizeB
305
- * @param {String} [color='#fff']
306
- * @memberof Debug */
307
- declare function debugAABB(pA: any, sA: any, pB: any, sB: any, color?: string): void;
308
- /** Draw a debug axis aligned bounding box in world space
309
- * @param {String} text
310
- * @param {Vector2} pos
311
- * @param {Number} [size=1]
312
- * @param {String} [color='#fff']
313
- * @param {Number} [time=0]
314
- * @param {Number} [angle=0]
315
- * @param {String} [font='monospace']
316
- * @memberof Debug */
317
- declare function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
318
- /** Clear all debug primitives in the list
319
- * @memberof Debug */
320
- declare function debugClear(): any[];
321
- /** Save a canvas to disk
322
- * @param {HTMLCanvasElement} canvas
323
- * @param {String} [filename]
324
- * @memberof Debug */
325
- declare function debugSaveCanvas(canvas: HTMLCanvasElement, filename?: string): void;
326
- declare function debugInit(): void;
327
- declare function debugUpdate(): void;
328
- declare function debugRender(): void;
329
- /** A shortcut to get Math.PI
330
- * @const
331
- * @memberof Utilities */
332
- declare const PI: number;
333
- /** Returns absoulte value of value passed in
334
- * @param {Number} value
335
- * @return {Number}
336
- * @memberof Utilities */
337
- declare function abs(a: any): number;
338
- /** Returns lowest of two values passed in
339
- * @param {Number} valueA
340
- * @param {Number} valueB
341
- * @return {Number}
342
- * @memberof Utilities */
343
- declare function min(a: any, b: any): number;
344
- /** Returns highest of two values passed in
345
- * @param {Number} valueA
346
- * @param {Number} valueB
347
- * @return {Number}
348
- * @memberof Utilities */
349
- declare function max(a: any, b: any): number;
350
- /** Returns the sign of value passed in (also returns 1 if 0)
351
- * @param {Number} value
352
- * @return {Number}
353
- * @memberof Utilities */
354
- declare function sign(a: any): number;
355
- /** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
356
- * @param {Number} dividend
357
- * @param {Number} [divisor=1]
358
- * @return {Number}
359
- * @memberof Utilities */
360
- declare function mod(a: any, b?: number): number;
361
- /** Clamps the value beween max and min
362
- * @param {Number} value
363
- * @param {Number} [min=0]
364
- * @param {Number} [max=1]
365
- * @return {Number}
366
- * @memberof Utilities */
367
- declare function clamp(v: any, min?: number, max?: number): number;
368
- /** Returns what percentage the value is between max and min
369
- * @param {Number} value
370
- * @param {Number} [min=0]
371
- * @param {Number} [max=1]
372
- * @return {Number}
373
- * @memberof Utilities */
374
- declare function percent(v: any, min?: number, max?: number): number;
375
- /** Linearly interpolates the percent value between max and min
376
- * @param {Number} percent
377
- * @param {Number} [min=0]
378
- * @param {Number} [max=1]
379
- * @return {Number}
380
- * @memberof Utilities */
381
- declare function lerp(p: any, min?: number, max?: number): number;
382
- /** Applies smoothstep function to the percentage value
383
- * @param {Number} value
384
- * @return {Number}
385
- * @memberof Utilities */
386
- declare function smoothStep(p: any): number;
387
- /** Returns the nearest power of two not less then the value
388
- * @param {Number} value
389
- * @return {Number}
390
- * @memberof Utilities */
391
- declare function nearestPowerOfTwo(v: any): number;
392
- /** Returns true if two axis aligned bounding boxes are overlapping
393
- * @param {Vector2} pointA - Center of box A
394
- * @param {Vector2} sizeA - Size of box A
395
- * @param {Vector2} pointB - Center of box B
396
- * @param {Vector2} [sizeB] - Size of box B
397
- * @return {Boolean} - True if overlapping
398
- * @memberof Utilities */
399
- declare function isOverlapping(pA: any, sA: any, pB: any, sB: any): boolean;
400
- /** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
401
- * @param {Number} [frequency=1] - Frequency of the wave in Hz
402
- * @param {Number} [amplitude=1] - Amplitude (max height) of the wave
403
- * @param {Number} [t=time] - Value to use for time of the wave
404
- * @return {Number} - Value waving between 0 and amplitude
405
- * @memberof Utilities */
406
- declare function wave(frequency?: number, amplitude?: number, t?: number): number;
407
- /** Formats seconds to mm:ss style for display purposes
408
- * @param {Number} t - time in seconds
409
- * @return {String}
410
- * @memberof Utilities */
411
- declare function formatTime(t: number): string;
412
- /** Random global functions
413
- * @namespace Random */
414
- /** Returns a random value between the two values passed in
415
- * @param {Number} [valueA=1]
416
- * @param {Number} [valueB=0]
417
- * @return {Number}
418
- * @memberof Random */
419
- declare function rand(a?: number, b?: number): number;
420
- /** Returns a floored random value the two values passed in
421
- * @param {Number} [valueA=1]
422
- * @param {Number} [valueB=0]
423
- * @return {Number}
424
- * @memberof Random */
425
- declare function randInt(a?: number, b?: number): number;
426
- /** Randomly returns either -1 or 1
427
- * @return {Number}
428
- * @memberof Random */
429
- declare function randSign(): number;
430
- /** Returns a random Vector2 within a circular shape
431
- * @param {Number} [radius=1]
432
- * @param {Number} [minRadius=0]
433
- * @return {Vector2}
434
- * @memberof Random */
435
- declare function randInCircle(radius?: number, minRadius?: number): Vector2;
436
- /** Returns a random Vector2 with the passed in length
437
- * @param {Number} [length=1]
438
- * @return {Vector2}
439
- * @memberof Random */
440
- declare function randVector(length?: number): Vector2;
441
- /** Returns a random color between the two passed in colors, combine components if linear
442
- * @param {Color} [colorA=new Color(1,1,1,1)]
443
- * @param {Color} [colorB=new Color(0,0,0,1)]
444
- * @param {Boolean} [linear]
445
- * @return {Color}
446
- * @memberof Random */
447
- declare function randColor(cA?: Color, cB?: Color, linear?: boolean): Color;
448
- /** Seed used by the randSeeded function
449
- * @memberof Random */
450
- declare let randSeed: number;
451
- /** Set seed used by the randSeeded function, should not be 0
452
- * @param {Number} seed
453
- * @memberof Random */
454
- declare function setRandSeed(seed: number): number;
455
- /** Returns a seeded random value between the two values passed in using randSeed
456
- * @param {Number} [valueA=1]
457
- * @param {Number} [valueB=0]
458
- * @return {Number}
459
- * @memberof Random */
460
- declare function randSeeded(a?: number, b?: number): number;
461
- /**
462
- * Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar
463
- * @param {Number} [x=0]
464
- * @param {Number} [y=0]
465
- * @return {Vector2}
466
- * @example
467
- * let a = vec2(0, 1); // vector with coordinates (0, 1)
468
- * let b = vec2(a); // copy a into b
469
- * a = vec2(5); // set a to (5, 5)
470
- * b = vec2(); // set b to (0, 0)
471
- * @memberof Utilities
472
- */
473
- declare function vec2(x?: number, y?: number): Vector2;
474
- /**
475
- * Check if object is a valid Vector2
476
- * @param {Vector2} vector
477
- * @return {Boolean}
478
- * @memberof Utilities
479
- */
480
- declare function isVector2(v: any): boolean;
481
- /**
482
- * 2D Vector object with vector math library
483
- * <br> - Functions do not change this so they can be chained together
484
- * @example
485
- * let a = new Vector2(2, 3); // vector with coordinates (2, 3)
486
- * let b = new Vector2; // vector with coordinates (0, 0)
487
- * let c = vec2(4, 2); // use the vec2 function to make a Vector2
488
- * let d = a.add(b).scale(5); // operators can be chained
489
- */
490
- declare class Vector2 {
491
- /** Create a 2D vector with the x and y passed in, can also be created with vec2()
492
- * @param {Number} [x=0] - X axis location
493
- * @param {Number} [y=0] - Y axis location */
494
- constructor(x?: number, y?: number);
495
- /** @property {Number} - X axis location */
496
- x: number;
497
- /** @property {Number} - Y axis location */
498
- y: number;
499
- /** Returns a new vector that is a copy of this
500
- * @return {Vector2} */
501
- copy(): Vector2;
502
- /** Returns a copy of this vector plus the vector passed in
503
- * @param {Vector2} vector
504
- * @return {Vector2} */
505
- add(v: any): Vector2;
506
- /** Returns a copy of this vector minus the vector passed in
507
- * @param {Vector2} vector
508
- * @return {Vector2} */
509
- subtract(v: any): Vector2;
510
- /** Returns a copy of this vector times the vector passed in
511
- * @param {Vector2} vector
512
- * @return {Vector2} */
513
- multiply(v: any): Vector2;
514
- /** Returns a copy of this vector divided by the vector passed in
515
- * @param {Vector2} vector
516
- * @return {Vector2} */
517
- divide(v: any): Vector2;
518
- /** Returns a copy of this vector scaled by the vector passed in
519
- * @param {Number} scale
520
- * @return {Vector2} */
521
- scale(s: any): Vector2;
522
- /** Returns the length of this vector
523
- * @return {Number} */
524
- length(): number;
525
- /** Returns the length of this vector squared
526
- * @return {Number} */
527
- lengthSquared(): number;
528
- /** Returns the distance from this vector to vector passed in
529
- * @param {Vector2} vector
530
- * @return {Number} */
531
- distance(v: any): number;
532
- /** Returns the distance squared from this vector to vector passed in
533
- * @param {Vector2} vector
534
- * @return {Number} */
535
- distanceSquared(v: any): number;
536
- /** Returns a new vector in same direction as this one with the length passed in
537
- * @param {Number} [length=1]
538
- * @return {Vector2} */
539
- normalize(length?: number): Vector2;
540
- /** Returns a new vector clamped to length passed in
541
- * @param {Number} [length=1]
542
- * @return {Vector2} */
543
- clampLength(length?: number): Vector2;
544
- /** Returns the dot product of this and the vector passed in
545
- * @param {Vector2} vector
546
- * @return {Number} */
547
- dot(v: any): number;
548
- /** Returns the cross product of this and the vector passed in
549
- * @param {Vector2} vector
550
- * @return {Number} */
551
- cross(v: any): number;
552
- /** Returns the angle of this vector, up is angle 0
553
- * @return {Number} */
554
- angle(): number;
555
- /** Sets this vector with angle and length passed in
556
- * @param {Number} [angle=0]
557
- * @param {Number} [length=1] */
558
- setAngle(a?: number, length?: number): Vector2;
559
- /** Returns copy of this vector rotated by the angle passed in
560
- * @param {Number} angle
561
- * @return {Vector2} */
562
- rotate(a: any): Vector2;
563
- /** Returns the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)
564
- * @return {Number} */
565
- direction(): number;
566
- /** Returns a copy of this vector that has been inverted
567
- * @return {Vector2} */
568
- invert(): Vector2;
569
- /** Returns a copy of this vector with each axis floored
570
- * @return {Vector2} */
571
- floor(): Vector2;
572
- /** Returns the area this vector covers as a rectangle
573
- * @return {Number} */
574
- area(): number;
575
- /** Returns a new vector that is p percent between this and the vector passed in
576
- * @param {Vector2} vector
577
- * @param {Number} percent
578
- * @return {Vector2} */
579
- lerp(v: any, p: any): Vector2;
580
- /** Returns true if this vector is within the bounds of an array size passed in
581
- * @param {Vector2} arraySize
582
- * @return {Boolean} */
583
- arrayCheck(arraySize: Vector2): boolean;
584
- /** Returns this vector expressed as a string
585
- * @param {float} digits - precision to display
586
- * @return {String} */
587
- toString(digits?: float): string;
588
- }
589
- /**
590
- * Create a color object with RGBA values
591
- * @param {Number} [r=1]
592
- * @param {Number} [g=1]
593
- * @param {Number} [b=1]
594
- * @param {Number} [a=1]
595
- * @return {Color}
596
- * @memberof Utilities
597
- */
598
- declare function colorRGBA(r?: number, g?: number, b?: number, a?: number): Color;
599
- /**
600
- * Create a color object with HSLA values
601
- * @param {Number} [h=0]
602
- * @param {Number} [s=0]
603
- * @param {Number} [l=1]
604
- * @param {Number} [a=1]
605
- * @return {Color}
606
- * @memberof Utilities
607
- */
608
- declare function colorHSLA(h?: number, s?: number, l?: number, a?: number): Color;
609
- /**
610
- * Color object (red, green, blue, alpha) with some helpful functions
611
- * @example
612
- * let a = new Color; // white
613
- * let b = new Color(1, 0, 0); // red
614
- * let c = new Color(0, 0, 0, 0); // transparent black
615
- */
616
- declare class Color {
617
- /** Create a color with the components passed in, white by default
618
- * @param {Number} [red=1]
619
- * @param {Number} [green=1]
620
- * @param {Number} [blue=1]
621
- * @param {Number} [alpha=1] */
622
- constructor(r?: number, g?: number, b?: number, a?: number);
623
- /** @property {Number} - Red */
624
- r: number;
625
- /** @property {Number} - Green */
626
- g: number;
627
- /** @property {Number} - Blue */
628
- b: number;
629
- /** @property {Number} - Alpha */
630
- a: number;
631
- /** Returns a new color that is a copy of this
632
- * @return {Color} */
633
- copy(): Color;
634
- /** Returns a copy of this color plus the color passed in
635
- * @param {Color} color
636
- * @return {Color} */
637
- add(c: any): Color;
638
- /** Returns a copy of this color minus the color passed in
639
- * @param {Color} color
640
- * @return {Color} */
641
- subtract(c: any): Color;
642
- /** Returns a copy of this color times the color passed in
643
- * @param {Color} color
644
- * @return {Color} */
645
- multiply(c: any): Color;
646
- /** Returns a copy of this color divided by the color passed in
647
- * @param {Color} color
648
- * @return {Color} */
649
- divide(c: any): Color;
650
- /** Returns a copy of this color scaled by the value passed in, alpha can be scaled separately
651
- * @param {Number} scale
652
- * @param {Number} [alphaScale=scale]
653
- * @return {Color} */
654
- scale(s: any, a?: any): Color;
655
- /** Returns a copy of this color clamped to the valid range between 0 and 1
656
- * @return {Color} */
657
- clamp(): Color;
658
- /** Returns a new color that is p percent between this and the color passed in
659
- * @param {Color} color
660
- * @param {Number} percent
661
- * @return {Color} */
662
- lerp(c: any, p: any): Color;
663
- /** Sets this color given a hue, saturation, lightness, and alpha
664
- * @param {Number} [hue=0]
665
- * @param {Number} [saturation=0]
666
- * @param {Number} [lightness=1]
667
- * @param {Number} [alpha=1]
668
- * @return {Color} */
669
- setHSLA(h?: number, s?: number, l?: number, a?: number): Color;
670
- /** Returns this color expressed in hsla format
671
- * @return {Array} */
672
- getHSLA(): any[];
673
- /** Returns a new color that has each component randomly adjusted
674
- * @param {Number} [amount=.05]
675
- * @param {Number} [alphaAmount=0]
676
- * @return {Color} */
677
- mutate(amount?: number, alphaAmount?: number): Color;
678
- /** Returns this color expressed as a hex color code
679
- * @param {Boolean} [useAlpha=1] - if alpha should be included in result
680
- * @return {String} */
681
- toString(useAlpha?: boolean): string;
682
- /** Set this color from a hex code
683
- * @param {String} hex - html hex code
684
- * @return {Color} */
685
- setHex(hex: string): Color;
686
- /** Returns this color expressed as 32 bit RGBA value
687
- * @return {Number} */
688
- rgbaInt(): number;
689
- }
690
- /**
691
- * Timer object tracks how long has passed since it was set
692
- * @example
693
- * let a = new Timer; // creates a timer that is not set
694
- * a.set(3); // sets the timer to 3 seconds
695
- *
696
- * let b = new Timer(1); // creates a timer with 1 second left
697
- * b.unset(); // unsets the timer
698
- */
699
- declare class Timer {
700
- /** Create a timer object set time passed in
701
- * @param {Number} [timeLeft] - How much time left before the timer elapses in seconds */
702
- constructor(timeLeft?: number);
703
- time: number;
704
- setTime: number;
705
- /** Set the timer with seconds passed in
706
- * @param {Number} [timeLeft=0] - How much time left before the timer is elapsed in seconds */
707
- set(timeLeft?: number): void;
708
- /** Unset the timer */
709
- unset(): void;
710
- /** Returns true if set
711
- * @return {Boolean} */
712
- isSet(): boolean;
713
- /** Returns true if set and has not elapsed
714
- * @return {Boolean} */
715
- active(): boolean;
716
- /** Returns true if set and elapsed
717
- * @return {Boolean} */
718
- elapsed(): boolean;
719
- /** Get how long since elapsed, returns 0 if not set (returns negative if currently active)
720
- * @return {Number} */
721
- get(): number;
722
- /** Get percentage elapsed based on time it was set to, returns 0 if not set
723
- * @return {Number} */
724
- getPercent(): number;
725
- /** Returns this timer expressed as a string
726
- * @return {String} */
727
- toString(): string;
728
- /** Get how long since elapsed, returns 0 if not set (returns negative if currently active)
729
- * @return {Number} */
730
- valueOf(): number;
731
- }
732
- /** Position of camera in world space
733
- * @type {Vector2}
734
- * @default
735
- * @memberof Settings */
736
- declare let cameraPos: Vector2;
737
- /** Scale of camera in world space
738
- * @default
739
- * @memberof Settings */
740
- declare let cameraScale: number;
741
- /** The max size of the canvas, centered if window is larger
742
- * @type {Vector2}
743
- * @default
744
- * @memberof Settings */
745
- declare let canvasMaxSize: Vector2;
746
- /** Fixed size of the canvas, if enabled canvas size never changes
747
- * - you may also need to set mainCanvasSize if using screen space coords in startup
748
- * @type {Vector2}
749
- * @default
750
- * @memberof Settings */
751
- declare let canvasFixedSize: Vector2;
752
- /** Disables anti aliasing for pixel art if true
753
- * @default
754
- * @memberof Settings */
755
- declare let cavasPixelated: number;
756
- /** Default font used for text rendering
757
- * @default
758
- * @memberof Settings */
759
- declare let fontDefault: string;
760
- /** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
761
- * @default
762
- * @memberof Settings */
763
- declare let glEnable: number;
764
- /** Fixes slow rendering in some browsers by not compositing the WebGL canvas
765
- * @default
766
- * @memberof Settings */
767
- declare let glOverlay: number;
768
- /** Default size of tiles in pixels
769
- * @type {Vector2}
770
- * @default
771
- * @memberof Settings */
772
- declare let tileSizeDefault: Vector2;
773
- /** Prevent tile bleeding from neighbors in pixels
774
- * @default
775
- * @memberof Settings */
776
- declare let tileFixBleedScale: number;
777
- /** Default size of objects
778
- * @type {Vector2}
779
- * @default
780
- * @memberof Settings */
781
- declare let objectDefaultSize: Vector2;
782
- /** Enable physics solver for collisions between objects
783
- * @default
784
- * @memberof Settings */
785
- declare let enablePhysicsSolver: number;
786
- /** Default object mass for collison calcuations (how heavy objects are)
787
- * @default
788
- * @memberof Settings */
789
- declare let objectDefaultMass: number;
790
- /** How much to slow velocity by each frame (0-1)
791
- * @default
792
- * @memberof Settings */
793
- declare let objectDefaultDamping: number;
794
- /** How much to slow angular velocity each frame (0-1)
795
- * @default
796
- * @memberof Settings */
797
- declare let objectDefaultAngleDamping: number;
798
- /** How much to bounce when a collision occurs (0-1)
799
- * @default
800
- * @memberof Settings */
801
- declare let objectDefaultElasticity: number;
802
- /** How much to slow when touching (0-1)
803
- * @default
804
- * @memberof Settings */
805
- declare let objectDefaultFriction: number;
806
- /** Clamp max speed to avoid fast objects missing collisions
807
- * @default
808
- * @memberof Settings */
809
- declare let objectMaxSpeed: number;
810
- /** How much gravity to apply to objects along the Y axis, negative is down
811
- * @default
812
- * @memberof Settings */
813
- declare let gravity: number;
814
- /** Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)
815
- * @default
816
- * @memberof Settings */
817
- declare let particleEmitRateScale: number;
818
- /** Should gamepads be allowed
819
- * @default
820
- * @memberof Settings */
821
- declare let gamepadsEnable: number;
822
- /** If true, the dpad input is also routed to the left analog stick (for better accessability)
823
- * @default
824
- * @memberof Settings */
825
- declare let gamepadDirectionEmulateStick: number;
826
- /** If true the WASD keys are also routed to the direction keys (for better accessability)
827
- * @default
828
- * @memberof Settings */
829
- declare let inputWASDEmulateDirection: number;
830
- /** True if touch gamepad should appear on mobile devices
831
- * <br> - Supports left analog stick, 4 face buttons and start button (button 9)
832
- * <br> - Must be set by end of gameInit to be activated
833
- * @default
834
- * @memberof Settings */
835
- declare let touchGamepadEnable: number;
836
- /** True if touch gamepad should be analog stick or false to use if 8 way dpad
837
- * @default
838
- * @memberof Settings */
839
- declare let touchGamepadAnalog: number;
840
- /** Size of virutal gamepad for touch devices in pixels
841
- * @default
842
- * @memberof Settings */
843
- declare let touchGamepadSize: number;
844
- /** Transparency of touch gamepad overlay
845
- * @default
846
- * @memberof Settings */
847
- declare let touchGamepadAlpha: number;
848
- /** Allow vibration hardware if it exists
849
- * @default
850
- * @memberof Settings */
851
- declare let vibrateEnable: number;
852
- /** All audio code can be disabled and removed from build
853
- * @default
854
- * @memberof Settings */
855
- declare let soundEnable: number;
856
- /** Volume scale to apply to all sound, music and speech
857
- * @default
858
- * @memberof Settings */
859
- declare let soundVolume: number;
860
- /** Default range where sound no longer plays
861
- * @default
862
- * @memberof Settings */
863
- declare let soundDefaultRange: number;
864
- /** Default range percent to start tapering off sound (0-1)
865
- * @default
866
- * @memberof Settings */
867
- declare let soundDefaultTaper: number;
868
- /** How long to show medals for in seconds
869
- * @default
870
- * @memberof Settings */
871
- declare let medalDisplayTime: number;
872
- /** How quickly to slide on/off medals in seconds
873
- * @default
874
- * @memberof Settings */
875
- declare let medalDisplaySlideTime: number;
876
- /** Size of medal display
877
- * @default
878
- * @memberof Settings */
879
- declare let medalDisplaySize: Vector2;
880
- /** Size of icon in medal display
881
- * @default
882
- * @memberof Settings */
883
- declare let medalDisplayIconSize: number;
884
- /** Set to stop medals from being unlockable (like if cheats are enabled)
885
- * @default
886
- * @memberof Settings */
887
- declare let medalsPreventUnlock: any;
888
- /**
889
- * LittleJS Object Base Object Class
890
- * <br> - Base object class used by the engine
891
- * <br> - Automatically adds self to object list
892
- * <br> - Will be updated and rendered each frame
893
- * <br> - Renders as a sprite from a tilesheet by default
894
- * <br> - Can have color and addtive color applied
895
- * <br> - 2d Physics and collision system
896
- * <br> - Sorted by renderOrder
897
- * <br> - Objects can have children attached
898
- * <br> - Parents are updated before children, and set child transform
899
- * <br> - Call destroy() to get rid of objects
900
- * <br>
901
- * <br>The physics system used by objects is simple and fast with some caveats...
902
- * <br> - Collision uses the axis aligned size, the object's rotation angle is only for rendering
903
- * <br> - Objects are guaranteed to not intersect tile collision from physics
904
- * <br> - If an object starts or is moved inside tile collision, it will not collide with that tile
905
- * <br> - Collision for objects can be set to be solid to block other objects
906
- * <br> - Objects may get pushed into overlapping other solid objects, if so they will push away
907
- * <br> - Solid objects are more performance intensive and should be used sparingly
908
- * @example
909
- * // create an engine object, normally you would first extend the class with your own
910
- * const pos = vec2(2,3);
911
- * const object = new EngineObject(pos);
912
- */
913
- declare class EngineObject {
914
- /** Create an engine object and adds it to the list of objects
915
- * @param {Vector2} [position=new Vector2()] - World space position of the object
916
- * @param {Vector2} [size=objectDefaultSize] - World space size of the object
917
- * @param {Number} [tileIndex=-1] - Tile to use to render object (-1 is untextured)
918
- * @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
919
- * @param {Number} [angle=0] - Angle the object is rotated by
920
- * @param {Color} [color] - Color to apply to tile when rendered
921
- * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
922
- */
923
- constructor(pos?: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, angle?: number, color?: Color, renderOrder?: number);
924
- /** @property {Vector2} - World space position of the object */
925
- pos: Vector2;
926
- /** @property {Vector2} - World space width and height of the object */
927
- size: Vector2;
928
- /** @property {Number} - Tile to use to render object (-1 is untextured) */
929
- tileIndex: number;
930
- /** @property {Vector2} - Size of tile in source pixels */
931
- tileSize: Vector2;
932
- /** @property {Number} - Angle to rotate the object */
933
- angle: number;
934
- /** @property {Color} - Color to apply when rendered */
935
- color: Color;
936
- /** @property {Number} [mass=objectDefaultMass] - How heavy the object is, static if 0 */
937
- mass: number;
938
- /** @property {Number} [damping=objectDefaultDamping] - How much to slow down velocity each frame (0-1) */
939
- damping: number;
940
- /** @property {Number} [angleDamping=objectDefaultAngleDamping] - How much to slow down rotation each frame (0-1) */
941
- angleDamping: number;
942
- /** @property {Number} [elasticity=objectDefaultElasticity] - How bouncy the object is when colliding (0-1) */
943
- elasticity: number;
944
- /** @property {Number} [friction=objectDefaultFriction] - How much friction to apply when sliding (0-1) */
945
- friction: number;
946
- /** @property {Number} [gravityScale=1] - How much to scale gravity by for this object */
947
- gravityScale: number;
948
- /** @property {Number} [renderOrder=0] - Objects are sorted by render order */
949
- renderOrder: number;
950
- /** @property {Vector2} [velocity=new Vector2()] - Velocity of the object */
951
- velocity: Vector2;
952
- /** @property {Number} [angleVelocity=0] - Angular velocity of the object */
953
- angleVelocity: number;
954
- spawnTime: number;
955
- children: any[];
956
- collideTiles: number;
957
- /** Update the object transform and physics, called automatically by engine once each frame */
958
- update(): void;
959
- groundObject: any;
960
- /** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
961
- render(): void;
962
- /** Destroy this object, destroy it's children, detach it's parent, and mark it for removal */
963
- destroy(): void;
964
- destroyed: number;
965
- /** Called to check if a tile collision should be resolved
966
- * @param {Number} tileData - the value of the tile at the position
967
- * @param {Vector2} pos - tile where the collision occured
968
- * @return {Boolean} - true if the collision should be resolved */
969
- collideWithTile(tileData: number, pos: Vector2): boolean;
970
- /** Called to check if a tile raycast hit
971
- * @param {Number} tileData - the value of the tile at the position
972
- * @param {Vector2} pos - tile where the raycast is
973
- * @return {Boolean} - true if the raycast should hit */
974
- collideWithTileRaycast(tileData: number, pos: Vector2): boolean;
975
- /** Called to check if a object collision should be resolved
976
- * @param {EngineObject} object - the object to test against
977
- * @return {Boolean} - true if the collision should be resolved
978
- */
979
- collideWithObject(o: any): boolean;
980
- /** How long since the object was created
981
- * @return {Number} */
982
- getAliveTime(): number;
983
- /** Apply acceleration to this object (adjust velocity, not affected by mass)
984
- * @param {Vector2} acceleration */
985
- applyAcceleration(a: any): void;
986
- /** Apply force to this object (adjust velocity, affected by mass)
987
- * @param {Vector2} force */
988
- applyForce(force: Vector2): void;
989
- /** Get the direction of the mirror
990
- * @return {Number} -1 if this.mirror is true, or 1 if not mirrored */
991
- getMirrorSign(): number;
992
- /** Attaches a child to this with a given local transform
993
- * @param {EngineObject} child
994
- * @param {Vector2} [localPos=new Vector2]
995
- * @param {Number} [localAngle=0] */
996
- addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
997
- /** Removes a child from this one
998
- * @param {EngineObject} child */
999
- removeChild(child: EngineObject): void;
1000
- /** Set how this object collides
1001
- * @param {boolean} [collideSolidObjects=1] - Does it collide with solid objects
1002
- * @param {boolean} [isSolid=1] - Does it collide with and block other objects (expensive in large numbers)
1003
- * @param {boolean} [collideTiles=1] - Does it collide with the tile collision */
1004
- setCollision(collideSolidObjects?: boolean, isSolid?: boolean, collideTiles?: boolean): void;
1005
- collideSolidObjects: boolean;
1006
- isSolid: boolean;
1007
- toString(): string;
1008
- }
1009
- /** The primary 2D canvas visible to the user
1010
- * @type {HTMLCanvasElement}
1011
- * @memberof Draw */
1012
- declare let mainCanvas: HTMLCanvasElement;
1013
- /** 2d context for mainCanvas
1014
- * @type {CanvasRenderingContext2D}
1015
- * @memberof Draw */
1016
- declare let mainContext: CanvasRenderingContext2D;
1017
- /** A canvas that appears on top of everything the same size as mainCanvas
1018
- * @type {HTMLCanvasElement}
1019
- * @memberof Draw */
1020
- declare let overlayCanvas: HTMLCanvasElement;
1021
- /** 2d context for overlayCanvas
1022
- * @type {CanvasRenderingContext2D}
1023
- * @memberof Draw */
1024
- declare let overlayContext: CanvasRenderingContext2D;
1025
- /** The size of the main canvas (and other secondary canvases)
1026
- * @type {Vector2}
1027
- * @memberof Draw */
1028
- declare let mainCanvasSize: Vector2;
1029
- /** Tile sheet for batch rendering system
1030
- * @type {Image}
1031
- * @memberof Draw */
1032
- declare const tileImage: new (width?: number, height?: number) => HTMLImageElement;
1033
- declare let tileImageSize: any;
1034
- declare let tileImageFixBleed: any;
1035
- declare let drawCount: any;
1036
- /** Convert from screen to world space coordinates
1037
- * - if calling outside of render, you may need to manually set mainCanvasSize
1038
- * @param {Vector2} screenPos
1039
- * @return {Vector2}
1040
- * @memberof Draw */
1041
- declare function screenToWorld(screenPos: Vector2): Vector2;
1042
- /** Convert from world to screen space coordinates
1043
- * - if calling outside of render, you may need to manually set mainCanvasSize
1044
- * @param {Vector2} worldPos
1045
- * @return {Vector2}
1046
- * @memberof Draw */
1047
- declare function worldToScreen(worldPos: Vector2): Vector2;
1048
- /**
1049
- * Font Image Object - Draw text on a 2D canvas by using characters in an image
1050
- * <br> - 96 characters (from space to tilde) are stored in an image
1051
- * <br> - Uses a default 8x8 font if none is supplied
1052
- * <br> - You can also use fonts from the main tile sheet
1053
- * @example
1054
- * // use built in font
1055
- * const font = new ImageFont;
1056
- *
1057
- * // draw text
1058
- * font.drawTextScreen("LittleJS\nHello World!", vec2(200, 50));
1059
- */
1060
- declare let engineFontImage: any;
1061
- declare class FontImage {
1062
- /** Create an image font
1063
- * @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
1064
- * @param {Vector2} [tileSize=vec2(8)] - Size of the font source tiles
1065
- * @param {Vector2} [paddingSize=vec2(0,1)] - How much extra space to add between characters
1066
- * @param {Number} [startTileIndex=0] - Tile index in image where font starts
1067
- * @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
1068
- */
1069
- constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, startTileIndex?: number, context?: CanvasRenderingContext2D);
1070
- image: any;
1071
- tileSize: Vector2;
1072
- paddingSize: Vector2;
1073
- startTileIndex: number;
1074
- context: CanvasRenderingContext2D;
1075
- /** Draw text in screen space using the image font
1076
- * @param {String} text
1077
- * @param {Vector2} pos
1078
- * @param {Number} [scale=4]
1079
- * @param {Boolean} [center]
1080
- */
1081
- drawTextScreen(text: string, pos: Vector2, scale?: number, center?: boolean): void;
1082
- /** Draw text in world space using the image font
1083
- * @param {String} text
1084
- * @param {Vector2} pos
1085
- * @param {Number} [scale=.25]
1086
- * @param {Boolean} [center]
1087
- */
1088
- drawText(text: string, pos: Vector2, scale?: number, center?: boolean): void;
1089
- }
1090
- /** Returns true if fullscreen mode is active
1091
- * @return {Boolean}
1092
- * @memberof Draw */
1093
- declare function isFullscreen(): boolean;
1094
- /** Returns true if device key is down
1095
- * @param {Number} key
1096
- * @param {Number} [device=0]
1097
- * @return {Boolean}
1098
- * @memberof Input */
1099
- declare function keyIsDown(key: number, device?: number): boolean;
1100
- /** Returns true if device key was pressed this frame
1101
- * @param {Number} key
1102
- * @param {Number} [device=0]
1103
- * @return {Boolean}
1104
- * @memberof Input */
1105
- declare function keyWasPressed(key: number, device?: number): boolean;
1106
- /** Returns true if device key was released this frame
1107
- * @param {Number} key
1108
- * @param {Number} [device=0]
1109
- * @return {Boolean}
1110
- * @memberof Input */
1111
- declare function keyWasReleased(key: number, device?: number): boolean;
1112
- /** Clears all input
1113
- * @memberof Input */
1114
- declare function clearInput(): any[][];
1115
- /** Returns true if device key is down
1116
- * @param {Number} key
1117
- * @param {Number} [device=0]
1118
- * @return {Boolean}
1119
- * @memberof Input */
1120
- declare function mouseIsDown(key: number, device?: number): boolean;
1121
- /** Returns true if device key was pressed this frame
1122
- * @param {Number} key
1123
- * @param {Number} [device=0]
1124
- * @return {Boolean}
1125
- * @memberof Input */
1126
- declare function mouseWasPressed(key: number, device?: number): boolean;
1127
- /** Returns true if device key was released this frame
1128
- * @param {Number} key
1129
- * @param {Number} [device=0]
1130
- * @return {Boolean}
1131
- * @memberof Input */
1132
- declare function mouseWasReleased(key: number, device?: number): boolean;
1133
- /** Mouse pos in world space
1134
- * @type {Vector2}
1135
- * @memberof Input */
1136
- declare let mousePos: Vector2;
1137
- /** Mouse pos in screen space
1138
- * @type {Vector2}
1139
- * @memberof Input */
1140
- declare let mousePosScreen: Vector2;
1141
- /** Mouse wheel delta this frame
1142
- * @memberof Input */
1143
- declare let mouseWheel: number;
1144
- /** Returns true if user is using gamepad (has more recently pressed a gamepad button)
1145
- * @memberof Input */
1146
- declare let isUsingGamepad: number;
1147
- /** Prevents input continuing to the default browser handling (false by default)
1148
- * @memberof Input */
1149
- declare let preventDefaultInput: number;
1150
- /** Returns true if gamepad button is down
1151
- * @param {Number} button
1152
- * @param {Number} [gamepad=0]
1153
- * @return {Boolean}
1154
- * @memberof Input */
1155
- declare function gamepadIsDown(button: number, gamepad?: number): boolean;
1156
- /** Returns true if gamepad button was pressed
1157
- * @param {Number} button
1158
- * @param {Number} [gamepad=0]
1159
- * @return {Boolean}
1160
- * @memberof Input */
1161
- declare function gamepadWasPressed(button: number, gamepad?: number): boolean;
1162
- /** Returns true if gamepad button was released
1163
- * @param {Number} button
1164
- * @param {Number} [gamepad=0]
1165
- * @return {Boolean}
1166
- * @memberof Input */
1167
- declare function gamepadWasReleased(button: number, gamepad?: number): boolean;
1168
- /** Returns gamepad stick value
1169
- * @param {Number} stick
1170
- * @param {Number} [gamepad=0]
1171
- * @return {Vector2}
1172
- * @memberof Input */
1173
- declare function gamepadStick(stick: number, gamepad?: number): Vector2;
1174
- declare let inputData: any[][];
1175
- declare function remapKeyCode(c: any): any;
1176
- declare function mouseToScreen(mousePos: any): Vector2;
1177
- declare const stickData: any[];
1178
- /** Pulse the vibration hardware if it exists
1179
- * @param {Number} [pattern=100] - a single value in miliseconds or vibration interval array
1180
- * @memberof Input */
1181
- declare function vibrate(pattern?: number): boolean;
1182
- /** Cancel any ongoing vibration
1183
- * @memberof Input */
1184
- declare function vibrateStop(): boolean;
1185
- /** True if a touch device has been detected
1186
- * @const {boolean}
1187
- * @memberof Input */
1188
- declare const isTouchDevice: boolean;
1189
- declare let touchGamepadTimer: Timer;
1190
- declare let touchGamepadButtons: any;
1191
- declare let touchGamepadStick: any;
1192
- /**
1193
- * Sound Object - Stores a zzfx sound for later use and can be played positionally
1194
- * <br>
1195
- * <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
1196
- * @example
1197
- * // create a sound
1198
- * const sound_example = new Sound([.5,.5]);
1199
- *
1200
- * // play the sound
1201
- * sound_example.play();
1202
- */
1203
- declare class Sound {
1204
- /** Create a sound object and cache the zzfx samples for later use
1205
- * @param {Array} zzfxSound - Array of zzfx parameters, ex. [.5,.5]
1206
- * @param {Number} [range=soundDefaultRange] - World space max range of sound, will not play if camera is farther away
1207
- * @param {Number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering off
1208
- */
1209
- constructor(zzfxSound: any[], range?: number, taper?: number);
1210
- /** @property {Number} - World space max range of sound, will not play if camera is farther away */
1211
- range: number;
1212
- /** @property {Number} - At what percentage of range should it start tapering off */
1213
- taper: number;
1214
- randomness: any;
1215
- cachedSamples: number[];
1216
- /** Play the sound
1217
- * @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
1218
- * @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
1219
- * @param {Number} [pitch=1] - How much to scale pitch by (also adjusted by this.randomness)
1220
- * @param {Number} [randomnessScale=1] - How much to scale randomness
1221
- * @return {AudioBufferSourceNode} - The audio, can be used to stop sound later
1222
- */
1223
- play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number): AudioBufferSourceNode;
1224
- /** Play the sound as a note with a semitone offset
1225
- * @param {Number} semitoneOffset - How many semitones to offset pitch
1226
- * @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
1227
- * @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
1228
- * @return {AudioBufferSourceNode} - The audio, can be used to stop sound later
1229
- */
1230
- playNote(semitoneOffset: number, pos?: Vector2, volume?: number): AudioBufferSourceNode;
1231
- }
1232
- /**
1233
- * Music Object - Stores a zzfx music track for later use
1234
- * <br>
1235
- * <br><b><a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a></b>
1236
- * @example
1237
- * // create some music
1238
- * const music_example = new Music(
1239
- * [
1240
- * [ // instruments
1241
- * [,0,400] // simple note
1242
- * ],
1243
- * [ // patterns
1244
- * [ // pattern 1
1245
- * [ // channel 0
1246
- * 0, -1, // instrument 0, left speaker
1247
- * 1, 0, 9, 1 // channel notes
1248
- * ],
1249
- * [ // channel 1
1250
- * 0, 1, // instrument 1, right speaker
1251
- * 0, 12, 17, -1 // channel notes
1252
- * ]
1253
- * ],
1254
- * ],
1255
- * [0, 0, 0, 0], // sequence, play pattern 0 four times
1256
- * 90 // BPM
1257
- * ]);
1258
- *
1259
- * // play the music
1260
- * music_example.play();
1261
- */
1262
- declare class Music {
1263
- /** Create a music object and cache the zzfx music samples for later use
1264
- * @param {Array} zzfxMusic - Array of zzfx music parameters
1265
- */
1266
- constructor(zzfxMusic: any[]);
1267
- cachedSamples: any[];
1268
- /** Play the music
1269
- * @param {Number} [volume=1] - How much to scale volume by
1270
- * @param {Boolean} [loop=1] - True if the music should loop when it reaches the end
1271
- * @return {AudioBufferSourceNode} - The audio node, can be used to stop sound later
1272
- */
1273
- play(volume?: number, loop?: boolean): AudioBufferSourceNode;
1274
- }
1275
- /** Stop all queued speech
1276
- * @memberof Audio */
1277
- declare function speakStop(): void;
1278
- /** Get frequency of a note on a musical scale
1279
- * @param {Number} semitoneOffset - How many semitones away from the root note
1280
- * @param {Number} [rootNoteFrequency=220] - Frequency at semitone offset 0
1281
- * @return {Number} - The frequency of the note
1282
- * @memberof Audio */
1283
- declare function getNoteFrequency(semitoneOffset: number, rootFrequency?: number): number;
1284
- /** Audio context used by the engine
1285
- * @memberof Audio */
1286
- declare let audioContext: any;
1287
- /** Generate and play a ZzFX sound
1288
- * <br>
1289
- * <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
1290
- * @param {Array} zzfxSound - Array of ZzFX parameters, ex. [.5,.5]
1291
- * @return {Array} - Array of audio samples
1292
- * @memberof Audio */
1293
- declare function zzfx(...zzfxSound: any[]): any[];
1294
- /** Sample rate used for all ZzFX sounds
1295
- * @default 44100
1296
- * @memberof Audio */
1297
- declare const zzfxR: 44100;
1298
- /** The tile collision layer array, use setTileCollisionData and getTileCollisionData to access
1299
- * @memberof TileCollision */
1300
- declare let tileCollision: any[];
1301
- /** Size of the tile collision layer
1302
- * @type {Vector2}
1303
- * @memberof TileCollision */
1304
- declare let tileCollisionSize: Vector2;
1305
- /** Set tile collision data
1306
- * @param {Vector2} pos
1307
- * @param {Number} [data=0]
1308
- * @memberof TileCollision */
1309
- declare function setTileCollisionData(pos: Vector2, data?: number): number;
1310
- /** Get tile collision data
1311
- * @param {Vector2} pos
1312
- * @return {Number}
1313
- * @memberof TileCollision */
1314
- declare function getTileCollisionData(pos: Vector2): number;
1315
- /**
1316
- * Tile layer data object stores info about how to render a tile
1317
- * @example
1318
- * // create tile layer data with tile index 0 and random orientation and color
1319
- * const tileIndex = 0;
1320
- * const direction = randInt(4)
1321
- * const mirror = randInt(2);
1322
- * const color = randColor();
1323
- * const data = new TileLayerData(tileIndex, direction, mirror, color);
1324
- */
1325
- declare class TileLayerData {
1326
- /** Create a tile layer data object, one for each tile in a TileLayer
1327
- * @param {Number} [tile] - The tile to use, untextured if undefined
1328
- * @param {Number} [direction=0] - Integer direction of tile, in 90 degree increments
1329
- * @param {Boolean} [mirror=0] - If the tile should be mirrored along the x axis
1330
- * @param {Color} [color=new Color(1,1,1)] - Color of the tile */
1331
- constructor(tile?: number, direction?: number, mirror?: boolean, color?: Color);
1332
- /** @property {Number} - The tile to use, untextured if undefined */
1333
- tile: number;
1334
- /** @property {Number} - Integer direction of tile, in 90 degree increments */
1335
- direction: number;
1336
- /** @property {Boolean} - If the tile should be mirrored along the x axis */
1337
- mirror: boolean;
1338
- /** @property {Color} - Color of the tile */
1339
- color: Color;
1340
- /** Set this tile to clear, it will not be rendered */
1341
- clear(): void;
1342
- }
1343
- /**
1344
- * Tile layer object - cached rendering system for tile layers
1345
- * <br> - Each Tile layer is rendered to an off screen canvas
1346
- * <br> - To allow dynamic modifications, layers are rendered using canvas 2d
1347
- * <br> - Some devices like mobile phones are limited to 4k texture resolution
1348
- * <br> - So with 16x16 tiles this limits layers to 256x256 on mobile devices
1349
- * @extends EngineObject
1350
- * @example
1351
- * // create tile collision and visible tile layer
1352
- * initTileCollision(vec2(200,100));
1353
- * const tileLayer = new TileLayer();
1354
- */
1355
- declare class TileLayer extends EngineObject {
1356
- /** Create a tile layer object
1357
- * @param {Vector2} [position=new Vector2()] - World space position
1358
- * @param {Vector2} [size=tileCollisionSize] - World space size
1359
- * @param {Vector2} [tileSize=tileSizeDefault] - Size of tiles in source pixels
1360
- * @param {Vector2} [scale=new Vector2(1,1)] - How much to scale this layer when rendered
1361
- * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
1362
- */
1363
- constructor(pos: any, size?: Vector2, tileSize?: Vector2, scale?: Vector2, renderOrder?: number);
1364
- /** @property {HTMLCanvasElement} - The canvas used by this tile layer */
1365
- canvas: HTMLCanvasElement;
1366
- /** @property {CanvasRenderingContext2D} - The 2D canvas context used by this tile layer */
1367
- context: CanvasRenderingContext2D;
1368
- /** @property {Vector2} - How much to scale this layer when rendered */
1369
- scale: Vector2;
1370
- data: TileLayerData[];
1371
- /** Set data at a given position in the array
1372
- * @param {Vector2} position - Local position in array
1373
- * @param {TileLayerData} data - Data to set
1374
- * @param {Boolean} [redraw=0] - Force the tile to redraw if true */
1375
- setData(layerPos: any, data: TileLayerData, redraw?: boolean): void;
1376
- /** Get data at a given position in the array
1377
- * @param {Vector2} layerPos - Local position in array
1378
- * @return {TileLayerData} */
1379
- getData(layerPos: Vector2): TileLayerData;
1380
- /** Draw all the tile data to an offscreen canvas
1381
- * - This may be slow in some browsers
1382
- */
1383
- redraw(): void;
1384
- /** Call to start the redraw process
1385
- * @param {Boolean} [clear=0] - Should it clear the canvas before drawing */
1386
- redrawStart(clear?: boolean): void;
1387
- savedRenderSettings: (number | HTMLCanvasElement | CanvasRenderingContext2D | Vector2)[];
1388
- /** Call to end the redraw process */
1389
- redrawEnd(): void;
1390
- /** Draw the tile at a given position
1391
- * @param {Vector2} layerPos */
1392
- drawTileData(layerPos: Vector2): void;
1393
- /** Draw all the tiles in this layer */
1394
- drawAllTileData(): void;
1395
- /** Draw directly to the 2D canvas in world space (bipass webgl)
1396
- * @param {Vector2} pos
1397
- * @param {Vector2} size
1398
- * @param {Number} [angle=0]
1399
- * @param {Boolean} [mirror=0]
1400
- * @param {Function} drawFunction */
1401
- drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction: Function): void;
1402
- /** Draw a tile directly onto the layer canvas
1403
- * @param {Vector2} pos
1404
- * @param {Vector2} [size=new Vector2(1,1)]
1405
- * @param {Number} [tileIndex=-1]
1406
- * @param {Vector2} [tileSize=tileSizeDefault]
1407
- * @param {Color} [color=new Color(1,1,1)]
1408
- * @param {Number} [angle=0]
1409
- * @param {Boolean} [mirror=0] */
1410
- drawTile(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean): void;
1411
- /** Draw a rectangle directly onto the layer canvas
1412
- * @param {Vector2} pos
1413
- * @param {Vector2} [size=new Vector2(1,1)]
1414
- * @param {Color} [color=new Color(1,1,1)]
1415
- * @param {Number} [angle=0] */
1416
- drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
1417
- }
1418
- /**
1419
- * Particle Emitter - Spawns particles with the given settings
1420
- * @extends EngineObject
1421
- * @example
1422
- * // create a particle emitter
1423
- * let pos = vec2(2,3);
1424
- * let particleEmiter = new ParticleEmitter
1425
- * (
1426
- * pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
1427
- * 0, vec2(16), // tileIndex, tileSize
1428
- * new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
1429
- * new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
1430
- * 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
1431
- * .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
1432
- * .5, 1 // randomness, collide, additive, randomColorLinear, renderOrder
1433
- * );
1434
- */
1435
- declare class ParticleEmitter extends EngineObject {
1436
- /** Create a particle system with the given settings
1437
- * @param {Vector2} position - World space position of the emitter
1438
- * @param {Number} [angle=0] - Angle to emit the particles
1439
- * @param {Number} [emitSize=0] - World space size of the emitter (float for circle diameter, vec2 for rect)
1440
- * @param {Number} [emitTime=0] - How long to stay alive (0 is forever)
1441
- * @param {Number} [emitRate=100] - How many particles per second to spawn, does not emit if 0
1442
- * @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
1443
- * @param {Number} [tileIndex=-1] - Index into tile sheet, if <0 no texture is applied
1444
- * @param {Number} [tileSize=tileSizeDefault] - Tile size for particles
1445
- * @param {Color} [colorStartA=new Color(1,1,1)] - Color at start of life 1, randomized between start colors
1446
- * @param {Color} [colorStartB=new Color(1,1,1)] - Color at start of life 2, randomized between start colors
1447
- * @param {Color} [colorEndA=new Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
1448
- * @param {Color} [colorEndB=new Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
1449
- * @param {Number} [particleTime=.5] - How long particles live
1450
- * @param {Number} [sizeStart=.1] - How big are particles at start
1451
- * @param {Number} [sizeEnd=1] - How big are particles at end
1452
- * @param {Number} [speed=.1] - How fast are particles when spawned
1453
- * @param {Number} [angleSpeed=.05] - How fast are particles rotating
1454
- * @param {Number} [damping=1] - How much to dampen particle speed
1455
- * @param {Number} [angleDamping=1] - How much to dampen particle angular speed
1456
- * @param {Number} [gravityScale=0] - How much does gravity effect particles
1457
- * @param {Number} [particleConeAngle=PI] - Cone for start particle angle
1458
- * @param {Number} [fadeRate=.1] - How quick to fade in particles at start/end in percent of life
1459
- * @param {Number} [randomness=.2] - Apply extra randomness percent
1460
- * @param {Boolean} [collideTiles=0] - Do particles collide against tiles
1461
- * @param {Boolean} [additive=0] - Should particles use addtive blend
1462
- * @param {Boolean} [randomColorLinear=1] - Should color be randomized linearly or across each component
1463
- * @param {Number} [renderOrder=0] - Render order for particles (additive is above other stuff by default)
1464
- * @param {Boolean} [localSpace=0] - Should it be in local space of emitter (world space is default)
1465
- */
1466
- constructor(pos: any, angle?: number, emitSize?: number, emitTime?: number, emitRate?: number, emitConeAngle?: number, tileIndex?: number, tileSize?: number, colorStartA?: Color, colorStartB?: Color, colorEndA?: Color, colorEndB?: Color, particleTime?: number, sizeStart?: number, sizeEnd?: number, speed?: number, angleSpeed?: number, damping?: number, angleDamping?: number, gravityScale?: number, particleConeAngle?: number, fadeRate?: number, randomness?: number, collideTiles?: boolean, additive?: boolean, randomColorLinear?: boolean, renderOrder?: number, localSpace?: boolean);
1467
- /** @property {Number} - World space size of the emitter (float for circle diameter, vec2 for rect) */
1468
- emitSize: number;
1469
- /** @property {Number} - How long to stay alive (0 is forever) */
1470
- emitTime: number;
1471
- /** @property {Number} - How many particles per second to spawn, does not emit if 0 */
1472
- emitRate: number;
1473
- /** @property {Number} - Local angle to apply velocity to particles from emitter */
1474
- emitConeAngle: number;
1475
- /** @property {Color} - Color at start of life 1, randomized between start colors */
1476
- colorStartA: Color;
1477
- /** @property {Color} - Color at start of life 2, randomized between start colors */
1478
- colorStartB: Color;
1479
- /** @property {Color} - Color at end of life 1, randomized between end colors */
1480
- colorEndA: Color;
1481
- /** @property {Color} - Color at end of life 2, randomized between end colors */
1482
- colorEndB: Color;
1483
- /** @property {Boolean} - Should color be randomized linearly or across each component */
1484
- randomColorLinear: boolean;
1485
- /** @property {Number} - How long particles live */
1486
- particleTime: number;
1487
- /** @property {Number} - How big are particles at start */
1488
- sizeStart: number;
1489
- /** @property {Number} - How big are particles at end */
1490
- sizeEnd: number;
1491
- /** @property {Number} - How fast are particles when spawned */
1492
- speed: number;
1493
- /** @property {Number} - How fast are particles rotating */
1494
- angleSpeed: number;
1495
- /** @property {Number} - Cone for start particle angle */
1496
- particleConeAngle: number;
1497
- /** @property {Number} - How quick to fade in particles at start/end in percent of life */
1498
- fadeRate: number;
1499
- /** @property {Number} - Apply extra randomness percent */
1500
- randomness: number;
1501
- /** @property {Number} - Do particles collide against tiles */
1502
- collideTiles: boolean;
1503
- /** @property {Number} - Should particles use addtive blend */
1504
- additive: boolean;
1505
- /** @property {Boolean} - Should it be in local space of emitter */
1506
- localSpace: boolean;
1507
- /** @property {Number} - If set the partile is drawn as a trail, stretched in the drection of velocity */
1508
- trailScale: number;
1509
- emitTimeBuffer: number;
1510
- /** Spawn one particle
1511
- * @return {Particle} */
1512
- emitParticle(): Particle;
1513
- }
1514
- /**
1515
- * Particle Object - Created automatically by Particle Emitters
1516
- * @extends EngineObject
1517
- */
1518
- declare class Particle extends EngineObject {
1519
- /**
1520
- * Create a particle with the given settings
1521
- * @param {Vector2} position - World space position of the particle
1522
- * @param {Number} [tileIndex=-1] - Tile to use to render, untextured if -1
1523
- * @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
1524
- * @param {Number} [angle=0] - Angle to rotate the particle
1525
- */
1526
- constructor(pos: any, tileIndex?: number, tileSize?: Vector2, angle?: number);
1527
- }
1528
- /** List of all medals
1529
- * @memberof Medals */
1530
- declare const medals: any[];
1531
- declare let medalsDisplayQueue: any[];
1532
- declare let medalsSaveName: any;
1533
- declare let medalsDisplayTimeLast: any;
1534
- /**
1535
- * Medal Object - Tracks an unlockable medal
1536
- * @example
1537
- * // create a medal
1538
- * const medal_example = new Medal(0, 'Example Medal', 'More info about the medal goes here.', '🎖️');
1539
- *
1540
- * // initialize medals
1541
- * medalsInit('Example Game');
1542
- *
1543
- * // unlock the medal
1544
- * medal_example.unlock();
1545
- */
1546
- declare class Medal {
1547
- /** Create an medal object and adds it to the list of medals
1548
- * @param {Number} id - The unique identifier of the medal
1549
- * @param {String} name - Name of the medal
1550
- * @param {String} [description] - Description of the medal
1551
- * @param {String} [icon='🏆'] - Icon for the medal
1552
- * @param {String} [src] - Image location for the medal
1553
- */
1554
- constructor(id: number, name: string, description?: string, icon?: string, src?: string);
1555
- id: number;
1556
- name: string;
1557
- description: string;
1558
- icon: string;
1559
- image: HTMLImageElement;
1560
- /** Unlocks a medal if not already unlocked */
1561
- unlock(): void;
1562
- unlocked: number;
1563
- /** Render a medal
1564
- * @param {Number} [hidePercent=0] - How much to slide the medal off screen
1565
- */
1566
- render(hidePercent?: number): void;
1567
- /** Render the icon for a medal
1568
- * @param {Number} x - Screen space X position
1569
- * @param {Number} y - Screen space Y position
1570
- * @param {Number} [size=medalDisplayIconSize] - Screen space size
1571
- */
1572
- renderIcon(pos: any, size?: number): void;
1573
- storageKey(): string;
1574
- }
1575
- declare let newgrounds: any;
1576
- /**
1577
- * Newgrounds API wrapper object
1578
- * @example
1579
- * // create a newgrounds object, replace the app id and cipher with your own
1580
- * const app_id = '53123:1ZuSTQ9l';
1581
- * const cipher = 'enF0vGH@Mj/FRASKL23Q==';
1582
- * newgrounds = new Newgrounds(app_id, cipher);
1583
- */
1584
- declare class Newgrounds {
1585
- /** Create a newgrounds object
1586
- * @param {Number} app_id - The newgrounds App ID
1587
- * @param {String} [cipher] - The encryption Key (AES-128/Base64) */
1588
- constructor(app_id: number, cipher?: string);
1589
- app_id: number;
1590
- cipher: string;
1591
- host: string;
1592
- cryptoJS: any;
1593
- session_id: string;
1594
- medals: any;
1595
- scoreboards: any;
1596
- /** Send message to unlock a medal by id
1597
- * @param {Number} id - The medal id */
1598
- unlockMedal(id: number): any;
1599
- /** Send message to post score
1600
- * @param {Number} id - The scoreboard id
1601
- * @param {Number} value - The score value */
1602
- postScore(id: number, value: number): any;
1603
- /** Get scores from a scoreboard
1604
- * @param {Number} id - The scoreboard id
1605
- * @param {String} [user=0] - A user's id or name
1606
- * @param {Number} [social=0] - If true, only social scores will be loaded
1607
- * @param {Number} [skip=0] - Number of scores to skip before start
1608
- * @param {Number} [limit=10] - Number of scores to include in the list
1609
- * @return {Object} - The response JSON object
1610
- */
1611
- getScores(id: number, user?: string, social?: number, skip?: number, limit?: number): any;
1612
- /** Send message to log a view */
1613
- logView(): any;
1614
- /** Send a message to call a component of the Newgrounds API
1615
- * @param {String} component - Name of the component
1616
- * @param {Object} [parameters=0] - Parameters to use for call
1617
- * @param {Boolean} [async=0] - If true, don't wait for response before continuing (avoid stall)
1618
- * @return {Object} - The response JSON object
1619
- */
1620
- call(component: string, parameters?: any, async?: boolean): any;
1621
- CryptoJS(): any;
1622
- }
1623
- /** The WebGL canvas which appears above the main canvas and below the overlay canvas
1624
- * @type {HTMLCanvasElement}
1625
- * @memberof WebGL */
1626
- declare let glCanvas: HTMLCanvasElement;
1627
- /** 2d context for glCanvas
1628
- * @type {WebGLRenderingContext}
1629
- * @memberof WebGL */
1630
- declare let glContext: WebGLRenderingContext;
1631
- /** Main tile sheet texture automatically loaded by engine
1632
- * @type {WebGLTexture}
1633
- * @memberof WebGL */
1634
- declare let glTileTexture: WebGLTexture;
1635
- declare let glActiveTexture: any;
1636
- declare let glShader: any;
1637
- declare let glArrayBuffer: any;
1638
- declare let glPositionData: any;
1639
- declare let glColorData: any;
1640
- declare let glBatchCount: any;
1641
- declare let glBatchAdditive: any;
1642
- declare let glAdditive: any;
1643
- declare let glPostShader: any;
1644
- declare let glPostArrayBuffer: any;
1645
- declare let glPostTexture: any;
1646
- declare const gl_ONE: 1;
1647
- declare const gl_TRIANGLES: 4;
1648
- declare const gl_SRC_ALPHA: 770;
1649
- declare const gl_ONE_MINUS_SRC_ALPHA: 771;
1650
- declare const gl_BLEND: 3042;
1651
- declare const gl_TEXTURE_2D: 3553;
1652
- declare const gl_UNSIGNED_BYTE: 5121;
1653
- declare const gl_BYTE: 5120;
1654
- declare const gl_FLOAT: 5126;
1655
- declare const gl_RGBA: 6408;
1656
- declare const gl_NEAREST: 9728;
1657
- declare const gl_LINEAR: 9729;
1658
- declare const gl_TEXTURE_MAG_FILTER: 10240;
1659
- declare const gl_TEXTURE_MIN_FILTER: 10241;
1660
- declare const gl_TEXTURE_WRAP_S: 10242;
1661
- declare const gl_TEXTURE_WRAP_T: 10243;
1662
- declare const gl_COLOR_BUFFER_BIT: 16384;
1663
- declare const gl_CLAMP_TO_EDGE: 33071;
1664
- declare const gl_TEXTURE0: 33984;
1665
- declare const gl_TEXTURE1: 33985;
1666
- declare const gl_ARRAY_BUFFER: 34962;
1667
- declare const gl_STATIC_DRAW: 35044;
1668
- declare const gl_DYNAMIC_DRAW: 35048;
1669
- declare const gl_FRAGMENT_SHADER: 35632;
1670
- declare const gl_VERTEX_SHADER: 35633;
1671
- declare const gl_COMPILE_STATUS: 35713;
1672
- declare const gl_LINK_STATUS: 35714;
1673
- declare const gl_UNPACK_FLIP_Y_WEBGL: 37440;
1674
- declare const gl_VERTICES_PER_QUAD: 6;
1675
- declare const gl_INDICIES_PER_VERT: 6;
1676
- declare const gl_MAX_BATCH: number;
1677
- declare const gl_VERTEX_BYTE_STRIDE: number;
1678
- declare const gl_VERTEX_BUFFER_SIZE: number;
1679
- /** Name of engine */
1680
- declare const engineName: "LittleJS";
1681
- /** Version of engine */
1682
- declare const engineVersion: "1.4.9";
1683
- /** Frames per second to update objects
1684
- * @default */
1685
- declare const frameRate: 60;
1686
- /** How many seconds each frame lasts, engine uses a fixed time step
1687
- * @default 1/60 */
1688
- declare const timeDelta: number;
1689
- /** Array containing all engine objects */
1690
- declare let engineObjects: any[];
1691
- /** Array containing only objects that are set to collide with other objects this frame (for optimization) */
1692
- declare let engineObjectsCollide: any[];
1693
- /** Current update frame, used to calculate time */
1694
- declare let frame: number;
1695
- /** Current engine time since start in seconds, derived from frame */
1696
- declare let time: number;
1697
- /** Actual clock time since start in seconds (not affected by pause or frame rate clamping) */
1698
- declare let timeReal: number;
1699
- /** Is the game paused? Causes time and objects to not be updated */
1700
- declare let paused: number;
1
+ declare module "engine.all.module" {
2
+ /**
3
+ * LittleJS Module Export
4
+ * <br> - Export engine as a module with extra functions where necessary
5
+ */
6
+ /** Set position of camera in world space
7
+ * @param {Vector2} pos
8
+ * @memberof Settings */
9
+ export function setCameraPos(pos: Vector2): Vector2;
10
+ /** Set scale of camera in world space
11
+ * @param {Number} scale
12
+ * @memberof Settings */
13
+ export function setCameraScale(scale: number): number;
14
+ /** Set max size of the canvas
15
+ * @param {Vector2} size
16
+ * @memberof Settings */
17
+ export function setCanvasMaxSize(size: Vector2): Vector2;
18
+ /** Set fixed size of the canvas
19
+ * @param {Vector2} size
20
+ * @memberof Settings */
21
+ export function setCanvasFixedSize(size: Vector2): Vector2;
22
+ /** Disables anti aliasing for pixel art if true
23
+ * @param {Boolean} pixelated
24
+ * @memberof Settings */
25
+ export function setCavasPixelated(pixelated: boolean): boolean;
26
+ /** Set default font used for text rendering
27
+ * @param {String} font
28
+ * @memberof Settings */
29
+ export function setFontDefault(font: string): string;
30
+ /** Set if webgl rendering is enabled
31
+ * @param {Boolean} enable
32
+ * @memberof Settings */
33
+ export function setGlEnable(enable: boolean): boolean;
34
+ /** Set to not composite the WebGL canvas
35
+ * @param {Boolean} overlay
36
+ * @memberof Settings */
37
+ export function setGlOverlay(overlay: boolean): boolean;
38
+ /** Set default size of tiles in pixels
39
+ * @param {Vector2} size
40
+ * @memberof Settings */
41
+ export function setTileSizeDefault(size: Vector2): Vector2;
42
+ /** Set to prevent tile bleeding from neighbors in pixels
43
+ * @param {Number} scale
44
+ * @memberof Settings */
45
+ export function setTileFixBleedScale(scale: number): number;
46
+ /** Set if collisions between objects are enabled
47
+ * @param {Boolean} enable
48
+ * @memberof Settings */
49
+ export function setEnablePhysicsSolver(enable: boolean): boolean;
50
+ /** Set default object mass for collison calcuations
51
+ * @param {Number} mass
52
+ * @memberof Settings */
53
+ export function setObjectDefaultMass(mass: number): number;
54
+ /** Set how much to slow velocity by each frame
55
+ * @param {Number} damping
56
+ * @memberof Settings */
57
+ export function setObjectDefaultDamping(damp: any): any;
58
+ /** Set how much to slow angular velocity each frame
59
+ * @param {Number} damping
60
+ * @memberof Settings */
61
+ export function setObjectDefaultAngleDamping(damp: any): any;
62
+ /** Set how much to bounce when a collision occur
63
+ * @param {Number} elasticity
64
+ * @memberof Settings */
65
+ export function setObjectDefaultElasticity(elasticity: number): number;
66
+ /** Set how much to slow when touching
67
+ * @param {Number} friction
68
+ * @memberof Settings */
69
+ export function setObjectDefaultFriction(friction: number): number;
70
+ /** Set max speed to avoid fast objects missing collisions
71
+ * @param {Number} speed
72
+ * @memberof Settings */
73
+ export function setObjectMaxSpeed(speed: number): number;
74
+ /** Set how much gravity to apply to objects along the Y axis
75
+ * @param {Number} gravity
76
+ * @memberof Settings */
77
+ export function setGravity(g: any): any;
78
+ /** Set to scales emit rate of particles
79
+ * @param {Number} scale
80
+ * @memberof Settings */
81
+ export function setParticleEmitRateScale(scale: number): number;
82
+ /** Set if gamepads are enabled
83
+ * @param {Boolean} enable
84
+ * @memberof Settings */
85
+ export function setGamepadsEnable(enable: boolean): boolean;
86
+ /** Set if the dpad input is also routed to the left analog stick
87
+ * @param {Boolean} enable
88
+ * @memberof Settings */
89
+ export function setGamepadDirectionEmulateStick(enable: boolean): boolean;
90
+ /** Set if true the WASD keys are also routed to the direction keys
91
+ * @param {Boolean} enable
92
+ * @memberof Settings */
93
+ export function setInputWASDEmulateDirection(enable: boolean): boolean;
94
+ /** Set if touch gamepad should appear on mobile devices
95
+ * @param {Boolean} enable
96
+ * @memberof Settings */
97
+ export function setTouchGamepadEnable(enable: boolean): boolean;
98
+ /** Set if touch gamepad should be analog stick or 8 way dpad
99
+ * @param {Boolean} analog
100
+ * @memberof Settings */
101
+ export function setTouchGamepadAnalog(analog: boolean): boolean;
102
+ /** Set size of virutal gamepad for touch devices in pixels
103
+ * @param {Number} size
104
+ * @memberof Settings */
105
+ export function setTouchGamepadSize(size: number): number;
106
+ /** Set transparency of touch gamepad overlay
107
+ * @param {Number} alpha
108
+ * @memberof Settings */
109
+ export function setTouchGamepadAlpha(alpha: number): number;
110
+ /** Set to allow vibration hardware if it exists
111
+ * @param {Boolean} enable
112
+ * @memberof Settings */
113
+ export function setVibrateEnable(enable: boolean): boolean;
114
+ /** Set to disable all audio code
115
+ * @param {Boolean} enable
116
+ * @memberof Settings */
117
+ export function setSoundEnable(enable: boolean): boolean;
118
+ /** Set volume scale to apply to all sound, music and speech
119
+ * @param {Number} volume
120
+ * @memberof Settings */
121
+ export function setSoundVolume(volume: number): number;
122
+ /** Set default range where sound no longer plays
123
+ * @param {Number} range
124
+ * @memberof Settings */
125
+ export function setSoundDefaultRange(range: number): number;
126
+ /** Set default range percent to start tapering off sound
127
+ * @param {Number} taper
128
+ * @memberof Settings */
129
+ export function setSoundDefaultTaper(taper: number): number;
130
+ /** Set how long to show medals for in seconds
131
+ * @param {Number} time
132
+ * @memberof Settings */
133
+ export function setMedalDisplayTime(time: number): number;
134
+ /** Set how quickly to slide on/off medals in seconds
135
+ * @param {Number} time
136
+ * @memberof Settings */
137
+ export function setMedalDisplaySlideTime(time: number): number;
138
+ /** Set size of medal display
139
+ * @param {Vector2} size
140
+ * @memberof Settings */
141
+ export function setMedalDisplaySize(size: Vector2): Vector2;
142
+ /** Set size of icon in medal display
143
+ * @param {Number} size
144
+ * @memberof Settings */
145
+ export function setMedalDisplayIconSize(size: number): number;
146
+ /** Set to stop medals from being unlockable
147
+ * @param {Boolean} preventUnlock
148
+ * @memberof Settings */
149
+ export function setMedalsPreventUnlock(prevent: any): any;
150
+ /** The max size of the canvas, centered if window is larger
151
+ * @type {Vector2}
152
+ * @default Vector2(1920,1200)
153
+ * @memberof Settings */
154
+ export let canvasMaxSize: Vector2;
155
+ /** Fixed size of the canvas, if enabled canvas size never changes
156
+ * - you may also need to set mainCanvasSize if using screen space coords in startup
157
+ * @type {Vector2}
158
+ * @default Vector2()
159
+ * @memberof Settings */
160
+ export let canvasFixedSize: Vector2;
161
+ /** Disables anti aliasing for pixel art if true
162
+ * @type {Boolean}
163
+ * @default
164
+ * @memberof Settings */
165
+ export let cavasPixelated: boolean;
166
+ /** Default font used for text rendering
167
+ * @type {String}
168
+ * @default
169
+ * @memberof Settings */
170
+ export let fontDefault: string;
171
+ /** Default size of tiles in pixels
172
+ * @type {Vector2}
173
+ * @default Vector2(16,16)
174
+ * @memberof Settings */
175
+ export let tileSizeDefault: Vector2;
176
+ /** Prevent tile bleeding from neighbors in pixels
177
+ * @type {Number}
178
+ * @default
179
+ * @memberof Settings */
180
+ export let tileFixBleedScale: number;
181
+ /** Enable physics solver for collisions between objects
182
+ * @type {Boolean}
183
+ * @default
184
+ * @memberof Settings */
185
+ export let enablePhysicsSolver: boolean;
186
+ /** Default object mass for collison calcuations (how heavy objects are)
187
+ * @type {Number}
188
+ * @default
189
+ * @memberof Settings */
190
+ export let objectDefaultMass: number;
191
+ /** How much to slow velocity by each frame (0-1)
192
+ * @type {Number}
193
+ * @default
194
+ * @memberof Settings */
195
+ export let objectDefaultDamping: number;
196
+ /** How much to slow angular velocity each frame (0-1)
197
+ * @type {Number}
198
+ * @default
199
+ * @memberof Settings */
200
+ export let objectDefaultAngleDamping: number;
201
+ /** How much to bounce when a collision occurs (0-1)
202
+ * @type {Number}
203
+ * @default 0
204
+ * @memberof Settings */
205
+ export let objectDefaultElasticity: number;
206
+ /** How much to slow when touching (0-1)
207
+ * @type {Number}
208
+ * @default
209
+ * @memberof Settings */
210
+ export let objectDefaultFriction: number;
211
+ /** Clamp max speed to avoid fast objects missing collisions
212
+ * @type {Number}
213
+ * @default
214
+ * @memberof Settings */
215
+ export let objectMaxSpeed: number;
216
+ /** How much gravity to apply to objects along the Y axis, negative is down
217
+ * @type {Number}
218
+ * @default 0
219
+ * @memberof Settings */
220
+ export let gravity: number;
221
+ /** Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)
222
+ * @type {Number}
223
+ * @default
224
+ * @memberof Settings */
225
+ export let particleEmitRateScale: number;
226
+ /** Position of camera in world space
227
+ * @type {Vector2}
228
+ * @default Vector2()
229
+ * @memberof Settings */
230
+ export let cameraPos: Vector2;
231
+ /** Scale of camera in world space
232
+ * @type {Number}
233
+ * @default
234
+ * @memberof Settings */
235
+ export let cameraScale: number;
236
+ /** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
237
+ * @type {Boolean}
238
+ * @default
239
+ * @memberof Settings */
240
+ export let glEnable: boolean;
241
+ /** Fixes slow rendering in some browsers by not compositing the WebGL canvas
242
+ * @type {Boolean}
243
+ * @default
244
+ * @memberof Settings */
245
+ export let glOverlay: boolean;
246
+ /** Should gamepads be allowed
247
+ * @type {Boolean}
248
+ * @default
249
+ * @memberof Settings */
250
+ export let gamepadsEnable: boolean;
251
+ /** If true, the dpad input is also routed to the left analog stick (for better accessability)
252
+ * @type {Boolean}
253
+ * @default
254
+ * @memberof Settings */
255
+ export let gamepadDirectionEmulateStick: boolean;
256
+ /** If true the WASD keys are also routed to the direction keys (for better accessability)
257
+ * @type {Boolean}
258
+ * @default
259
+ * @memberof Settings */
260
+ export let inputWASDEmulateDirection: boolean;
261
+ /** True if touch gamepad should appear on mobile devices
262
+ * <br> - Supports left analog stick, 4 face buttons and start button (button 9)
263
+ * <br> - Must be set by end of gameInit to be activated
264
+ * @type {Boolean}
265
+ * @default 0
266
+ * @memberof Settings */
267
+ export let touchGamepadEnable: boolean;
268
+ /** True if touch gamepad should be analog stick or false to use if 8 way dpad
269
+ * @type {Boolean}
270
+ * @default
271
+ * @memberof Settings */
272
+ export let touchGamepadAnalog: boolean;
273
+ /** Size of virutal gamepad for touch devices in pixels
274
+ * @type {Number}
275
+ * @default
276
+ * @memberof Settings */
277
+ export let touchGamepadSize: number;
278
+ /** Transparency of touch gamepad overlay
279
+ * @type {Number}
280
+ * @default
281
+ * @memberof Settings */
282
+ export let touchGamepadAlpha: number;
283
+ /** Allow vibration hardware if it exists
284
+ * @type {Boolean}
285
+ * @default
286
+ * @memberof Settings */
287
+ export let vibrateEnable: boolean;
288
+ /** All audio code can be disabled and removed from build
289
+ * @type {Boolean}
290
+ * @default
291
+ * @memberof Settings */
292
+ export let soundEnable: boolean;
293
+ /** Volume scale to apply to all sound, music and speech
294
+ * @type {Number}
295
+ * @default
296
+ * @memberof Settings */
297
+ export let soundVolume: number;
298
+ /** Default range where sound no longer plays
299
+ * @type {Number}
300
+ * @default
301
+ * @memberof Settings */
302
+ export let soundDefaultRange: number;
303
+ /** Default range percent to start tapering off sound (0-1)
304
+ * @type {Number}
305
+ * @default
306
+ * @memberof Settings */
307
+ export let soundDefaultTaper: number;
308
+ /** How long to show medals for in seconds
309
+ * @type {Number}
310
+ * @default
311
+ * @memberof Settings */
312
+ export let medalDisplayTime: number;
313
+ /** How quickly to slide on/off medals in seconds
314
+ * @type {Number}
315
+ * @default
316
+ * @memberof Settings */
317
+ export let medalDisplaySlideTime: number;
318
+ /** Size of medal display
319
+ * @type {Vector2}
320
+ * @default Vector2(640,80)
321
+ * @memberof Settings */
322
+ export let medalDisplaySize: Vector2;
323
+ /** Size of icon in medal display
324
+ * @type {Number}
325
+ * @default
326
+ * @memberof Settings */
327
+ export let medalDisplayIconSize: number;
328
+ /** True if debug is enabled
329
+ * @type {Boolean}
330
+ * @default
331
+ * @memberof Debug */
332
+ export const debug: boolean;
333
+ /** True if watermark with FPS should be down, false in release builds
334
+ * @type {Boolean}
335
+ * @default
336
+ * @memberof Debug */
337
+ export let showWatermark: boolean;
338
+ /** True if god mode is enabled, handle this however you want
339
+ * @type {Boolean}
340
+ * @default
341
+ * @memberof Debug */
342
+ export let godMode: boolean;
343
+ export function ASSERT(...assert: any[]): void;
344
+ /** Draw a debug rectangle in world space
345
+ * @param {Vector2} pos
346
+ * @param {Vector2} [size=Vector2()]
347
+ * @param {String} [color='#fff']
348
+ * @param {Number} [time=0]
349
+ * @param {Number} [angle=0]
350
+ * @param {Boolean} [fill=false]
351
+ * @memberof Debug */
352
+ export function debugRect(pos: Vector2, size?: Vector2, color?: string, time?: number, angle?: number, fill?: boolean): void;
353
+ /** Draw a debug circle in world space
354
+ * @param {Vector2} pos
355
+ * @param {Number} [radius=0]
356
+ * @param {String} [color='#fff']
357
+ * @param {Number} [time=0]
358
+ * @param {Boolean} [fill=false]
359
+ * @memberof Debug */
360
+ export function debugCircle(pos: Vector2, radius?: number, color?: string, time?: number, fill?: boolean): void;
361
+ /** Draw a debug point in world space
362
+ * @param {Vector2} pos
363
+ * @param {String} [color='#fff']
364
+ * @param {Number} [time=0]
365
+ * @param {Number} [angle=0]
366
+ * @memberof Debug */
367
+ export function debugPoint(pos: Vector2, color?: string, time?: number, angle?: number): void;
368
+ /** Draw a debug line in world space
369
+ * @param {Vector2} posA
370
+ * @param {Vector2} posB
371
+ * @param {String} [color='#fff']
372
+ * @param {Number} [thickness=.1]
373
+ * @param {Number} [time=0]
374
+ * @memberof Debug */
375
+ export function debugLine(posA: Vector2, posB: Vector2, color?: string, thickness?: number, time?: number): void;
376
+ /** Draw a debug axis aligned bounding box in world space
377
+ * @param {Vector2} posA
378
+ * @param {Vector2} sizeA
379
+ * @param {Vector2} posB
380
+ * @param {Vector2} sizeB
381
+ * @param {String} [color='#fff']
382
+ * @memberof Debug */
383
+ export function debugAABB(pA: any, sA: any, pB: any, sB: any, color?: string): void;
384
+ /** Draw a debug axis aligned bounding box in world space
385
+ * @param {String} text
386
+ * @param {Vector2} pos
387
+ * @param {Number} [size=1]
388
+ * @param {String} [color='#fff']
389
+ * @param {Number} [time=0]
390
+ * @param {Number} [angle=0]
391
+ * @param {String} [font='monospace']
392
+ * @memberof Debug */
393
+ export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
394
+ /** Clear all debug primitives in the list
395
+ * @memberof Debug */
396
+ export function debugClear(): any[];
397
+ /** Save a canvas to disk
398
+ * @param {HTMLCanvasElement} canvas
399
+ * @param {String} [filename]
400
+ * @memberof Debug */
401
+ export function debugSaveCanvas(canvas: HTMLCanvasElement, filename?: string): void;
402
+ /** A shortcut to get Math.PI
403
+ * @type {Number}
404
+ * @default Math.PI
405
+ * @memberof Utilities */
406
+ export const PI: number;
407
+ /** Returns absoulte value of value passed in
408
+ * @param {Number} value
409
+ * @return {Number}
410
+ * @memberof Utilities */
411
+ export function abs(a: any): number;
412
+ /** Returns lowest of two values passed in
413
+ * @param {Number} valueA
414
+ * @param {Number} valueB
415
+ * @return {Number}
416
+ * @memberof Utilities */
417
+ export function min(a: any, b: any): number;
418
+ /** Returns highest of two values passed in
419
+ * @param {Number} valueA
420
+ * @param {Number} valueB
421
+ * @return {Number}
422
+ * @memberof Utilities */
423
+ export function max(a: any, b: any): number;
424
+ /** Returns the sign of value passed in (also returns 1 if 0)
425
+ * @param {Number} value
426
+ * @return {Number}
427
+ * @memberof Utilities */
428
+ export function sign(a: any): number;
429
+ /** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
430
+ * @param {Number} dividend
431
+ * @param {Number} [divisor=1]
432
+ * @return {Number}
433
+ * @memberof Utilities */
434
+ export function mod(a: any, b?: number): number;
435
+ /** Clamps the value beween max and min
436
+ * @param {Number} value
437
+ * @param {Number} [min=0]
438
+ * @param {Number} [max=1]
439
+ * @return {Number}
440
+ * @memberof Utilities */
441
+ export function clamp(v: any, min?: number, max?: number): number;
442
+ /** Returns what percentage the value is between max and min
443
+ * @param {Number} value
444
+ * @param {Number} [min=0]
445
+ * @param {Number} [max=1]
446
+ * @return {Number}
447
+ * @memberof Utilities */
448
+ export function percent(v: any, min?: number, max?: number): number;
449
+ /** Linearly interpolates the percent value between max and min
450
+ * @param {Number} percent
451
+ * @param {Number} [min=0]
452
+ * @param {Number} [max=1]
453
+ * @return {Number}
454
+ * @memberof Utilities */
455
+ export function lerp(p: any, min?: number, max?: number): number;
456
+ /** Applies smoothstep function to the percentage value
457
+ * @param {Number} value
458
+ * @return {Number}
459
+ * @memberof Utilities */
460
+ export function smoothStep(p: any): number;
461
+ /** Returns the nearest power of two not less then the value
462
+ * @param {Number} value
463
+ * @return {Number}
464
+ * @memberof Utilities */
465
+ export function nearestPowerOfTwo(v: any): number;
466
+ /** Returns true if two axis aligned bounding boxes are overlapping
467
+ * @param {Vector2} pointA - Center of box A
468
+ * @param {Vector2} sizeA - Size of box A
469
+ * @param {Vector2} pointB - Center of box B
470
+ * @param {Vector2} [sizeB] - Size of box B
471
+ * @return {Boolean} - True if overlapping
472
+ * @memberof Utilities */
473
+ export function isOverlapping(pA: any, sA: any, pB: any, sB: any): boolean;
474
+ /** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
475
+ * @param {Number} [frequency=1] - Frequency of the wave in Hz
476
+ * @param {Number} [amplitude=1] - Amplitude (max height) of the wave
477
+ * @param {Number} [t=time] - Value to use for time of the wave
478
+ * @return {Number} - Value waving between 0 and amplitude
479
+ * @memberof Utilities */
480
+ export function wave(frequency?: number, amplitude?: number, t?: number): number;
481
+ /** Formats seconds to mm:ss style for display purposes
482
+ * @param {Number} t - time in seconds
483
+ * @return {String}
484
+ * @memberof Utilities */
485
+ export function formatTime(t: number): string;
486
+ /** Random global functions
487
+ * @namespace Random */
488
+ /** Returns a random value between the two values passed in
489
+ * @param {Number} [valueA=1]
490
+ * @param {Number} [valueB=0]
491
+ * @return {Number}
492
+ * @memberof Random */
493
+ export function rand(a?: number, b?: number): number;
494
+ /** Returns a floored random value the two values passed in
495
+ * @param {Number} [valueA=1]
496
+ * @param {Number} [valueB=0]
497
+ * @return {Number}
498
+ * @memberof Random */
499
+ export function randInt(a?: number, b?: number): number;
500
+ /** Randomly returns either -1 or 1
501
+ * @return {Number}
502
+ * @memberof Random */
503
+ export function randSign(): number;
504
+ /** Returns a random Vector2 within a circular shape
505
+ * @param {Number} [radius=1]
506
+ * @param {Number} [minRadius=0]
507
+ * @return {Vector2}
508
+ * @memberof Random */
509
+ export function randInCircle(radius?: number, minRadius?: number): Vector2;
510
+ /** Returns a random Vector2 with the passed in length
511
+ * @param {Number} [length=1]
512
+ * @return {Vector2}
513
+ * @memberof Random */
514
+ export function randVector(length?: number): Vector2;
515
+ /** Returns a random color between the two passed in colors, combine components if linear
516
+ * @param {Color} [colorA=Color()]
517
+ * @param {Color} [colorB=Color(0,0,0,1)]
518
+ * @param {Boolean} [linear]
519
+ * @return {Color}
520
+ * @memberof Random */
521
+ export function randColor(cA?: Color, cB?: Color, linear?: boolean): Color;
522
+ /** Seed used by the randSeeded function
523
+ * @type {Number}
524
+ * @default
525
+ * @memberof Random */
526
+ export let randSeed: number;
527
+ /** Set seed used by the randSeeded function, should not be 0
528
+ * @param {Number} seed
529
+ * @memberof Random */
530
+ export function setRandSeed(seed: number): number;
531
+ /** Returns a seeded random value between the two values passed in using randSeed
532
+ * @param {Number} [valueA=1]
533
+ * @param {Number} [valueB=0]
534
+ * @return {Number}
535
+ * @memberof Random */
536
+ export function randSeeded(a?: number, b?: number): number;
537
+ /**
538
+ * 2D Vector object with vector math library
539
+ * <br> - Functions do not change this so they can be chained together
540
+ * @example
541
+ * let a = new Vector2(2, 3); // vector with coordinates (2, 3)
542
+ * let b = new Vector2; // vector with coordinates (0, 0)
543
+ * let c = vec2(4, 2); // use the vec2 function to make a Vector2
544
+ * let d = a.add(b).scale(5); // operators can be chained
545
+ */
546
+ export class Vector2 {
547
+ /** Create a 2D vector with the x and y passed in, can also be created with vec2()
548
+ * @param {Number} [x=0] - X axis location
549
+ * @param {Number} [y=0] - Y axis location */
550
+ constructor(x?: number, y?: number);
551
+ /** @property {Number} - X axis location */
552
+ x: number;
553
+ /** @property {Number} - Y axis location */
554
+ y: number;
555
+ /** Returns a new vector that is a copy of this
556
+ * @return {Vector2} */
557
+ copy(): Vector2;
558
+ /** Returns a copy of this vector plus the vector passed in
559
+ * @param {Vector2} vector
560
+ * @return {Vector2} */
561
+ add(v: any): Vector2;
562
+ /** Returns a copy of this vector minus the vector passed in
563
+ * @param {Vector2} vector
564
+ * @return {Vector2} */
565
+ subtract(v: any): Vector2;
566
+ /** Returns a copy of this vector times the vector passed in
567
+ * @param {Vector2} vector
568
+ * @return {Vector2} */
569
+ multiply(v: any): Vector2;
570
+ /** Returns a copy of this vector divided by the vector passed in
571
+ * @param {Vector2} vector
572
+ * @return {Vector2} */
573
+ divide(v: any): Vector2;
574
+ /** Returns a copy of this vector scaled by the vector passed in
575
+ * @param {Number} scale
576
+ * @return {Vector2} */
577
+ scale(s: any): Vector2;
578
+ /** Returns the length of this vector
579
+ * @return {Number} */
580
+ length(): number;
581
+ /** Returns the length of this vector squared
582
+ * @return {Number} */
583
+ lengthSquared(): number;
584
+ /** Returns the distance from this vector to vector passed in
585
+ * @param {Vector2} vector
586
+ * @return {Number} */
587
+ distance(v: any): number;
588
+ /** Returns the distance squared from this vector to vector passed in
589
+ * @param {Vector2} vector
590
+ * @return {Number} */
591
+ distanceSquared(v: any): number;
592
+ /** Returns a new vector in same direction as this one with the length passed in
593
+ * @param {Number} [length=1]
594
+ * @return {Vector2} */
595
+ normalize(length?: number): Vector2;
596
+ /** Returns a new vector clamped to length passed in
597
+ * @param {Number} [length=1]
598
+ * @return {Vector2} */
599
+ clampLength(length?: number): Vector2;
600
+ /** Returns the dot product of this and the vector passed in
601
+ * @param {Vector2} vector
602
+ * @return {Number} */
603
+ dot(v: any): number;
604
+ /** Returns the cross product of this and the vector passed in
605
+ * @param {Vector2} vector
606
+ * @return {Number} */
607
+ cross(v: any): number;
608
+ /** Returns the angle of this vector, up is angle 0
609
+ * @return {Number} */
610
+ angle(): number;
611
+ /** Sets this vector with angle and length passed in
612
+ * @param {Number} [angle=0]
613
+ * @param {Number} [length=1]
614
+ * @return {Vector2} */
615
+ setAngle(a?: number, length?: number): Vector2;
616
+ /** Returns copy of this vector rotated by the angle passed in
617
+ * @param {Number} angle
618
+ * @return {Vector2} */
619
+ rotate(a: any): Vector2;
620
+ /** Returns the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)
621
+ * @return {Number} */
622
+ direction(): number;
623
+ /** Returns a copy of this vector that has been inverted
624
+ * @return {Vector2} */
625
+ invert(): Vector2;
626
+ /** Returns a copy of this vector with each axis floored
627
+ * @return {Vector2} */
628
+ floor(): Vector2;
629
+ /** Returns the area this vector covers as a rectangle
630
+ * @return {Number} */
631
+ area(): number;
632
+ /** Returns a new vector that is p percent between this and the vector passed in
633
+ * @param {Vector2} vector
634
+ * @param {Number} percent
635
+ * @return {Vector2} */
636
+ lerp(v: any, p: any): Vector2;
637
+ /** Returns true if this vector is within the bounds of an array size passed in
638
+ * @param {Vector2} arraySize
639
+ * @return {Boolean} */
640
+ arrayCheck(arraySize: Vector2): boolean;
641
+ /** Returns this vector expressed as a string
642
+ * @param {float} digits - precision to display
643
+ * @return {String} */
644
+ toString(digits?: float): string;
645
+ }
646
+ /**
647
+ * Color object (red, green, blue, alpha) with some helpful functions
648
+ * @example
649
+ * let a = new Color; // white
650
+ * let b = new Color(1, 0, 0); // red
651
+ * let c = new Color(0, 0, 0, 0); // transparent black
652
+ * let d = colorRGBA(0, 0, 1); // blue using rgb color
653
+ * let e = colorHSLA(.3, 1, .5); // green using hsl color
654
+ */
655
+ export class Color {
656
+ /** Create a color with the components passed in, white by default
657
+ * @param {Number} [red=1]
658
+ * @param {Number} [green=1]
659
+ * @param {Number} [blue=1]
660
+ * @param {Number} [alpha=1] */
661
+ constructor(r?: number, g?: number, b?: number, a?: number);
662
+ /** @property {Number} - Red */
663
+ r: number;
664
+ /** @property {Number} - Green */
665
+ g: number;
666
+ /** @property {Number} - Blue */
667
+ b: number;
668
+ /** @property {Number} - Alpha */
669
+ a: number;
670
+ /** Returns a new color that is a copy of this
671
+ * @return {Color} */
672
+ copy(): Color;
673
+ /** Returns a copy of this color plus the color passed in
674
+ * @param {Color} color
675
+ * @return {Color} */
676
+ add(c: any): Color;
677
+ /** Returns a copy of this color minus the color passed in
678
+ * @param {Color} color
679
+ * @return {Color} */
680
+ subtract(c: any): Color;
681
+ /** Returns a copy of this color times the color passed in
682
+ * @param {Color} color
683
+ * @return {Color} */
684
+ multiply(c: any): Color;
685
+ /** Returns a copy of this color divided by the color passed in
686
+ * @param {Color} color
687
+ * @return {Color} */
688
+ divide(c: any): Color;
689
+ /** Returns a copy of this color scaled by the value passed in, alpha can be scaled separately
690
+ * @param {Number} scale
691
+ * @param {Number} [alphaScale=scale]
692
+ * @return {Color} */
693
+ scale(s: any, a?: any): Color;
694
+ /** Returns a copy of this color clamped to the valid range between 0 and 1
695
+ * @return {Color} */
696
+ clamp(): Color;
697
+ /** Returns a new color that is p percent between this and the color passed in
698
+ * @param {Color} color
699
+ * @param {Number} percent
700
+ * @return {Color} */
701
+ lerp(c: any, p: any): Color;
702
+ /** Sets this color given a hue, saturation, lightness, and alpha
703
+ * @param {Number} [hue=0]
704
+ * @param {Number} [saturation=0]
705
+ * @param {Number} [lightness=1]
706
+ * @param {Number} [alpha=1]
707
+ * @return {Color} */
708
+ setHSLA(h?: number, s?: number, l?: number, a?: number): Color;
709
+ /** Returns this color expressed in hsla format
710
+ * @return {Array} */
711
+ getHSLA(): any[];
712
+ /** Returns a new color that has each component randomly adjusted
713
+ * @param {Number} [amount=.05]
714
+ * @param {Number} [alphaAmount=0]
715
+ * @return {Color} */
716
+ mutate(amount?: number, alphaAmount?: number): Color;
717
+ /** Returns this color expressed as a hex color code
718
+ * @param {Boolean} [useAlpha=1] - if alpha should be included in result
719
+ * @return {String} */
720
+ toString(useAlpha?: boolean): string;
721
+ /** Set this color from a hex code
722
+ * @param {String} hex - html hex code
723
+ * @return {Color} */
724
+ setHex(hex: string): Color;
725
+ /** Returns this color expressed as 32 bit RGBA value
726
+ * @return {Number} */
727
+ rgbaInt(): number;
728
+ }
729
+ /**
730
+ * Timer object tracks how long has passed since it was set
731
+ * @example
732
+ * let a = new Timer; // creates a timer that is not set
733
+ * a.set(3); // sets the timer to 3 seconds
734
+ *
735
+ * let b = new Timer(1); // creates a timer with 1 second left
736
+ * b.unset(); // unsets the timer
737
+ */
738
+ export class Timer {
739
+ /** Create a timer object set time passed in
740
+ * @param {Number} [timeLeft] - How much time left before the timer elapses in seconds */
741
+ constructor(timeLeft?: number);
742
+ time: number;
743
+ setTime: number;
744
+ /** Set the timer with seconds passed in
745
+ * @param {Number} [timeLeft=0] - How much time left before the timer is elapsed in seconds */
746
+ set(timeLeft?: number): void;
747
+ /** Unset the timer */
748
+ unset(): void;
749
+ /** Returns true if set
750
+ * @return {Boolean} */
751
+ isSet(): boolean;
752
+ /** Returns true if set and has not elapsed
753
+ * @return {Boolean} */
754
+ active(): boolean;
755
+ /** Returns true if set and elapsed
756
+ * @return {Boolean} */
757
+ elapsed(): boolean;
758
+ /** Get how long since elapsed, returns 0 if not set (returns negative if currently active)
759
+ * @return {Number} */
760
+ get(): number;
761
+ /** Get percentage elapsed based on time it was set to, returns 0 if not set
762
+ * @return {Number} */
763
+ getPercent(): number;
764
+ /** Returns this timer expressed as a string
765
+ * @return {String} */
766
+ toString(): string;
767
+ /** Get how long since elapsed, returns 0 if not set (returns negative if currently active)
768
+ * @return {Number} */
769
+ valueOf(): number;
770
+ }
771
+ /**
772
+ * Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar
773
+ * @param {Number} [x=0]
774
+ * @param {Number} [y=0]
775
+ * @return {Vector2}
776
+ * @example
777
+ * let a = vec2(0, 1); // vector with coordinates (0, 1)
778
+ * let b = vec2(a); // copy a into b
779
+ * a = vec2(5); // set a to (5, 5)
780
+ * b = vec2(); // set b to (0, 0)
781
+ * @memberof Utilities
782
+ */
783
+ export function vec2(x?: number, y?: number): Vector2;
784
+ /**
785
+ * Create a color object with RGBA values
786
+ * @param {Number} [r=1]
787
+ * @param {Number} [g=1]
788
+ * @param {Number} [b=1]
789
+ * @param {Number} [a=1]
790
+ * @return {Color}
791
+ * @memberof Utilities
792
+ */
793
+ export function colorRGBA(r?: number, g?: number, b?: number, a?: number): Color;
794
+ /**
795
+ * Create a color object with HSLA values
796
+ * @param {Number} [h=0]
797
+ * @param {Number} [s=0]
798
+ * @param {Number} [l=1]
799
+ * @param {Number} [a=1]
800
+ * @return {Color}
801
+ * @memberof Utilities
802
+ */
803
+ export function colorHSLA(h?: number, s?: number, l?: number, a?: number): Color;
804
+ /**
805
+ * LittleJS Object Base Object Class
806
+ * <br> - Base object class used by the engine
807
+ * <br> - Automatically adds self to object list
808
+ * <br> - Will be updated and rendered each frame
809
+ * <br> - Renders as a sprite from a tilesheet by default
810
+ * <br> - Can have color and addtive color applied
811
+ * <br> - 2d Physics and collision system
812
+ * <br> - Sorted by renderOrder
813
+ * <br> - Objects can have children attached
814
+ * <br> - Parents are updated before children, and set child transform
815
+ * <br> - Call destroy() to get rid of objects
816
+ * <br>
817
+ * <br>The physics system used by objects is simple and fast with some caveats...
818
+ * <br> - Collision uses the axis aligned size, the object's rotation angle is only for rendering
819
+ * <br> - Objects are guaranteed to not intersect tile collision from physics
820
+ * <br> - If an object starts or is moved inside tile collision, it will not collide with that tile
821
+ * <br> - Collision for objects can be set to be solid to block other objects
822
+ * <br> - Objects may get pushed into overlapping other solid objects, if so they will push away
823
+ * <br> - Solid objects are more performance intensive and should be used sparingly
824
+ * @example
825
+ * // create an engine object, normally you would first extend the class with your own
826
+ * const pos = vec2(2,3);
827
+ * const object = new EngineObject(pos);
828
+ */
829
+ export class EngineObject {
830
+ /** Create an engine object and adds it to the list of objects
831
+ * @param {Vector2} [position=Vector2()] - World space position of the object
832
+ * @param {Vector2} [size=Vector2(1,1)] - World space size of the object
833
+ * @param {Number} [tileIndex=-1] - Tile to use to render object (-1 is untextured)
834
+ * @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
835
+ * @param {Number} [angle=0] - Angle the object is rotated by
836
+ * @param {Color} [color=Color()] - Color to apply to tile when rendered
837
+ * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
838
+ */
839
+ constructor(pos?: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, angle?: number, color?: Color, renderOrder?: number);
840
+ /** @property {Vector2} - World space position of the object */
841
+ pos: Vector2;
842
+ /** @property {Vector2} - World space width and height of the object */
843
+ size: Vector2;
844
+ /** @property {Number} - Tile to use to render object (-1 is untextured) */
845
+ tileIndex: number;
846
+ /** @property {Vector2} - Size of tile in source pixels */
847
+ tileSize: Vector2;
848
+ /** @property {Number} - Angle to rotate the object */
849
+ angle: number;
850
+ /** @property {Color} - Color to apply when rendered */
851
+ color: Color;
852
+ /** @property {Number} [mass=objectDefaultMass] - How heavy the object is, static if 0 */
853
+ mass: number;
854
+ /** @property {Number} [damping=objectDefaultDamping] - How much to slow down velocity each frame (0-1) */
855
+ damping: number;
856
+ /** @property {Number} [angleDamping=objectDefaultAngleDamping] - How much to slow down rotation each frame (0-1) */
857
+ angleDamping: number;
858
+ /** @property {Number} [elasticity=objectDefaultElasticity] - How bouncy the object is when colliding (0-1) */
859
+ elasticity: number;
860
+ /** @property {Number} [friction=objectDefaultFriction] - How much friction to apply when sliding (0-1) */
861
+ friction: number;
862
+ /** @property {Number} [gravityScale=1] - How much to scale gravity by for this object */
863
+ gravityScale: number;
864
+ /** @property {Number} [renderOrder=0] - Objects are sorted by render order */
865
+ renderOrder: number;
866
+ /** @property {Vector2} [velocity=Vector2()] - Velocity of the object */
867
+ velocity: Vector2;
868
+ /** @property {Number} [angleVelocity=0] - Angular velocity of the object */
869
+ angleVelocity: number;
870
+ spawnTime: number;
871
+ children: any[];
872
+ collideTiles: number;
873
+ /** Update the object transform and physics, called automatically by engine once each frame */
874
+ update(): void;
875
+ groundObject: any;
876
+ /** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
877
+ render(): void;
878
+ /** Destroy this object, destroy it's children, detach it's parent, and mark it for removal */
879
+ destroy(): void;
880
+ destroyed: number;
881
+ /** Called to check if a tile collision should be resolved
882
+ * @param {Number} tileData - the value of the tile at the position
883
+ * @param {Vector2} pos - tile where the collision occured
884
+ * @return {Boolean} - true if the collision should be resolved */
885
+ collideWithTile(tileData: number, pos: Vector2): boolean;
886
+ /** Called to check if a tile raycast hit
887
+ * @param {Number} tileData - the value of the tile at the position
888
+ * @param {Vector2} pos - tile where the raycast is
889
+ * @return {Boolean} - true if the raycast should hit */
890
+ collideWithTileRaycast(tileData: number, pos: Vector2): boolean;
891
+ /** Called to check if a object collision should be resolved
892
+ * @param {EngineObject} object - the object to test against
893
+ * @return {Boolean} - true if the collision should be resolved
894
+ */
895
+ collideWithObject(o: any): boolean;
896
+ /** How long since the object was created
897
+ * @return {Number} */
898
+ getAliveTime(): number;
899
+ /** Apply acceleration to this object (adjust velocity, not affected by mass)
900
+ * @param {Vector2} acceleration */
901
+ applyAcceleration(a: any): void;
902
+ /** Apply force to this object (adjust velocity, affected by mass)
903
+ * @param {Vector2} force */
904
+ applyForce(force: Vector2): void;
905
+ /** Get the direction of the mirror
906
+ * @return {Number} -1 if this.mirror is true, or 1 if not mirrored */
907
+ getMirrorSign(): number;
908
+ /** Attaches a child to this with a given local transform
909
+ * @param {EngineObject} child
910
+ * @param {Vector2} [localPos=Vector2()]
911
+ * @param {Number} [localAngle=0] */
912
+ addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
913
+ /** Removes a child from this one
914
+ * @param {EngineObject} child */
915
+ removeChild(child: EngineObject): void;
916
+ /** Set how this object collides
917
+ * @param {Boolean} [collideSolidObjects=1] - Does it collide with solid objects
918
+ * @param {Boolean} [isSolid=1] - Does it collide with and block other objects (expensive in large numbers)
919
+ * @param {Boolean} [collideTiles=1] - Does it collide with the tile collision */
920
+ setCollision(collideSolidObjects?: boolean, isSolid?: boolean, collideTiles?: boolean): void;
921
+ collideSolidObjects: boolean;
922
+ isSolid: boolean;
923
+ /** Returns string containg info about this object for debugging
924
+ * @return {String} */
925
+ toString(): string;
926
+ }
927
+ /** Tile sheet for batch rendering system
928
+ * @type {CanvasImageSource}
929
+ * @memberof Draw */
930
+ export const tileImage: CanvasImageSource;
931
+ /** The primary 2D canvas visible to the user
932
+ * @type {HTMLCanvasElement}
933
+ * @memberof Draw */
934
+ export let mainCanvas: HTMLCanvasElement;
935
+ /** 2d context for mainCanvas
936
+ * @type {CanvasRenderingContext2D}
937
+ * @memberof Draw */
938
+ export let mainContext: CanvasRenderingContext2D;
939
+ /** A canvas that appears on top of everything the same size as mainCanvas
940
+ * @type {HTMLCanvasElement}
941
+ * @memberof Draw */
942
+ export let overlayCanvas: HTMLCanvasElement;
943
+ /** 2d context for overlayCanvas
944
+ * @type {CanvasRenderingContext2D}
945
+ * @memberof Draw */
946
+ export let overlayContext: CanvasRenderingContext2D;
947
+ /** The size of the main canvas (and other secondary canvases)
948
+ * @type {Vector2}
949
+ * @memberof Draw */
950
+ export let mainCanvasSize: Vector2;
951
+ /** Convert from screen to world space coordinates
952
+ * - if calling outside of render, you may need to manually set mainCanvasSize
953
+ * @param {Vector2} screenPos
954
+ * @return {Vector2}
955
+ * @memberof Draw */
956
+ export function screenToWorld(screenPos: Vector2): Vector2;
957
+ /** Convert from world to screen space coordinates
958
+ * - if calling outside of render, you may need to manually set mainCanvasSize
959
+ * @param {Vector2} worldPos
960
+ * @return {Vector2}
961
+ * @memberof Draw */
962
+ export function worldToScreen(worldPos: Vector2): Vector2;
963
+ /** Draw textured tile centered in world space, with color applied if using WebGL
964
+ * @param {Vector2} pos - Center of the tile in world space
965
+ * @param {Vector2} [size=Vector2(1,1)] - Size of the tile in world space
966
+ * @param {Number} [tileIndex=-1] - Tile index to use, negative is untextured
967
+ * @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
968
+ * @param {Color} [color=Color()] - Color to modulate with
969
+ * @param {Number} [angle=0] - Angle to rotate by
970
+ * @param {Boolean} [mirror=0] - If true image is flipped along the Y axis
971
+ * @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
972
+ * @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
973
+ * @memberof Draw */
974
+ export function drawTile(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean): void;
975
+ /** Draw colored rect centered on pos
976
+ * @param {Vector2} pos
977
+ * @param {Vector2} [size=Vector2(1,1)]
978
+ * @param {Color} [color=Color()]
979
+ * @param {Number} [angle=0]
980
+ * @param {Boolean} [useWebGL=glEnable]
981
+ * @memberof Draw */
982
+ export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean): void;
983
+ /** Draw textured tile centered on pos in screen space
984
+ * @param {Vector2} pos - Center of the tile
985
+ * @param {Vector2} [size=Vector2(1,1)] - Size of the tile
986
+ * @param {Number} [tileIndex=-1] - Tile index to use, negative is untextured
987
+ * @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
988
+ * @param {Color} [color=Color()]
989
+ * @param {Number} [angle=0]
990
+ * @param {Boolean} [mirror=0]
991
+ * @param {Color} [additiveColor=Color(0,0,0,0)]
992
+ * @param {Boolean} [useWebGL=glEnable]
993
+ * @memberof Draw */
994
+ export function drawTileScreenSpace(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean): void;
995
+ /** Draw colored rectangle in screen space
996
+ * @param {Vector2} pos
997
+ * @param {Vector2} [size=Vector2(1,1)]
998
+ * @param {Color} [color=Color()]
999
+ * @param {Number} [angle=0]
1000
+ * @param {Boolean} [useWebGL=glEnable]
1001
+ * @memberof Draw */
1002
+ export function drawRectScreenSpace(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean): void;
1003
+ /** Draw colored line between two points
1004
+ * @param {Vector2} posA
1005
+ * @param {Vector2} posB
1006
+ * @param {Number} [thickness=.1]
1007
+ * @param {Color} [color=Color()]
1008
+ * @param {Boolean} [useWebGL=glEnable]
1009
+ * @memberof Draw */
1010
+ export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean): void;
1011
+ /** Draw directly to a 2d canvas context in world space
1012
+ * @param {Vector2} pos
1013
+ * @param {Vector2} size
1014
+ * @param {Number} angle
1015
+ * @param {Boolean} mirror
1016
+ * @param {Function} drawFunction
1017
+ * @param {CanvasRenderingContext2D} [context=mainContext]
1018
+ * @memberof Draw */
1019
+ export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, context?: CanvasRenderingContext2D): void;
1020
+ /** Enable normal or additive blend mode
1021
+ * @param {Boolean} [additive=0]
1022
+ * @param {Boolean} [useWebGL=glEnable]
1023
+ * @memberof Draw */
1024
+ export function setBlendMode(additive?: boolean, useWebGL?: boolean): void;
1025
+ /** Draw text on overlay canvas in screen space
1026
+ * Automatically splits new lines into rows
1027
+ * @param {String} text
1028
+ * @param {Vector2} pos
1029
+ * @param {Number} [size=1]
1030
+ * @param {Color} [color=Color()]
1031
+ * @param {Number} [lineWidth=0]
1032
+ * @param {Color} [lineColor=Color(0,0,0)]
1033
+ * @param {String} [textAlign='center']
1034
+ * @memberof Draw */
1035
+ export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: string, font?: string, context?: CanvasRenderingContext2D): void;
1036
+ /** Draw text on overlay canvas in world space
1037
+ * Automatically splits new lines into rows
1038
+ * @param {String} text
1039
+ * @param {Vector2} pos
1040
+ * @param {Number} [size=1]
1041
+ * @param {Color} [color=Color()]
1042
+ * @param {Number} [lineWidth=0]
1043
+ * @param {Color} [lineColor=Color(0,0,0)]
1044
+ * @param {String} [textAlign='center']
1045
+ * @memberof Draw */
1046
+ export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: string, font: any): void;
1047
+ export let engineFontImage: any;
1048
+ /**
1049
+ * Font Image Object - Draw text on a 2D canvas by using characters in an image
1050
+ * <br> - 96 characters (from space to tilde) are stored in an image
1051
+ * <br> - Uses a default 8x8 font if none is supplied
1052
+ * <br> - You can also use fonts from the main tile sheet
1053
+ * @example
1054
+ * // use built in font
1055
+ * const font = new ImageFont;
1056
+ *
1057
+ * // draw text
1058
+ * font.drawTextScreen("LittleJS\nHello World!", vec2(200, 50));
1059
+ */
1060
+ export class FontImage {
1061
+ /** Create an image font
1062
+ * @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
1063
+ * @param {Vector2} [tileSize=vec2(8)] - Size of the font source tiles
1064
+ * @param {Vector2} [paddingSize=vec2(0,1)] - How much extra space to add between characters
1065
+ * @param {Number} [startTileIndex=0] - Tile index in image where font starts
1066
+ * @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
1067
+ */
1068
+ constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, startTileIndex?: number, context?: CanvasRenderingContext2D);
1069
+ image: any;
1070
+ tileSize: Vector2;
1071
+ paddingSize: Vector2;
1072
+ startTileIndex: number;
1073
+ context: CanvasRenderingContext2D;
1074
+ /** Draw text in screen space using the image font
1075
+ * @param {String} text
1076
+ * @param {Vector2} pos
1077
+ * @param {Number} [scale=4]
1078
+ * @param {Boolean} [center]
1079
+ */
1080
+ drawTextScreen(text: string, pos: Vector2, scale?: number, center?: boolean): void;
1081
+ /** Draw text in world space using the image font
1082
+ * @param {String} text
1083
+ * @param {Vector2} pos
1084
+ * @param {Number} [scale=.25]
1085
+ * @param {Boolean} [center]
1086
+ */
1087
+ drawText(text: string, pos: Vector2, scale?: number, center?: boolean): void;
1088
+ }
1089
+ /** Returns true if fullscreen mode is active
1090
+ * @return {Boolean}
1091
+ * @memberof Draw */
1092
+ export function isFullscreen(): boolean;
1093
+ /** Toggle fullsceen mode
1094
+ * @memberof Draw */
1095
+ export function toggleFullscreen(): void;
1096
+ /** Returns true if device key is down
1097
+ * @param {Number} key
1098
+ * @param {Number} [device=0]
1099
+ * @return {Boolean}
1100
+ * @memberof Input */
1101
+ export function keyIsDown(key: number, device?: number): boolean;
1102
+ /** Returns true if device key was pressed this frame
1103
+ * @param {Number} key
1104
+ * @param {Number} [device=0]
1105
+ * @return {Boolean}
1106
+ * @memberof Input */
1107
+ export function keyWasPressed(key: number, device?: number): boolean;
1108
+ /** Returns true if device key was released this frame
1109
+ * @param {Number} key
1110
+ * @param {Number} [device=0]
1111
+ * @return {Boolean}
1112
+ * @memberof Input */
1113
+ export function keyWasReleased(key: number, device?: number): boolean;
1114
+ /** Clears all input
1115
+ * @memberof Input */
1116
+ export function clearInput(): any[][];
1117
+ /** Returns true if device key is down
1118
+ * @param {Number} key
1119
+ * @param {Number} [device=0]
1120
+ * @return {Boolean}
1121
+ * @memberof Input */
1122
+ export function mouseIsDown(key: number, device?: number): boolean;
1123
+ /** Returns true if device key was pressed this frame
1124
+ * @param {Number} key
1125
+ * @param {Number} [device=0]
1126
+ * @return {Boolean}
1127
+ * @memberof Input */
1128
+ export function mouseWasPressed(key: number, device?: number): boolean;
1129
+ /** Returns true if device key was released this frame
1130
+ * @param {Number} key
1131
+ * @param {Number} [device=0]
1132
+ * @return {Boolean}
1133
+ * @memberof Input */
1134
+ export function mouseWasReleased(key: number, device?: number): boolean;
1135
+ /** Mouse pos in world space
1136
+ * @type {Vector2}
1137
+ * @memberof Input */
1138
+ export let mousePos: Vector2;
1139
+ /** Mouse pos in screen space
1140
+ * @type {Vector2}
1141
+ * @memberof Input */
1142
+ export let mousePosScreen: Vector2;
1143
+ /** Mouse wheel delta this frame
1144
+ * @type {Number}
1145
+ * @memberof Input */
1146
+ export let mouseWheel: number;
1147
+ /** Returns true if user is using gamepad (has more recently pressed a gamepad button)
1148
+ * @type {Boolean}
1149
+ * @memberof Input */
1150
+ export let isUsingGamepad: boolean;
1151
+ /** Prevents input continuing to the default browser handling (false by default)
1152
+ * @type {Boolean}
1153
+ * @memberof Input */
1154
+ export let preventDefaultInput: boolean;
1155
+ /** Returns true if gamepad button is down
1156
+ * @param {Number} button
1157
+ * @param {Number} [gamepad=0]
1158
+ * @return {Boolean}
1159
+ * @memberof Input */
1160
+ export function gamepadIsDown(button: number, gamepad?: number): boolean;
1161
+ /** Returns true if gamepad button was pressed
1162
+ * @param {Number} button
1163
+ * @param {Number} [gamepad=0]
1164
+ * @return {Boolean}
1165
+ * @memberof Input */
1166
+ export function gamepadWasPressed(button: number, gamepad?: number): boolean;
1167
+ /** Returns true if gamepad button was released
1168
+ * @param {Number} button
1169
+ * @param {Number} [gamepad=0]
1170
+ * @return {Boolean}
1171
+ * @memberof Input */
1172
+ export function gamepadWasReleased(button: number, gamepad?: number): boolean;
1173
+ /** Returns gamepad stick value
1174
+ * @param {Number} stick
1175
+ * @param {Number} [gamepad=0]
1176
+ * @return {Vector2}
1177
+ * @memberof Input */
1178
+ export function gamepadStick(stick: number, gamepad?: number): Vector2;
1179
+ export function mouseToScreen(mousePos: any): Vector2;
1180
+ export function gamepadsUpdate(): void;
1181
+ /** Pulse the vibration hardware if it exists
1182
+ * @param {Number} [pattern=100] - a single value in miliseconds or vibration interval array
1183
+ * @memberof Input */
1184
+ export function vibrate(pattern?: number): boolean;
1185
+ /** Cancel any ongoing vibration
1186
+ * @memberof Input */
1187
+ export function vibrateStop(): boolean;
1188
+ /** True if a touch device has been detected
1189
+ * @memberof Input */
1190
+ export const isTouchDevice: boolean;
1191
+ /**
1192
+ * Sound Object - Stores a zzfx sound for later use and can be played positionally
1193
+ * <br>
1194
+ * <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
1195
+ * @example
1196
+ * // create a sound
1197
+ * const sound_example = new Sound([.5,.5]);
1198
+ *
1199
+ * // play the sound
1200
+ * sound_example.play();
1201
+ */
1202
+ export class Sound {
1203
+ /** Create a sound object and cache the zzfx samples for later use
1204
+ * @param {Array} zzfxSound - Array of zzfx parameters, ex. [.5,.5]
1205
+ * @param {Number} [range=soundDefaultRange] - World space max range of sound, will not play if camera is farther away
1206
+ * @param {Number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering off
1207
+ */
1208
+ constructor(zzfxSound: any[], range?: number, taper?: number);
1209
+ /** @property {Number} - World space max range of sound, will not play if camera is farther away */
1210
+ range: number;
1211
+ /** @property {Number} - At what percentage of range should it start tapering off */
1212
+ taper: number;
1213
+ randomness: any;
1214
+ cachedSamples: number[];
1215
+ /** Play the sound
1216
+ * @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
1217
+ * @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
1218
+ * @param {Number} [pitch=1] - How much to scale pitch by (also adjusted by this.randomness)
1219
+ * @param {Number} [randomnessScale=1] - How much to scale randomness
1220
+ * @return {AudioBufferSourceNode} - The audio, can be used to stop sound later
1221
+ */
1222
+ play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number): AudioBufferSourceNode;
1223
+ /** Play the sound as a note with a semitone offset
1224
+ * @param {Number} semitoneOffset - How many semitones to offset pitch
1225
+ * @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
1226
+ * @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
1227
+ * @return {AudioBufferSourceNode} - The audio, can be used to stop sound later
1228
+ */
1229
+ playNote(semitoneOffset: number, pos?: Vector2, volume?: number): AudioBufferSourceNode;
1230
+ }
1231
+ /**
1232
+ * Music Object - Stores a zzfx music track for later use
1233
+ * <br>
1234
+ * <br><b><a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a></b>
1235
+ * @example
1236
+ * // create some music
1237
+ * const music_example = new Music(
1238
+ * [
1239
+ * [ // instruments
1240
+ * [,0,400] // simple note
1241
+ * ],
1242
+ * [ // patterns
1243
+ * [ // pattern 1
1244
+ * [ // channel 0
1245
+ * 0, -1, // instrument 0, left speaker
1246
+ * 1, 0, 9, 1 // channel notes
1247
+ * ],
1248
+ * [ // channel 1
1249
+ * 0, 1, // instrument 1, right speaker
1250
+ * 0, 12, 17, -1 // channel notes
1251
+ * ]
1252
+ * ],
1253
+ * ],
1254
+ * [0, 0, 0, 0], // sequence, play pattern 0 four times
1255
+ * 90 // BPM
1256
+ * ]);
1257
+ *
1258
+ * // play the music
1259
+ * music_example.play();
1260
+ */
1261
+ export class Music {
1262
+ /** Create a music object and cache the zzfx music samples for later use
1263
+ * @param {Array} zzfxMusic - Array of zzfx music parameters
1264
+ */
1265
+ constructor(zzfxMusic: any[]);
1266
+ cachedSamples: any[];
1267
+ /** Play the music
1268
+ * @param {Number} [volume=1] - How much to scale volume by
1269
+ * @param {Boolean} [loop=1] - True if the music should loop when it reaches the end
1270
+ * @return {AudioBufferSourceNode} - The audio node, can be used to stop sound later
1271
+ */
1272
+ play(volume?: number, loop?: boolean): AudioBufferSourceNode;
1273
+ source: number | AudioBufferSourceNode;
1274
+ /** Stop the music */
1275
+ stop(): void;
1276
+ /** Check if music is playing
1277
+ * @return {Boolean}
1278
+ */
1279
+ isPlaying(): boolean;
1280
+ }
1281
+ /** Play an mp3 or wav audio from a local file or url
1282
+ * @param {String} url - Location of sound file to play
1283
+ * @param {Number} [volume=1] - How much to scale volume by
1284
+ * @param {Boolean} [loop=1] - True if the music should loop when it reaches the end
1285
+ * @return {HTMLAudioElement} - The audio element for this sound
1286
+ * @memberof Audio */
1287
+ export function playAudioFile(url: string, volume?: number, loop?: boolean): HTMLAudioElement;
1288
+ /** Speak text with passed in settings
1289
+ * @param {String} text - The text to speak
1290
+ * @param {String} [language] - The language/accent to use (examples: en, it, ru, ja, zh)
1291
+ * @param {Number} [volume=1] - How much to scale volume by
1292
+ * @param {Number} [rate=1] - How quickly to speak
1293
+ * @param {Number} [pitch=1] - How much to change the pitch by
1294
+ * @return {SpeechSynthesisUtterance} - The utterance that was spoken
1295
+ * @memberof Audio */
1296
+ export function speak(text: string, language?: string, volume?: number, rate?: number, pitch?: number): SpeechSynthesisUtterance;
1297
+ /** Stop all queued speech
1298
+ * @memberof Audio */
1299
+ export function speakStop(): void;
1300
+ /** Get frequency of a note on a musical scale
1301
+ * @param {Number} semitoneOffset - How many semitones away from the root note
1302
+ * @param {Number} [rootNoteFrequency=220] - Frequency at semitone offset 0
1303
+ * @return {Number} - The frequency of the note
1304
+ * @memberof Audio */
1305
+ export function getNoteFrequency(semitoneOffset: number, rootFrequency?: number): number;
1306
+ /** Audio context used by the engine
1307
+ * @memberof Audio */
1308
+ export let audioContext: any;
1309
+ /** Play cached audio samples with given settings
1310
+ * @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
1311
+ * @param {Number} [volume=1] - How much to scale volume by
1312
+ * @param {Number} [rate=1] - The playback rate to use
1313
+ * @param {Number} [pan=0] - How much to apply stereo panning
1314
+ * @param {Boolean} [loop=0] - True if the sound should loop when it reaches the end
1315
+ * @return {AudioBufferSourceNode} - The audio node of the sound played
1316
+ * @memberof Audio */
1317
+ export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean): AudioBufferSourceNode;
1318
+ /** Generate and play a ZzFX sound
1319
+ * <br>
1320
+ * <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
1321
+ * @param {Array} zzfxSound - Array of ZzFX parameters, ex. [.5,.5]
1322
+ * @return {Array} - Array of audio samples
1323
+ * @memberof Audio */
1324
+ export function zzfx(...zzfxSound: any[]): any[];
1325
+ /** The tile collision layer array, use setTileCollisionData and getTileCollisionData to access
1326
+ * @type {Array}
1327
+ * @memberof TileCollision */
1328
+ export let tileCollision: any[];
1329
+ /** Size of the tile collision layer
1330
+ * @type {Vector2}
1331
+ * @memberof TileCollision */
1332
+ export let tileCollisionSize: Vector2;
1333
+ /** Clear and initialize tile collision
1334
+ * @param {Vector2} size
1335
+ * @memberof TileCollision */
1336
+ export function initTileCollision(size: Vector2): void;
1337
+ /** Set tile collision data
1338
+ * @param {Vector2} pos
1339
+ * @param {Number} [data=0]
1340
+ * @memberof TileCollision */
1341
+ export function setTileCollisionData(pos: Vector2, data?: number): number;
1342
+ /** Get tile collision data
1343
+ * @param {Vector2} pos
1344
+ * @return {Number}
1345
+ * @memberof TileCollision */
1346
+ export function getTileCollisionData(pos: Vector2): number;
1347
+ /** Check if collision with another object should occur
1348
+ * @param {Vector2} pos
1349
+ * @param {Vector2} [size=Vector2(1,1)]
1350
+ * @param {EngineObject} [object]
1351
+ * @return {Boolean}
1352
+ * @memberof TileCollision */
1353
+ export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
1354
+ /** Return the center of tile if any that is hit (this does not return the exact hit point)
1355
+ * @param {Vector2} posStart
1356
+ * @param {Vector2} posEnd
1357
+ * @param {EngineObject} [object]
1358
+ * @return {Vector2}
1359
+ * @memberof TileCollision */
1360
+ export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject): Vector2;
1361
+ /**
1362
+ * Tile layer data object stores info about how to render a tile
1363
+ * @example
1364
+ * // create tile layer data with tile index 0 and random orientation and color
1365
+ * const tileIndex = 0;
1366
+ * const direction = randInt(4)
1367
+ * const mirror = randInt(2);
1368
+ * const color = randColor();
1369
+ * const data = new TileLayerData(tileIndex, direction, mirror, color);
1370
+ */
1371
+ export class TileLayerData {
1372
+ /** Create a tile layer data object, one for each tile in a TileLayer
1373
+ * @param {Number} [tile] - The tile to use, untextured if undefined
1374
+ * @param {Number} [direction=0] - Integer direction of tile, in 90 degree increments
1375
+ * @param {Boolean} [mirror=0] - If the tile should be mirrored along the x axis
1376
+ * @param {Color} [color=Color()] - Color of the tile */
1377
+ constructor(tile?: number, direction?: number, mirror?: boolean, color?: Color);
1378
+ /** @property {Number} - The tile to use, untextured if undefined */
1379
+ tile: number;
1380
+ /** @property {Number} - Integer direction of tile, in 90 degree increments */
1381
+ direction: number;
1382
+ /** @property {Boolean} - If the tile should be mirrored along the x axis */
1383
+ mirror: boolean;
1384
+ /** @property {Color} - Color of the tile */
1385
+ color: Color;
1386
+ /** Set this tile to clear, it will not be rendered */
1387
+ clear(): void;
1388
+ }
1389
+ /**
1390
+ * Tile layer object - cached rendering system for tile layers
1391
+ * <br> - Each Tile layer is rendered to an off screen canvas
1392
+ * <br> - To allow dynamic modifications, layers are rendered using canvas 2d
1393
+ * <br> - Some devices like mobile phones are limited to 4k texture resolution
1394
+ * <br> - So with 16x16 tiles this limits layers to 256x256 on mobile devices
1395
+ * @extends EngineObject
1396
+ * @example
1397
+ * // create tile collision and visible tile layer
1398
+ * initTileCollision(vec2(200,100));
1399
+ * const tileLayer = new TileLayer();
1400
+ */
1401
+ export class TileLayer extends EngineObject {
1402
+ /** Create a tile layer object
1403
+ * @param {Vector2} [position=Vector2()] - World space position
1404
+ * @param {Vector2} [size=tileCollisionSize] - World space size
1405
+ * @param {Vector2} [tileSize=tileSizeDefault] - Size of tiles in source pixels
1406
+ * @param {Vector2} [scale=Vector2(1,1)] - How much to scale this layer when rendered
1407
+ * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
1408
+ */
1409
+ constructor(pos: any, size?: Vector2, tileSize?: Vector2, scale?: Vector2, renderOrder?: number);
1410
+ /** @property {HTMLCanvasElement} - The canvas used by this tile layer */
1411
+ canvas: HTMLCanvasElement;
1412
+ /** @property {CanvasRenderingContext2D} - The 2D canvas context used by this tile layer */
1413
+ context: CanvasRenderingContext2D;
1414
+ /** @property {Vector2} - How much to scale this layer when rendered */
1415
+ scale: Vector2;
1416
+ data: TileLayerData[];
1417
+ /** Set data at a given position in the array
1418
+ * @param {Vector2} position - Local position in array
1419
+ * @param {TileLayerData} data - Data to set
1420
+ * @param {Boolean} [redraw=0] - Force the tile to redraw if true */
1421
+ setData(layerPos: any, data: TileLayerData, redraw?: boolean): void;
1422
+ /** Get data at a given position in the array
1423
+ * @param {Vector2} layerPos - Local position in array
1424
+ * @return {TileLayerData} */
1425
+ getData(layerPos: Vector2): TileLayerData;
1426
+ /** Draw all the tile data to an offscreen canvas
1427
+ * - This may be slow in some browsers
1428
+ */
1429
+ redraw(): void;
1430
+ /** Call to start the redraw process
1431
+ * @param {Boolean} [clear=0] - Should it clear the canvas before drawing */
1432
+ redrawStart(clear?: boolean): void;
1433
+ savedRenderSettings: (number | HTMLCanvasElement | CanvasRenderingContext2D | Vector2)[];
1434
+ /** Call to end the redraw process */
1435
+ redrawEnd(): void;
1436
+ /** Draw the tile at a given position
1437
+ * @param {Vector2} layerPos */
1438
+ drawTileData(layerPos: Vector2): void;
1439
+ /** Draw all the tiles in this layer */
1440
+ drawAllTileData(): void;
1441
+ /** Draw directly to the 2D canvas in world space (bipass webgl)
1442
+ * @param {Vector2} pos
1443
+ * @param {Vector2} size
1444
+ * @param {Number} [angle=0]
1445
+ * @param {Boolean} [mirror=0]
1446
+ * @param {Function} drawFunction */
1447
+ drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction: Function): void;
1448
+ /** Draw a tile directly onto the layer canvas
1449
+ * @param {Vector2} pos
1450
+ * @param {Vector2} [size=Vector2(1,1)]
1451
+ * @param {Number} [tileIndex=-1]
1452
+ * @param {Vector2} [tileSize=tileSizeDefault]
1453
+ * @param {Color} [color=Color()]
1454
+ * @param {Number} [angle=0]
1455
+ * @param {Boolean} [mirror=0] */
1456
+ drawTile(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean): void;
1457
+ /** Draw a rectangle directly onto the layer canvas
1458
+ * @param {Vector2} pos
1459
+ * @param {Vector2} [size=Vector2(1,1)]
1460
+ * @param {Color} [color=Color()]
1461
+ * @param {Number} [angle=0] */
1462
+ drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
1463
+ }
1464
+ /**
1465
+ * Particle Emitter - Spawns particles with the given settings
1466
+ * @extends EngineObject
1467
+ * @example
1468
+ * // create a particle emitter
1469
+ * let pos = vec2(2,3);
1470
+ * let particleEmiter = new ParticleEmitter
1471
+ * (
1472
+ * pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
1473
+ * 0, vec2(16), // tileIndex, tileSize
1474
+ * new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
1475
+ * new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
1476
+ * 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
1477
+ * .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
1478
+ * .5, 1 // randomness, collide, additive, randomColorLinear, renderOrder
1479
+ * );
1480
+ */
1481
+ export class ParticleEmitter extends EngineObject {
1482
+ /** Create a particle system with the given settings
1483
+ * @param {Vector2} position - World space position of the emitter
1484
+ * @param {Number} [angle=0] - Angle to emit the particles
1485
+ * @param {Number} [emitSize=0] - World space size of the emitter (float for circle diameter, vec2 for rect)
1486
+ * @param {Number} [emitTime=0] - How long to stay alive (0 is forever)
1487
+ * @param {Number} [emitRate=100] - How many particles per second to spawn, does not emit if 0
1488
+ * @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
1489
+ * @param {Number} [tileIndex=-1] - Index into tile sheet, if <0 no texture is applied
1490
+ * @param {Vector2} [tileSize=tileSizeDefault] - Tile size for particles
1491
+ * @param {Color} [colorStartA=Color()] - Color at start of life 1, randomized between start colors
1492
+ * @param {Color} [colorStartB=Color()] - Color at start of life 2, randomized between start colors
1493
+ * @param {Color} [colorEndA=Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
1494
+ * @param {Color} [colorEndB=Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
1495
+ * @param {Number} [particleTime=.5] - How long particles live
1496
+ * @param {Number} [sizeStart=.1] - How big are particles at start
1497
+ * @param {Number} [sizeEnd=1] - How big are particles at end
1498
+ * @param {Number} [speed=.1] - How fast are particles when spawned
1499
+ * @param {Number} [angleSpeed=.05] - How fast are particles rotating
1500
+ * @param {Number} [damping=1] - How much to dampen particle speed
1501
+ * @param {Number} [angleDamping=1] - How much to dampen particle angular speed
1502
+ * @param {Number} [gravityScale=0] - How much does gravity effect particles
1503
+ * @param {Number} [particleConeAngle=PI] - Cone for start particle angle
1504
+ * @param {Number} [fadeRate=.1] - How quick to fade in particles at start/end in percent of life
1505
+ * @param {Number} [randomness=.2] - Apply extra randomness percent
1506
+ * @param {Boolean} [collideTiles=0] - Do particles collide against tiles
1507
+ * @param {Boolean} [additive=0] - Should particles use addtive blend
1508
+ * @param {Boolean} [randomColorLinear=1] - Should color be randomized linearly or across each component
1509
+ * @param {Number} [renderOrder=0] - Render order for particles (additive is above other stuff by default)
1510
+ * @param {Boolean} [localSpace=0] - Should it be in local space of emitter (world space is default)
1511
+ */
1512
+ constructor(pos: any, angle?: number, emitSize?: number, emitTime?: number, emitRate?: number, emitConeAngle?: number, tileIndex?: number, tileSize?: Vector2, colorStartA?: Color, colorStartB?: Color, colorEndA?: Color, colorEndB?: Color, particleTime?: number, sizeStart?: number, sizeEnd?: number, speed?: number, angleSpeed?: number, damping?: number, angleDamping?: number, gravityScale?: number, particleConeAngle?: number, fadeRate?: number, randomness?: number, collideTiles?: boolean, additive?: boolean, randomColorLinear?: boolean, renderOrder?: number, localSpace?: boolean);
1513
+ /** @property {Number} - World space size of the emitter (float for circle diameter, vec2 for rect) */
1514
+ emitSize: number;
1515
+ /** @property {Number} - How long to stay alive (0 is forever) */
1516
+ emitTime: number;
1517
+ /** @property {Number} - How many particles per second to spawn, does not emit if 0 */
1518
+ emitRate: number;
1519
+ /** @property {Number} - Local angle to apply velocity to particles from emitter */
1520
+ emitConeAngle: number;
1521
+ /** @property {Color} - Color at start of life 1, randomized between start colors */
1522
+ colorStartA: Color;
1523
+ /** @property {Color} - Color at start of life 2, randomized between start colors */
1524
+ colorStartB: Color;
1525
+ /** @property {Color} - Color at end of life 1, randomized between end colors */
1526
+ colorEndA: Color;
1527
+ /** @property {Color} - Color at end of life 2, randomized between end colors */
1528
+ colorEndB: Color;
1529
+ /** @property {Boolean} - Should color be randomized linearly or across each component */
1530
+ randomColorLinear: boolean;
1531
+ /** @property {Number} - How long particles live */
1532
+ particleTime: number;
1533
+ /** @property {Number} - How big are particles at start */
1534
+ sizeStart: number;
1535
+ /** @property {Number} - How big are particles at end */
1536
+ sizeEnd: number;
1537
+ /** @property {Number} - How fast are particles when spawned */
1538
+ speed: number;
1539
+ /** @property {Number} - How fast are particles rotating */
1540
+ angleSpeed: number;
1541
+ /** @property {Number} - Cone for start particle angle */
1542
+ particleConeAngle: number;
1543
+ /** @property {Number} - How quick to fade in particles at start/end in percent of life */
1544
+ fadeRate: number;
1545
+ /** @property {Number} - Apply extra randomness percent */
1546
+ randomness: number;
1547
+ /** @property {Number} - Do particles collide against tiles */
1548
+ collideTiles: boolean;
1549
+ /** @property {Number} - Should particles use addtive blend */
1550
+ additive: boolean;
1551
+ /** @property {Boolean} - Should it be in local space of emitter */
1552
+ localSpace: boolean;
1553
+ /** @property {Number} - If set the partile is drawn as a trail, stretched in the drection of velocity */
1554
+ trailScale: number;
1555
+ emitTimeBuffer: number;
1556
+ /** Spawn one particle
1557
+ * @return {Particle} */
1558
+ emitParticle(): Particle;
1559
+ }
1560
+ /**
1561
+ * Particle Object - Created automatically by Particle Emitters
1562
+ * @extends EngineObject
1563
+ */
1564
+ export class Particle extends EngineObject {
1565
+ /**
1566
+ * Create a particle with the given settings
1567
+ * @param {Vector2} position - World space position of the particle
1568
+ * @param {Number} [tileIndex=-1] - Tile to use to render, untextured if -1
1569
+ * @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
1570
+ * @param {Number} [angle=0] - Angle to rotate the particle
1571
+ */
1572
+ constructor(pos: any, tileIndex?: number, tileSize?: Vector2, angle?: number);
1573
+ }
1574
+ /** List of all medals
1575
+ * @type {Array}
1576
+ * @memberof Medals */
1577
+ export const medals: any[];
1578
+ /** Set to stop medals from being unlockable (like if cheats are enabled)
1579
+ * @type {Boolean}
1580
+ * @default 0
1581
+ * @memberof Settings */
1582
+ export let medalsPreventUnlock: boolean;
1583
+ /** Initialize medals with a save name used for storage
1584
+ * <br> - Call this after creating all medals
1585
+ * <br> - Checks if medals are unlocked
1586
+ * @param {String} saveName
1587
+ * @memberof Medals */
1588
+ export function medalsInit(saveName: string): void;
1589
+ /** This can used to enable Newgrounds functionality
1590
+ * @param {Number} app_id - The newgrounds App ID
1591
+ * @param {String} [cipher] - The encryption Key (AES-128/Base64)
1592
+ * @memberof Medals */
1593
+ export function newgroundsInit(app_id: number, cipher?: string): void;
1594
+ /**
1595
+ * Medal Object - Tracks an unlockable medal
1596
+ * @example
1597
+ * // create a medal
1598
+ * const medal_example = new Medal(0, 'Example Medal', 'More info about the medal goes here.', '🎖️');
1599
+ *
1600
+ * // initialize medals
1601
+ * medalsInit('Example Game');
1602
+ *
1603
+ * // unlock the medal
1604
+ * medal_example.unlock();
1605
+ */
1606
+ export class Medal {
1607
+ /** Create an medal object and adds it to the list of medals
1608
+ * @param {Number} id - The unique identifier of the medal
1609
+ * @param {String} name - Name of the medal
1610
+ * @param {String} [description] - Description of the medal
1611
+ * @param {String} [icon='🏆'] - Icon for the medal
1612
+ * @param {String} [src] - Image location for the medal
1613
+ */
1614
+ constructor(id: number, name: string, description?: string, icon?: string, src?: string);
1615
+ id: number;
1616
+ name: string;
1617
+ description: string;
1618
+ icon: string;
1619
+ image: HTMLImageElement;
1620
+ /** Unlocks a medal if not already unlocked */
1621
+ unlock(): void;
1622
+ unlocked: number;
1623
+ /** Render a medal
1624
+ * @param {Number} [hidePercent=0] - How much to slide the medal off screen
1625
+ */
1626
+ render(hidePercent?: number): void;
1627
+ /** Render the icon for a medal
1628
+ * @param {Number} x - Screen space X position
1629
+ * @param {Number} y - Screen space Y position
1630
+ * @param {Number} [size=medalDisplayIconSize] - Screen space size
1631
+ */
1632
+ renderIcon(pos: any, size?: number): void;
1633
+ storageKey(): string;
1634
+ }
1635
+ /**
1636
+ * Newgrounds API wrapper object
1637
+ * @example
1638
+ * // create a newgrounds object, replace the app id and cipher with your own
1639
+ * const app_id = '53123:1ZuSTQ9l';
1640
+ * const cipher = 'enF0vGH@Mj/FRASKL23Q==';
1641
+ * newgrounds = new Newgrounds(app_id, cipher);
1642
+ */
1643
+ export class Newgrounds {
1644
+ /** Create a newgrounds object
1645
+ * @param {Number} app_id - The newgrounds App ID
1646
+ * @param {String} [cipher] - The encryption Key (AES-128/Base64) */
1647
+ constructor(app_id: number, cipher?: string);
1648
+ app_id: number;
1649
+ cipher: string;
1650
+ host: string;
1651
+ cryptoJS: any;
1652
+ session_id: string;
1653
+ medals: any;
1654
+ scoreboards: any;
1655
+ /** Send message to unlock a medal by id
1656
+ * @param {Number} id - The medal id */
1657
+ unlockMedal(id: number): any;
1658
+ /** Send message to post score
1659
+ * @param {Number} id - The scoreboard id
1660
+ * @param {Number} value - The score value */
1661
+ postScore(id: number, value: number): any;
1662
+ /** Get scores from a scoreboard
1663
+ * @param {Number} id - The scoreboard id
1664
+ * @param {String} [user=0] - A user's id or name
1665
+ * @param {Number} [social=0] - If true, only social scores will be loaded
1666
+ * @param {Number} [skip=0] - Number of scores to skip before start
1667
+ * @param {Number} [limit=10] - Number of scores to include in the list
1668
+ * @return {Object} - The response JSON object
1669
+ */
1670
+ getScores(id: number, user?: string, social?: number, skip?: number, limit?: number): any;
1671
+ /** Send message to log a view */
1672
+ logView(): any;
1673
+ /** Send a message to call a component of the Newgrounds API
1674
+ * @param {String} component - Name of the component
1675
+ * @param {Object} [parameters=0] - Parameters to use for call
1676
+ * @param {Boolean} [async=0] - If true, don't wait for response before continuing (avoid stall)
1677
+ * @return {Object} - The response JSON object
1678
+ */
1679
+ call(component: string, parameters?: any, async?: boolean): any;
1680
+ CryptoJS(): any;
1681
+ }
1682
+ /** The WebGL canvas which appears above the main canvas and below the overlay canvas
1683
+ * @type {HTMLCanvasElement}
1684
+ * @memberof WebGL */
1685
+ export let glCanvas: HTMLCanvasElement;
1686
+ /** 2d context for glCanvas
1687
+ * @type {WebGLRenderingContext}
1688
+ * @memberof WebGL */
1689
+ export let glContext: WebGLRenderingContext;
1690
+ /** Set the WebGl blend mode, normally you should call setBlendMode instead
1691
+ * @param {Boolean} [additive=0]
1692
+ * @memberof WebGL */
1693
+ export function glSetBlendMode(additive?: boolean): void;
1694
+ /** Set the WebGl texture, not normally necessary unless multiple tile sheets are used
1695
+ * <br> - This may also flush the gl buffer resulting in more draw calls and worse performance
1696
+ * @param {WebGLTexture} [texture=glTileTexture]
1697
+ * @memberof WebGL */
1698
+ export function glSetTexture(texture?: WebGLTexture): void;
1699
+ /** Compile WebGL shader of the given type, will throw errors if in debug mode
1700
+ * @param {String} source
1701
+ * @param type
1702
+ * @return {WebGLShader}
1703
+ * @memberof WebGL */
1704
+ export function glCompileShader(source: string, type: any): WebGLShader;
1705
+ /** Create WebGL program with given shaders
1706
+ * @param {WebGLShader} vsSource
1707
+ * @param {WebGLShader} fsSource
1708
+ * @return {WebGLProgram}
1709
+ * @memberof WebGL */
1710
+ export function glCreateProgram(vsSource: WebGLShader, fsSource: WebGLShader): WebGLProgram;
1711
+ /** Create WebGL texture from an image and set the texture settings
1712
+ * @param {Image} image
1713
+ * @return {WebGLTexture}
1714
+ * @memberof WebGL */
1715
+ export function glCreateTexture(image: new (width?: number, height?: number) => HTMLImageElement): WebGLTexture;
1716
+ /** Set up a post processing shader
1717
+ * @param {String} shaderCode
1718
+ * @param {Boolean} includeOverlay
1719
+ * @memberof WebGL */
1720
+ export function glInitPostProcess(shaderCode: string, includeOverlay: boolean): void;
1721
+ /** Name of engine
1722
+ * @type {String}
1723
+ * @default
1724
+ * @memberof Engine */
1725
+ export const engineName: string;
1726
+ /** Version of engine
1727
+ * @type {String}
1728
+ * @default
1729
+ * @memberof Engine */
1730
+ export const engineVersion: string;
1731
+ /** Frames per second to update objects
1732
+ * @type {Number}
1733
+ * @default
1734
+ * @memberof Engine */
1735
+ export const frameRate: number;
1736
+ /** How many seconds each frame lasts, engine uses a fixed time step
1737
+ * @type {Number}
1738
+ * @default 1/60
1739
+ * @memberof Engine */
1740
+ export const timeDelta: number;
1741
+ /** Array containing all engine objects
1742
+ * @type {Array}
1743
+ * @memberof Engine */
1744
+ export let engineObjects: any[];
1745
+ /** Current update frame, used to calculate time
1746
+ * @type {Number}
1747
+ * @memberof Engine */
1748
+ export let frame: number;
1749
+ /** Current engine time since start in seconds, derived from frame
1750
+ * @type {Number}
1751
+ * @memberof Engine */
1752
+ export let time: number;
1753
+ /** Actual clock time since start in seconds (not affected by pause or frame rate clamping)
1754
+ * @type {Number}
1755
+ * @memberof Engine */
1756
+ export let timeReal: number;
1757
+ /** Is the game paused? Causes time and objects to not be updated
1758
+ * @type {Boolean}
1759
+ * @default 0
1760
+ * @memberof Engine */
1761
+ export let paused: boolean;
1762
+ /** Set if game is paused
1763
+ * @param {Boolean} paused
1764
+ * @memberof Engine */
1765
+ export function setPaused(_paused: any): void;
1766
+ /** Start up LittleJS engine with your callback functions
1767
+ * @param {Function} gameInit - Called once after the engine starts up, setup the game
1768
+ * @param {Function} gameUpdate - Called every frame at 60 frames per second, handle input and update the game state
1769
+ * @param {Function} gameUpdatePost - Called after physics and objects are updated, setup camera and prepare for render
1770
+ * @param {Function} gameRender - Called before objects are rendered, draw any background effects that appear behind objects
1771
+ * @param {Function} gameRenderPost - Called after objects are rendered, draw effects or hud that appear above all objects
1772
+ * @param {String} [tileImageSource] - Tile image to use, everything starts when the image is finished loading
1773
+ * @memberof Engine */
1774
+ export function engineInit(gameInit: Function, gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, tileImageSource?: string): void;
1775
+ /** Update each engine object, remove destroyed objects, and update time
1776
+ * @memberof Engine */
1777
+ export function engineObjectsUpdate(): void;
1778
+ /** Destroy and remove all objects
1779
+ * @memberof Engine */
1780
+ export function engineObjectsDestroy(): void;
1781
+ /** Triggers a callback for each object within a given area
1782
+ * @param {Vector2} [pos] - Center of test area
1783
+ * @param {Number} [size] - Radius of circle if float, rectangle size if Vector2
1784
+ * @param {Function} [callbackFunction] - Calls this function on every object that passes the test
1785
+ * @param {Array} [objects=engineObjects] - List of objects to check
1786
+ * @memberof Engine */
1787
+ export function engineObjectsCallback(pos?: Vector2, size?: number, callbackFunction?: Function, objects?: any[]): void;
1788
+ }