littlejsengine 1.1.18 → 1.2.3

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