littlejsengine 1.8.1 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,156 +1,188 @@
1
1
  declare module "littlejs.esm" {
2
- /** Set position of camera in world space
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
3
113
  * @param {Vector2} pos
4
- * @memberof Settings */
5
- export function setCameraPos(pos: Vector2): void;
6
- /** Set scale of camera in world space
7
- * @param {Number} scale
8
- * @memberof Settings */
9
- export function setCameraScale(scale: number): void;
10
- /** Set max size of the canvas
11
- * @param {Vector2} size
12
- * @memberof Settings */
13
- export function setCanvasMaxSize(size: Vector2): void;
14
- /** Set fixed size of the canvas
15
- * @param {Vector2} size
16
- * @memberof Settings */
17
- export function setCanvasFixedSize(size: Vector2): void;
18
- /** Disables anti aliasing for pixel art if true
19
- * @param {Boolean} pixelated
20
- * @memberof Settings */
21
- export function setCanvasPixelated(pixelated: boolean): void;
22
- /** Set default font used for text rendering
23
- * @param {String} font
24
- * @memberof Settings */
25
- export function setFontDefault(font: string): void;
26
- /** Set if webgl rendering is enabled
27
- * @param {Boolean} enable
28
- * @memberof Settings */
29
- export function setGlEnable(enable: boolean): void;
30
- /** Set to not composite the WebGL canvas
31
- * @param {Boolean} overlay
32
- * @memberof Settings */
33
- export function setGlOverlay(overlay: boolean): void;
34
- /** Set default size of tiles in pixels
35
- * @param {Vector2} size
36
- * @memberof Settings */
37
- export function setTileSizeDefault(size: Vector2): void;
38
- /** Set to prevent tile bleeding from neighbors in pixels
39
- * @param {Number} scale
40
- * @memberof Settings */
41
- export function setTileFixBleedScale(scale: number): void;
42
- /** Set if collisions between objects are enabled
43
- * @param {Boolean} enable
44
- * @memberof Settings */
45
- export function setEnablePhysicsSolver(enable: boolean): void;
46
- /** Set default object mass for collison calcuations
47
- * @param {Number} mass
48
- * @memberof Settings */
49
- export function setObjectDefaultMass(mass: number): void;
50
- /** Set how much to slow velocity by each frame
51
- * @param {Number} damping
52
- * @memberof Settings */
53
- export function setObjectDefaultDamping(damp: any): void;
54
- /** Set how much to slow angular velocity each frame
55
- * @param {Number} damping
56
- * @memberof Settings */
57
- export function setObjectDefaultAngleDamping(damp: any): void;
58
- /** Set how much to bounce when a collision occur
59
- * @param {Number} elasticity
60
- * @memberof Settings */
61
- export function setObjectDefaultElasticity(elasticity: number): void;
62
- /** Set how much to slow when touching
63
- * @param {Number} friction
64
- * @memberof Settings */
65
- export function setObjectDefaultFriction(friction: number): void;
66
- /** Set max speed to avoid fast objects missing collisions
67
- * @param {Number} speed
68
- * @memberof Settings */
69
- export function setObjectMaxSpeed(speed: number): void;
70
- /** Set how much gravity to apply to objects along the Y axis
71
- * @param {Number} gravity
72
- * @memberof Settings */
73
- export function setGravity(g: any): void;
74
- /** Set to scales emit rate of particles
75
- * @param {Number} scale
76
- * @memberof Settings */
77
- export function setParticleEmitRateScale(scale: number): void;
78
- /** Set if gamepads are enabled
79
- * @param {Boolean} enable
80
- * @memberof Settings */
81
- export function setGamepadsEnable(enable: boolean): void;
82
- /** Set if the dpad input is also routed to the left analog stick
83
- * @param {Boolean} enable
84
- * @memberof Settings */
85
- export function setGamepadDirectionEmulateStick(enable: boolean): void;
86
- /** Set if true the WASD keys are also routed to the direction keys
87
- * @param {Boolean} enable
88
- * @memberof Settings */
89
- export function setInputWASDEmulateDirection(enable: boolean): void;
90
- /** Set if touch gamepad should appear on mobile devices
91
- * @param {Boolean} enable
92
- * @memberof Settings */
93
- export function setTouchGamepadEnable(enable: boolean): void;
94
- /** Set if touch gamepad should be analog stick or 8 way dpad
95
- * @param {Boolean} analog
96
- * @memberof Settings */
97
- export function setTouchGamepadAnalog(analog: boolean): void;
98
- /** Set size of virutal gamepad for touch devices in pixels
99
- * @param {Number} size
100
- * @memberof Settings */
101
- export function setTouchGamepadSize(size: number): void;
102
- /** Set transparency of touch gamepad overlay
103
- * @param {Number} alpha
104
- * @memberof Settings */
105
- export function setTouchGamepadAlpha(alpha: number): void;
106
- /** Set to allow vibration hardware if it exists
107
- * @param {Boolean} enable
108
- * @memberof Settings */
109
- export function setVibrateEnable(enable: boolean): void;
110
- /** Set to disable all audio code
111
- * @param {Boolean} enable
112
- * @memberof Settings */
113
- export function setSoundEnable(enable: boolean): void;
114
- /** Set volume scale to apply to all sound, music and speech
115
- * @param {Number} volume
116
- * @memberof Settings */
117
- export function setSoundVolume(volume: number): void;
118
- /** Set default range where sound no longer plays
119
- * @param {Number} range
120
- * @memberof Settings */
121
- export function setSoundDefaultRange(range: number): void;
122
- /** Set default range percent to start tapering off sound
123
- * @param {Number} taper
124
- * @memberof Settings */
125
- export function setSoundDefaultTaper(taper: number): void;
126
- /** Set how long to show medals for in seconds
127
- * @param {Number} time
128
- * @memberof Settings */
129
- export function setMedalDisplayTime(time: number): void;
130
- /** Set how quickly to slide on/off medals in seconds
131
- * @param {Number} time
132
- * @memberof Settings */
133
- export function setMedalDisplaySlideTime(time: number): void;
134
- /** Set size of medal display
135
- * @param {Vector2} size
136
- * @memberof Settings */
137
- export function setMedalDisplaySize(size: Vector2): void;
138
- /** Set size of icon in medal display
139
- * @param {Number} size
140
- * @memberof Settings */
141
- export function setMedalDisplayIconSize(size: number): void;
142
- /** Set to stop medals from being unlockable
143
- * @param {Boolean} preventUnlock
144
- * @memberof Settings */
145
- export function setMedalsPreventUnlock(preventUnlock: boolean): void;
146
- /** Set if watermark with FPS should be shown
147
- * @param {Boolean} show
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]
148
119
  * @memberof Debug */
149
- export function setShowWatermark(show: boolean): void;
150
- /** Set key code used to toggle debug mode, Esc by default
151
- * @param {Number} key
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]
152
127
  * @memberof Debug */
153
- export function setDebugKey(key: number): void;
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;
154
186
  /** The max size of the canvas, centered if window is larger
155
187
  * @type {Vector2}
156
188
  * @default Vector2(1920,1200)
@@ -227,21 +259,6 @@ declare module "littlejs.esm" {
227
259
  * @default
228
260
  * @memberof Settings */
229
261
  export let particleEmitRateScale: number;
230
- /**
231
- * LittleJS Engine Settings
232
- * - All settings for the engine are here
233
- * @namespace Settings
234
- */
235
- /** Position of camera in world space
236
- * @type {Vector2}
237
- * @default Vector2()
238
- * @memberof Settings */
239
- export let cameraPos: Vector2;
240
- /** Scale of camera in world space
241
- * @type {Number}
242
- * @default
243
- * @memberof Settings */
244
- export let cameraScale: number;
245
262
  /** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
246
263
  * @type {Boolean}
247
264
  * @default
@@ -334,89 +351,158 @@ declare module "littlejs.esm" {
334
351
  * @default
335
352
  * @memberof Settings */
336
353
  export let medalDisplayIconSize: number;
337
- /**
338
- * LittleJS Debug System
339
- * - Press Esc to show debug overlay with mouse pick
340
- * - Number keys toggle debug functions
341
- * - +/- apply time scale
342
- * - Debug primitive rendering
343
- * - Save a 2d canvas as a png image
344
- * @namespace Debug
345
- */
346
- /** True if debug is enabled
347
- * @type {Boolean}
348
- * @default
349
- * @memberof Debug */
350
- export const debug: boolean;
351
- /** True if watermark with FPS should be shown, false in release builds
352
- * @type {Boolean}
353
- * @default
354
- * @memberof Debug */
355
- export let showWatermark: boolean;
356
- /** Asserts if the experssion is false, does not do anything in release builds
357
- * @param {Boolean} assertion
358
- * @param {Object} output
359
- * @memberof Debug */
360
- export function ASSERT(...assert: any[]): void;
361
- /** Draw a debug rectangle in world space
362
- * @param {Vector2} pos
363
- * @param {Vector2} [size=Vector2()]
364
- * @param {String} [color='#fff']
365
- * @param {Number} [time=0]
366
- * @param {Number} [angle=0]
367
- * @param {Boolean} [fill=false]
368
- * @memberof Debug */
369
- export function debugRect(pos: Vector2, size?: Vector2, color?: string, time?: number, angle?: number, fill?: boolean): void;
370
- /** Draw a debug circle in world space
371
- * @param {Vector2} pos
372
- * @param {Number} [radius=0]
373
- * @param {String} [color='#fff']
374
- * @param {Number} [time=0]
375
- * @param {Boolean} [fill=false]
376
- * @memberof Debug */
377
- export function debugCircle(pos: Vector2, radius?: number, color?: string, time?: number, fill?: boolean): void;
378
- /** Draw a debug point in world space
379
- * @param {Vector2} pos
380
- * @param {String} [color='#fff']
381
- * @param {Number} [time=0]
382
- * @param {Number} [angle=0]
383
- * @memberof Debug */
384
- export function debugPoint(pos: Vector2, color?: string, time?: number, angle?: number): void;
385
- /** Draw a debug line in world space
386
- * @param {Vector2} posA
387
- * @param {Vector2} posB
388
- * @param {String} [color='#fff']
389
- * @param {Number} [thickness=.1]
390
- * @param {Number} [time=0]
391
- * @memberof Debug */
392
- export function debugLine(posA: Vector2, posB: Vector2, color?: string, thickness?: number, time?: number): void;
393
- /** Draw a debug axis aligned bounding box in world space
394
- * @param {Vector2} posA
395
- * @param {Vector2} sizeA
396
- * @param {Vector2} posB
397
- * @param {Vector2} sizeB
398
- * @param {String} [color='#fff']
399
- * @memberof Debug */
400
- export function debugAABB(pA: any, sA: any, pB: any, sB: any, color?: string): void;
401
- /** Draw a debug axis aligned bounding box in world space
402
- * @param {String} text
354
+ /** Set position of camera in world space
403
355
  * @param {Vector2} pos
404
- * @param {Number} [size=1]
405
- * @param {String} [color='#fff']
406
- * @param {Number} [time=0]
407
- * @param {Number} [angle=0]
408
- * @param {String} [font='monospace']
409
- * @memberof Debug */
410
- export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
411
- /** Clear all debug primitives in the list
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
412
500
  * @memberof Debug */
413
- export function debugClear(): void;
414
- /** Save a canvas to disk
415
- * @param {HTMLCanvasElement} canvas
416
- * @param {String} [filename]
417
- * @param {String} [type='image/png']
501
+ export function setShowWatermark(show: boolean): void;
502
+ /** Set key code used to toggle debug mode, Esc by default
503
+ * @param {Number} key
418
504
  * @memberof Debug */
419
- export function debugSaveCanvas(canvas: HTMLCanvasElement, filename?: string, type?: string): void;
505
+ export function setDebugKey(key: number): void;
420
506
  /**
421
507
  * LittleJS Utility Classes and Functions
422
508
  * - General purpose math library
@@ -871,129 +957,6 @@ declare module "littlejs.esm" {
871
957
  * @memberof Utilities
872
958
  */
873
959
  export function hsl(h?: number, s?: number, l?: number, a?: number): Color;
874
- /**
875
- * LittleJS Object System
876
- */
877
- /**
878
- * LittleJS Object Base Object Class
879
- * - Top level object class used by the engine
880
- * - Automatically adds self to object list
881
- * - Will be updated and rendered each frame
882
- * - Renders as a sprite from a tilesheet by default
883
- * - Can have color and addtive color applied
884
- * - 2D Physics and collision system
885
- * - Sorted by renderOrder
886
- * - Objects can have children attached
887
- * - Parents are updated before children, and set child transform
888
- * - Call destroy() to get rid of objects
889
- *
890
- * The physics system used by objects is simple and fast with some caveats...
891
- * - Collision uses the axis aligned size, the object's rotation angle is only for rendering
892
- * - Objects are guaranteed to not intersect tile collision from physics
893
- * - If an object starts or is moved inside tile collision, it will not collide with that tile
894
- * - Collision for objects can be set to be solid to block other objects
895
- * - Objects may get pushed into overlapping other solid objects, if so they will push away
896
- * - Solid objects are more performance intensive and should be used sparingly
897
- * @example
898
- * // create an engine object, normally you would first extend the class with your own
899
- * const pos = vec2(2,3);
900
- * const object = new EngineObject(pos);
901
- */
902
- export class EngineObject {
903
- /** Create an engine object and adds it to the list of objects
904
- * @param {Vector2} [pos=Vector2()] - World space position of the object
905
- * @param {Vector2} [size=Vector2(1,1)] - World space size of the object
906
- * @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
907
- * @param {Number} [angle=0] - Angle the object is rotated by
908
- * @param {Color} [color=Color()] - Color to apply to tile when rendered
909
- * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
910
- */
911
- constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
912
- /** @property {Vector2} - World space position of the object */
913
- pos: Vector2;
914
- /** @property {Vector2} - World space width and height of the object */
915
- size: Vector2;
916
- /** @property {TileInfo} - Tile info to render object (undefined is untextured) */
917
- tileInfo: TileInfo;
918
- /** @property {Number} - Angle to rotate the object */
919
- angle: number;
920
- /** @property {Color} - Color to apply when rendered */
921
- color: Color;
922
- /** @property {Number} [mass=objectDefaultMass] - How heavy the object is, static if 0 */
923
- mass: number;
924
- /** @property {Number} [damping=objectDefaultDamping] - How much to slow down velocity each frame (0-1) */
925
- damping: number;
926
- /** @property {Number} [angleDamping=objectDefaultAngleDamping] - How much to slow down rotation each frame (0-1) */
927
- angleDamping: number;
928
- /** @property {Number} [elasticity=objectDefaultElasticity] - How bouncy the object is when colliding (0-1) */
929
- elasticity: number;
930
- /** @property {Number} [friction=objectDefaultFriction] - How much friction to apply when sliding (0-1) */
931
- friction: number;
932
- /** @property {Number} [gravityScale=1] - How much to scale gravity by for this object */
933
- gravityScale: number;
934
- /** @property {Number} [renderOrder=0] - Objects are sorted by render order */
935
- renderOrder: number;
936
- /** @property {Vector2} [velocity=Vector2()] - Velocity of the object */
937
- velocity: Vector2;
938
- /** @property {Number} [angleVelocity=0] - Angular velocity of the object */
939
- angleVelocity: number;
940
- spawnTime: number;
941
- children: any[];
942
- collideTiles: number;
943
- /** Update the object transform and physics, called automatically by engine once each frame */
944
- update(): void;
945
- groundObject: any;
946
- /** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
947
- render(): void;
948
- /** Destroy this object, destroy it's children, detach it's parent, and mark it for removal */
949
- destroy(): void;
950
- destroyed: number;
951
- /** Called to check if a tile collision should be resolved
952
- * @param {Number} tileData - the value of the tile at the position
953
- * @param {Vector2} pos - tile where the collision occured
954
- * @return {Boolean} - true if the collision should be resolved */
955
- collideWithTile(tileData: number, pos: Vector2): boolean;
956
- /** Called to check if a tile raycast hit
957
- * @param {Number} tileData - the value of the tile at the position
958
- * @param {Vector2} pos - tile where the raycast is
959
- * @return {Boolean} - true if the raycast should hit */
960
- collideWithTileRaycast(tileData: number, pos: Vector2): boolean;
961
- /** Called to check if a object collision should be resolved
962
- * @param {EngineObject} object - the object to test against
963
- * @return {Boolean} - true if the collision should be resolved
964
- */
965
- collideWithObject(object: EngineObject): boolean;
966
- /** How long since the object was created
967
- * @return {Number} */
968
- getAliveTime(): number;
969
- /** Apply acceleration to this object (adjust velocity, not affected by mass)
970
- * @param {Vector2} acceleration */
971
- applyAcceleration(acceleration: Vector2): void;
972
- /** Apply force to this object (adjust velocity, affected by mass)
973
- * @param {Vector2} force */
974
- applyForce(force: Vector2): void;
975
- /** Get the direction of the mirror
976
- * @return {Number} -1 if this.mirror is true, or 1 if not mirrored */
977
- getMirrorSign(): number;
978
- /** Attaches a child to this with a given local transform
979
- * @param {EngineObject} child
980
- * @param {Vector2} [localPos=Vector2()]
981
- * @param {Number} [localAngle=0] */
982
- addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
983
- /** Removes a child from this one
984
- * @param {EngineObject} child */
985
- removeChild(child: EngineObject): void;
986
- /** Set how this object collides
987
- * @param {Boolean} [collideSolidObjects=1] - Does it collide with solid objects
988
- * @param {Boolean} [isSolid=1] - Does it collide with and block other objects (expensive in large numbers)
989
- * @param {Boolean} [collideTiles=1] - Does it collide with the tile collision */
990
- setCollision(collideSolidObjects?: boolean, isSolid?: boolean, collideTiles?: boolean): void;
991
- collideSolidObjects: boolean;
992
- isSolid: boolean;
993
- /** Returns string containg info about this object for debugging
994
- * @return {String} */
995
- toString(): string;
996
- }
997
960
  /** Array containing texture info for batch rendering system
998
961
  * @type {Array}
999
962
  * @memberof Draw */
@@ -1114,8 +1077,9 @@ declare module "littlejs.esm" {
1114
1077
  * @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
1115
1078
  * @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
1116
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
1117
1081
  * @memberof Draw */
1118
- export function drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean): void;
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;
1119
1083
  /** Draw colored rect centered on pos
1120
1084
  * @param {Vector2} pos
1121
1085
  * @param {Vector2} [size=Vector2(1,1)]
@@ -1123,8 +1087,9 @@ declare module "littlejs.esm" {
1123
1087
  * @param {Number} [angle=0]
1124
1088
  * @param {Boolean} [useWebGL=glEnable]
1125
1089
  * @param {Boolean} [screenSpace=0]
1090
+ * @param {CanvasRenderingContext2D} [context]
1126
1091
  * @memberof Draw */
1127
- export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean): void;
1092
+ export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
1128
1093
  /** Draw colored line between two points
1129
1094
  * @param {Vector2} posA
1130
1095
  * @param {Vector2} posB
@@ -1132,23 +1097,25 @@ declare module "littlejs.esm" {
1132
1097
  * @param {Color} [color=Color()]
1133
1098
  * @param {Boolean} [useWebGL=glEnable]
1134
1099
  * @param {Boolean} [screenSpace=0]
1100
+ * @param {CanvasRenderingContext2D} [context]
1135
1101
  * @memberof Draw */
1136
- export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean, screenSpace?: boolean): void;
1102
+ export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
1137
1103
  /** Draw directly to a 2d canvas context in world space
1138
1104
  * @param {Vector2} pos
1139
1105
  * @param {Vector2} size
1140
1106
  * @param {Number} angle
1141
1107
  * @param {Boolean} mirror
1142
1108
  * @param {Function} drawFunction
1143
- * @param {CanvasRenderingContext2D} [context=mainContext]
1144
1109
  * @param {Boolean} [screenSpace=0]
1110
+ * @param {CanvasRenderingContext2D} [context=mainContext]
1145
1111
  * @memberof Draw */
1146
- export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, context?: CanvasRenderingContext2D, screenSpace?: boolean): void;
1112
+ export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
1147
1113
  /** Enable normal or additive blend mode
1148
1114
  * @param {Boolean} [additive=0]
1149
1115
  * @param {Boolean} [useWebGL=glEnable]
1116
+ * @param {CanvasRenderingContext2D} [context=mainContext]
1150
1117
  * @memberof Draw */
1151
- export function setBlendMode(additive?: boolean, useWebGL?: boolean): void;
1118
+ export function setBlendMode(additive?: boolean, useWebGL?: boolean, context?: CanvasRenderingContext2D): void;
1152
1119
  /** Draw text on overlay canvas in screen space
1153
1120
  * Automatically splits new lines into rows
1154
1121
  * @param {String} text
@@ -1222,6 +1189,52 @@ declare module "littlejs.esm" {
1222
1189
  /** Toggle fullsceen mode
1223
1190
  * @memberof Draw */
1224
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 set 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;
1225
1238
  /**
1226
1239
  * LittleJS Input System
1227
1240
  * - Tracks keyboard down, pressed, and released
@@ -1489,6 +1502,129 @@ declare module "littlejs.esm" {
1489
1502
  * @return {AudioBufferSourceNode} - The audio node of the sound played
1490
1503
  * @memberof Audio */
1491
1504
  export function zzfx(...zzfxSound: any[]): AudioBufferSourceNode;
1505
+ /**
1506
+ * LittleJS Object System
1507
+ */
1508
+ /**
1509
+ * LittleJS Object Base Object Class
1510
+ * - Top level object class used by the engine
1511
+ * - Automatically adds self to object list
1512
+ * - Will be updated and rendered each frame
1513
+ * - Renders as a sprite from a tilesheet by default
1514
+ * - Can have color and addtive color applied
1515
+ * - 2D Physics and collision system
1516
+ * - Sorted by renderOrder
1517
+ * - Objects can have children attached
1518
+ * - Parents are updated before children, and set child transform
1519
+ * - Call destroy() to get rid of objects
1520
+ *
1521
+ * The physics system used by objects is simple and fast with some caveats...
1522
+ * - Collision uses the axis aligned size, the object's rotation angle is only for rendering
1523
+ * - Objects are guaranteed to not intersect tile collision from physics
1524
+ * - If an object starts or is moved inside tile collision, it will not collide with that tile
1525
+ * - Collision for objects can be set to be solid to block other objects
1526
+ * - Objects may get pushed into overlapping other solid objects, if so they will push away
1527
+ * - Solid objects are more performance intensive and should be used sparingly
1528
+ * @example
1529
+ * // create an engine object, normally you would first extend the class with your own
1530
+ * const pos = vec2(2,3);
1531
+ * const object = new EngineObject(pos);
1532
+ */
1533
+ export class EngineObject {
1534
+ /** Create an engine object and adds it to the list of objects
1535
+ * @param {Vector2} [pos=Vector2()] - World space position of the object
1536
+ * @param {Vector2} [size=Vector2(1,1)] - World space size of the object
1537
+ * @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
1538
+ * @param {Number} [angle=0] - Angle the object is rotated by
1539
+ * @param {Color} [color=Color()] - Color to apply to tile when rendered
1540
+ * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
1541
+ */
1542
+ constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
1543
+ /** @property {Vector2} - World space position of the object */
1544
+ pos: Vector2;
1545
+ /** @property {Vector2} - World space width and height of the object */
1546
+ size: Vector2;
1547
+ /** @property {TileInfo} - Tile info to render object (undefined is untextured) */
1548
+ tileInfo: TileInfo;
1549
+ /** @property {Number} - Angle to rotate the object */
1550
+ angle: number;
1551
+ /** @property {Color} - Color to apply when rendered */
1552
+ color: Color;
1553
+ /** @property {Number} [mass=objectDefaultMass] - How heavy the object is, static if 0 */
1554
+ mass: number;
1555
+ /** @property {Number} [damping=objectDefaultDamping] - How much to slow down velocity each frame (0-1) */
1556
+ damping: number;
1557
+ /** @property {Number} [angleDamping=objectDefaultAngleDamping] - How much to slow down rotation each frame (0-1) */
1558
+ angleDamping: number;
1559
+ /** @property {Number} [elasticity=objectDefaultElasticity] - How bouncy the object is when colliding (0-1) */
1560
+ elasticity: number;
1561
+ /** @property {Number} [friction=objectDefaultFriction] - How much friction to apply when sliding (0-1) */
1562
+ friction: number;
1563
+ /** @property {Number} [gravityScale=1] - How much to scale gravity by for this object */
1564
+ gravityScale: number;
1565
+ /** @property {Number} [renderOrder=0] - Objects are sorted by render order */
1566
+ renderOrder: number;
1567
+ /** @property {Vector2} [velocity=Vector2()] - Velocity of the object */
1568
+ velocity: Vector2;
1569
+ /** @property {Number} [angleVelocity=0] - Angular velocity of the object */
1570
+ angleVelocity: number;
1571
+ spawnTime: number;
1572
+ children: any[];
1573
+ collideTiles: number;
1574
+ /** Update the object transform and physics, called automatically by engine once each frame */
1575
+ update(): void;
1576
+ groundObject: any;
1577
+ /** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
1578
+ render(): void;
1579
+ /** Destroy this object, destroy it's children, detach it's parent, and mark it for removal */
1580
+ destroy(): void;
1581
+ destroyed: number;
1582
+ /** Called to check if a tile collision should be resolved
1583
+ * @param {Number} tileData - the value of the tile at the position
1584
+ * @param {Vector2} pos - tile where the collision occured
1585
+ * @return {Boolean} - true if the collision should be resolved */
1586
+ collideWithTile(tileData: number, pos: Vector2): boolean;
1587
+ /** Called to check if a tile raycast hit
1588
+ * @param {Number} tileData - the value of the tile at the position
1589
+ * @param {Vector2} pos - tile where the raycast is
1590
+ * @return {Boolean} - true if the raycast should hit */
1591
+ collideWithTileRaycast(tileData: number, pos: Vector2): boolean;
1592
+ /** Called to check if a object collision should be resolved
1593
+ * @param {EngineObject} object - the object to test against
1594
+ * @return {Boolean} - true if the collision should be resolved
1595
+ */
1596
+ collideWithObject(object: EngineObject): boolean;
1597
+ /** How long since the object was created
1598
+ * @return {Number} */
1599
+ getAliveTime(): number;
1600
+ /** Apply acceleration to this object (adjust velocity, not affected by mass)
1601
+ * @param {Vector2} acceleration */
1602
+ applyAcceleration(acceleration: Vector2): void;
1603
+ /** Apply force to this object (adjust velocity, affected by mass)
1604
+ * @param {Vector2} force */
1605
+ applyForce(force: Vector2): void;
1606
+ /** Get the direction of the mirror
1607
+ * @return {Number} -1 if this.mirror is true, or 1 if not mirrored */
1608
+ getMirrorSign(): number;
1609
+ /** Attaches a child to this with a given local transform
1610
+ * @param {EngineObject} child
1611
+ * @param {Vector2} [localPos=Vector2()]
1612
+ * @param {Number} [localAngle=0] */
1613
+ addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
1614
+ /** Removes a child from this one
1615
+ * @param {EngineObject} child */
1616
+ removeChild(child: EngineObject): void;
1617
+ /** Set how this object collides
1618
+ * @param {Boolean} [collideSolidObjects=1] - Does it collide with solid objects
1619
+ * @param {Boolean} [isSolid=1] - Does it collide with and block other objects (expensive in large numbers)
1620
+ * @param {Boolean} [collideTiles=1] - Does it collide with the tile collision */
1621
+ setCollision(collideSolidObjects?: boolean, isSolid?: boolean, collideTiles?: boolean): void;
1622
+ collideSolidObjects: boolean;
1623
+ isSolid: boolean;
1624
+ /** Returns string containg info about this object for debugging
1625
+ * @return {String} */
1626
+ toString(): string;
1627
+ }
1492
1628
  /**
1493
1629
  * LittleJS Tile Layer System
1494
1630
  * - Caches arrays of tiles to off screen canvas for fast rendering
@@ -1864,140 +2000,4 @@ declare module "littlejs.esm" {
1864
2000
  */
1865
2001
  call(component: string, parameters?: any, async?: boolean): any;
1866
2002
  }
1867
- /**
1868
- * LittleJS WebGL Interface
1869
- * - All webgl used by the engine is wrapped up here
1870
- * - For normal stuff you won't need to see or call anything in this file
1871
- * - For advanced stuff there are helper functions to create shaders, textures, etc
1872
- * - Can be disabled with glEnable to revert to 2D canvas rendering
1873
- * - Batches sprite rendering on GPU for incredibly fast performance
1874
- * - Sprite transform math is done in the shader where possible
1875
- * - Supports shadertoy style post processing shaders
1876
- * @namespace WebGL
1877
- */
1878
- /** The WebGL canvas which appears above the main canvas and below the overlay canvas
1879
- * @type {HTMLCanvasElement}
1880
- * @memberof WebGL */
1881
- export let glCanvas: HTMLCanvasElement;
1882
- /** 2d context for glCanvas
1883
- * @type {WebGLRenderingContext}
1884
- * @memberof WebGL */
1885
- export let glContext: WebGLRenderingContext;
1886
- /** Set the WebGl blend mode, normally you should call setBlendMode instead
1887
- * @param {Boolean} [additive=0]
1888
- * @memberof WebGL */
1889
- export function glSetBlendMode(additive?: boolean): void;
1890
- /** Set the WebGl texture, called automatically if using multiple textures
1891
- * - This may also flush the gl buffer resulting in more draw calls and worse performance
1892
- * @param {WebGLTexture} texture
1893
- * @memberof WebGL */
1894
- export function glSetTexture(texture: WebGLTexture): void;
1895
- /** Compile WebGL shader of the given type, will throw errors if in debug mode
1896
- * @param {String} source
1897
- * @param type
1898
- * @return {WebGLShader}
1899
- * @memberof WebGL */
1900
- export function glCompileShader(source: string, type: any): WebGLShader;
1901
- /** Create WebGL program with given shaders
1902
- * @param {WebGLShader} vsSource
1903
- * @param {WebGLShader} fsSource
1904
- * @return {WebGLProgram}
1905
- * @memberof WebGL */
1906
- export function glCreateProgram(vsSource: WebGLShader, fsSource: WebGLShader): WebGLProgram;
1907
- /** Create WebGL texture from an image and set the texture settings
1908
- * @param {Image} image
1909
- * @return {WebGLTexture}
1910
- * @memberof WebGL */
1911
- export function glCreateTexture(image: new (width?: number, height?: number) => HTMLImageElement): WebGLTexture;
1912
- /** Set up a post processing shader
1913
- * @param {String} shaderCode
1914
- * @param {Boolean} includeOverlay
1915
- * @memberof WebGL */
1916
- export function glInitPostProcess(shaderCode: string, includeOverlay: boolean): void;
1917
- /**
1918
- * LittleJS - The Tiny JavaScript Game Engine That Can!
1919
- * MIT License - Copyright 2021 Frank Force
1920
- *
1921
- * Engine Features
1922
- * - Object oriented system with base class engine object
1923
- * - Base class object handles update, physics, collision, rendering, etc
1924
- * - Engine helper classes and functions like Vector2, Color, and Timer
1925
- * - Super fast rendering system for tile sheets
1926
- * - Sound effects audio with zzfx and music with zzfxm
1927
- * - Input processing system with gamepad and touchscreen support
1928
- * - Tile layer rendering and collision system
1929
- * - Particle effect system
1930
- * - Medal system tracks and displays achievements
1931
- * - Debug tools and debug rendering system
1932
- * - Post processing effects
1933
- * - Call engineInit() to start it up!
1934
- * @namespace Engine
1935
- */
1936
- /** Name of engine
1937
- * @type {String}
1938
- * @default
1939
- * @memberof Engine */
1940
- export const engineName: string;
1941
- /** Version of engine
1942
- * @type {String}
1943
- * @default
1944
- * @memberof Engine */
1945
- export const engineVersion: string;
1946
- /** Frames per second to update objects
1947
- * @type {Number}
1948
- * @default
1949
- * @memberof Engine */
1950
- export const frameRate: number;
1951
- /** How many seconds each frame lasts, engine uses a fixed time step
1952
- * @type {Number}
1953
- * @default 1/60
1954
- * @memberof Engine */
1955
- export const timeDelta: number;
1956
- /** Array containing all engine objects
1957
- * @type {Array}
1958
- * @memberof Engine */
1959
- export let engineObjects: any[];
1960
- /** Current update frame, used to calculate time
1961
- * @type {Number}
1962
- * @memberof Engine */
1963
- export let frame: number;
1964
- /** Current engine time since start in seconds, derived from frame
1965
- * @type {Number}
1966
- * @memberof Engine */
1967
- export let time: number;
1968
- /** Actual clock time since start in seconds (not affected by pause or frame rate clamping)
1969
- * @type {Number}
1970
- * @memberof Engine */
1971
- export let timeReal: number;
1972
- /** Is the game paused? Causes time and objects to not be updated
1973
- * @type {Boolean}
1974
- * @default 0
1975
- * @memberof Engine */
1976
- export let paused: boolean;
1977
- /** Set if game is paused
1978
- * @param {Boolean} paused
1979
- * @memberof Engine */
1980
- export function setPaused(_paused: any): void;
1981
- /** Start up LittleJS engine with your callback functions
1982
- * @param {Function} gameInit - Called once after the engine starts up, setup the game
1983
- * @param {Function} gameUpdate - Called every frame at 60 frames per second, handle input and update the game state
1984
- * @param {Function} gameUpdatePost - Called after physics and objects are updated, setup camera and prepare for render
1985
- * @param {Function} gameRender - Called before objects are rendered, draw any background effects that appear behind objects
1986
- * @param {Function} gameRenderPost - Called after objects are rendered, draw effects or hud that appear above all objects
1987
- * @param {String} [imageSources='tiles.png'] - Image to load
1988
- * @memberof Engine */
1989
- export function engineInit(gameInit: Function, gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?: string): void;
1990
- /** Update each engine object, remove destroyed objects, and update time
1991
- * @memberof Engine */
1992
- export function engineObjectsUpdate(): void;
1993
- /** Destroy and remove all objects
1994
- * @memberof Engine */
1995
- export function engineObjectsDestroy(): void;
1996
- /** Triggers a callback for each object within a given area
1997
- * @param {Vector2} [pos] - Center of test area
1998
- * @param {Number} [size] - Radius of circle if float, rectangle size if Vector2
1999
- * @param {Function} [callbackFunction] - Calls this function on every object that passes the test
2000
- * @param {Array} [objects=engineObjects] - List of objects to check
2001
- * @memberof Engine */
2002
- export function engineObjectsCallback(pos?: Vector2, size?: number, callbackFunction?: Function, objects?: any[]): void;
2003
2003
  }