littlejsengine 1.1.17 → 1.2.0

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.
@@ -0,0 +1,1612 @@
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
+ /** Size of virutal gamepad for touch devices in pixels
764
+ * @default
765
+ * @memberof Settings */
766
+ declare let touchGamepadSize: number;
767
+ /** Transparency of touch gamepad overlay
768
+ * @default
769
+ * @memberof Settings */
770
+ declare let touchGamepadAlpha: number;
771
+ /** Allow vibration hardware if it exists
772
+ * @default
773
+ * @memberof Settings */
774
+ declare let vibrateEnable: number;
775
+ /** Volume scale to apply to all sound, music and speech
776
+ * @default
777
+ * @memberof Settings */
778
+ declare let soundVolume: number;
779
+ /** All audio code can be disabled and removed from build
780
+ * @default
781
+ * @memberof Settings */
782
+ declare let soundEnable: number;
783
+ /** Default range where sound no longer plays
784
+ * @default
785
+ * @memberof Settings */
786
+ declare let soundDefaultRange: number;
787
+ /** Default range percent to start tapering off sound (0-1)
788
+ * @default
789
+ * @memberof Settings */
790
+ declare let soundDefaultTaper: number;
791
+ /** How long to show medals for in seconds
792
+ * @default
793
+ * @memberof Settings */
794
+ declare let medalDisplayTime: number;
795
+ /** How quickly to slide on/off medals in seconds
796
+ * @default
797
+ * @memberof Settings */
798
+ declare let medalDisplaySlideTime: number;
799
+ /** Width of medal display
800
+ * @default
801
+ * @memberof Settings */
802
+ declare let medalDisplayWidth: number;
803
+ /** Height of medal display
804
+ * @default
805
+ * @memberof Settings */
806
+ declare let medalDisplayHeight: number;
807
+ /** Size of icon in medal display
808
+ * @default
809
+ * @memberof Settings */
810
+ declare let medalDisplayIconSize: number;
811
+ /**
812
+ * LittleJS Object Base Object Class
813
+ * <br> - Base object class used by the engine
814
+ * <br> - Automatically adds self to object list
815
+ * <br> - Will be updated and rendered each frame
816
+ * <br> - Renders as a sprite from a tilesheet by default
817
+ * <br> - Can have color and addtive color applied
818
+ * <br> - 2d Physics and collision system
819
+ * <br> - Sorted by renderOrder
820
+ * <br> - Objects can have children attached
821
+ * <br> - Parents are updated before children, and set child transform
822
+ * <br> - Call destroy() to get rid of objects
823
+ * <br>
824
+ * <br>The physics system used by objects is simple and fast with some caveats...
825
+ * <br> - Collision uses the axis aligned size, the object's rotation angle is only for rendering
826
+ * <br> - Objects are guaranteed to not intersect tile collision from physics
827
+ * <br> - If an object starts or is moved inside tile collision, it will not collide with that tile
828
+ * <br> - Collision for objects can be set to be solid to block other objects
829
+ * <br> - Objects may get pushed into overlapping other solid objects, if so they will push away
830
+ * <br> - Solid objects are more performance intensive and should be used sparingly
831
+ * @example
832
+ * // create an engine object, normally you would first extend the class with your own
833
+ * const pos = vec2(2,3);
834
+ * const object = new EngineObject(pos);
835
+ */
836
+ declare class EngineObject {
837
+ /** Create an engine object and adds it to the list of objects
838
+ * @param {Vector2} [position=new Vector2()] - World space position of the object
839
+ * @param {Vector2} [size=objectDefaultSize] - World space size of the object
840
+ * @param {Number} [tileIndex=-1] - Tile to use to render object, untextured if -1
841
+ * @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
842
+ * @param {Number} [angle=0] - Angle to rotate the object
843
+ * @param {Color} [color] - Color to apply to tile when rendered
844
+ * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
845
+ */
846
+ constructor(pos?: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, angle?: number, color?: Color, renderOrder?: number);
847
+ /** @property {Vector2} - World space position of the object */
848
+ pos: Vector2;
849
+ /** @property {Vector2} - World space width and height of the object */
850
+ size: Vector2;
851
+ /** @property {Number} - Tile to use to render object, untextured if -1 */
852
+ tileIndex: number;
853
+ /** @property {Vector2} - Size of tile in source pixels */
854
+ tileSize: Vector2;
855
+ /** @property {Number} - Angle to rotate the object */
856
+ angle: number;
857
+ /** @property {Color} - Color to apply when rendered */
858
+ color: Color;
859
+ /** @property {Number} [mass=objectDefaultMass] - How heavy the object is */
860
+ mass: number;
861
+ /** @property {Number} [damping=objectDefaultDamping] - How much to slow down velocity each frame (0-1) */
862
+ damping: number;
863
+ /** @property {Number} [angleDamping=objectDefaultAngleDamping] - How much to slow down rotation each frame (0-1) */
864
+ angleDamping: number;
865
+ /** @property {Number} [elasticity=objectDefaultElasticity] - How bouncy the object is when colliding (0-1) */
866
+ elasticity: number;
867
+ /** @property {Number} [friction=objectDefaultFriction] - How much friction to apply when sliding (0-1) */
868
+ friction: number;
869
+ /** @property {Number} [gravityScale=1] - How much to scale gravity by for this object */
870
+ gravityScale: number;
871
+ /** @property {Number} [renderOrder=0] - Objects are sorted by render order */
872
+ renderOrder: number;
873
+ /** @property {Vector2} [velocity=new Vector2()] - Velocity of the object */
874
+ velocity: Vector2;
875
+ /** @property {Number} [angleVelocity=0] - Angular velocity of the object */
876
+ angleVelocity: number;
877
+ spawnTime: number;
878
+ children: any[];
879
+ collideTiles: number;
880
+ /** Update the object transform and physics, called automatically by engine once each frame */
881
+ update(): void;
882
+ groundObject: any;
883
+ /** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
884
+ render(): void;
885
+ /** Destroy this object, destroy it's children, detach it's parent, and mark it for removal */
886
+ destroy(): void;
887
+ destroyed: number;
888
+ /** Called to check if a tile collision should be resolved
889
+ * @param {Number} tileData - the value of the tile at the position
890
+ * @param {Vector2} pos - tile where the collision occured
891
+ * @return {Boolean} - true if the collision should be resolved */
892
+ collideWithTile(tileData: number, pos: Vector2): boolean;
893
+ /** Called to check if a tile raycast hit
894
+ * @param {Number} tileData - the value of the tile at the position
895
+ * @param {Vector2} pos - tile where the raycast is
896
+ * @return {Boolean} - true if the raycast should hit */
897
+ collideWithTileRaycast(tileData: number, pos: Vector2): boolean;
898
+ /** Called to check if a tile raycast hit
899
+ * @param {EngineObject} object - the object to test against
900
+ * @return {Boolean} - true if the collision should be resolved
901
+ */
902
+ collideWithObject(o: any): boolean;
903
+ /** How long since the object was created
904
+ * @return {Number} */
905
+ getAliveTime(): number;
906
+ /** Apply acceleration to this object (adjust velocity, not affected by mass)
907
+ * @param {Vector2} acceleration */
908
+ applyAcceleration(a: any): void;
909
+ /** Apply force to this object (adjust velocity, affected by mass)
910
+ * @param {Vector2} force */
911
+ applyForce(force: Vector2): void;
912
+ /** Get the direction of the mirror
913
+ * @return {Number} -1 if this.mirror is true, or 1 if not mirrored */
914
+ getMirrorSign(): number;
915
+ /** Attaches a child to this with a given local transform
916
+ * @param {EngineObject} child
917
+ * @param {Vector2} [localPos=new Vector2]
918
+ * @param {Number} [localAngle=0] */
919
+ addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
920
+ /** Removes a child from this one
921
+ * @param {EngineObject} child */
922
+ removeChild(child: EngineObject): void;
923
+ /** Set how this object collides
924
+ * @param {boolean} [collideSolidObjects=0] - Does it collide with solid objects
925
+ * @param {boolean} [isSolid=0] - Does it collide with and block other objects (expensive in large numbers)
926
+ * @param {boolean} [collideTiles=1] - Does it collide with the tile collision */
927
+ setCollision(collideSolidObjects?: boolean, isSolid?: boolean, collideTiles?: boolean): void;
928
+ collideSolidObjects: boolean;
929
+ isSolid: boolean;
930
+ }
931
+ /** Tile sheet for batch rendering system
932
+ * @type {Image}
933
+ * @memberof Draw */
934
+ declare const tileImage: new (width?: number, height?: number) => HTMLImageElement;
935
+ /** The primary 2D canvas visible to the user
936
+ * @type {HTMLCanvasElement}
937
+ * @memberof Draw */
938
+ declare let mainCanvas: HTMLCanvasElement;
939
+ /** 2d context for mainCanvas
940
+ * @type {CanvasRenderingContext2D}
941
+ * @memberof Draw */
942
+ declare let mainContext: CanvasRenderingContext2D;
943
+ /** A canvas that appears on top of everything the same size as mainCanvas
944
+ * @type {HTMLCanvasElement}
945
+ * @memberof Draw */
946
+ declare let overlayCanvas: HTMLCanvasElement;
947
+ /** 2d context for overlayCanvas
948
+ * @type {CanvasRenderingContext2D}
949
+ * @memberof Draw */
950
+ declare let overlayContext: CanvasRenderingContext2D;
951
+ /** The size of the main canvas (and other secondary canvases)
952
+ * @type {Vector2}
953
+ * @memberof Draw */
954
+ declare let mainCanvasSize: Vector2;
955
+ /** Convert from screen to world space coordinates
956
+ * @param {Vector2} screenPos
957
+ * @return {Vector2}
958
+ * @memberof Draw */
959
+ declare function screenToWorld(screenPos: Vector2): Vector2;
960
+ /** Convert from world to screen space coordinates
961
+ * @param {Vector2} worldPos
962
+ * @return {Vector2}
963
+ * @memberof Draw */
964
+ declare function worldToScreen(worldPos: Vector2): Vector2;
965
+ /**
966
+ * Font Image Object - Draw text on a 2D canvas by using characters in an image
967
+ * <br> - 96 characters (from space to tilde) are stored in an image
968
+ * <br> - Uses a default 8x8 font if none is supplied
969
+ * <br> - You can also use fonts from the main tile sheet
970
+ * @example
971
+ * // use built in font
972
+ * const font = new ImageFont;
973
+ *
974
+ * // draw text
975
+ * font.drawTextScreen("LittleJS\nHello World!", vec2(200, 50));
976
+ */
977
+ declare class FontImage {
978
+ /** Create an image font
979
+ * @param {Image} [image] - The image the font is stored in, if undefined the default font is used
980
+ * @param {Vector2} [tileSize=vec2(8)] - The size of the font source tiles
981
+ * @param {Vector2} [paddingSize=vec2(0,1)] - How much extra space to add between characters
982
+ * @param {Number} [startTileIndex=0] - Tile index in image where font starts
983
+ * @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
984
+ */
985
+ constructor(image?: new (width?: number, height?: number) => HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, startTileIndex?: number, context?: CanvasRenderingContext2D);
986
+ image: new (width?: number, height?: number) => HTMLImageElement;
987
+ tileSize: Vector2;
988
+ paddingSize: Vector2;
989
+ startTileIndex: number;
990
+ context: CanvasRenderingContext2D;
991
+ /** Draw text in screen space using the image font
992
+ * @param {String} text
993
+ * @param {Vector2} pos
994
+ * @param {Number} [scale=4]
995
+ * @param {Boolean} [center]
996
+ */
997
+ drawTextScreen(text: string, pos: Vector2, scale?: number, center?: boolean): void;
998
+ /** Draw text in world space using the image font
999
+ * @param {String} text
1000
+ * @param {Vector2} pos
1001
+ * @param {Number} [scale=.25]
1002
+ * @param {Boolean} [center]
1003
+ */
1004
+ drawText(text: string, pos: Vector2, scale?: number, center?: boolean): void;
1005
+ }
1006
+ /** Returns true if fullscreen mode is active
1007
+ * @return {Boolean}
1008
+ * @memberof Draw */
1009
+ declare function isFullscreen(): boolean;
1010
+ /** Returns true if device key is down
1011
+ * @param {Number} key
1012
+ * @param {Number} [device=0]
1013
+ * @return {Boolean}
1014
+ * @memberof Input */
1015
+ declare function keyIsDown(key: number, device?: number): boolean;
1016
+ /** Returns true if device key was pressed this frame
1017
+ * @param {Number} key
1018
+ * @param {Number} [device=0]
1019
+ * @return {Boolean}
1020
+ * @memberof Input */
1021
+ declare function keyWasPressed(key: number, device?: number): boolean;
1022
+ /** Returns true if device key was released this frame
1023
+ * @param {Number} key
1024
+ * @param {Number} [device=0]
1025
+ * @return {Boolean}
1026
+ * @memberof Input */
1027
+ declare function keyWasReleased(key: number, device?: number): boolean;
1028
+ /** Clears all input
1029
+ * @memberof Input */
1030
+ declare function clearInput(): any[][];
1031
+ /** Returns true if device key is down
1032
+ * @param {Number} key
1033
+ * @param {Number} [device=0]
1034
+ * @return {Boolean}
1035
+ * @memberof Input */
1036
+ declare function mouseIsDown(key: number, device?: number): boolean;
1037
+ /** Returns true if device key was pressed this frame
1038
+ * @param {Number} key
1039
+ * @param {Number} [device=0]
1040
+ * @return {Boolean}
1041
+ * @memberof Input */
1042
+ declare function mouseWasPressed(key: number, device?: number): boolean;
1043
+ /** Returns true if device key was released this frame
1044
+ * @param {Number} key
1045
+ * @param {Number} [device=0]
1046
+ * @return {Boolean}
1047
+ * @memberof Input */
1048
+ declare function mouseWasReleased(key: number, device?: number): boolean;
1049
+ /** Mouse pos in world space
1050
+ * @type {Vector2}
1051
+ * @memberof Input */
1052
+ declare let mousePos: Vector2;
1053
+ /** Mouse pos in screen space
1054
+ * @type {Vector2}
1055
+ * @memberof Input */
1056
+ declare let mousePosScreen: Vector2;
1057
+ /** Mouse wheel delta this frame
1058
+ * @memberof Input */
1059
+ declare let mouseWheel: number;
1060
+ /** Returns true if user is using gamepad (has more recently pressed a gamepad button)
1061
+ * @memberof Input */
1062
+ declare let isUsingGamepad: number;
1063
+ /** Returns true if gamepad button is down
1064
+ * @param {Number} button
1065
+ * @param {Number} [gamepad=0]
1066
+ * @return {Boolean}
1067
+ * @memberof Input */
1068
+ declare function gamepadIsDown(button: number, gamepad?: number): boolean;
1069
+ /** Returns true if gamepad button was pressed
1070
+ * @param {Number} button
1071
+ * @param {Number} [gamepad=0]
1072
+ * @return {Boolean}
1073
+ * @memberof Input */
1074
+ declare function gamepadWasPressed(button: number, gamepad?: number): boolean;
1075
+ /** Returns true if gamepad button was released
1076
+ * @param {Number} button
1077
+ * @param {Number} [gamepad=0]
1078
+ * @return {Boolean}
1079
+ * @memberof Input */
1080
+ declare function gamepadWasReleased(button: number, gamepad?: number): boolean;
1081
+ /** Returns gamepad stick value
1082
+ * @param {Number} stick
1083
+ * @param {Number} [gamepad=0]
1084
+ * @return {Vector2}
1085
+ * @memberof Input */
1086
+ declare function gamepadStick(stick: number, gamepad?: number): Vector2;
1087
+ declare let inputData: any[][];
1088
+ declare function remapKeyCode(c: any): any;
1089
+ declare function mouseToScreen(mousePos: any): Vector2;
1090
+ declare const stickData: any[];
1091
+ /** Pulse the vibration hardware if it exists
1092
+ * @param {Number} [pattern=100] - a single value in miliseconds or vibration interval array
1093
+ * @memberof Input */
1094
+ declare function vibrate(pattern?: number): any;
1095
+ /** Cancel any ongoing vibration
1096
+ * @memberof Input */
1097
+ declare function vibrateStop(): any;
1098
+ /** True if a touch device has been detected
1099
+ * @const {boolean}
1100
+ * @memberof Input */
1101
+ declare const isTouchDevice: boolean;
1102
+ declare let touchGamepadTimer: Timer;
1103
+ declare let touchGamepadButtons: any[];
1104
+ declare let touchGamepadStick: Vector2;
1105
+ declare let touchGamepadAnalog: number;
1106
+ /**
1107
+ * Sound Object - Stores a zzfx sound for later use and can be played positionally
1108
+ * <br>
1109
+ * <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
1110
+ * @example
1111
+ * // create a sound
1112
+ * const sound_example = new Sound([.5,.5]);
1113
+ *
1114
+ * // play the sound
1115
+ * sound_example.play();
1116
+ */
1117
+ declare class Sound {
1118
+ /** Create a sound object and cache the zzfx samples for later use
1119
+ * @param {Array} zzfxSound - Array of zzfx parameters, ex. [.5,.5]
1120
+ * @param {Number} [range=soundDefaultRange] - World space max range of sound, will not play if camera is farther away
1121
+ * @param {Number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering off
1122
+ */
1123
+ constructor(zzfxSound: any[], range?: number, taper?: number);
1124
+ /** @property {Number} - World space max range of sound, will not play if camera is farther away */
1125
+ range: number;
1126
+ /** @property {Number} - At what percentage of range should it start tapering off */
1127
+ taper: number;
1128
+ randomness: any;
1129
+ cachedSamples: number[];
1130
+ /** Play the sound
1131
+ * @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
1132
+ * @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
1133
+ * @param {Number} [pitch=1] - How much to scale pitch by (also adjusted by this.randomness)
1134
+ * @param {Number} [randomnessScale=1] - How much to scale randomness
1135
+ * @return {AudioBufferSourceNode} - The audio, can be used to stop sound later
1136
+ */
1137
+ play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number): AudioBufferSourceNode;
1138
+ /** Play the sound as a note with a semitone offset
1139
+ * @param {Number} semitoneOffset - How many semitones to offset pitch
1140
+ * @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
1141
+ * @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
1142
+ * @return {AudioBufferSourceNode} - The audio, can be used to stop sound later
1143
+ */
1144
+ playNote(semitoneOffset: number, pos?: Vector2, volume?: number): AudioBufferSourceNode;
1145
+ }
1146
+ /**
1147
+ * Music Object - Stores a zzfx music track for later use
1148
+ * <br>
1149
+ * <br><b><a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a></b>
1150
+ * @example
1151
+ * // create some music
1152
+ * const music_example = new Music(
1153
+ * [
1154
+ * [ // instruments
1155
+ * [,0,400] // simple note
1156
+ * ],
1157
+ * [ // patterns
1158
+ * [ // pattern 1
1159
+ * [ // channel 0
1160
+ * 0, -1, // instrument 0, left speaker
1161
+ * 1, 0, 9, 1 // channel notes
1162
+ * ],
1163
+ * [ // channel 1
1164
+ * 0, 1, // instrument 1, right speaker
1165
+ * 0, 12, 17, -1 // channel notes
1166
+ * ]
1167
+ * ],
1168
+ * ],
1169
+ * [0, 0, 0, 0], // sequence, play pattern 0 four times
1170
+ * 90 // BPM
1171
+ * ]);
1172
+ *
1173
+ * // play the music
1174
+ * music_example.play();
1175
+ */
1176
+ declare class Music {
1177
+ /** Create a music object and cache the zzfx music samples for later use
1178
+ * @param {Array} zzfxMusic - Array of zzfx music parameters
1179
+ */
1180
+ constructor(zzfxMusic: any[]);
1181
+ cachedSamples: any[];
1182
+ /** Play the music
1183
+ * @param {Number} [volume=1] - How much to scale volume by
1184
+ * @param {Boolean} [loop=1] - True if the music should loop when it reaches the end
1185
+ * @return {AudioBufferSourceNode} - The audio node, can be used to stop sound later
1186
+ */
1187
+ play(volume?: number, loop?: boolean): AudioBufferSourceNode;
1188
+ }
1189
+ /** Stop all queued speech
1190
+ * @memberof Audio */
1191
+ declare function speakStop(): void;
1192
+ /** Get frequency of a note on a musical scale
1193
+ * @param {Number} semitoneOffset - How many semitones away from the root note
1194
+ * @param {Number} [rootNoteFrequency=220] - Frequency at semitone offset 0
1195
+ * @return {Number} - The frequency of the note
1196
+ * @memberof Audio */
1197
+ declare function getNoteFrequency(semitoneOffset: number, rootFrequency?: number): number;
1198
+ /** Audio context used by the engine
1199
+ * @memberof Audio */
1200
+ declare let audioContext: any;
1201
+ /** Generate and play a ZzFX sound
1202
+ * <br>
1203
+ * <br><b><a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a></b>
1204
+ * @param {Array} zzfxSound - Array of ZzFX parameters, ex. [.5,.5]
1205
+ * @return {Array} - Array of audio samples
1206
+ * @memberof Audio */
1207
+ declare function zzfx(...zzfxSound: any[]): any[];
1208
+ /** Sample rate used for all ZzFX sounds
1209
+ * @default 44100
1210
+ * @memberof Audio */
1211
+ declare const zzfxR: 44100;
1212
+ /** The tile collision layer array, use setTileCollisionData and getTileCollisionData to access
1213
+ * @memberof TileCollision */
1214
+ declare let tileCollision: any[];
1215
+ /** Size of the tile collision layer
1216
+ * @type {Vector2}
1217
+ * @memberof TileCollision */
1218
+ declare let tileCollisionSize: Vector2;
1219
+ /** Set tile collision data
1220
+ * @param {Vector2} pos
1221
+ * @param {Number} [data=0]
1222
+ * @memberof TileCollision */
1223
+ declare function setTileCollisionData(pos: Vector2, data?: number): number;
1224
+ /** Get tile collision data
1225
+ * @param {Vector2} pos
1226
+ * @return {Number}
1227
+ * @memberof TileCollision */
1228
+ declare function getTileCollisionData(pos: Vector2): number;
1229
+ /**
1230
+ * Tile layer data object stores info about how to render a tile
1231
+ * @example
1232
+ * // create tile layer data with tile index 0 and random orientation and color
1233
+ * const tileIndex = 0;
1234
+ * const direction = randInt(4)
1235
+ * const mirror = randInt(2);
1236
+ * const color = randColor();
1237
+ * const data = new TileLayerData(tileIndex, direction, mirror, color);
1238
+ */
1239
+ declare class TileLayerData {
1240
+ /** Create a tile layer data object, one for each tile in a TileLayer
1241
+ * @param {Number} [tile] - The tile to use, untextured if undefined
1242
+ * @param {Number} [direction=0] - Integer direction of tile, in 90 degree increments
1243
+ * @param {Boolean} [mirror=0] - If the tile should be mirrored along the x axis
1244
+ * @param {Color} [color=new Color(1,1,1)] - Color of the tile */
1245
+ constructor(tile?: number, direction?: number, mirror?: boolean, color?: Color);
1246
+ /** @property {Number} - The tile to use, untextured if undefined */
1247
+ tile: number;
1248
+ /** @property {Number} - Integer direction of tile, in 90 degree increments */
1249
+ direction: number;
1250
+ /** @property {Boolean} - If the tile should be mirrored along the x axis */
1251
+ mirror: boolean;
1252
+ /** @property {Color} - Color of the tile */
1253
+ color: Color;
1254
+ /** Set this tile to clear, it will not be rendered */
1255
+ clear(): void;
1256
+ }
1257
+ /**
1258
+ * Tile layer object - cached rendering system for tile layers
1259
+ * <br> - Each Tile layer is rendered to an off screen canvas
1260
+ * <br> - To allow dynamic modifications, layers are rendered using canvas 2d
1261
+ * <br> - Some devices like mobile phones are limited to 4k texture resolution
1262
+ * <br> - So with 16x16 tiles this limits layers to 256x256 on mobile devices
1263
+ * @extends EngineObject
1264
+ * @example
1265
+ * // create tile collision and visible tile layer
1266
+ * initTileCollision(vec2(200,100));
1267
+ * const tileLayer = new TileLayer();
1268
+ */
1269
+ declare class TileLayer extends EngineObject {
1270
+ /** Create a tile layer object
1271
+ * @param {Vector2} [position=new Vector2()] - World space position
1272
+ * @param {Vector2} [size=objectDefaultSize] - World space size
1273
+ * @param {Vector2} [tileSize=tileSizeDefault] - Size of tiles in source pixels
1274
+ * @param {Vector2} [scale=new Vector2(1,1)] - How much to scale this layer when rendered
1275
+ * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
1276
+ */
1277
+ constructor(pos: any, size?: Vector2, tileSize?: Vector2, scale?: Vector2, renderOrder?: number);
1278
+ /** @property {HTMLCanvasElement} - The canvas used by this tile layer */
1279
+ canvas: HTMLCanvasElement;
1280
+ /** @property {CanvasRenderingContext2D} - The 2D canvas context used by this tile layer */
1281
+ context: CanvasRenderingContext2D;
1282
+ /** @property {Vector2} - How much to scale this layer when rendered */
1283
+ scale: Vector2;
1284
+ data: TileLayerData[];
1285
+ /** Set data at a given position in the array
1286
+ * @param {Vector2} position - Local position in array
1287
+ * @param {TileLayerData} data - Data to set
1288
+ * @param {Boolean} [redraw=0] - Force the tile to redraw if true */
1289
+ setData(layerPos: any, data: TileLayerData, redraw?: boolean): void;
1290
+ /** Get data at a given position in the array
1291
+ * @param {Vector2} layerPos - Local position in array
1292
+ * @return {TileLayerData} */
1293
+ getData(layerPos: Vector2): TileLayerData;
1294
+ /** Draw all the tile data to an offscreen canvas
1295
+ * - This may be slow in some browsers
1296
+ */
1297
+ redraw(): void;
1298
+ /** Call to start the redraw process
1299
+ * @param {Boolean} [clear=0] - Should it clear the canvas before drawing */
1300
+ redrawStart(clear?: boolean): void;
1301
+ savedRenderSettings: (number | HTMLCanvasElement | CanvasRenderingContext2D | Vector2)[];
1302
+ /** Call to end the redraw process */
1303
+ redrawEnd(): void;
1304
+ /** Draw the tile at a given position
1305
+ * @param {Vector2} layerPos */
1306
+ drawTileData(layerPos: Vector2): void;
1307
+ /** Draw all the tiles in this layer */
1308
+ drawAllTileData(): void;
1309
+ /** Draw directly to the 2D canvas in world space (bipass webgl)
1310
+ * @param {Vector2} pos
1311
+ * @param {Vector2} size
1312
+ * @param {Number} [angle=0]
1313
+ * @param {Boolean} [mirror=0]
1314
+ * @param {Function} drawFunction */
1315
+ drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction: Function): void;
1316
+ /** Draw a tile directly onto the layer canvas
1317
+ * @param {Vector2} pos
1318
+ * @param {Vector2} [size=new Vector2(1,1)]
1319
+ * @param {Number} [tileIndex=-1]
1320
+ * @param {Vector2} [tileSize=tileSizeDefault]
1321
+ * @param {Color} [color=new Color(1,1,1)]
1322
+ * @param {Number} [angle=0]
1323
+ * @param {Boolean} [mirror=0] */
1324
+ drawTile(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean): void;
1325
+ /** Draw a rectangle directly onto the layer canvas
1326
+ * @param {Vector2} pos
1327
+ * @param {Vector2} [size=new Vector2(1,1)]
1328
+ * @param {Color} [color=new Color(1,1,1)]
1329
+ * @param {Number} [angle=0] */
1330
+ drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
1331
+ }
1332
+ /**
1333
+ * Particle Emitter - Spawns particles with the given settings
1334
+ * @extends EngineObject
1335
+ * @example
1336
+ * // create a particle emitter
1337
+ * let pos = vec2(2,3);
1338
+ * let particleEmiter = new ParticleEmitter
1339
+ * (
1340
+ * pos, 1, 0, 500, PI, // pos, emitSize, emitTime, emitRate, emiteCone
1341
+ * 0, vec2(16), // tileIndex, tileSize
1342
+ * new Color, new Color(0,0,0), // colorStartA, colorStartB
1343
+ * new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
1344
+ * 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
1345
+ * .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
1346
+ * .5, 1 // randomness, collide, additive, randomColorLinear, renderOrder
1347
+ * );
1348
+ */
1349
+ declare class ParticleEmitter extends EngineObject {
1350
+ /** Create a particle system with the given settings
1351
+ * @param {Vector2} position - World space position of the emitter
1352
+ * @param {Number} [emitSize=0] - World space size of the emitter (float for circle diameter, vec2 for rect)
1353
+ * @param {Number} [emitTime=0] - How long to stay alive (0 is forever)
1354
+ * @param {Number} [emitRate=100] - How many particles per second to spawn, does not emit if 0
1355
+ * @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
1356
+ * @param {Number} [tileIndex=-1] - Index into tile sheet, if <0 no texture is applied
1357
+ * @param {Number} [tileSize=tileSizeDefault] - Tile size for particles
1358
+ * @param {Color} [colorStartA=new Color(1,1,1)] - Color at start of life 1, randomized between start colors
1359
+ * @param {Color} [colorStartB=new Color(1,1,1)] - Color at start of life 2, randomized between start colors
1360
+ * @param {Color} [colorEndA=new Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
1361
+ * @param {Color} [colorEndB=new Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
1362
+ * @param {Number} [particleTime=.5] - How long particles live
1363
+ * @param {Number} [sizeStart=.1] - How big are particles at start
1364
+ * @param {Number} [sizeEnd=1] - How big are particles at end
1365
+ * @param {Number} [speed=.1] - How fast are particles when spawned
1366
+ * @param {Number} [angleSpeed=.05] - How fast are particles rotating
1367
+ * @param {Number} [damping=1] - How much to dampen particle speed
1368
+ * @param {Number} [angleDamping=1] - How much to dampen particle angular speed
1369
+ * @param {Number} [gravityScale=0] - How much does gravity effect particles
1370
+ * @param {Number} [particleConeAngle=PI] - Cone for start particle angle
1371
+ * @param {Number} [fadeRate=.1] - How quick to fade in particles at start/end in percent of life
1372
+ * @param {Number} [randomness=.2] - Apply extra randomness percent
1373
+ * @param {Boolean} [collideTiles=0] - Do particles collide against tiles
1374
+ * @param {Boolean} [additive=0] - Should particles use addtive blend
1375
+ * @param {Boolean} [randomColorLinear=1] - Should color be randomized linearly or across each component
1376
+ * @param {Number} [renderOrder=0] - Render order for particles (additive is above other stuff by default)
1377
+ */
1378
+ constructor(pos: any, 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);
1379
+ /** @property {Number} - World space size of the emitter (float for circle diameter, vec2 for rect) */
1380
+ emitSize: number;
1381
+ /** @property {Number} - How long to stay alive (0 is forever) */
1382
+ emitTime: number;
1383
+ /** @property {Number} - How many particles per second to spawn, does not emit if 0 */
1384
+ emitRate: number;
1385
+ /** @property {Number} - Local angle to apply velocity to particles from emitter */
1386
+ emitConeAngle: number;
1387
+ /** @property {Color} - Color at start of life 1, randomized between start colors */
1388
+ colorStartA: Color;
1389
+ /** @property {Color} - Color at start of life 2, randomized between start colors */
1390
+ colorStartB: Color;
1391
+ /** @property {Color} - Color at end of life 1, randomized between end colors */
1392
+ colorEndA: Color;
1393
+ /** @property {Color} - Color at end of life 2, randomized between end colors */
1394
+ colorEndB: Color;
1395
+ /** @property {Boolean} - Should color be randomized linearly or across each component */
1396
+ randomColorLinear: boolean;
1397
+ /** @property {Number} - How long particles live */
1398
+ particleTime: number;
1399
+ /** @property {Number} - How big are particles at start */
1400
+ sizeStart: number;
1401
+ /** @property {Number} - How big are particles at end */
1402
+ sizeEnd: number;
1403
+ /** @property {Number} - How fast are particles when spawned */
1404
+ speed: number;
1405
+ /** @property {Number} - How fast are particles rotating */
1406
+ angleSpeed: number;
1407
+ /** @property {Number} - Cone for start particle angle */
1408
+ particleConeAngle: number;
1409
+ /** @property {Number} - How quick to fade in particles at start/end in percent of life */
1410
+ fadeRate: number;
1411
+ /** @property {Number} - Apply extra randomness percent */
1412
+ randomness: number;
1413
+ /** @property {Number} - Should particles use addtive blend */
1414
+ additive: boolean;
1415
+ /** @property {Number} - If set the partile is drawn as a trail, stretched in the drection of velocity */
1416
+ trailScale: number;
1417
+ emitTimeBuffer: number;
1418
+ /** Spawn one particle
1419
+ * @return {Particle} */
1420
+ emitParticle(): Particle;
1421
+ }
1422
+ /**
1423
+ * Particle Object - Created automatically by Particle Emitters
1424
+ * @extends EngineObject
1425
+ */
1426
+ declare class Particle extends EngineObject {
1427
+ /**
1428
+ * Create a particle with the given settings
1429
+ * @param {Vector2} position - World space position of the particle
1430
+ * @param {Number} [tileIndex=-1] - Tile to use to render, untextured if -1
1431
+ * @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
1432
+ * @param {Number} [angle=0] - Angle to rotate the particle
1433
+ */
1434
+ constructor(pos: any, tileIndex?: number, tileSize?: Vector2, angle?: number);
1435
+ }
1436
+ /** List of all medals
1437
+ * @memberof Medals */
1438
+ declare const medals: any[];
1439
+ /** Set to stop medals from being unlockable (like if cheats are enabled)
1440
+ * @memberof Medals */
1441
+ declare let medalsPreventUnlock: any;
1442
+ /** This can used to enable Newgrounds functionality
1443
+ * @type {Newgrounds}
1444
+ * @memberof Medals */
1445
+ declare let newgrounds: Newgrounds;
1446
+ declare let medalsDisplayQueue: any[];
1447
+ declare let medalsSaveName: any;
1448
+ declare let medalsDisplayTimeLast: any;
1449
+ /**
1450
+ * Medal Object - Tracks an unlockable medal
1451
+ * @example
1452
+ * // create a medal
1453
+ * const medal_example = new Medal(0, 'Example Medal', 'More info about the medal goes here.', '🎖️');
1454
+ *
1455
+ * // initialize medals
1456
+ * medalsInit('Example Game');
1457
+ *
1458
+ * // unlock the medal
1459
+ * medal_example.unlock();
1460
+ */
1461
+ declare class Medal {
1462
+ /** Create an medal object and adds it to the list of medals
1463
+ * @param {Number} id - The unique identifier of the medal
1464
+ * @param {String} name - Name of the medal
1465
+ * @param {String} [description] - Description of the medal
1466
+ * @param {String} [icon='🏆'] - Icon for the medal
1467
+ * @param {String} [src] - Image location for the medal
1468
+ */
1469
+ constructor(id: number, name: string, description?: string, icon?: string, src?: string);
1470
+ id: number;
1471
+ name: string;
1472
+ description: string;
1473
+ icon: string;
1474
+ image: HTMLImageElement;
1475
+ /** Unlocks a medal if not already unlocked */
1476
+ unlock(): void;
1477
+ unlocked: number;
1478
+ /** Render a medal
1479
+ * @param {Number} [hidePercent=0] - How much to slide the medal off screen
1480
+ */
1481
+ render(hidePercent?: number): void;
1482
+ /** Render the icon for a medal
1483
+ * @param {Number} x - Screen space X position
1484
+ * @param {Number} y - Screen space Y position
1485
+ * @param {Number} [size=medalDisplayIconSize] - Screen space size
1486
+ */
1487
+ renderIcon(x: number, y: number, size?: number): void;
1488
+ storageKey(): string;
1489
+ }
1490
+ /**
1491
+ * Newgrounds API wrapper object
1492
+ * @example
1493
+ * // create a newgrounds object, replace the app id and cipher with your own
1494
+ * const app_id = '53123:1ZuSTQ9l';
1495
+ * const cipher = 'enF0vGH@Mj/FRASKL23Q==';
1496
+ * newgrounds = new Newgrounds(app_id, cipher);
1497
+ */
1498
+ declare class Newgrounds {
1499
+ /** Create a newgrounds object
1500
+ * @param {Number} app_id - The newgrounds App ID
1501
+ * @param {String} [cipher] - The encryption Key (AES-128/Base64) */
1502
+ constructor(app_id: number, cipher?: string);
1503
+ app_id: number;
1504
+ cipher: string;
1505
+ host: string;
1506
+ cryptoJS: any;
1507
+ session_id: string | number;
1508
+ medals: any;
1509
+ scoreboards: any;
1510
+ /** Send message to unlock a medal by id
1511
+ * @param {Number} id - The medal id */
1512
+ unlockMedal(id: number): any;
1513
+ /** Send message to post score
1514
+ * @param {Number} id - The scoreboard id
1515
+ * @param {Number} value - The score value */
1516
+ postScore(id: number, value: number): any;
1517
+ /** Send message to log a view */
1518
+ logView(): any;
1519
+ /** Get scores from a scoreboard
1520
+ * @param {Number} id - The scoreboard id
1521
+ * @param {String} [user=0] - A user's id or name
1522
+ * @param {Number} [social=0] - If true, only social scores will be loaded
1523
+ * @param {Number} [skip=0] - Number of scores to skip before start
1524
+ * @param {Number} [limit=10] - Number of scores to include in the list
1525
+ * @return {Object} - The response JSON object
1526
+ */
1527
+ getScores(id: number, user?: string, social?: number, skip?: number, limit?: number): any;
1528
+ /** Send a message to call a component of the Newgrounds API
1529
+ * @param {String} component - Name of the component
1530
+ * @param {Object} [parameters=0] - Parameters to use for call
1531
+ * @param {Boolean} [async=0] - If true, don't wait for response before continuing (avoid stall)
1532
+ * @return {Object} - The response JSON object
1533
+ */
1534
+ call(component: string, parameters?: any, async?: boolean): any;
1535
+ }
1536
+ declare function CryptoJS(): any;
1537
+ /** The WebGL canvas which appears above the main canvas and below the overlay canvas
1538
+ * @type {HTMLCanvasElement}
1539
+ * @memberof WebGL */
1540
+ declare let glCanvas: HTMLCanvasElement;
1541
+ /** 2d context for glCanvas
1542
+ * @type {WebGLRenderingContext}
1543
+ * @memberof WebGL */
1544
+ declare let glContext: WebGLRenderingContext;
1545
+ /** Main tile sheet texture automatically loaded by engine
1546
+ * @type {WebGLTexture}
1547
+ * @memberof WebGL */
1548
+ declare let glTileTexture: WebGLTexture;
1549
+ declare let glActiveTexture: any;
1550
+ declare let glShader: any;
1551
+ declare let glPositionData: any;
1552
+ declare let glColorData: any;
1553
+ declare let glBatchCount: any;
1554
+ declare let glBatchAdditive: any;
1555
+ declare let glAdditive: any;
1556
+ declare const gl_ONE: 1;
1557
+ declare const gl_TRIANGLES: 4;
1558
+ declare const gl_SRC_ALPHA: 770;
1559
+ declare const gl_ONE_MINUS_SRC_ALPHA: 771;
1560
+ declare const gl_BLEND: 3042;
1561
+ declare const gl_TEXTURE_2D: 3553;
1562
+ declare const gl_UNSIGNED_BYTE: 5121;
1563
+ declare const gl_FLOAT: 5126;
1564
+ declare const gl_RGBA: 6408;
1565
+ declare const gl_NEAREST: 9728;
1566
+ declare const gl_LINEAR: 9729;
1567
+ declare const gl_TEXTURE_MAG_FILTER: 10240;
1568
+ declare const gl_TEXTURE_MIN_FILTER: 10241;
1569
+ declare const gl_TEXTURE_WRAP_S: 10242;
1570
+ declare const gl_TEXTURE_WRAP_T: 10243;
1571
+ declare const gl_COLOR_BUFFER_BIT: 16384;
1572
+ declare const gl_CLAMP_TO_EDGE: 33071;
1573
+ declare const gl_ARRAY_BUFFER: 34962;
1574
+ declare const gl_DYNAMIC_DRAW: 35048;
1575
+ declare const gl_FRAGMENT_SHADER: 35632;
1576
+ declare const gl_VERTEX_SHADER: 35633;
1577
+ declare const gl_COMPILE_STATUS: 35713;
1578
+ declare const gl_LINK_STATUS: 35714;
1579
+ declare const gl_VERTICES_PER_QUAD: 6;
1580
+ declare const gl_INDICIES_PER_VERT: 6;
1581
+ declare const gl_MAX_BATCH: number;
1582
+ declare const gl_VERTEX_BYTE_STRIDE: number;
1583
+ /** Name of engine */
1584
+ declare const engineName: "LittleJS";
1585
+ /** Version of engine */
1586
+ declare const engineVersion: "1.2.0";
1587
+ /** Frames per second to update objects
1588
+ * @default */
1589
+ declare const frameRate: 60;
1590
+ /** How many seconds each frame lasts, engine uses a fixed time step
1591
+ * @default 1/60 */
1592
+ declare const timeDelta: number;
1593
+ /** Array containing all engine objects */
1594
+ declare let engineObjects: any[];
1595
+ /** Array containing only objects that are set to collide with other objects this frame (for optimization) */
1596
+ declare let engineObjectsCollide: any[];
1597
+ /** Current update frame, used to calculate time */
1598
+ declare let frame: number;
1599
+ /** Current engine time since start in seconds, derived from frame */
1600
+ declare let time: number;
1601
+ /** Actual clock time since start in seconds (not affected by pause or frame rate clamping) */
1602
+ declare let timeReal: number;
1603
+ /** Is the game paused? Causes time and objects to not be updated. */
1604
+ declare let paused: number;
1605
+ declare let frameTimeLastMS: number;
1606
+ declare let frameTimeBufferMS: number;
1607
+ declare let tileImageSize: any;
1608
+ declare let tileImageFixBleed: any;
1609
+ declare let averageFPS: any;
1610
+ declare let drawCount: any;
1611
+ declare const styleBody: string;
1612
+ declare const styleCanvas: "position:absolute";