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