littlejsengine 1.6.4 → 1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/build/littlejs.d.ts +92 -88
- package/build/littlejs.esm.js +312 -251
- package/build/littlejs.esm.min.js +1 -1
- package/build/littlejs.js +270 -206
- package/build/littlejs.min.js +1 -1
- package/build/littlejs.release.js +271 -203
- package/examples/breakout/index.html +3 -3
- package/examples/breakoutTutorial/index.html +2 -2
- package/examples/favicon.png +0 -0
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +1 -1
- package/examples/platformer/index.html +6 -6
- package/examples/puzzle/game.js +1 -1
- package/examples/puzzle/index.html +2 -2
- package/examples/starter/index.html +13 -13
- package/examples/stress/index.html +1 -1
- package/examples/typescript/index.html +1 -1
- package/package.json +2 -2
- package/src/engine.js +29 -30
- package/src/engineAudio.js +42 -18
- package/src/engineDebug.js +17 -22
- package/src/engineDraw.js +24 -24
- package/src/engineExport.js +42 -45
- package/src/engineInput.js +32 -19
- package/src/engineMedals.js +31 -8
- package/src/engineObject.js +21 -21
- package/src/engineParticles.js +3 -6
- package/src/engineRelease.js +18 -19
- package/src/engineSettings.js +4 -4
- package/src/engineTileLayer.js +18 -14
- package/src/engineUtilities.js +41 -32
- package/src/engineWebGL.js +8 -8
package/README.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## All aboard!
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
LittleJS is a super lightweight JavaScript game engine designed for modern web development. With its fast hybrid rendering system, it offers a comprehensive suite of game development tools from rendering to sound effects. The code is very clean and well documented with a variety of examples to get you started. Choo-Choo! 🚂
|
|
6
7
|
<div align="center">
|
|
7
8
|
|
|
8
9
|
## [Demo](https://killedbyapixel.github.io/LittleJS/examples/starter/) | [Docs](https://killedbyapixel.github.io/LittleJS/docs) | [Trailer](https://youtu.be/chuBzGjv7Ms) | [Discord](https://discord.gg/zb7hcGkyZe) | [Tutorial](https://github.com/KilledByAPixel/LittleJS/tree/main/examples/breakoutTutorial)
|
|
@@ -23,27 +24,29 @@ LittleJS is a super lightweight JavaScript game engine with a fast hybrid render
|
|
|
23
24
|
|
|
24
25
|
LittleJS is a small but powerful game engine with many features and no depenencies.
|
|
25
26
|
|
|
26
|
-
Graphics
|
|
27
|
+
### Graphics
|
|
27
28
|
|
|
28
29
|
- Fast sprite and tile map rendering engine with WebGL
|
|
29
30
|
- Update and render 10,000+ objects at 60fps, often many times more
|
|
30
31
|
- Apply [Shadertoy](https://www.shadertoy.com) compatible shaders for post processinge effects
|
|
31
32
|
|
|
32
|
-
Audio
|
|
33
|
+
### Audio
|
|
33
34
|
|
|
34
35
|
- Positional sound effects with [ZzFX](https://killedbyapixel.github.io/ZzFX/) sound effect generator
|
|
35
36
|
- Music with [ZzFXM](https://keithclark.github.io/ZzFXM/), mp3, or wav audio
|
|
36
37
|
|
|
37
|
-
Input
|
|
38
|
+
### Input
|
|
38
39
|
|
|
39
40
|
- Input processing system for keyboard, mouse, gamepad, and touch
|
|
41
|
+
- On screen touch gamepad for mobile devices
|
|
40
42
|
|
|
41
|
-
Physics
|
|
43
|
+
### Physics
|
|
42
44
|
|
|
45
|
+
- Kinematic physics object update
|
|
43
46
|
- 2D physics engine with collision handling for axis aligned boxes
|
|
44
47
|
- Very fast collision handling for tile maps
|
|
45
48
|
|
|
46
|
-
Flexability
|
|
49
|
+
### Flexability
|
|
47
50
|
|
|
48
51
|
- Designed to work with all modern web bowsers and mobile devices
|
|
49
52
|
- Compatible with TypeScript and includes [an example TS project](https://killedbyapixel.github.io/LittleJS/examples/typescript)
|
|
@@ -51,7 +54,7 @@ Flexability
|
|
|
51
54
|
- Build to a Windows executable with [Electron](https://www.electronjs.org/) for distribution on platforms like Steam
|
|
52
55
|
- Open Source with the [MIT license](https://github.com/KilledByAPixel/LittleJS/blob/main/LICENSE) so it can be used for anything you want
|
|
53
56
|
|
|
54
|
-
Extra Systems
|
|
57
|
+
### Extra Systems
|
|
55
58
|
|
|
56
59
|
- Debug rendering system
|
|
57
60
|
- Particle effects system and design tool
|
|
@@ -176,9 +179,9 @@ Optional Components, these components are built to synergize with the rest of th
|
|
|
176
179
|
|
|
177
180
|
## Debugging
|
|
178
181
|
|
|
179
|
-
Debug builds of LittleJS have a special menu that can be opened by pressing
|
|
182
|
+
Debug builds of LittleJS have a special menu that can be opened by pressing the Esc key.
|
|
180
183
|
|
|
181
|
-
-
|
|
184
|
+
- Esc: Debug Overlay
|
|
182
185
|
- 1: Debug Physics
|
|
183
186
|
- 2: Debug Particles
|
|
184
187
|
- 3: Debug Gamepads
|
|
@@ -198,6 +201,7 @@ Here are a few of the amazing games people are making with LittleJS.
|
|
|
198
201
|
- [Bit Butcher](https://js13kgames.com/entries/bit-butcher) - Survival crafting game by [Deathray Games](https://github.com/deathraygames/bit-butcher)
|
|
199
202
|
- [Necrotic Commander](https://js13kgames.com/entries/necrotic-commander) - Tower defense game by [Daniel Jeffery](https://github.com/d-jeffery/NecroticCommander)
|
|
200
203
|
- [Boxing up Bamboo](https://patrickgh3.itch.io/boxing-up-bamboo) - A challenging puzzle game by [Patrick Traynor](https://cwpat.me/about)
|
|
204
|
+
- [Samurai Sam](https://dev.js13kgames.com/2023/games/samurai-sam) - A Fruit Ninja inspired game by [John Edvard](https://reitgames.com)
|
|
201
205
|
- Send me your games!
|
|
202
206
|
|
|
203
207
|

|
package/build/littlejs.d.ts
CHANGED
|
@@ -1,164 +1,164 @@
|
|
|
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(prevent: any):
|
|
149
|
+
export function setMedalsPreventUnlock(prevent: any): 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):
|
|
153
|
+
export function setShowWatermark(show: boolean): void;
|
|
154
154
|
/** Set if god mode is enabled
|
|
155
155
|
* @param {Boolean} enable
|
|
156
156
|
* @memberof Debug */
|
|
157
|
-
export function setGodMode(enable: boolean):
|
|
157
|
+
export function setGodMode(enable: boolean): void;
|
|
158
158
|
/** Set key code used to toggle debug mode, Esc by default
|
|
159
159
|
* @param {Number} key
|
|
160
160
|
* @memberof Debug */
|
|
161
|
-
export function setDebugKey(key: number):
|
|
161
|
+
export function setDebugKey(key: number): void;
|
|
162
162
|
/** The max size of the canvas, centered if window is larger
|
|
163
163
|
* @type {Vector2}
|
|
164
164
|
* @default Vector2(1920,1200)
|
|
@@ -170,11 +170,11 @@ declare module "littlejs.esm" {
|
|
|
170
170
|
* @default Vector2()
|
|
171
171
|
* @memberof Settings */
|
|
172
172
|
export let canvasFixedSize: Vector2;
|
|
173
|
-
/** Disables
|
|
173
|
+
/** Disables filtering for crisper pixel art if true
|
|
174
174
|
* @type {Boolean}
|
|
175
175
|
* @default
|
|
176
176
|
* @memberof Settings */
|
|
177
|
-
export let
|
|
177
|
+
export let canvasPixelated: boolean;
|
|
178
178
|
/** Default font used for text rendering
|
|
179
179
|
* @type {String}
|
|
180
180
|
* @default
|
|
@@ -271,8 +271,8 @@ declare module "littlejs.esm" {
|
|
|
271
271
|
* @memberof Settings */
|
|
272
272
|
export let inputWASDEmulateDirection: boolean;
|
|
273
273
|
/** True if touch gamepad should appear on mobile devices
|
|
274
|
-
*
|
|
275
|
-
*
|
|
274
|
+
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
275
|
+
* - Must be set by end of gameInit to be activated
|
|
276
276
|
* @type {Boolean}
|
|
277
277
|
* @default 0
|
|
278
278
|
* @memberof Settings */
|
|
@@ -352,6 +352,10 @@ declare module "littlejs.esm" {
|
|
|
352
352
|
* @default
|
|
353
353
|
* @memberof Debug */
|
|
354
354
|
export let godMode: boolean;
|
|
355
|
+
/** Asserts if the experssion is false, does not do anything in release builds
|
|
356
|
+
* @param {Boolean} assertion
|
|
357
|
+
* @param {Object} output
|
|
358
|
+
* @memberof Debug */
|
|
355
359
|
export function ASSERT(...assert: any[]): void;
|
|
356
360
|
/** Draw a debug rectangle in world space
|
|
357
361
|
* @param {Vector2} pos
|
|
@@ -405,7 +409,7 @@ declare module "littlejs.esm" {
|
|
|
405
409
|
export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
|
|
406
410
|
/** Clear all debug primitives in the list
|
|
407
411
|
* @memberof Debug */
|
|
408
|
-
export function debugClear():
|
|
412
|
+
export function debugClear(): void;
|
|
409
413
|
/** Save a canvas to disk
|
|
410
414
|
* @param {HTMLCanvasElement} canvas
|
|
411
415
|
* @param {String} [filename]
|
|
@@ -539,7 +543,7 @@ declare module "littlejs.esm" {
|
|
|
539
543
|
/** Set seed used by the randSeeded function, should not be 0
|
|
540
544
|
* @param {Number} seed
|
|
541
545
|
* @memberof Random */
|
|
542
|
-
export function setRandSeed(seed: number):
|
|
546
|
+
export function setRandSeed(seed: number): void;
|
|
543
547
|
/** Returns a seeded random value between the two values passed in using randSeed
|
|
544
548
|
* @param {Number} [valueA=1]
|
|
545
549
|
* @param {Number} [valueB=0]
|
|
@@ -548,7 +552,7 @@ declare module "littlejs.esm" {
|
|
|
548
552
|
export function randSeeded(a?: number, b?: number): number;
|
|
549
553
|
/**
|
|
550
554
|
* 2D Vector object with vector math library
|
|
551
|
-
*
|
|
555
|
+
* - Functions do not change this so they can be chained together
|
|
552
556
|
* @example
|
|
553
557
|
* let a = new Vector2(2, 3); // vector with coordinates (2, 3)
|
|
554
558
|
* let b = new Vector2; // vector with coordinates (0, 0)
|
|
@@ -815,24 +819,24 @@ declare module "littlejs.esm" {
|
|
|
815
819
|
export function hsl(h?: number, s?: number, l?: number, a?: number): Color;
|
|
816
820
|
/**
|
|
817
821
|
* LittleJS Object Base Object Class
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
*
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
*
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
822
|
+
* - Base object class used by the engine
|
|
823
|
+
* - Automatically adds self to object list
|
|
824
|
+
* - Will be updated and rendered each frame
|
|
825
|
+
* - Renders as a sprite from a tilesheet by default
|
|
826
|
+
* - Can have color and addtive color applied
|
|
827
|
+
* - 2d Physics and collision system
|
|
828
|
+
* - Sorted by renderOrder
|
|
829
|
+
* - Objects can have children attached
|
|
830
|
+
* - Parents are updated before children, and set child transform
|
|
831
|
+
* - Call destroy() to get rid of objects
|
|
832
|
+
*
|
|
833
|
+
* The physics system used by objects is simple and fast with some caveats...
|
|
834
|
+
* - Collision uses the axis aligned size, the object's rotation angle is only for rendering
|
|
835
|
+
* - Objects are guaranteed to not intersect tile collision from physics
|
|
836
|
+
* - If an object starts or is moved inside tile collision, it will not collide with that tile
|
|
837
|
+
* - Collision for objects can be set to be solid to block other objects
|
|
838
|
+
* - Objects may get pushed into overlapping other solid objects, if so they will push away
|
|
839
|
+
* - Solid objects are more performance intensive and should be used sparingly
|
|
836
840
|
* @example
|
|
837
841
|
* // create an engine object, normally you would first extend the class with your own
|
|
838
842
|
* const pos = vec2(2,3);
|
|
@@ -1063,9 +1067,9 @@ declare module "littlejs.esm" {
|
|
|
1063
1067
|
export let engineFontImage: any;
|
|
1064
1068
|
/**
|
|
1065
1069
|
* Font Image Object - Draw text on a 2D canvas by using characters in an image
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1070
|
+
* - 96 characters (from space to tilde) are stored in an image
|
|
1071
|
+
* - Uses a default 8x8 font if none is supplied
|
|
1072
|
+
* - You can also use fonts from the main tile sheet
|
|
1069
1073
|
* @example
|
|
1070
1074
|
* // use built in font
|
|
1071
1075
|
* const font = new ImageFont;
|
|
@@ -1129,7 +1133,7 @@ declare module "littlejs.esm" {
|
|
|
1129
1133
|
export function keyWasReleased(key: number, device?: number): boolean;
|
|
1130
1134
|
/** Clears all input
|
|
1131
1135
|
* @memberof Input */
|
|
1132
|
-
export function clearInput():
|
|
1136
|
+
export function clearInput(): void;
|
|
1133
1137
|
/** Returns true if device key is down
|
|
1134
1138
|
* @param {Number} key
|
|
1135
1139
|
* @param {Number} [device=0]
|
|
@@ -1197,17 +1201,17 @@ declare module "littlejs.esm" {
|
|
|
1197
1201
|
/** Pulse the vibration hardware if it exists
|
|
1198
1202
|
* @param {Number} [pattern=100] - a single value in miliseconds or vibration interval array
|
|
1199
1203
|
* @memberof Input */
|
|
1200
|
-
export function vibrate(pattern?: number):
|
|
1204
|
+
export function vibrate(pattern?: number): void;
|
|
1201
1205
|
/** Cancel any ongoing vibration
|
|
1202
1206
|
* @memberof Input */
|
|
1203
|
-
export function vibrateStop():
|
|
1207
|
+
export function vibrateStop(): void;
|
|
1204
1208
|
/** True if a touch device has been detected
|
|
1205
1209
|
* @memberof Input */
|
|
1206
1210
|
export const isTouchDevice: boolean;
|
|
1207
1211
|
/**
|
|
1208
1212
|
* Sound Object - Stores a zzfx sound for later use and can be played positionally
|
|
1209
|
-
*
|
|
1210
|
-
* <
|
|
1213
|
+
*
|
|
1214
|
+
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
1211
1215
|
* @example
|
|
1212
1216
|
* // create a sound
|
|
1213
1217
|
* const sound_example = new Sound([.5,.5]);
|
|
@@ -1227,7 +1231,7 @@ declare module "littlejs.esm" {
|
|
|
1227
1231
|
/** @property {Number} - At what percentage of range should it start tapering off */
|
|
1228
1232
|
taper: number;
|
|
1229
1233
|
randomness: any;
|
|
1230
|
-
cachedSamples:
|
|
1234
|
+
cachedSamples: any[];
|
|
1231
1235
|
/** Play the sound
|
|
1232
1236
|
* @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
|
|
1233
1237
|
* @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
|
|
@@ -1246,8 +1250,8 @@ declare module "littlejs.esm" {
|
|
|
1246
1250
|
}
|
|
1247
1251
|
/**
|
|
1248
1252
|
* Music Object - Stores a zzfx music track for later use
|
|
1249
|
-
*
|
|
1250
|
-
* <
|
|
1253
|
+
*
|
|
1254
|
+
* <a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a>
|
|
1251
1255
|
* @example
|
|
1252
1256
|
* // create some music
|
|
1253
1257
|
* const music_example = new Music(
|
|
@@ -1332,12 +1336,12 @@ declare module "littlejs.esm" {
|
|
|
1332
1336
|
* @memberof Audio */
|
|
1333
1337
|
export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean): AudioBufferSourceNode;
|
|
1334
1338
|
/** Generate and play a ZzFX sound
|
|
1335
|
-
*
|
|
1336
|
-
* <
|
|
1339
|
+
*
|
|
1340
|
+
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
1337
1341
|
* @param {Array} zzfxSound - Array of ZzFX parameters, ex. [.5,.5]
|
|
1338
|
-
* @return {
|
|
1342
|
+
* @return {AudioBufferSourceNode} - The audio node of the sound played
|
|
1339
1343
|
* @memberof Audio */
|
|
1340
|
-
export function zzfx(...zzfxSound: any[]):
|
|
1344
|
+
export function zzfx(...zzfxSound: any[]): AudioBufferSourceNode;
|
|
1341
1345
|
/** The tile collision layer array, use setTileCollisionData and getTileCollisionData to access
|
|
1342
1346
|
* @type {Array}
|
|
1343
1347
|
* @memberof TileCollision */
|
|
@@ -1354,7 +1358,7 @@ declare module "littlejs.esm" {
|
|
|
1354
1358
|
* @param {Vector2} pos
|
|
1355
1359
|
* @param {Number} [data=0]
|
|
1356
1360
|
* @memberof TileCollision */
|
|
1357
|
-
export function setTileCollisionData(pos: Vector2, data?: number):
|
|
1361
|
+
export function setTileCollisionData(pos: Vector2, data?: number): void;
|
|
1358
1362
|
/** Get tile collision data
|
|
1359
1363
|
* @param {Vector2} pos
|
|
1360
1364
|
* @return {Number}
|
|
@@ -1404,10 +1408,10 @@ declare module "littlejs.esm" {
|
|
|
1404
1408
|
}
|
|
1405
1409
|
/**
|
|
1406
1410
|
* Tile layer object - cached rendering system for tile layers
|
|
1407
|
-
*
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
+
* - Each Tile layer is rendered to an off screen canvas
|
|
1412
|
+
* - To allow dynamic modifications, layers are rendered using canvas 2d
|
|
1413
|
+
* - Some devices like mobile phones are limited to 4k texture resolution
|
|
1414
|
+
* - So with 16x16 tiles this limits layers to 256x256 on mobile devices
|
|
1411
1415
|
* @extends EngineObject
|
|
1412
1416
|
* @example
|
|
1413
1417
|
* // create tile collision and visible tile layer
|
|
@@ -1597,8 +1601,8 @@ declare module "littlejs.esm" {
|
|
|
1597
1601
|
* @memberof Settings */
|
|
1598
1602
|
export let medalsPreventUnlock: boolean;
|
|
1599
1603
|
/** Initialize medals with a save name used for storage
|
|
1600
|
-
*
|
|
1601
|
-
*
|
|
1604
|
+
* - Call this after creating all medals
|
|
1605
|
+
* - Checks if medals are unlocked
|
|
1602
1606
|
* @param {String} saveName
|
|
1603
1607
|
* @memberof Medals */
|
|
1604
1608
|
export function medalsInit(saveName: string): void;
|
|
@@ -1708,7 +1712,7 @@ declare module "littlejs.esm" {
|
|
|
1708
1712
|
* @memberof WebGL */
|
|
1709
1713
|
export function glSetBlendMode(additive?: boolean): void;
|
|
1710
1714
|
/** Set the WebGl texture, not normally necessary unless multiple tile sheets are used
|
|
1711
|
-
*
|
|
1715
|
+
* - This may also flush the gl buffer resulting in more draw calls and worse performance
|
|
1712
1716
|
* @param {WebGLTexture} [texture=glTileTexture]
|
|
1713
1717
|
* @memberof WebGL */
|
|
1714
1718
|
export function glSetTexture(texture?: WebGLTexture): void;
|