littlejsengine 1.6.4 → 1.6.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -41
- package/build/littlejs.d.ts +160 -165
- package/build/littlejs.esm.js +451 -367
- package/build/littlejs.esm.min.js +1 -1
- package/build/littlejs.js +408 -314
- package/build/littlejs.min.js +1 -1
- package/build/littlejs.release.js +2573 -2470
- package/examples/breakout/game.js +5 -1
- package/examples/breakout/index.html +5 -5
- package/examples/breakoutTutorial/README.md +6 -6
- package/examples/breakoutTutorial/game.js +3 -0
- package/examples/breakoutTutorial/index.html +3 -3
- package/examples/electron/build.js +105 -0
- package/examples/electron/game.js +4 -2
- package/examples/electron/index.html +13 -2
- package/examples/electron/package.json +5 -3
- package/examples/empty/game.js +3 -1
- package/examples/empty/index.html +1 -1
- package/examples/favicon.png +0 -0
- package/examples/js13k/build.bat +2 -0
- package/examples/js13k/build.js +110 -0
- package/examples/js13k/game.js +109 -0
- package/examples/js13k/index.html +18 -0
- package/examples/js13k/tiles.png +0 -0
- package/examples/module/game.js +9 -3
- package/examples/module/index.html +2 -2
- package/examples/particles/index.html +7 -13
- package/examples/platformer/game.js +5 -2
- package/examples/platformer/gameEffects.js +1 -2
- package/examples/platformer/gamePlayer.js +2 -2
- package/examples/platformer/index.html +8 -8
- package/examples/puzzle/game.js +6 -4
- package/examples/puzzle/index.html +4 -4
- package/examples/starter/build.bat +2 -78
- package/examples/starter/build.js +109 -0
- package/examples/starter/game.js +4 -1
- package/examples/starter/index.html +15 -18
- package/examples/stress/index.html +2 -4
- package/examples/typescript/build.bat +2 -14
- package/examples/typescript/build.js +31 -0
- package/examples/typescript/game.js +94 -89
- package/examples/typescript/game.ts +9 -3
- package/examples/typescript/index.html +2 -2
- package/package.json +3 -3
- package/src/engine.js +30 -31
- package/src/engineAudio.js +44 -20
- package/src/engineBuild.bat +2 -132
- package/src/engineBuild.js +143 -0
- package/src/engineDebug.js +21 -32
- package/src/engineDraw.js +36 -28
- package/src/engineExport.js +41 -51
- package/src/engineInput.js +33 -20
- package/src/engineMedals.js +31 -8
- package/src/engineObject.js +34 -32
- package/src/engineParticles.js +9 -12
- package/src/engineRelease.js +18 -20
- package/src/engineSettings.js +4 -4
- package/src/engineTileLayer.js +49 -32
- package/src/engineUtilities.js +96 -74
- package/src/engineWebGL.js +8 -8
- package/examples/electron/build.bat +0 -52
package/build/littlejs.d.ts
CHANGED
|
@@ -1,164 +1,160 @@
|
|
|
1
1
|
declare module "littlejs.esm" {
|
|
2
2
|
/**
|
|
3
3
|
* LittleJS Module Export
|
|
4
|
-
*
|
|
4
|
+
* - Export engine as a module with extra functions where necessary
|
|
5
5
|
*/
|
|
6
6
|
/** Set position of camera in world space
|
|
7
7
|
* @param {Vector2} pos
|
|
8
8
|
* @memberof Settings */
|
|
9
|
-
export function setCameraPos(pos: Vector2):
|
|
9
|
+
export function setCameraPos(pos: Vector2): void;
|
|
10
10
|
/** Set scale of camera in world space
|
|
11
11
|
* @param {Number} scale
|
|
12
12
|
* @memberof Settings */
|
|
13
|
-
export function setCameraScale(scale: number):
|
|
13
|
+
export function setCameraScale(scale: number): void;
|
|
14
14
|
/** Set max size of the canvas
|
|
15
15
|
* @param {Vector2} size
|
|
16
16
|
* @memberof Settings */
|
|
17
|
-
export function setCanvasMaxSize(size: Vector2):
|
|
17
|
+
export function setCanvasMaxSize(size: Vector2): void;
|
|
18
18
|
/** Set fixed size of the canvas
|
|
19
19
|
* @param {Vector2} size
|
|
20
20
|
* @memberof Settings */
|
|
21
|
-
export function setCanvasFixedSize(size: Vector2):
|
|
21
|
+
export function setCanvasFixedSize(size: Vector2): void;
|
|
22
22
|
/** Disables anti aliasing for pixel art if true
|
|
23
23
|
* @param {Boolean} pixelated
|
|
24
24
|
* @memberof Settings */
|
|
25
|
-
export function
|
|
25
|
+
export function setCanvasPixelated(pixelated: boolean): void;
|
|
26
26
|
/** Set default font used for text rendering
|
|
27
27
|
* @param {String} font
|
|
28
28
|
* @memberof Settings */
|
|
29
|
-
export function setFontDefault(font: string):
|
|
29
|
+
export function setFontDefault(font: string): void;
|
|
30
30
|
/** Set if webgl rendering is enabled
|
|
31
31
|
* @param {Boolean} enable
|
|
32
32
|
* @memberof Settings */
|
|
33
|
-
export function setGlEnable(enable: boolean):
|
|
33
|
+
export function setGlEnable(enable: boolean): void;
|
|
34
34
|
/** Set to not composite the WebGL canvas
|
|
35
35
|
* @param {Boolean} overlay
|
|
36
36
|
* @memberof Settings */
|
|
37
|
-
export function setGlOverlay(overlay: boolean):
|
|
37
|
+
export function setGlOverlay(overlay: boolean): void;
|
|
38
38
|
/** Set default size of tiles in pixels
|
|
39
39
|
* @param {Vector2} size
|
|
40
40
|
* @memberof Settings */
|
|
41
|
-
export function setTileSizeDefault(size: Vector2):
|
|
41
|
+
export function setTileSizeDefault(size: Vector2): void;
|
|
42
42
|
/** Set to prevent tile bleeding from neighbors in pixels
|
|
43
43
|
* @param {Number} scale
|
|
44
44
|
* @memberof Settings */
|
|
45
|
-
export function setTileFixBleedScale(scale: number):
|
|
45
|
+
export function setTileFixBleedScale(scale: number): void;
|
|
46
46
|
/** Set if collisions between objects are enabled
|
|
47
47
|
* @param {Boolean} enable
|
|
48
48
|
* @memberof Settings */
|
|
49
|
-
export function setEnablePhysicsSolver(enable: boolean):
|
|
49
|
+
export function setEnablePhysicsSolver(enable: boolean): void;
|
|
50
50
|
/** Set default object mass for collison calcuations
|
|
51
51
|
* @param {Number} mass
|
|
52
52
|
* @memberof Settings */
|
|
53
|
-
export function setObjectDefaultMass(mass: number):
|
|
53
|
+
export function setObjectDefaultMass(mass: number): void;
|
|
54
54
|
/** Set how much to slow velocity by each frame
|
|
55
55
|
* @param {Number} damping
|
|
56
56
|
* @memberof Settings */
|
|
57
|
-
export function setObjectDefaultDamping(damp: any):
|
|
57
|
+
export function setObjectDefaultDamping(damp: any): void;
|
|
58
58
|
/** Set how much to slow angular velocity each frame
|
|
59
59
|
* @param {Number} damping
|
|
60
60
|
* @memberof Settings */
|
|
61
|
-
export function setObjectDefaultAngleDamping(damp: any):
|
|
61
|
+
export function setObjectDefaultAngleDamping(damp: any): void;
|
|
62
62
|
/** Set how much to bounce when a collision occur
|
|
63
63
|
* @param {Number} elasticity
|
|
64
64
|
* @memberof Settings */
|
|
65
|
-
export function setObjectDefaultElasticity(elasticity: number):
|
|
65
|
+
export function setObjectDefaultElasticity(elasticity: number): void;
|
|
66
66
|
/** Set how much to slow when touching
|
|
67
67
|
* @param {Number} friction
|
|
68
68
|
* @memberof Settings */
|
|
69
|
-
export function setObjectDefaultFriction(friction: number):
|
|
69
|
+
export function setObjectDefaultFriction(friction: number): void;
|
|
70
70
|
/** Set max speed to avoid fast objects missing collisions
|
|
71
71
|
* @param {Number} speed
|
|
72
72
|
* @memberof Settings */
|
|
73
|
-
export function setObjectMaxSpeed(speed: number):
|
|
73
|
+
export function setObjectMaxSpeed(speed: number): void;
|
|
74
74
|
/** Set how much gravity to apply to objects along the Y axis
|
|
75
75
|
* @param {Number} gravity
|
|
76
76
|
* @memberof Settings */
|
|
77
|
-
export function setGravity(g: any):
|
|
77
|
+
export function setGravity(g: any): void;
|
|
78
78
|
/** Set to scales emit rate of particles
|
|
79
79
|
* @param {Number} scale
|
|
80
80
|
* @memberof Settings */
|
|
81
|
-
export function setParticleEmitRateScale(scale: number):
|
|
81
|
+
export function setParticleEmitRateScale(scale: number): void;
|
|
82
82
|
/** Set if gamepads are enabled
|
|
83
83
|
* @param {Boolean} enable
|
|
84
84
|
* @memberof Settings */
|
|
85
|
-
export function setGamepadsEnable(enable: boolean):
|
|
85
|
+
export function setGamepadsEnable(enable: boolean): void;
|
|
86
86
|
/** Set if the dpad input is also routed to the left analog stick
|
|
87
87
|
* @param {Boolean} enable
|
|
88
88
|
* @memberof Settings */
|
|
89
|
-
export function setGamepadDirectionEmulateStick(enable: boolean):
|
|
89
|
+
export function setGamepadDirectionEmulateStick(enable: boolean): void;
|
|
90
90
|
/** Set if true the WASD keys are also routed to the direction keys
|
|
91
91
|
* @param {Boolean} enable
|
|
92
92
|
* @memberof Settings */
|
|
93
|
-
export function setInputWASDEmulateDirection(enable: boolean):
|
|
93
|
+
export function setInputWASDEmulateDirection(enable: boolean): void;
|
|
94
94
|
/** Set if touch gamepad should appear on mobile devices
|
|
95
95
|
* @param {Boolean} enable
|
|
96
96
|
* @memberof Settings */
|
|
97
|
-
export function setTouchGamepadEnable(enable: boolean):
|
|
97
|
+
export function setTouchGamepadEnable(enable: boolean): void;
|
|
98
98
|
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
99
99
|
* @param {Boolean} analog
|
|
100
100
|
* @memberof Settings */
|
|
101
|
-
export function setTouchGamepadAnalog(analog: boolean):
|
|
101
|
+
export function setTouchGamepadAnalog(analog: boolean): void;
|
|
102
102
|
/** Set size of virutal gamepad for touch devices in pixels
|
|
103
103
|
* @param {Number} size
|
|
104
104
|
* @memberof Settings */
|
|
105
|
-
export function setTouchGamepadSize(size: number):
|
|
105
|
+
export function setTouchGamepadSize(size: number): void;
|
|
106
106
|
/** Set transparency of touch gamepad overlay
|
|
107
107
|
* @param {Number} alpha
|
|
108
108
|
* @memberof Settings */
|
|
109
|
-
export function setTouchGamepadAlpha(alpha: number):
|
|
109
|
+
export function setTouchGamepadAlpha(alpha: number): void;
|
|
110
110
|
/** Set to allow vibration hardware if it exists
|
|
111
111
|
* @param {Boolean} enable
|
|
112
112
|
* @memberof Settings */
|
|
113
|
-
export function setVibrateEnable(enable: boolean):
|
|
113
|
+
export function setVibrateEnable(enable: boolean): void;
|
|
114
114
|
/** Set to disable all audio code
|
|
115
115
|
* @param {Boolean} enable
|
|
116
116
|
* @memberof Settings */
|
|
117
|
-
export function setSoundEnable(enable: boolean):
|
|
117
|
+
export function setSoundEnable(enable: boolean): void;
|
|
118
118
|
/** Set volume scale to apply to all sound, music and speech
|
|
119
119
|
* @param {Number} volume
|
|
120
120
|
* @memberof Settings */
|
|
121
|
-
export function setSoundVolume(volume: number):
|
|
121
|
+
export function setSoundVolume(volume: number): void;
|
|
122
122
|
/** Set default range where sound no longer plays
|
|
123
123
|
* @param {Number} range
|
|
124
124
|
* @memberof Settings */
|
|
125
|
-
export function setSoundDefaultRange(range: number):
|
|
125
|
+
export function setSoundDefaultRange(range: number): void;
|
|
126
126
|
/** Set default range percent to start tapering off sound
|
|
127
127
|
* @param {Number} taper
|
|
128
128
|
* @memberof Settings */
|
|
129
|
-
export function setSoundDefaultTaper(taper: number):
|
|
129
|
+
export function setSoundDefaultTaper(taper: number): void;
|
|
130
130
|
/** Set how long to show medals for in seconds
|
|
131
131
|
* @param {Number} time
|
|
132
132
|
* @memberof Settings */
|
|
133
|
-
export function setMedalDisplayTime(time: number):
|
|
133
|
+
export function setMedalDisplayTime(time: number): void;
|
|
134
134
|
/** Set how quickly to slide on/off medals in seconds
|
|
135
135
|
* @param {Number} time
|
|
136
136
|
* @memberof Settings */
|
|
137
|
-
export function setMedalDisplaySlideTime(time: number):
|
|
137
|
+
export function setMedalDisplaySlideTime(time: number): void;
|
|
138
138
|
/** Set size of medal display
|
|
139
139
|
* @param {Vector2} size
|
|
140
140
|
* @memberof Settings */
|
|
141
|
-
export function setMedalDisplaySize(size: Vector2):
|
|
141
|
+
export function setMedalDisplaySize(size: Vector2): void;
|
|
142
142
|
/** Set size of icon in medal display
|
|
143
143
|
* @param {Number} size
|
|
144
144
|
* @memberof Settings */
|
|
145
|
-
export function setMedalDisplayIconSize(size: number):
|
|
145
|
+
export function setMedalDisplayIconSize(size: number): void;
|
|
146
146
|
/** Set to stop medals from being unlockable
|
|
147
147
|
* @param {Boolean} preventUnlock
|
|
148
148
|
* @memberof Settings */
|
|
149
|
-
export function setMedalsPreventUnlock(
|
|
149
|
+
export function setMedalsPreventUnlock(preventUnlock: boolean): void;
|
|
150
150
|
/** Set if watermark with FPS should be shown
|
|
151
151
|
* @param {Boolean} show
|
|
152
152
|
* @memberof Debug */
|
|
153
|
-
export function setShowWatermark(show: boolean):
|
|
154
|
-
/** Set if god mode is enabled
|
|
155
|
-
* @param {Boolean} enable
|
|
156
|
-
* @memberof Debug */
|
|
157
|
-
export function setGodMode(enable: boolean): boolean;
|
|
153
|
+
export function setShowWatermark(show: boolean): void;
|
|
158
154
|
/** Set key code used to toggle debug mode, Esc by default
|
|
159
155
|
* @param {Number} key
|
|
160
156
|
* @memberof Debug */
|
|
161
|
-
export function setDebugKey(key: number):
|
|
157
|
+
export function setDebugKey(key: number): void;
|
|
162
158
|
/** The max size of the canvas, centered if window is larger
|
|
163
159
|
* @type {Vector2}
|
|
164
160
|
* @default Vector2(1920,1200)
|
|
@@ -170,11 +166,11 @@ declare module "littlejs.esm" {
|
|
|
170
166
|
* @default Vector2()
|
|
171
167
|
* @memberof Settings */
|
|
172
168
|
export let canvasFixedSize: Vector2;
|
|
173
|
-
/** Disables
|
|
169
|
+
/** Disables filtering for crisper pixel art if true
|
|
174
170
|
* @type {Boolean}
|
|
175
171
|
* @default
|
|
176
172
|
* @memberof Settings */
|
|
177
|
-
export let
|
|
173
|
+
export let canvasPixelated: boolean;
|
|
178
174
|
/** Default font used for text rendering
|
|
179
175
|
* @type {String}
|
|
180
176
|
* @default
|
|
@@ -271,8 +267,8 @@ declare module "littlejs.esm" {
|
|
|
271
267
|
* @memberof Settings */
|
|
272
268
|
export let inputWASDEmulateDirection: boolean;
|
|
273
269
|
/** True if touch gamepad should appear on mobile devices
|
|
274
|
-
*
|
|
275
|
-
*
|
|
270
|
+
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
271
|
+
* - Must be set by end of gameInit to be activated
|
|
276
272
|
* @type {Boolean}
|
|
277
273
|
* @default 0
|
|
278
274
|
* @memberof Settings */
|
|
@@ -347,11 +343,10 @@ declare module "littlejs.esm" {
|
|
|
347
343
|
* @default
|
|
348
344
|
* @memberof Debug */
|
|
349
345
|
export let showWatermark: boolean;
|
|
350
|
-
/**
|
|
351
|
-
* @
|
|
352
|
-
* @
|
|
346
|
+
/** Asserts if the experssion is false, does not do anything in release builds
|
|
347
|
+
* @param {Boolean} assertion
|
|
348
|
+
* @param {Object} output
|
|
353
349
|
* @memberof Debug */
|
|
354
|
-
export let godMode: boolean;
|
|
355
350
|
export function ASSERT(...assert: any[]): void;
|
|
356
351
|
/** Draw a debug rectangle in world space
|
|
357
352
|
* @param {Vector2} pos
|
|
@@ -405,7 +400,7 @@ declare module "littlejs.esm" {
|
|
|
405
400
|
export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
|
|
406
401
|
/** Clear all debug primitives in the list
|
|
407
402
|
* @memberof Debug */
|
|
408
|
-
export function debugClear():
|
|
403
|
+
export function debugClear(): void;
|
|
409
404
|
/** Save a canvas to disk
|
|
410
405
|
* @param {HTMLCanvasElement} canvas
|
|
411
406
|
* @param {String} [filename]
|
|
@@ -420,69 +415,69 @@ declare module "littlejs.esm" {
|
|
|
420
415
|
* @param {Number} value
|
|
421
416
|
* @return {Number}
|
|
422
417
|
* @memberof Utilities */
|
|
423
|
-
export function abs(
|
|
418
|
+
export function abs(value: number): number;
|
|
424
419
|
/** Returns lowest of two values passed in
|
|
425
420
|
* @param {Number} valueA
|
|
426
421
|
* @param {Number} valueB
|
|
427
422
|
* @return {Number}
|
|
428
423
|
* @memberof Utilities */
|
|
429
|
-
export function min(
|
|
424
|
+
export function min(valueA: number, valueB: number): number;
|
|
430
425
|
/** Returns highest of two values passed in
|
|
431
426
|
* @param {Number} valueA
|
|
432
427
|
* @param {Number} valueB
|
|
433
428
|
* @return {Number}
|
|
434
429
|
* @memberof Utilities */
|
|
435
|
-
export function max(
|
|
430
|
+
export function max(valueA: number, valueB: number): number;
|
|
436
431
|
/** Returns the sign of value passed in (also returns 1 if 0)
|
|
437
432
|
* @param {Number} value
|
|
438
433
|
* @return {Number}
|
|
439
434
|
* @memberof Utilities */
|
|
440
|
-
export function sign(
|
|
435
|
+
export function sign(value: number): number;
|
|
441
436
|
/** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
|
|
442
437
|
* @param {Number} dividend
|
|
443
438
|
* @param {Number} [divisor=1]
|
|
444
439
|
* @return {Number}
|
|
445
440
|
* @memberof Utilities */
|
|
446
|
-
export function mod(
|
|
441
|
+
export function mod(dividend: number, divisor?: number): number;
|
|
447
442
|
/** Clamps the value beween max and min
|
|
448
443
|
* @param {Number} value
|
|
449
444
|
* @param {Number} [min=0]
|
|
450
445
|
* @param {Number} [max=1]
|
|
451
446
|
* @return {Number}
|
|
452
447
|
* @memberof Utilities */
|
|
453
|
-
export function clamp(
|
|
448
|
+
export function clamp(value: number, min?: number, max?: number): number;
|
|
454
449
|
/** Returns what percentage the value is between max and min
|
|
455
450
|
* @param {Number} value
|
|
456
451
|
* @param {Number} [min=0]
|
|
457
452
|
* @param {Number} [max=1]
|
|
458
453
|
* @return {Number}
|
|
459
454
|
* @memberof Utilities */
|
|
460
|
-
export function percent(
|
|
455
|
+
export function percent(value: number, min?: number, max?: number): number;
|
|
461
456
|
/** Linearly interpolates the percent value between max and min
|
|
462
457
|
* @param {Number} percent
|
|
463
458
|
* @param {Number} [min=0]
|
|
464
459
|
* @param {Number} [max=1]
|
|
465
460
|
* @return {Number}
|
|
466
461
|
* @memberof Utilities */
|
|
467
|
-
export function lerp(
|
|
462
|
+
export function lerp(percent: number, min?: number, max?: number): number;
|
|
468
463
|
/** Applies smoothstep function to the percentage value
|
|
469
|
-
* @param {Number}
|
|
464
|
+
* @param {Number} percent
|
|
470
465
|
* @return {Number}
|
|
471
466
|
* @memberof Utilities */
|
|
472
|
-
export function smoothStep(
|
|
467
|
+
export function smoothStep(percent: number): number;
|
|
473
468
|
/** Returns the nearest power of two not less then the value
|
|
474
469
|
* @param {Number} value
|
|
475
470
|
* @return {Number}
|
|
476
471
|
* @memberof Utilities */
|
|
477
|
-
export function nearestPowerOfTwo(
|
|
472
|
+
export function nearestPowerOfTwo(value: number): number;
|
|
478
473
|
/** Returns true if two axis aligned bounding boxes are overlapping
|
|
479
474
|
* @param {Vector2} pointA - Center of box A
|
|
480
475
|
* @param {Vector2} sizeA - Size of box A
|
|
481
476
|
* @param {Vector2} pointB - Center of box B
|
|
482
|
-
* @param {Vector2}
|
|
477
|
+
* @param {Vector2} sizeB - Size of box B
|
|
483
478
|
* @return {Boolean} - True if overlapping
|
|
484
479
|
* @memberof Utilities */
|
|
485
|
-
export function isOverlapping(
|
|
480
|
+
export function isOverlapping(pointA: Vector2, sizeA: Vector2, pointB: Vector2, sizeB: Vector2): boolean;
|
|
486
481
|
/** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
|
|
487
482
|
* @param {Number} [frequency=1] - Frequency of the wave in Hz
|
|
488
483
|
* @param {Number} [amplitude=1] - Amplitude (max height) of the wave
|
|
@@ -502,13 +497,13 @@ declare module "littlejs.esm" {
|
|
|
502
497
|
* @param {Number} [valueB=0]
|
|
503
498
|
* @return {Number}
|
|
504
499
|
* @memberof Random */
|
|
505
|
-
export function rand(
|
|
500
|
+
export function rand(valueA?: number, valueB?: number): number;
|
|
506
501
|
/** Returns a floored random value the two values passed in
|
|
507
502
|
* @param {Number} [valueA=1]
|
|
508
503
|
* @param {Number} [valueB=0]
|
|
509
504
|
* @return {Number}
|
|
510
505
|
* @memberof Random */
|
|
511
|
-
export function randInt(
|
|
506
|
+
export function randInt(valueA?: number, valueB?: number): number;
|
|
512
507
|
/** Randomly returns either -1 or 1
|
|
513
508
|
* @return {Number}
|
|
514
509
|
* @memberof Random */
|
|
@@ -530,7 +525,7 @@ declare module "littlejs.esm" {
|
|
|
530
525
|
* @param {Boolean} [linear]
|
|
531
526
|
* @return {Color}
|
|
532
527
|
* @memberof Random */
|
|
533
|
-
export function randColor(
|
|
528
|
+
export function randColor(colorA?: Color, colorB?: Color, linear?: boolean): Color;
|
|
534
529
|
/** Seed used by the randSeeded function
|
|
535
530
|
* @type {Number}
|
|
536
531
|
* @default
|
|
@@ -539,16 +534,16 @@ declare module "littlejs.esm" {
|
|
|
539
534
|
/** Set seed used by the randSeeded function, should not be 0
|
|
540
535
|
* @param {Number} seed
|
|
541
536
|
* @memberof Random */
|
|
542
|
-
export function setRandSeed(seed: number):
|
|
537
|
+
export function setRandSeed(seed: number): void;
|
|
543
538
|
/** Returns a seeded random value between the two values passed in using randSeed
|
|
544
539
|
* @param {Number} [valueA=1]
|
|
545
540
|
* @param {Number} [valueB=0]
|
|
546
541
|
* @return {Number}
|
|
547
542
|
* @memberof Random */
|
|
548
|
-
export function randSeeded(
|
|
543
|
+
export function randSeeded(valueA?: number, valueB?: number): number;
|
|
549
544
|
/**
|
|
550
545
|
* 2D Vector object with vector math library
|
|
551
|
-
*
|
|
546
|
+
* - Functions do not change this so they can be chained together
|
|
552
547
|
* @example
|
|
553
548
|
* let a = new Vector2(2, 3); // vector with coordinates (2, 3)
|
|
554
549
|
* let b = new Vector2; // vector with coordinates (0, 0)
|
|
@@ -568,25 +563,25 @@ declare module "littlejs.esm" {
|
|
|
568
563
|
* @return {Vector2} */
|
|
569
564
|
copy(): Vector2;
|
|
570
565
|
/** Returns a copy of this vector plus the vector passed in
|
|
571
|
-
* @param {Vector2} vector
|
|
566
|
+
* @param {Vector2} v - other vector
|
|
572
567
|
* @return {Vector2} */
|
|
573
|
-
add(v:
|
|
568
|
+
add(v: Vector2): Vector2;
|
|
574
569
|
/** Returns a copy of this vector minus the vector passed in
|
|
575
|
-
* @param {Vector2} vector
|
|
570
|
+
* @param {Vector2} v - other vector
|
|
576
571
|
* @return {Vector2} */
|
|
577
|
-
subtract(v:
|
|
572
|
+
subtract(v: Vector2): Vector2;
|
|
578
573
|
/** Returns a copy of this vector times the vector passed in
|
|
579
|
-
* @param {Vector2} vector
|
|
574
|
+
* @param {Vector2} v - other vector
|
|
580
575
|
* @return {Vector2} */
|
|
581
|
-
multiply(v:
|
|
576
|
+
multiply(v: Vector2): Vector2;
|
|
582
577
|
/** Returns a copy of this vector divided by the vector passed in
|
|
583
|
-
* @param {Vector2} vector
|
|
578
|
+
* @param {Vector2} v - other vector
|
|
584
579
|
* @return {Vector2} */
|
|
585
|
-
divide(v:
|
|
580
|
+
divide(v: Vector2): Vector2;
|
|
586
581
|
/** Returns a copy of this vector scaled by the vector passed in
|
|
587
|
-
* @param {Number} scale
|
|
582
|
+
* @param {Number} s - scale
|
|
588
583
|
* @return {Vector2} */
|
|
589
|
-
scale(s:
|
|
584
|
+
scale(s: number): Vector2;
|
|
590
585
|
/** Returns the length of this vector
|
|
591
586
|
* @return {Number} */
|
|
592
587
|
length(): number;
|
|
@@ -594,13 +589,13 @@ declare module "littlejs.esm" {
|
|
|
594
589
|
* @return {Number} */
|
|
595
590
|
lengthSquared(): number;
|
|
596
591
|
/** Returns the distance from this vector to vector passed in
|
|
597
|
-
* @param {Vector2} vector
|
|
592
|
+
* @param {Vector2} v - other vector
|
|
598
593
|
* @return {Number} */
|
|
599
|
-
distance(v:
|
|
594
|
+
distance(v: Vector2): number;
|
|
600
595
|
/** Returns the distance squared from this vector to vector passed in
|
|
601
|
-
* @param {Vector2} vector
|
|
596
|
+
* @param {Vector2} v - other vector
|
|
602
597
|
* @return {Number} */
|
|
603
|
-
distanceSquared(v:
|
|
598
|
+
distanceSquared(v: Vector2): number;
|
|
604
599
|
/** Returns a new vector in same direction as this one with the length passed in
|
|
605
600
|
* @param {Number} [length=1]
|
|
606
601
|
* @return {Vector2} */
|
|
@@ -610,13 +605,13 @@ declare module "littlejs.esm" {
|
|
|
610
605
|
* @return {Vector2} */
|
|
611
606
|
clampLength(length?: number): Vector2;
|
|
612
607
|
/** Returns the dot product of this and the vector passed in
|
|
613
|
-
* @param {Vector2} vector
|
|
608
|
+
* @param {Vector2} v - other vector
|
|
614
609
|
* @return {Number} */
|
|
615
|
-
dot(v:
|
|
610
|
+
dot(v: Vector2): number;
|
|
616
611
|
/** Returns the cross product of this and the vector passed in
|
|
617
|
-
* @param {Vector2} vector
|
|
612
|
+
* @param {Vector2} v - other vector
|
|
618
613
|
* @return {Number} */
|
|
619
|
-
cross(v:
|
|
614
|
+
cross(v: Vector2): number;
|
|
620
615
|
/** Returns the angle of this vector, up is angle 0
|
|
621
616
|
* @return {Number} */
|
|
622
617
|
angle(): number;
|
|
@@ -624,11 +619,11 @@ declare module "littlejs.esm" {
|
|
|
624
619
|
* @param {Number} [angle=0]
|
|
625
620
|
* @param {Number} [length=1]
|
|
626
621
|
* @return {Vector2} */
|
|
627
|
-
setAngle(
|
|
622
|
+
setAngle(angle?: number, length?: number): Vector2;
|
|
628
623
|
/** Returns copy of this vector rotated by the angle passed in
|
|
629
624
|
* @param {Number} angle
|
|
630
625
|
* @return {Vector2} */
|
|
631
|
-
rotate(
|
|
626
|
+
rotate(angle: number): Vector2;
|
|
632
627
|
/** Returns the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)
|
|
633
628
|
* @return {Number} */
|
|
634
629
|
direction(): number;
|
|
@@ -642,10 +637,10 @@ declare module "littlejs.esm" {
|
|
|
642
637
|
* @return {Number} */
|
|
643
638
|
area(): number;
|
|
644
639
|
/** Returns a new vector that is p percent between this and the vector passed in
|
|
645
|
-
* @param {Vector2} vector
|
|
640
|
+
* @param {Vector2} v - other vector
|
|
646
641
|
* @param {Number} percent
|
|
647
642
|
* @return {Vector2} */
|
|
648
|
-
lerp(v:
|
|
643
|
+
lerp(v: Vector2, percent: number): Vector2;
|
|
649
644
|
/** Returns true if this vector is within the bounds of an array size passed in
|
|
650
645
|
* @param {Vector2} arraySize
|
|
651
646
|
* @return {Boolean} */
|
|
@@ -665,11 +660,11 @@ declare module "littlejs.esm" {
|
|
|
665
660
|
* let e = HSL(.3, 1, .5); // green using hsl color
|
|
666
661
|
*/
|
|
667
662
|
export class Color {
|
|
668
|
-
/** Create a color with the components passed in, white by default
|
|
669
|
-
* @param {Number} [
|
|
670
|
-
* @param {Number} [
|
|
671
|
-
* @param {Number} [
|
|
672
|
-
* @param {Number} [
|
|
663
|
+
/** Create a color with the rgba components passed in, white by default
|
|
664
|
+
* @param {Number} [r=1] - red
|
|
665
|
+
* @param {Number} [g=1] - green
|
|
666
|
+
* @param {Number} [b=1] - blue
|
|
667
|
+
* @param {Number} [a=1] - alpha*/
|
|
673
668
|
constructor(r?: number, g?: number, b?: number, a?: number);
|
|
674
669
|
/** @property {Number} - Red */
|
|
675
670
|
r: number;
|
|
@@ -683,39 +678,39 @@ declare module "littlejs.esm" {
|
|
|
683
678
|
* @return {Color} */
|
|
684
679
|
copy(): Color;
|
|
685
680
|
/** Returns a copy of this color plus the color passed in
|
|
686
|
-
* @param {Color} color
|
|
681
|
+
* @param {Color} c - other color
|
|
687
682
|
* @return {Color} */
|
|
688
|
-
add(c:
|
|
683
|
+
add(c: Color): Color;
|
|
689
684
|
/** Returns a copy of this color minus the color passed in
|
|
690
|
-
* @param {Color} color
|
|
685
|
+
* @param {Color} c - other color
|
|
691
686
|
* @return {Color} */
|
|
692
|
-
subtract(c:
|
|
687
|
+
subtract(c: Color): Color;
|
|
693
688
|
/** Returns a copy of this color times the color passed in
|
|
694
|
-
* @param {Color} color
|
|
689
|
+
* @param {Color} c - other color
|
|
695
690
|
* @return {Color} */
|
|
696
|
-
multiply(c:
|
|
691
|
+
multiply(c: Color): Color;
|
|
697
692
|
/** Returns a copy of this color divided by the color passed in
|
|
698
|
-
* @param {Color} color
|
|
693
|
+
* @param {Color} c - other color
|
|
699
694
|
* @return {Color} */
|
|
700
|
-
divide(c:
|
|
695
|
+
divide(c: Color): Color;
|
|
701
696
|
/** Returns a copy of this color scaled by the value passed in, alpha can be scaled separately
|
|
702
697
|
* @param {Number} scale
|
|
703
698
|
* @param {Number} [alphaScale=scale]
|
|
704
699
|
* @return {Color} */
|
|
705
|
-
scale(
|
|
700
|
+
scale(scale: number, alphaScale?: number): Color;
|
|
706
701
|
/** Returns a copy of this color clamped to the valid range between 0 and 1
|
|
707
702
|
* @return {Color} */
|
|
708
703
|
clamp(): Color;
|
|
709
704
|
/** Returns a new color that is p percent between this and the color passed in
|
|
710
|
-
* @param {Color} color
|
|
705
|
+
* @param {Color} c - other color
|
|
711
706
|
* @param {Number} percent
|
|
712
707
|
* @return {Color} */
|
|
713
|
-
lerp(c:
|
|
708
|
+
lerp(c: Color, percent: number): Color;
|
|
714
709
|
/** Sets this color given a hue, saturation, lightness, and alpha
|
|
715
|
-
* @param {Number} [
|
|
716
|
-
* @param {Number} [
|
|
717
|
-
* @param {Number} [
|
|
718
|
-
* @param {Number} [
|
|
710
|
+
* @param {Number} [h=0] - hue
|
|
711
|
+
* @param {Number} [s=0] - saturation
|
|
712
|
+
* @param {Number} [l=1] - lightness
|
|
713
|
+
* @param {Number} [a=1] - alpha
|
|
719
714
|
* @return {Color} */
|
|
720
715
|
setHSLA(h?: number, s?: number, l?: number, a?: number): Color;
|
|
721
716
|
/** Returns this color expressed in hsla format
|
|
@@ -795,44 +790,44 @@ declare module "littlejs.esm" {
|
|
|
795
790
|
export function vec2(x?: number, y?: number): Vector2;
|
|
796
791
|
/**
|
|
797
792
|
* Create a color object with RGBA values
|
|
798
|
-
* @param {Number} [r=1]
|
|
799
|
-
* @param {Number} [g=1]
|
|
800
|
-
* @param {Number} [b=1]
|
|
801
|
-
* @param {Number} [a=1]
|
|
793
|
+
* @param {Number} [r=1] - red
|
|
794
|
+
* @param {Number} [g=1] - green
|
|
795
|
+
* @param {Number} [b=1] - blue
|
|
796
|
+
* @param {Number} [a=1] - alpha
|
|
802
797
|
* @return {Color}
|
|
803
798
|
* @memberof Utilities
|
|
804
799
|
*/
|
|
805
800
|
export function rgb(r?: number, g?: number, b?: number, a?: number): Color;
|
|
806
801
|
/**
|
|
807
802
|
* Create a color object with HSLA values
|
|
808
|
-
* @param {Number} [h=0]
|
|
809
|
-
* @param {Number} [s=0]
|
|
810
|
-
* @param {Number} [l=1]
|
|
811
|
-
* @param {Number} [a=1]
|
|
803
|
+
* @param {Number} [h=0] - hue
|
|
804
|
+
* @param {Number} [s=0] - saturation
|
|
805
|
+
* @param {Number} [l=1] - lightness
|
|
806
|
+
* @param {Number} [a=1] - alpha
|
|
812
807
|
* @return {Color}
|
|
813
808
|
* @memberof Utilities
|
|
814
809
|
*/
|
|
815
810
|
export function hsl(h?: number, s?: number, l?: number, a?: number): Color;
|
|
816
811
|
/**
|
|
817
812
|
* LittleJS Object Base Object Class
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
*
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
*
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
813
|
+
* - Base object class used by the engine
|
|
814
|
+
* - Automatically adds self to object list
|
|
815
|
+
* - Will be updated and rendered each frame
|
|
816
|
+
* - Renders as a sprite from a tilesheet by default
|
|
817
|
+
* - Can have color and addtive color applied
|
|
818
|
+
* - 2d Physics and collision system
|
|
819
|
+
* - Sorted by renderOrder
|
|
820
|
+
* - Objects can have children attached
|
|
821
|
+
* - Parents are updated before children, and set child transform
|
|
822
|
+
* - Call destroy() to get rid of objects
|
|
823
|
+
*
|
|
824
|
+
* The physics system used by objects is simple and fast with some caveats...
|
|
825
|
+
* - Collision uses the axis aligned size, the object's rotation angle is only for rendering
|
|
826
|
+
* - Objects are guaranteed to not intersect tile collision from physics
|
|
827
|
+
* - If an object starts or is moved inside tile collision, it will not collide with that tile
|
|
828
|
+
* - Collision for objects can be set to be solid to block other objects
|
|
829
|
+
* - Objects may get pushed into overlapping other solid objects, if so they will push away
|
|
830
|
+
* - Solid objects are more performance intensive and should be used sparingly
|
|
836
831
|
* @example
|
|
837
832
|
* // create an engine object, normally you would first extend the class with your own
|
|
838
833
|
* const pos = vec2(2,3);
|
|
@@ -904,13 +899,13 @@ declare module "littlejs.esm" {
|
|
|
904
899
|
* @param {EngineObject} object - the object to test against
|
|
905
900
|
* @return {Boolean} - true if the collision should be resolved
|
|
906
901
|
*/
|
|
907
|
-
collideWithObject(
|
|
902
|
+
collideWithObject(object: EngineObject): boolean;
|
|
908
903
|
/** How long since the object was created
|
|
909
904
|
* @return {Number} */
|
|
910
905
|
getAliveTime(): number;
|
|
911
906
|
/** Apply acceleration to this object (adjust velocity, not affected by mass)
|
|
912
907
|
* @param {Vector2} acceleration */
|
|
913
|
-
applyAcceleration(
|
|
908
|
+
applyAcceleration(acceleration: Vector2): void;
|
|
914
909
|
/** Apply force to this object (adjust velocity, affected by mass)
|
|
915
910
|
* @param {Vector2} force */
|
|
916
911
|
applyForce(force: Vector2): void;
|
|
@@ -1063,9 +1058,9 @@ declare module "littlejs.esm" {
|
|
|
1063
1058
|
export let engineFontImage: any;
|
|
1064
1059
|
/**
|
|
1065
1060
|
* Font Image Object - Draw text on a 2D canvas by using characters in an image
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1061
|
+
* - 96 characters (from space to tilde) are stored in an image
|
|
1062
|
+
* - Uses a default 8x8 font if none is supplied
|
|
1063
|
+
* - You can also use fonts from the main tile sheet
|
|
1069
1064
|
* @example
|
|
1070
1065
|
* // use built in font
|
|
1071
1066
|
* const font = new ImageFont;
|
|
@@ -1129,7 +1124,7 @@ declare module "littlejs.esm" {
|
|
|
1129
1124
|
export function keyWasReleased(key: number, device?: number): boolean;
|
|
1130
1125
|
/** Clears all input
|
|
1131
1126
|
* @memberof Input */
|
|
1132
|
-
export function clearInput():
|
|
1127
|
+
export function clearInput(): void;
|
|
1133
1128
|
/** Returns true if device key is down
|
|
1134
1129
|
* @param {Number} key
|
|
1135
1130
|
* @param {Number} [device=0]
|
|
@@ -1197,17 +1192,17 @@ declare module "littlejs.esm" {
|
|
|
1197
1192
|
/** Pulse the vibration hardware if it exists
|
|
1198
1193
|
* @param {Number} [pattern=100] - a single value in miliseconds or vibration interval array
|
|
1199
1194
|
* @memberof Input */
|
|
1200
|
-
export function vibrate(pattern?: number):
|
|
1195
|
+
export function vibrate(pattern?: number): void;
|
|
1201
1196
|
/** Cancel any ongoing vibration
|
|
1202
1197
|
* @memberof Input */
|
|
1203
|
-
export function vibrateStop():
|
|
1198
|
+
export function vibrateStop(): void;
|
|
1204
1199
|
/** True if a touch device has been detected
|
|
1205
1200
|
* @memberof Input */
|
|
1206
1201
|
export const isTouchDevice: boolean;
|
|
1207
1202
|
/**
|
|
1208
1203
|
* Sound Object - Stores a zzfx sound for later use and can be played positionally
|
|
1209
|
-
*
|
|
1210
|
-
* <
|
|
1204
|
+
*
|
|
1205
|
+
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
1211
1206
|
* @example
|
|
1212
1207
|
* // create a sound
|
|
1213
1208
|
* const sound_example = new Sound([.5,.5]);
|
|
@@ -1227,7 +1222,7 @@ declare module "littlejs.esm" {
|
|
|
1227
1222
|
/** @property {Number} - At what percentage of range should it start tapering off */
|
|
1228
1223
|
taper: number;
|
|
1229
1224
|
randomness: any;
|
|
1230
|
-
cachedSamples:
|
|
1225
|
+
cachedSamples: any[];
|
|
1231
1226
|
/** Play the sound
|
|
1232
1227
|
* @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
|
|
1233
1228
|
* @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
|
|
@@ -1246,8 +1241,8 @@ declare module "littlejs.esm" {
|
|
|
1246
1241
|
}
|
|
1247
1242
|
/**
|
|
1248
1243
|
* Music Object - Stores a zzfx music track for later use
|
|
1249
|
-
*
|
|
1250
|
-
* <
|
|
1244
|
+
*
|
|
1245
|
+
* <a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a>
|
|
1251
1246
|
* @example
|
|
1252
1247
|
* // create some music
|
|
1253
1248
|
* const music_example = new Music(
|
|
@@ -1332,12 +1327,12 @@ declare module "littlejs.esm" {
|
|
|
1332
1327
|
* @memberof Audio */
|
|
1333
1328
|
export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean): AudioBufferSourceNode;
|
|
1334
1329
|
/** Generate and play a ZzFX sound
|
|
1335
|
-
*
|
|
1336
|
-
* <
|
|
1330
|
+
*
|
|
1331
|
+
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
1337
1332
|
* @param {Array} zzfxSound - Array of ZzFX parameters, ex. [.5,.5]
|
|
1338
|
-
* @return {
|
|
1333
|
+
* @return {AudioBufferSourceNode} - The audio node of the sound played
|
|
1339
1334
|
* @memberof Audio */
|
|
1340
|
-
export function zzfx(...zzfxSound: any[]):
|
|
1335
|
+
export function zzfx(...zzfxSound: any[]): AudioBufferSourceNode;
|
|
1341
1336
|
/** The tile collision layer array, use setTileCollisionData and getTileCollisionData to access
|
|
1342
1337
|
* @type {Array}
|
|
1343
1338
|
* @memberof TileCollision */
|
|
@@ -1354,7 +1349,7 @@ declare module "littlejs.esm" {
|
|
|
1354
1349
|
* @param {Vector2} pos
|
|
1355
1350
|
* @param {Number} [data=0]
|
|
1356
1351
|
* @memberof TileCollision */
|
|
1357
|
-
export function setTileCollisionData(pos: Vector2, data?: number):
|
|
1352
|
+
export function setTileCollisionData(pos: Vector2, data?: number): void;
|
|
1358
1353
|
/** Get tile collision data
|
|
1359
1354
|
* @param {Vector2} pos
|
|
1360
1355
|
* @return {Number}
|
|
@@ -1367,7 +1362,7 @@ declare module "littlejs.esm" {
|
|
|
1367
1362
|
* @return {Boolean}
|
|
1368
1363
|
* @memberof TileCollision */
|
|
1369
1364
|
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
|
|
1370
|
-
/** Return the center of tile if any that is hit (
|
|
1365
|
+
/** Return the center of tile if any that is hit (does not return the exact intersection)
|
|
1371
1366
|
* @param {Vector2} posStart
|
|
1372
1367
|
* @param {Vector2} posEnd
|
|
1373
1368
|
* @param {EngineObject} [object]
|
|
@@ -1404,10 +1399,10 @@ declare module "littlejs.esm" {
|
|
|
1404
1399
|
}
|
|
1405
1400
|
/**
|
|
1406
1401
|
* Tile layer object - cached rendering system for tile layers
|
|
1407
|
-
*
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1402
|
+
* - Each Tile layer is rendered to an off screen canvas
|
|
1403
|
+
* - To allow dynamic modifications, layers are rendered using canvas 2d
|
|
1404
|
+
* - Some devices like mobile phones are limited to 4k texture resolution
|
|
1405
|
+
* - So with 16x16 tiles this limits layers to 256x256 on mobile devices
|
|
1411
1406
|
* @extends EngineObject
|
|
1412
1407
|
* @example
|
|
1413
1408
|
* // create tile collision and visible tile layer
|
|
@@ -1597,8 +1592,8 @@ declare module "littlejs.esm" {
|
|
|
1597
1592
|
* @memberof Settings */
|
|
1598
1593
|
export let medalsPreventUnlock: boolean;
|
|
1599
1594
|
/** Initialize medals with a save name used for storage
|
|
1600
|
-
*
|
|
1601
|
-
*
|
|
1595
|
+
* - Call this after creating all medals
|
|
1596
|
+
* - Checks if medals are unlocked
|
|
1602
1597
|
* @param {String} saveName
|
|
1603
1598
|
* @memberof Medals */
|
|
1604
1599
|
export function medalsInit(saveName: string): void;
|
|
@@ -1708,7 +1703,7 @@ declare module "littlejs.esm" {
|
|
|
1708
1703
|
* @memberof WebGL */
|
|
1709
1704
|
export function glSetBlendMode(additive?: boolean): void;
|
|
1710
1705
|
/** Set the WebGl texture, not normally necessary unless multiple tile sheets are used
|
|
1711
|
-
*
|
|
1706
|
+
* - This may also flush the gl buffer resulting in more draw calls and worse performance
|
|
1712
1707
|
* @param {WebGLTexture} [texture=glTileTexture]
|
|
1713
1708
|
* @memberof WebGL */
|
|
1714
1709
|
export function glSetTexture(texture?: WebGLTexture): void;
|