littlejsengine 1.8.4 → 1.8.6

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