littlejsengine 1.7.21 → 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.
- package/README.md +28 -55
- package/build/littlejs.d.ts +595 -552
- package/build/littlejs.esm.js +626 -535
- package/build/littlejs.esm.min.js +1 -1
- package/build/littlejs.js +542 -264
- package/build/littlejs.min.js +1 -1
- package/build/littlejs.release.js +542 -264
- package/examples/breakout/game.js +17 -14
- package/examples/breakout/gameObjects.js +29 -8
- package/examples/breakout/index.html +3 -3
- package/examples/breakoutTutorial/README.md +3 -3
- package/examples/breakoutTutorial/game.js +4 -4
- package/examples/breakoutTutorial/index.html +2 -2
- package/examples/electron/game.js +3 -2
- package/examples/electron/index.html +2 -2
- package/examples/empty/game.js +1 -1
- package/examples/favicon.png +0 -0
- package/examples/js13k/game.js +20 -15
- package/examples/js13k/index.html +14 -14
- package/examples/module/game.js +5 -4
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +19 -22
- package/examples/platformer/game.js +3 -3
- package/examples/platformer/gameEffects.js +21 -19
- package/examples/platformer/gameLevel.js +6 -6
- package/examples/platformer/gameObjects.js +18 -18
- package/examples/platformer/gamePlayer.js +4 -3
- package/examples/platformer/index.html +6 -6
- package/examples/platformer/tiles.png +0 -0
- package/examples/platformer/tilesLevel.png +0 -0
- package/examples/puzzle/game.js +10 -8
- package/examples/puzzle/index.html +2 -2
- package/examples/screenshot.jpg +0 -0
- package/examples/starter/game.js +32 -21
- package/examples/starter/index.html +13 -13
- package/examples/starter/tiles.png +0 -0
- package/examples/stress/index.html +4 -4
- package/examples/typescript/game.js +4 -3
- package/examples/typescript/game.ts +5 -4
- package/examples/typescript/index.html +1 -1
- package/package.json +2 -1
- package/src/engine.js +59 -52
- package/src/engineAudio.js +2 -1
- package/src/engineDraw.js +171 -55
- package/src/engineExport.js +84 -271
- package/src/engineMedals.js +13 -45
- package/src/engineObject.js +13 -13
- package/src/engineParticles.js +17 -17
- package/src/engineSettings.js +195 -2
- package/src/engineTileLayer.js +23 -22
- package/src/engineUtilities.js +6 -6
- package/src/engineWebGL.js +43 -50
package/build/littlejs.d.ts
CHANGED
|
@@ -1,160 +1,188 @@
|
|
|
1
1
|
declare module "littlejs.esm" {
|
|
2
2
|
/**
|
|
3
|
-
* LittleJS
|
|
4
|
-
*
|
|
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
|
|
5
20
|
*/
|
|
6
|
-
/**
|
|
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
|
|
7
113
|
* @param {Vector2} pos
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @param {Number}
|
|
12
|
-
* @
|
|
13
|
-
export function setCameraScale(scale: number): void;
|
|
14
|
-
/** Set max size of the canvas
|
|
15
|
-
* @param {Vector2} size
|
|
16
|
-
* @memberof Settings */
|
|
17
|
-
export function setCanvasMaxSize(size: Vector2): void;
|
|
18
|
-
/** Set fixed size of the canvas
|
|
19
|
-
* @param {Vector2} size
|
|
20
|
-
* @memberof Settings */
|
|
21
|
-
export function setCanvasFixedSize(size: Vector2): void;
|
|
22
|
-
/** Disables anti aliasing for pixel art if true
|
|
23
|
-
* @param {Boolean} pixelated
|
|
24
|
-
* @memberof Settings */
|
|
25
|
-
export function setCanvasPixelated(pixelated: boolean): void;
|
|
26
|
-
/** Set default font used for text rendering
|
|
27
|
-
* @param {String} font
|
|
28
|
-
* @memberof Settings */
|
|
29
|
-
export function setFontDefault(font: string): void;
|
|
30
|
-
/** Set if webgl rendering is enabled
|
|
31
|
-
* @param {Boolean} enable
|
|
32
|
-
* @memberof Settings */
|
|
33
|
-
export function setGlEnable(enable: boolean): void;
|
|
34
|
-
/** Set to not composite the WebGL canvas
|
|
35
|
-
* @param {Boolean} overlay
|
|
36
|
-
* @memberof Settings */
|
|
37
|
-
export function setGlOverlay(overlay: boolean): void;
|
|
38
|
-
/** Set default size of tiles in pixels
|
|
39
|
-
* @param {Vector2} size
|
|
40
|
-
* @memberof Settings */
|
|
41
|
-
export function setTileSizeDefault(size: Vector2): void;
|
|
42
|
-
/** Set to prevent tile bleeding from neighbors in pixels
|
|
43
|
-
* @param {Number} scale
|
|
44
|
-
* @memberof Settings */
|
|
45
|
-
export function setTileFixBleedScale(scale: number): void;
|
|
46
|
-
/** Set if collisions between objects are enabled
|
|
47
|
-
* @param {Boolean} enable
|
|
48
|
-
* @memberof Settings */
|
|
49
|
-
export function setEnablePhysicsSolver(enable: boolean): void;
|
|
50
|
-
/** Set default object mass for collison calcuations
|
|
51
|
-
* @param {Number} mass
|
|
52
|
-
* @memberof Settings */
|
|
53
|
-
export function setObjectDefaultMass(mass: number): void;
|
|
54
|
-
/** Set how much to slow velocity by each frame
|
|
55
|
-
* @param {Number} damping
|
|
56
|
-
* @memberof Settings */
|
|
57
|
-
export function setObjectDefaultDamping(damp: any): void;
|
|
58
|
-
/** Set how much to slow angular velocity each frame
|
|
59
|
-
* @param {Number} damping
|
|
60
|
-
* @memberof Settings */
|
|
61
|
-
export function setObjectDefaultAngleDamping(damp: any): void;
|
|
62
|
-
/** Set how much to bounce when a collision occur
|
|
63
|
-
* @param {Number} elasticity
|
|
64
|
-
* @memberof Settings */
|
|
65
|
-
export function setObjectDefaultElasticity(elasticity: number): void;
|
|
66
|
-
/** Set how much to slow when touching
|
|
67
|
-
* @param {Number} friction
|
|
68
|
-
* @memberof Settings */
|
|
69
|
-
export function setObjectDefaultFriction(friction: number): void;
|
|
70
|
-
/** Set max speed to avoid fast objects missing collisions
|
|
71
|
-
* @param {Number} speed
|
|
72
|
-
* @memberof Settings */
|
|
73
|
-
export function setObjectMaxSpeed(speed: number): void;
|
|
74
|
-
/** Set how much gravity to apply to objects along the Y axis
|
|
75
|
-
* @param {Number} gravity
|
|
76
|
-
* @memberof Settings */
|
|
77
|
-
export function setGravity(g: any): void;
|
|
78
|
-
/** Set to scales emit rate of particles
|
|
79
|
-
* @param {Number} scale
|
|
80
|
-
* @memberof Settings */
|
|
81
|
-
export function setParticleEmitRateScale(scale: number): void;
|
|
82
|
-
/** Set if gamepads are enabled
|
|
83
|
-
* @param {Boolean} enable
|
|
84
|
-
* @memberof Settings */
|
|
85
|
-
export function setGamepadsEnable(enable: boolean): void;
|
|
86
|
-
/** Set if the dpad input is also routed to the left analog stick
|
|
87
|
-
* @param {Boolean} enable
|
|
88
|
-
* @memberof Settings */
|
|
89
|
-
export function setGamepadDirectionEmulateStick(enable: boolean): void;
|
|
90
|
-
/** Set if true the WASD keys are also routed to the direction keys
|
|
91
|
-
* @param {Boolean} enable
|
|
92
|
-
* @memberof Settings */
|
|
93
|
-
export function setInputWASDEmulateDirection(enable: boolean): void;
|
|
94
|
-
/** Set if touch gamepad should appear on mobile devices
|
|
95
|
-
* @param {Boolean} enable
|
|
96
|
-
* @memberof Settings */
|
|
97
|
-
export function setTouchGamepadEnable(enable: boolean): void;
|
|
98
|
-
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
99
|
-
* @param {Boolean} analog
|
|
100
|
-
* @memberof Settings */
|
|
101
|
-
export function setTouchGamepadAnalog(analog: boolean): void;
|
|
102
|
-
/** Set size of virutal gamepad for touch devices in pixels
|
|
103
|
-
* @param {Number} size
|
|
104
|
-
* @memberof Settings */
|
|
105
|
-
export function setTouchGamepadSize(size: number): void;
|
|
106
|
-
/** Set transparency of touch gamepad overlay
|
|
107
|
-
* @param {Number} alpha
|
|
108
|
-
* @memberof Settings */
|
|
109
|
-
export function setTouchGamepadAlpha(alpha: number): void;
|
|
110
|
-
/** Set to allow vibration hardware if it exists
|
|
111
|
-
* @param {Boolean} enable
|
|
112
|
-
* @memberof Settings */
|
|
113
|
-
export function setVibrateEnable(enable: boolean): void;
|
|
114
|
-
/** Set to disable all audio code
|
|
115
|
-
* @param {Boolean} enable
|
|
116
|
-
* @memberof Settings */
|
|
117
|
-
export function setSoundEnable(enable: boolean): void;
|
|
118
|
-
/** Set volume scale to apply to all sound, music and speech
|
|
119
|
-
* @param {Number} volume
|
|
120
|
-
* @memberof Settings */
|
|
121
|
-
export function setSoundVolume(volume: number): void;
|
|
122
|
-
/** Set default range where sound no longer plays
|
|
123
|
-
* @param {Number} range
|
|
124
|
-
* @memberof Settings */
|
|
125
|
-
export function setSoundDefaultRange(range: number): void;
|
|
126
|
-
/** Set default range percent to start tapering off sound
|
|
127
|
-
* @param {Number} taper
|
|
128
|
-
* @memberof Settings */
|
|
129
|
-
export function setSoundDefaultTaper(taper: number): void;
|
|
130
|
-
/** Set how long to show medals for in seconds
|
|
131
|
-
* @param {Number} time
|
|
132
|
-
* @memberof Settings */
|
|
133
|
-
export function setMedalDisplayTime(time: number): void;
|
|
134
|
-
/** Set how quickly to slide on/off medals in seconds
|
|
135
|
-
* @param {Number} time
|
|
136
|
-
* @memberof Settings */
|
|
137
|
-
export function setMedalDisplaySlideTime(time: number): void;
|
|
138
|
-
/** Set size of medal display
|
|
139
|
-
* @param {Vector2} size
|
|
140
|
-
* @memberof Settings */
|
|
141
|
-
export function setMedalDisplaySize(size: Vector2): void;
|
|
142
|
-
/** Set size of icon in medal display
|
|
143
|
-
* @param {Number} size
|
|
144
|
-
* @memberof Settings */
|
|
145
|
-
export function setMedalDisplayIconSize(size: number): void;
|
|
146
|
-
/** Set to stop medals from being unlockable
|
|
147
|
-
* @param {Boolean} preventUnlock
|
|
148
|
-
* @memberof Settings */
|
|
149
|
-
export function setMedalsPreventUnlock(preventUnlock: boolean): void;
|
|
150
|
-
/** Set if watermark with FPS should be shown
|
|
151
|
-
* @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]
|
|
152
119
|
* @memberof Debug */
|
|
153
|
-
export function
|
|
154
|
-
/**
|
|
155
|
-
* @param {
|
|
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]
|
|
156
127
|
* @memberof Debug */
|
|
157
|
-
export function
|
|
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;
|
|
158
186
|
/** The max size of the canvas, centered if window is larger
|
|
159
187
|
* @type {Vector2}
|
|
160
188
|
* @default Vector2(1920,1200)
|
|
@@ -181,7 +209,7 @@ declare module "littlejs.esm" {
|
|
|
181
209
|
* @default Vector2(16,16)
|
|
182
210
|
* @memberof Settings */
|
|
183
211
|
export let tileSizeDefault: Vector2;
|
|
184
|
-
/**
|
|
212
|
+
/** How many pixels smaller to draw tiles to prevent bleeding from neighbors
|
|
185
213
|
* @type {Number}
|
|
186
214
|
* @default
|
|
187
215
|
* @memberof Settings */
|
|
@@ -231,21 +259,6 @@ declare module "littlejs.esm" {
|
|
|
231
259
|
* @default
|
|
232
260
|
* @memberof Settings */
|
|
233
261
|
export let particleEmitRateScale: number;
|
|
234
|
-
/**
|
|
235
|
-
* LittleJS Engine Settings
|
|
236
|
-
* - All settings for the engine are here
|
|
237
|
-
* @namespace Settings
|
|
238
|
-
*/
|
|
239
|
-
/** Position of camera in world space
|
|
240
|
-
* @type {Vector2}
|
|
241
|
-
* @default Vector2()
|
|
242
|
-
* @memberof Settings */
|
|
243
|
-
export let cameraPos: Vector2;
|
|
244
|
-
/** Scale of camera in world space
|
|
245
|
-
* @type {Number}
|
|
246
|
-
* @default
|
|
247
|
-
* @memberof Settings */
|
|
248
|
-
export let cameraScale: number;
|
|
249
262
|
/** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
|
|
250
263
|
* @type {Boolean}
|
|
251
264
|
* @default
|
|
@@ -327,100 +340,169 @@ declare module "littlejs.esm" {
|
|
|
327
340
|
* @type {Number}
|
|
328
341
|
* @default
|
|
329
342
|
* @memberof Settings */
|
|
330
|
-
export let medalDisplaySlideTime: number;
|
|
331
|
-
/** Size of medal display
|
|
332
|
-
* @type {Vector2}
|
|
333
|
-
* @default Vector2(640,80)
|
|
343
|
+
export let medalDisplaySlideTime: number;
|
|
344
|
+
/** Size of medal display
|
|
345
|
+
* @type {Vector2}
|
|
346
|
+
* @default Vector2(640,80)
|
|
347
|
+
* @memberof Settings */
|
|
348
|
+
export let medalDisplaySize: Vector2;
|
|
349
|
+
/** Size of icon in medal display
|
|
350
|
+
* @type {Number}
|
|
351
|
+
* @default
|
|
352
|
+
* @memberof Settings */
|
|
353
|
+
export let medalDisplayIconSize: number;
|
|
354
|
+
/** Set position of camera in world space
|
|
355
|
+
* @param {Vector2} pos
|
|
356
|
+
* @memberof Settings */
|
|
357
|
+
export function setCameraPos(pos: Vector2): void;
|
|
358
|
+
/** Set scale of camera in world space
|
|
359
|
+
* @param {Number} scale
|
|
360
|
+
* @memberof Settings */
|
|
361
|
+
export function setCameraScale(scale: number): void;
|
|
362
|
+
/** Set max size of the canvas
|
|
363
|
+
* @param {Vector2} size
|
|
364
|
+
* @memberof Settings */
|
|
365
|
+
export function setCanvasMaxSize(size: Vector2): void;
|
|
366
|
+
/** Set fixed size of the canvas
|
|
367
|
+
* @param {Vector2} size
|
|
368
|
+
* @memberof Settings */
|
|
369
|
+
export function setCanvasFixedSize(size: Vector2): void;
|
|
370
|
+
/** Disables anti aliasing for pixel art if true
|
|
371
|
+
* @param {Boolean} pixelated
|
|
372
|
+
* @memberof Settings */
|
|
373
|
+
export function setCanvasPixelated(pixelated: boolean): void;
|
|
374
|
+
/** Set default font used for text rendering
|
|
375
|
+
* @param {String} font
|
|
376
|
+
* @memberof Settings */
|
|
377
|
+
export function setFontDefault(font: string): void;
|
|
378
|
+
/** Set if webgl rendering is enabled
|
|
379
|
+
* @param {Boolean} enable
|
|
380
|
+
* @memberof Settings */
|
|
381
|
+
export function setGlEnable(enable: boolean): void;
|
|
382
|
+
/** Set to not composite the WebGL canvas
|
|
383
|
+
* @param {Boolean} overlay
|
|
384
|
+
* @memberof Settings */
|
|
385
|
+
export function setGlOverlay(overlay: boolean): void;
|
|
386
|
+
/** Set default size of tiles in pixels
|
|
387
|
+
* @param {Vector2} size
|
|
388
|
+
* @memberof Settings */
|
|
389
|
+
export function setTileSizeDefault(size: Vector2): void;
|
|
390
|
+
/** Set to prevent tile bleeding from neighbors in pixels
|
|
391
|
+
* @param {Number} scale
|
|
392
|
+
* @memberof Settings */
|
|
393
|
+
export function setTileFixBleedScale(scale: number): void;
|
|
394
|
+
/** Set if collisions between objects are enabled
|
|
395
|
+
* @param {Boolean} enable
|
|
396
|
+
* @memberof Settings */
|
|
397
|
+
export function setEnablePhysicsSolver(enable: boolean): void;
|
|
398
|
+
/** Set default object mass for collison calcuations
|
|
399
|
+
* @param {Number} mass
|
|
400
|
+
* @memberof Settings */
|
|
401
|
+
export function setObjectDefaultMass(mass: number): void;
|
|
402
|
+
/** Set how much to slow velocity by each frame
|
|
403
|
+
* @param {Number} damping
|
|
404
|
+
* @memberof Settings */
|
|
405
|
+
export function setObjectDefaultDamping(damp: any): void;
|
|
406
|
+
/** Set how much to slow angular velocity each frame
|
|
407
|
+
* @param {Number} damping
|
|
408
|
+
* @memberof Settings */
|
|
409
|
+
export function setObjectDefaultAngleDamping(damp: any): void;
|
|
410
|
+
/** Set how much to bounce when a collision occur
|
|
411
|
+
* @param {Number} elasticity
|
|
412
|
+
* @memberof Settings */
|
|
413
|
+
export function setObjectDefaultElasticity(elasticity: number): void;
|
|
414
|
+
/** Set how much to slow when touching
|
|
415
|
+
* @param {Number} friction
|
|
416
|
+
* @memberof Settings */
|
|
417
|
+
export function setObjectDefaultFriction(friction: number): void;
|
|
418
|
+
/** Set max speed to avoid fast objects missing collisions
|
|
419
|
+
* @param {Number} speed
|
|
420
|
+
* @memberof Settings */
|
|
421
|
+
export function setObjectMaxSpeed(speed: number): void;
|
|
422
|
+
/** Set how much gravity to apply to objects along the Y axis
|
|
423
|
+
* @param {Number} gravity
|
|
424
|
+
* @memberof Settings */
|
|
425
|
+
export function setGravity(g: any): void;
|
|
426
|
+
/** Set to scales emit rate of particles
|
|
427
|
+
* @param {Number} scale
|
|
428
|
+
* @memberof Settings */
|
|
429
|
+
export function setParticleEmitRateScale(scale: number): void;
|
|
430
|
+
/** Set if gamepads are enabled
|
|
431
|
+
* @param {Boolean} enable
|
|
432
|
+
* @memberof Settings */
|
|
433
|
+
export function setGamepadsEnable(enable: boolean): void;
|
|
434
|
+
/** Set if the dpad input is also routed to the left analog stick
|
|
435
|
+
* @param {Boolean} enable
|
|
436
|
+
* @memberof Settings */
|
|
437
|
+
export function setGamepadDirectionEmulateStick(enable: boolean): void;
|
|
438
|
+
/** Set if true the WASD keys are also routed to the direction keys
|
|
439
|
+
* @param {Boolean} enable
|
|
440
|
+
* @memberof Settings */
|
|
441
|
+
export function setInputWASDEmulateDirection(enable: boolean): void;
|
|
442
|
+
/** Set if touch gamepad should appear on mobile devices
|
|
443
|
+
* @param {Boolean} enable
|
|
444
|
+
* @memberof Settings */
|
|
445
|
+
export function setTouchGamepadEnable(enable: boolean): void;
|
|
446
|
+
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
447
|
+
* @param {Boolean} analog
|
|
448
|
+
* @memberof Settings */
|
|
449
|
+
export function setTouchGamepadAnalog(analog: boolean): void;
|
|
450
|
+
/** Set size of virutal gamepad for touch devices in pixels
|
|
451
|
+
* @param {Number} size
|
|
452
|
+
* @memberof Settings */
|
|
453
|
+
export function setTouchGamepadSize(size: number): void;
|
|
454
|
+
/** Set transparency of touch gamepad overlay
|
|
455
|
+
* @param {Number} alpha
|
|
456
|
+
* @memberof Settings */
|
|
457
|
+
export function setTouchGamepadAlpha(alpha: number): void;
|
|
458
|
+
/** Set to allow vibration hardware if it exists
|
|
459
|
+
* @param {Boolean} enable
|
|
460
|
+
* @memberof Settings */
|
|
461
|
+
export function setVibrateEnable(enable: boolean): void;
|
|
462
|
+
/** Set to disable all audio code
|
|
463
|
+
* @param {Boolean} enable
|
|
464
|
+
* @memberof Settings */
|
|
465
|
+
export function setSoundEnable(enable: boolean): void;
|
|
466
|
+
/** Set volume scale to apply to all sound, music and speech
|
|
467
|
+
* @param {Number} volume
|
|
468
|
+
* @memberof Settings */
|
|
469
|
+
export function setSoundVolume(volume: number): void;
|
|
470
|
+
/** Set default range where sound no longer plays
|
|
471
|
+
* @param {Number} range
|
|
472
|
+
* @memberof Settings */
|
|
473
|
+
export function setSoundDefaultRange(range: number): void;
|
|
474
|
+
/** Set default range percent to start tapering off sound
|
|
475
|
+
* @param {Number} taper
|
|
476
|
+
* @memberof Settings */
|
|
477
|
+
export function setSoundDefaultTaper(taper: number): void;
|
|
478
|
+
/** Set how long to show medals for in seconds
|
|
479
|
+
* @param {Number} time
|
|
480
|
+
* @memberof Settings */
|
|
481
|
+
export function setMedalDisplayTime(time: number): void;
|
|
482
|
+
/** Set how quickly to slide on/off medals in seconds
|
|
483
|
+
* @param {Number} time
|
|
484
|
+
* @memberof Settings */
|
|
485
|
+
export function setMedalDisplaySlideTime(time: number): void;
|
|
486
|
+
/** Set size of medal display
|
|
487
|
+
* @param {Vector2} size
|
|
334
488
|
* @memberof Settings */
|
|
335
|
-
export
|
|
336
|
-
/**
|
|
337
|
-
* @
|
|
338
|
-
* @default
|
|
489
|
+
export function setMedalDisplaySize(size: Vector2): void;
|
|
490
|
+
/** Set size of icon in medal display
|
|
491
|
+
* @param {Number} size
|
|
339
492
|
* @memberof Settings */
|
|
340
|
-
export
|
|
341
|
-
/**
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
*
|
|
347
|
-
* - Save a 2d canvas as a png image
|
|
348
|
-
* @namespace Debug
|
|
349
|
-
*/
|
|
350
|
-
/** True if debug is enabled
|
|
351
|
-
* @type {Boolean}
|
|
352
|
-
* @default
|
|
353
|
-
* @memberof Debug */
|
|
354
|
-
export const debug: boolean;
|
|
355
|
-
/** True if watermark with FPS should be shown, false in release builds
|
|
356
|
-
* @type {Boolean}
|
|
357
|
-
* @default
|
|
358
|
-
* @memberof Debug */
|
|
359
|
-
export let showWatermark: boolean;
|
|
360
|
-
/** Asserts if the experssion is false, does not do anything in release builds
|
|
361
|
-
* @param {Boolean} assertion
|
|
362
|
-
* @param {Object} output
|
|
363
|
-
* @memberof Debug */
|
|
364
|
-
export function ASSERT(...assert: any[]): void;
|
|
365
|
-
/** Draw a debug rectangle in world space
|
|
366
|
-
* @param {Vector2} pos
|
|
367
|
-
* @param {Vector2} [size=Vector2()]
|
|
368
|
-
* @param {String} [color='#fff']
|
|
369
|
-
* @param {Number} [time=0]
|
|
370
|
-
* @param {Number} [angle=0]
|
|
371
|
-
* @param {Boolean} [fill=false]
|
|
372
|
-
* @memberof Debug */
|
|
373
|
-
export function debugRect(pos: Vector2, size?: Vector2, color?: string, time?: number, angle?: number, fill?: boolean): void;
|
|
374
|
-
/** Draw a debug circle in world space
|
|
375
|
-
* @param {Vector2} pos
|
|
376
|
-
* @param {Number} [radius=0]
|
|
377
|
-
* @param {String} [color='#fff']
|
|
378
|
-
* @param {Number} [time=0]
|
|
379
|
-
* @param {Boolean} [fill=false]
|
|
380
|
-
* @memberof Debug */
|
|
381
|
-
export function debugCircle(pos: Vector2, radius?: number, color?: string, time?: number, fill?: boolean): void;
|
|
382
|
-
/** Draw a debug point in world space
|
|
383
|
-
* @param {Vector2} pos
|
|
384
|
-
* @param {String} [color='#fff']
|
|
385
|
-
* @param {Number} [time=0]
|
|
386
|
-
* @param {Number} [angle=0]
|
|
387
|
-
* @memberof Debug */
|
|
388
|
-
export function debugPoint(pos: Vector2, color?: string, time?: number, angle?: number): void;
|
|
389
|
-
/** Draw a debug line in world space
|
|
390
|
-
* @param {Vector2} posA
|
|
391
|
-
* @param {Vector2} posB
|
|
392
|
-
* @param {String} [color='#fff']
|
|
393
|
-
* @param {Number} [thickness=.1]
|
|
394
|
-
* @param {Number} [time=0]
|
|
395
|
-
* @memberof Debug */
|
|
396
|
-
export function debugLine(posA: Vector2, posB: Vector2, color?: string, thickness?: number, time?: number): void;
|
|
397
|
-
/** Draw a debug axis aligned bounding box in world space
|
|
398
|
-
* @param {Vector2} posA
|
|
399
|
-
* @param {Vector2} sizeA
|
|
400
|
-
* @param {Vector2} posB
|
|
401
|
-
* @param {Vector2} sizeB
|
|
402
|
-
* @param {String} [color='#fff']
|
|
403
|
-
* @memberof Debug */
|
|
404
|
-
export function debugAABB(pA: any, sA: any, pB: any, sB: any, color?: string): void;
|
|
405
|
-
/** Draw a debug axis aligned bounding box in world space
|
|
406
|
-
* @param {String} text
|
|
407
|
-
* @param {Vector2} pos
|
|
408
|
-
* @param {Number} [size=1]
|
|
409
|
-
* @param {String} [color='#fff']
|
|
410
|
-
* @param {Number} [time=0]
|
|
411
|
-
* @param {Number} [angle=0]
|
|
412
|
-
* @param {String} [font='monospace']
|
|
413
|
-
* @memberof Debug */
|
|
414
|
-
export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
|
|
415
|
-
/** Clear all debug primitives in the list
|
|
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
|
|
416
500
|
* @memberof Debug */
|
|
417
|
-
export function
|
|
418
|
-
/**
|
|
419
|
-
* @param {
|
|
420
|
-
* @param {String} [filename]
|
|
421
|
-
* @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
|
|
422
504
|
* @memberof Debug */
|
|
423
|
-
export function
|
|
505
|
+
export function setDebugKey(key: number): void;
|
|
424
506
|
/**
|
|
425
507
|
* LittleJS Utility Classes and Functions
|
|
426
508
|
* - General purpose math library
|
|
@@ -583,10 +665,10 @@ declare module "littlejs.esm" {
|
|
|
583
665
|
* - Can be used to create a deterministic random number sequence
|
|
584
666
|
* @example
|
|
585
667
|
* let r = new RandomGenerator(123); // random number generator with seed 123
|
|
586
|
-
* let a = r.
|
|
587
|
-
* let b = r.
|
|
668
|
+
* let a = r.float(); // random value between 0 and 1
|
|
669
|
+
* let b = r.int(10); // random integer between 0 and 9
|
|
588
670
|
* r.seed = 123; // reset the seed
|
|
589
|
-
* let c = r.
|
|
671
|
+
* let c = r.float(); // the same value as a
|
|
590
672
|
*/
|
|
591
673
|
export class RandomGenerator {
|
|
592
674
|
/** Create a random number generator with the seed passed in
|
|
@@ -844,7 +926,7 @@ declare module "littlejs.esm" {
|
|
|
844
926
|
}
|
|
845
927
|
/**
|
|
846
928
|
* Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar
|
|
847
|
-
* @param {Number} [x=0]
|
|
929
|
+
* @param {(Number|Vector2)} [x=0]
|
|
848
930
|
* @param {Number} [y=0]
|
|
849
931
|
* @return {Vector2}
|
|
850
932
|
* @example
|
|
@@ -854,7 +936,7 @@ declare module "littlejs.esm" {
|
|
|
854
936
|
* b = vec2(); // set b to (0, 0)
|
|
855
937
|
* @memberof Utilities
|
|
856
938
|
*/
|
|
857
|
-
export function vec2(x?: number, y?: number): Vector2;
|
|
939
|
+
export function vec2(x?: (number | Vector2), y?: number): Vector2;
|
|
858
940
|
/**
|
|
859
941
|
* Create a color object with RGBA values
|
|
860
942
|
* @param {Number} [r=1] - red
|
|
@@ -875,136 +957,64 @@ declare module "littlejs.esm" {
|
|
|
875
957
|
* @memberof Utilities
|
|
876
958
|
*/
|
|
877
959
|
export function hsl(h?: number, s?: number, l?: number, a?: number): Color;
|
|
960
|
+
/** Array containing texture info for batch rendering system
|
|
961
|
+
* @type {Array}
|
|
962
|
+
* @memberof Draw */
|
|
963
|
+
export let textureInfos: any[];
|
|
878
964
|
/**
|
|
879
|
-
*
|
|
965
|
+
* Create a tile info object
|
|
966
|
+
* - This can take vecs or floats for easier use and conversion
|
|
967
|
+
* - If an index is passed in, the tile size and index will determine the position
|
|
968
|
+
* @param {(Number|Vector2)} [pos=Vector2()] - Top left corner of tile in pixels or index
|
|
969
|
+
* @param {(Number|Vector2)} [size=tileSizeDefault] - Size of tile in pixels
|
|
970
|
+
* @param {Number} [textureIndex=0] - Texture index to use
|
|
971
|
+
* @return {TileInfo}
|
|
972
|
+
* @example
|
|
973
|
+
* tile(2) // a tile at index 2 using the default tile size of 16
|
|
974
|
+
* tile(5, 8) // a tile at index 5 using a tile size of 8
|
|
975
|
+
* tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3
|
|
976
|
+
* tile(vec2(4,8), vec2(30,10)) // a tile at pixel location (4,8) with a size of (30,10)
|
|
977
|
+
* @memberof Draw
|
|
880
978
|
*/
|
|
979
|
+
export function tile(pos?: (number | Vector2), size?: (number | Vector2), textureIndex?: number): TileInfo;
|
|
881
980
|
/**
|
|
882
|
-
*
|
|
883
|
-
* - Top level object class used by the engine
|
|
884
|
-
* - Automatically adds self to object list
|
|
885
|
-
* - Will be updated and rendered each frame
|
|
886
|
-
* - Renders as a sprite from a tilesheet by default
|
|
887
|
-
* - Can have color and addtive color applied
|
|
888
|
-
* - 2D Physics and collision system
|
|
889
|
-
* - Sorted by renderOrder
|
|
890
|
-
* - Objects can have children attached
|
|
891
|
-
* - Parents are updated before children, and set child transform
|
|
892
|
-
* - Call destroy() to get rid of objects
|
|
893
|
-
*
|
|
894
|
-
* The physics system used by objects is simple and fast with some caveats...
|
|
895
|
-
* - Collision uses the axis aligned size, the object's rotation angle is only for rendering
|
|
896
|
-
* - Objects are guaranteed to not intersect tile collision from physics
|
|
897
|
-
* - If an object starts or is moved inside tile collision, it will not collide with that tile
|
|
898
|
-
* - Collision for objects can be set to be solid to block other objects
|
|
899
|
-
* - Objects may get pushed into overlapping other solid objects, if so they will push away
|
|
900
|
-
* - Solid objects are more performance intensive and should be used sparingly
|
|
901
|
-
* @example
|
|
902
|
-
* // create an engine object, normally you would first extend the class with your own
|
|
903
|
-
* const pos = vec2(2,3);
|
|
904
|
-
* const object = new EngineObject(pos);
|
|
981
|
+
* Tile Info - Stores info about how to draw a tile
|
|
905
982
|
*/
|
|
906
|
-
export class
|
|
907
|
-
/** Create
|
|
908
|
-
* @param {Vector2} [
|
|
909
|
-
* @param {Vector2} [size=
|
|
910
|
-
* @param {Number} [
|
|
911
|
-
* @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
|
|
912
|
-
* @param {Number} [angle=0] - Angle the object is rotated by
|
|
913
|
-
* @param {Color} [color=Color()] - Color to apply to tile when rendered
|
|
914
|
-
* @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
|
|
983
|
+
export class TileInfo {
|
|
984
|
+
/** Create a tile info object
|
|
985
|
+
* @param {Vector2} [pos=Vector2()] - Top left corner of tile in pixels
|
|
986
|
+
* @param {Vector2} [size=tileSizeDefault] - Size of tile in pixels
|
|
987
|
+
* @param {Number} [textureIndex=0] - Texture index to use
|
|
915
988
|
*/
|
|
916
|
-
constructor(pos?: Vector2, size?: Vector2,
|
|
917
|
-
/** @property {Vector2} -
|
|
989
|
+
constructor(pos?: Vector2, size?: Vector2, textureIndex?: number);
|
|
990
|
+
/** @property {Vector2} - Top left corner of tile in pixels */
|
|
918
991
|
pos: Vector2;
|
|
919
|
-
/** @property {Vector2} -
|
|
992
|
+
/** @property {Vector2} - Size of tile in pixels */
|
|
920
993
|
size: Vector2;
|
|
921
|
-
/** @property {Number}
|
|
922
|
-
|
|
923
|
-
/**
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
velocity: Vector2;
|
|
945
|
-
/** @property {Number} [angleVelocity=0] - Angular velocity of the object */
|
|
946
|
-
angleVelocity: number;
|
|
947
|
-
spawnTime: number;
|
|
948
|
-
children: any[];
|
|
949
|
-
collideTiles: number;
|
|
950
|
-
/** Update the object transform and physics, called automatically by engine once each frame */
|
|
951
|
-
update(): void;
|
|
952
|
-
groundObject: any;
|
|
953
|
-
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
954
|
-
render(): void;
|
|
955
|
-
/** Destroy this object, destroy it's children, detach it's parent, and mark it for removal */
|
|
956
|
-
destroy(): void;
|
|
957
|
-
destroyed: number;
|
|
958
|
-
/** Called to check if a tile collision should be resolved
|
|
959
|
-
* @param {Number} tileData - the value of the tile at the position
|
|
960
|
-
* @param {Vector2} pos - tile where the collision occured
|
|
961
|
-
* @return {Boolean} - true if the collision should be resolved */
|
|
962
|
-
collideWithTile(tileData: number, pos: Vector2): boolean;
|
|
963
|
-
/** Called to check if a tile raycast hit
|
|
964
|
-
* @param {Number} tileData - the value of the tile at the position
|
|
965
|
-
* @param {Vector2} pos - tile where the raycast is
|
|
966
|
-
* @return {Boolean} - true if the raycast should hit */
|
|
967
|
-
collideWithTileRaycast(tileData: number, pos: Vector2): boolean;
|
|
968
|
-
/** Called to check if a object collision should be resolved
|
|
969
|
-
* @param {EngineObject} object - the object to test against
|
|
970
|
-
* @return {Boolean} - true if the collision should be resolved
|
|
971
|
-
*/
|
|
972
|
-
collideWithObject(object: EngineObject): boolean;
|
|
973
|
-
/** How long since the object was created
|
|
974
|
-
* @return {Number} */
|
|
975
|
-
getAliveTime(): number;
|
|
976
|
-
/** Apply acceleration to this object (adjust velocity, not affected by mass)
|
|
977
|
-
* @param {Vector2} acceleration */
|
|
978
|
-
applyAcceleration(acceleration: Vector2): void;
|
|
979
|
-
/** Apply force to this object (adjust velocity, affected by mass)
|
|
980
|
-
* @param {Vector2} force */
|
|
981
|
-
applyForce(force: Vector2): void;
|
|
982
|
-
/** Get the direction of the mirror
|
|
983
|
-
* @return {Number} -1 if this.mirror is true, or 1 if not mirrored */
|
|
984
|
-
getMirrorSign(): number;
|
|
985
|
-
/** Attaches a child to this with a given local transform
|
|
986
|
-
* @param {EngineObject} child
|
|
987
|
-
* @param {Vector2} [localPos=Vector2()]
|
|
988
|
-
* @param {Number} [localAngle=0] */
|
|
989
|
-
addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
|
|
990
|
-
/** Removes a child from this one
|
|
991
|
-
* @param {EngineObject} child */
|
|
992
|
-
removeChild(child: EngineObject): void;
|
|
993
|
-
/** Set how this object collides
|
|
994
|
-
* @param {Boolean} [collideSolidObjects=1] - Does it collide with solid objects
|
|
995
|
-
* @param {Boolean} [isSolid=1] - Does it collide with and block other objects (expensive in large numbers)
|
|
996
|
-
* @param {Boolean} [collideTiles=1] - Does it collide with the tile collision */
|
|
997
|
-
setCollision(collideSolidObjects?: boolean, isSolid?: boolean, collideTiles?: boolean): void;
|
|
998
|
-
collideSolidObjects: boolean;
|
|
999
|
-
isSolid: boolean;
|
|
1000
|
-
/** Returns string containg info about this object for debugging
|
|
1001
|
-
* @return {String} */
|
|
1002
|
-
toString(): string;
|
|
994
|
+
/** @property {Number} - Texture index to use */
|
|
995
|
+
textureIndex: number;
|
|
996
|
+
/** Returns an offset copy of this tile, useful for animation
|
|
997
|
+
* @param {Vector2} offset - Offset to apply in pixels
|
|
998
|
+
* @return {TileInfo}
|
|
999
|
+
*/
|
|
1000
|
+
offset(offset: Vector2): TileInfo;
|
|
1001
|
+
/** Returns the texture info for this tile
|
|
1002
|
+
* @return {TextureInfo}
|
|
1003
|
+
*/
|
|
1004
|
+
getTextureInfo(): TextureInfo;
|
|
1005
|
+
}
|
|
1006
|
+
/** Texture Info - Stores info about each texture */
|
|
1007
|
+
export class TextureInfo {
|
|
1008
|
+
constructor(image: any);
|
|
1009
|
+
/** @property {CanvasImageSource} - image source */
|
|
1010
|
+
image: any;
|
|
1011
|
+
/** @property {Vector2} - size of the image */
|
|
1012
|
+
size: Vector2;
|
|
1013
|
+
/** @property {WebGLTexture} - webgl texture */
|
|
1014
|
+
glTexture: WebGLTexture;
|
|
1015
|
+
/** @property {Vector2} - size to adjust tile to fix bleeding */
|
|
1016
|
+
fixBleedSize: Vector2;
|
|
1003
1017
|
}
|
|
1004
|
-
/** Tile sheet for batch rendering system
|
|
1005
|
-
* @type {CanvasImageSource}
|
|
1006
|
-
* @memberof Draw */
|
|
1007
|
-
export const tileImage: CanvasImageSource;
|
|
1008
1018
|
/**
|
|
1009
1019
|
* LittleJS Drawing System
|
|
1010
1020
|
* - Hybrid system with both Canvas2D and WebGL available
|
|
@@ -1059,7 +1069,7 @@ declare module "littlejs.esm" {
|
|
|
1059
1069
|
/** Draw textured tile centered in world space, with color applied if using WebGL
|
|
1060
1070
|
* @param {Vector2} pos - Center of the tile in world space
|
|
1061
1071
|
* @param {Vector2} [size=Vector2(1,1)] - Size of the tile in world space
|
|
1062
|
-
* @param {
|
|
1072
|
+
* @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
|
|
1063
1073
|
* @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
|
|
1064
1074
|
* @param {Color} [color=Color()] - Color to modulate with
|
|
1065
1075
|
* @param {Number} [angle=0] - Angle to rotate by
|
|
@@ -1067,8 +1077,9 @@ declare module "littlejs.esm" {
|
|
|
1067
1077
|
* @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
|
|
1068
1078
|
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
1069
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
|
|
1070
1081
|
* @memberof Draw */
|
|
1071
|
-
export function drawTile(pos: Vector2, size?: Vector2,
|
|
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;
|
|
1072
1083
|
/** Draw colored rect centered on pos
|
|
1073
1084
|
* @param {Vector2} pos
|
|
1074
1085
|
* @param {Vector2} [size=Vector2(1,1)]
|
|
@@ -1076,8 +1087,9 @@ declare module "littlejs.esm" {
|
|
|
1076
1087
|
* @param {Number} [angle=0]
|
|
1077
1088
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1078
1089
|
* @param {Boolean} [screenSpace=0]
|
|
1090
|
+
* @param {CanvasRenderingContext2D} [context]
|
|
1079
1091
|
* @memberof Draw */
|
|
1080
|
-
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;
|
|
1081
1093
|
/** Draw colored line between two points
|
|
1082
1094
|
* @param {Vector2} posA
|
|
1083
1095
|
* @param {Vector2} posB
|
|
@@ -1085,23 +1097,25 @@ declare module "littlejs.esm" {
|
|
|
1085
1097
|
* @param {Color} [color=Color()]
|
|
1086
1098
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1087
1099
|
* @param {Boolean} [screenSpace=0]
|
|
1100
|
+
* @param {CanvasRenderingContext2D} [context]
|
|
1088
1101
|
* @memberof Draw */
|
|
1089
|
-
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;
|
|
1090
1103
|
/** Draw directly to a 2d canvas context in world space
|
|
1091
1104
|
* @param {Vector2} pos
|
|
1092
1105
|
* @param {Vector2} size
|
|
1093
1106
|
* @param {Number} angle
|
|
1094
1107
|
* @param {Boolean} mirror
|
|
1095
1108
|
* @param {Function} drawFunction
|
|
1096
|
-
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1097
1109
|
* @param {Boolean} [screenSpace=0]
|
|
1110
|
+
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1098
1111
|
* @memberof Draw */
|
|
1099
|
-
export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function,
|
|
1112
|
+
export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1100
1113
|
/** Enable normal or additive blend mode
|
|
1101
1114
|
* @param {Boolean} [additive=0]
|
|
1102
1115
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1116
|
+
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1103
1117
|
* @memberof Draw */
|
|
1104
|
-
export function setBlendMode(additive?: boolean, useWebGL?: boolean): void;
|
|
1118
|
+
export function setBlendMode(additive?: boolean, useWebGL?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1105
1119
|
/** Draw text on overlay canvas in screen space
|
|
1106
1120
|
* Automatically splits new lines into rows
|
|
1107
1121
|
* @param {String} text
|
|
@@ -1146,14 +1160,12 @@ declare module "littlejs.esm" {
|
|
|
1146
1160
|
* @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
|
|
1147
1161
|
* @param {Vector2} [tileSize=vec2(8)] - Size of the font source tiles
|
|
1148
1162
|
* @param {Vector2} [paddingSize=vec2(0,1)] - How much extra space to add between characters
|
|
1149
|
-
* @param {Number} [startTileIndex=0] - Tile index in image where font starts
|
|
1150
1163
|
* @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
|
|
1151
1164
|
*/
|
|
1152
|
-
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2,
|
|
1165
|
+
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, context?: CanvasRenderingContext2D);
|
|
1153
1166
|
image: any;
|
|
1154
1167
|
tileSize: Vector2;
|
|
1155
1168
|
paddingSize: Vector2;
|
|
1156
|
-
startTileIndex: number;
|
|
1157
1169
|
context: CanvasRenderingContext2D;
|
|
1158
1170
|
/** Draw text in world space using the image font
|
|
1159
1171
|
* @param {String} text
|
|
@@ -1177,6 +1189,52 @@ declare module "littlejs.esm" {
|
|
|
1177
1189
|
/** Toggle fullsceen mode
|
|
1178
1190
|
* @memberof Draw */
|
|
1179
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;
|
|
1180
1238
|
/**
|
|
1181
1239
|
* LittleJS Input System
|
|
1182
1240
|
* - Tracks keyboard down, pressed, and released
|
|
@@ -1444,6 +1502,129 @@ declare module "littlejs.esm" {
|
|
|
1444
1502
|
* @return {AudioBufferSourceNode} - The audio node of the sound played
|
|
1445
1503
|
* @memberof Audio */
|
|
1446
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
|
+
}
|
|
1447
1628
|
/**
|
|
1448
1629
|
* LittleJS Tile Layer System
|
|
1449
1630
|
* - Caches arrays of tiles to off screen canvas for fast rendering
|
|
@@ -1520,7 +1701,7 @@ declare module "littlejs.esm" {
|
|
|
1520
1701
|
clear(): void;
|
|
1521
1702
|
}
|
|
1522
1703
|
/**
|
|
1523
|
-
* Tile
|
|
1704
|
+
* Tile Layer - cached rendering system for tile layers
|
|
1524
1705
|
* - Each Tile layer is rendered to an off screen canvas
|
|
1525
1706
|
* - To allow dynamic modifications, layers are rendered using canvas 2d
|
|
1526
1707
|
* - Some devices like mobile phones are limited to 4k texture resolution
|
|
@@ -1535,11 +1716,11 @@ declare module "littlejs.esm" {
|
|
|
1535
1716
|
/** Create a tile layer object
|
|
1536
1717
|
* @param {Vector2} [position=Vector2()] - World space position
|
|
1537
1718
|
* @param {Vector2} [size=tileCollisionSize] - World space size
|
|
1538
|
-
* @param {
|
|
1719
|
+
* @param {TileInfo} [tileInfo] - Tile info for layer
|
|
1539
1720
|
* @param {Vector2} [scale=Vector2(1,1)] - How much to scale this layer when rendered
|
|
1540
1721
|
* @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
|
|
1541
1722
|
*/
|
|
1542
|
-
constructor(pos: any, size?: Vector2,
|
|
1723
|
+
constructor(pos: any, size?: Vector2, tileInfo?: TileInfo, scale?: Vector2, renderOrder?: number);
|
|
1543
1724
|
/** @property {HTMLCanvasElement} - The canvas used by this tile layer */
|
|
1544
1725
|
canvas: HTMLCanvasElement;
|
|
1545
1726
|
/** @property {CanvasRenderingContext2D} - The 2D canvas context used by this tile layer */
|
|
@@ -1581,12 +1762,11 @@ declare module "littlejs.esm" {
|
|
|
1581
1762
|
/** Draw a tile directly onto the layer canvas
|
|
1582
1763
|
* @param {Vector2} pos
|
|
1583
1764
|
* @param {Vector2} [size=Vector2(1,1)]
|
|
1584
|
-
* @param {
|
|
1585
|
-
* @param {Vector2} [tileSize=tileSizeDefault]
|
|
1765
|
+
* @param {TileInfo} [tileInfo]
|
|
1586
1766
|
* @param {Color} [color=Color()]
|
|
1587
1767
|
* @param {Number} [angle=0]
|
|
1588
1768
|
* @param {Boolean} [mirror=0] */
|
|
1589
|
-
drawTile(pos: Vector2, size?: Vector2,
|
|
1769
|
+
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
1590
1770
|
/** Draw a rectangle directly onto the layer canvas
|
|
1591
1771
|
* @param {Vector2} pos
|
|
1592
1772
|
* @param {Vector2} [size=Vector2(1,1)]
|
|
@@ -1606,7 +1786,7 @@ declare module "littlejs.esm" {
|
|
|
1606
1786
|
* let particleEmiter = new ParticleEmitter
|
|
1607
1787
|
* (
|
|
1608
1788
|
* pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
1609
|
-
* 0,
|
|
1789
|
+
* tile(0, 16), // tileInfo
|
|
1610
1790
|
* new Color(1,1,1), new Color(0,0,0), // colorStartA, colorStartB
|
|
1611
1791
|
* new Color(1,1,1,0), new Color(0,0,0,0), // colorEndA, colorEndB
|
|
1612
1792
|
* 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
@@ -1622,8 +1802,7 @@ declare module "littlejs.esm" {
|
|
|
1622
1802
|
* @param {Number} [emitTime=0] - How long to stay alive (0 is forever)
|
|
1623
1803
|
* @param {Number} [emitRate=100] - How many particles per second to spawn, does not emit if 0
|
|
1624
1804
|
* @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
|
|
1625
|
-
* @param {
|
|
1626
|
-
* @param {Vector2} [tileSize=tileSizeDefault] - Tile size for particles
|
|
1805
|
+
* @param {TileInfo} [tileInfo] - Tile info to render particles (undefined is untextured)
|
|
1627
1806
|
* @param {Color} [colorStartA=Color()] - Color at start of life 1, randomized between start colors
|
|
1628
1807
|
* @param {Color} [colorStartB=Color()] - Color at start of life 2, randomized between start colors
|
|
1629
1808
|
* @param {Color} [colorEndA=Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
|
|
@@ -1645,7 +1824,7 @@ declare module "littlejs.esm" {
|
|
|
1645
1824
|
* @param {Number} [renderOrder=0] - Render order for particles (additive is above other stuff by default)
|
|
1646
1825
|
* @param {Boolean} [localSpace=0] - Should it be in local space of emitter (world space is default)
|
|
1647
1826
|
*/
|
|
1648
|
-
constructor(pos: any, angle?: number, emitSize?: number, emitTime?: number, emitRate?: number, emitConeAngle?: number,
|
|
1827
|
+
constructor(pos: any, angle?: number, emitSize?: number, emitTime?: number, emitRate?: number, emitConeAngle?: number, tileInfo?: TileInfo, colorStartA?: Color, colorStartB?: Color, colorEndA?: Color, colorEndB?: Color, particleTime?: number, sizeStart?: number, sizeEnd?: number, speed?: number, angleSpeed?: number, damping?: number, angleDamping?: number, gravityScale?: number, particleConeAngle?: number, fadeRate?: number, randomness?: number, collideTiles?: boolean, additive?: boolean, randomColorLinear?: boolean, renderOrder?: number, localSpace?: boolean);
|
|
1649
1828
|
/** @property {Number} - World space size of the emitter (float for circle diameter, vec2 for rect) */
|
|
1650
1829
|
emitSize: number;
|
|
1651
1830
|
/** @property {Number} - How long to stay alive (0 is forever) */
|
|
@@ -1701,11 +1880,10 @@ declare module "littlejs.esm" {
|
|
|
1701
1880
|
/**
|
|
1702
1881
|
* Create a particle with the given settings
|
|
1703
1882
|
* @param {Vector2} position - World space position of the particle
|
|
1704
|
-
* @param {
|
|
1705
|
-
* @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
|
|
1883
|
+
* @param {TileInfo} [tileInfo] - Tile info to render particles (undefined is untextured)
|
|
1706
1884
|
* @param {Number} [angle=0] - Angle to rotate the particle
|
|
1707
1885
|
*/
|
|
1708
|
-
constructor(pos: any,
|
|
1886
|
+
constructor(pos: any, tileInfo?: TileInfo, angle?: number);
|
|
1709
1887
|
}
|
|
1710
1888
|
/**
|
|
1711
1889
|
* LittleJS Medal System
|
|
@@ -1732,10 +1910,11 @@ declare module "littlejs.esm" {
|
|
|
1732
1910
|
/** This can used to enable Newgrounds functionality
|
|
1733
1911
|
* @param {Number} app_id - The newgrounds App ID
|
|
1734
1912
|
* @param {String} [cipher] - The encryption Key (AES-128/Base64)
|
|
1913
|
+
* @param {Object} [cryptoJS] - An instance of CryptoJS, if there is a cipher
|
|
1735
1914
|
* @memberof Medals */
|
|
1736
|
-
export function newgroundsInit(app_id: number, cipher?: string): void;
|
|
1915
|
+
export function newgroundsInit(app_id: number, cipher?: string, cryptoJS?: any): void;
|
|
1737
1916
|
/**
|
|
1738
|
-
* Medal
|
|
1917
|
+
* Medal - Tracks an unlockable medal
|
|
1739
1918
|
* @example
|
|
1740
1919
|
* // create a medal
|
|
1741
1920
|
* const medal_example = new Medal(0, 'Example Medal', 'More info about the medal goes here.', '🎖️');
|
|
@@ -1747,7 +1926,7 @@ declare module "littlejs.esm" {
|
|
|
1747
1926
|
* medal_example.unlock();
|
|
1748
1927
|
*/
|
|
1749
1928
|
export class Medal {
|
|
1750
|
-
/** Create
|
|
1929
|
+
/** Create a medal object and adds it to the list of medals
|
|
1751
1930
|
* @param {Number} id - The unique identifier of the medal
|
|
1752
1931
|
* @param {String} name - Name of the medal
|
|
1753
1932
|
* @param {String} [description] - Description of the medal
|
|
@@ -1778,20 +1957,20 @@ declare module "littlejs.esm" {
|
|
|
1778
1957
|
/**
|
|
1779
1958
|
* Newgrounds API wrapper object
|
|
1780
1959
|
* @example
|
|
1781
|
-
* // create a newgrounds object, replace the app id
|
|
1960
|
+
* // create a newgrounds object, replace the app id with your own
|
|
1782
1961
|
* const app_id = '53123:1ZuSTQ9l';
|
|
1783
|
-
*
|
|
1784
|
-
* newgrounds = new Newgrounds(app_id, cipher);
|
|
1962
|
+
* newgrounds = new Newgrounds(app_id);
|
|
1785
1963
|
*/
|
|
1786
1964
|
export class Newgrounds {
|
|
1787
1965
|
/** Create a newgrounds object
|
|
1788
1966
|
* @param {Number} app_id - The newgrounds App ID
|
|
1789
|
-
* @param {String} [cipher] - The encryption Key (AES-128/Base64)
|
|
1790
|
-
|
|
1967
|
+
* @param {String} [cipher] - The encryption Key (AES-128/Base64)
|
|
1968
|
+
* @param {Object} [cryptoJS] - An instance of CryptoJS, if there is a cipher */
|
|
1969
|
+
constructor(app_id: number, cipher?: string, cryptoJS?: any);
|
|
1791
1970
|
app_id: number;
|
|
1792
1971
|
cipher: string;
|
|
1793
|
-
host: string;
|
|
1794
1972
|
cryptoJS: any;
|
|
1973
|
+
host: string;
|
|
1795
1974
|
session_id: string;
|
|
1796
1975
|
medals: any;
|
|
1797
1976
|
scoreboards: any;
|
|
@@ -1820,141 +1999,5 @@ declare module "littlejs.esm" {
|
|
|
1820
1999
|
* @return {Object} - The response JSON object
|
|
1821
2000
|
*/
|
|
1822
2001
|
call(component: string, parameters?: any, async?: boolean): any;
|
|
1823
|
-
CryptoJS(): any;
|
|
1824
2002
|
}
|
|
1825
|
-
/**
|
|
1826
|
-
* LittleJS WebGL Interface
|
|
1827
|
-
* - All webgl used by the engine is wrapped up here
|
|
1828
|
-
* - For normal stuff you won't need to see or call anything in this file
|
|
1829
|
-
* - For advanced stuff there are helper functions to create shaders, textures, etc
|
|
1830
|
-
* - Can be disabled with glEnable to revert to 2D canvas rendering
|
|
1831
|
-
* - Batches sprite rendering on GPU for incredibly fast performance
|
|
1832
|
-
* - Sprite transform math is done in the shader where possible
|
|
1833
|
-
* @namespace WebGL
|
|
1834
|
-
*/
|
|
1835
|
-
/** The WebGL canvas which appears above the main canvas and below the overlay canvas
|
|
1836
|
-
* @type {HTMLCanvasElement}
|
|
1837
|
-
* @memberof WebGL */
|
|
1838
|
-
export let glCanvas: HTMLCanvasElement;
|
|
1839
|
-
/** 2d context for glCanvas
|
|
1840
|
-
* @type {WebGLRenderingContext}
|
|
1841
|
-
* @memberof WebGL */
|
|
1842
|
-
export let glContext: WebGLRenderingContext;
|
|
1843
|
-
/** Set the WebGl blend mode, normally you should call setBlendMode instead
|
|
1844
|
-
* @param {Boolean} [additive=0]
|
|
1845
|
-
* @memberof WebGL */
|
|
1846
|
-
export function glSetBlendMode(additive?: boolean): void;
|
|
1847
|
-
/** Set the WebGl texture, not normally necessary unless multiple tile sheets are used
|
|
1848
|
-
* - This may also flush the gl buffer resulting in more draw calls and worse performance
|
|
1849
|
-
* @param {WebGLTexture} [texture=glTileTexture]
|
|
1850
|
-
* @memberof WebGL */
|
|
1851
|
-
export function glSetTexture(texture?: WebGLTexture): void;
|
|
1852
|
-
/** Compile WebGL shader of the given type, will throw errors if in debug mode
|
|
1853
|
-
* @param {String} source
|
|
1854
|
-
* @param type
|
|
1855
|
-
* @return {WebGLShader}
|
|
1856
|
-
* @memberof WebGL */
|
|
1857
|
-
export function glCompileShader(source: string, type: any): WebGLShader;
|
|
1858
|
-
/** Create WebGL program with given shaders
|
|
1859
|
-
* @param {WebGLShader} vsSource
|
|
1860
|
-
* @param {WebGLShader} fsSource
|
|
1861
|
-
* @return {WebGLProgram}
|
|
1862
|
-
* @memberof WebGL */
|
|
1863
|
-
export function glCreateProgram(vsSource: WebGLShader, fsSource: WebGLShader): WebGLProgram;
|
|
1864
|
-
/** Create WebGL texture from an image and set the texture settings
|
|
1865
|
-
* @param {Image} image
|
|
1866
|
-
* @return {WebGLTexture}
|
|
1867
|
-
* @memberof WebGL */
|
|
1868
|
-
export function glCreateTexture(image: new (width?: number, height?: number) => HTMLImageElement): WebGLTexture;
|
|
1869
|
-
/** Set up a post processing shader
|
|
1870
|
-
* @param {String} shaderCode
|
|
1871
|
-
* @param {Boolean} includeOverlay
|
|
1872
|
-
* @memberof WebGL */
|
|
1873
|
-
export function glInitPostProcess(shaderCode: string, includeOverlay: boolean): void;
|
|
1874
|
-
/**
|
|
1875
|
-
* LittleJS - The Tiny JavaScript Game Engine That Can!
|
|
1876
|
-
* MIT License - Copyright 2021 Frank Force
|
|
1877
|
-
*
|
|
1878
|
-
* Engine Features
|
|
1879
|
-
* - Object oriented system with base class engine object
|
|
1880
|
-
* - Base class object handles update, physics, collision, rendering, etc
|
|
1881
|
-
* - Engine helper classes and functions like Vector2, Color, and Timer
|
|
1882
|
-
* - Super fast rendering system for tile sheets
|
|
1883
|
-
* - Sound effects audio with zzfx and music with zzfxm
|
|
1884
|
-
* - Input processing system with gamepad and touchscreen support
|
|
1885
|
-
* - Tile layer rendering and collision system
|
|
1886
|
-
* - Particle effect system
|
|
1887
|
-
* - Medal system tracks and displays achievements
|
|
1888
|
-
* - Debug tools and debug rendering system
|
|
1889
|
-
* - Post processing effects
|
|
1890
|
-
* - Call engineInit() to start it up!
|
|
1891
|
-
* @namespace Engine
|
|
1892
|
-
*/
|
|
1893
|
-
/** Name of engine
|
|
1894
|
-
* @type {String}
|
|
1895
|
-
* @default
|
|
1896
|
-
* @memberof Engine */
|
|
1897
|
-
export const engineName: string;
|
|
1898
|
-
/** Version of engine
|
|
1899
|
-
* @type {String}
|
|
1900
|
-
* @default
|
|
1901
|
-
* @memberof Engine */
|
|
1902
|
-
export const engineVersion: string;
|
|
1903
|
-
/** Frames per second to update objects
|
|
1904
|
-
* @type {Number}
|
|
1905
|
-
* @default
|
|
1906
|
-
* @memberof Engine */
|
|
1907
|
-
export const frameRate: number;
|
|
1908
|
-
/** How many seconds each frame lasts, engine uses a fixed time step
|
|
1909
|
-
* @type {Number}
|
|
1910
|
-
* @default 1/60
|
|
1911
|
-
* @memberof Engine */
|
|
1912
|
-
export const timeDelta: number;
|
|
1913
|
-
/** Array containing all engine objects
|
|
1914
|
-
* @type {Array}
|
|
1915
|
-
* @memberof Engine */
|
|
1916
|
-
export let engineObjects: any[];
|
|
1917
|
-
/** Current update frame, used to calculate time
|
|
1918
|
-
* @type {Number}
|
|
1919
|
-
* @memberof Engine */
|
|
1920
|
-
export let frame: number;
|
|
1921
|
-
/** Current engine time since start in seconds, derived from frame
|
|
1922
|
-
* @type {Number}
|
|
1923
|
-
* @memberof Engine */
|
|
1924
|
-
export let time: number;
|
|
1925
|
-
/** Actual clock time since start in seconds (not affected by pause or frame rate clamping)
|
|
1926
|
-
* @type {Number}
|
|
1927
|
-
* @memberof Engine */
|
|
1928
|
-
export let timeReal: number;
|
|
1929
|
-
/** Is the game paused? Causes time and objects to not be updated
|
|
1930
|
-
* @type {Boolean}
|
|
1931
|
-
* @default 0
|
|
1932
|
-
* @memberof Engine */
|
|
1933
|
-
export let paused: boolean;
|
|
1934
|
-
/** Set if game is paused
|
|
1935
|
-
* @param {Boolean} paused
|
|
1936
|
-
* @memberof Engine */
|
|
1937
|
-
export function setPaused(_paused: any): void;
|
|
1938
|
-
/** Start up LittleJS engine with your callback functions
|
|
1939
|
-
* @param {Function} gameInit - Called once after the engine starts up, setup the game
|
|
1940
|
-
* @param {Function} gameUpdate - Called every frame at 60 frames per second, handle input and update the game state
|
|
1941
|
-
* @param {Function} gameUpdatePost - Called after physics and objects are updated, setup camera and prepare for render
|
|
1942
|
-
* @param {Function} gameRender - Called before objects are rendered, draw any background effects that appear behind objects
|
|
1943
|
-
* @param {Function} gameRenderPost - Called after objects are rendered, draw effects or hud that appear above all objects
|
|
1944
|
-
* @param {String} [tileImageSource] - Tile image to use, everything starts when the image is finished loading
|
|
1945
|
-
* @memberof Engine */
|
|
1946
|
-
export function engineInit(gameInit: Function, gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, tileImageSource?: string): void;
|
|
1947
|
-
/** Update each engine object, remove destroyed objects, and update time
|
|
1948
|
-
* @memberof Engine */
|
|
1949
|
-
export function engineObjectsUpdate(): void;
|
|
1950
|
-
/** Destroy and remove all objects
|
|
1951
|
-
* @memberof Engine */
|
|
1952
|
-
export function engineObjectsDestroy(): void;
|
|
1953
|
-
/** Triggers a callback for each object within a given area
|
|
1954
|
-
* @param {Vector2} [pos] - Center of test area
|
|
1955
|
-
* @param {Number} [size] - Radius of circle if float, rectangle size if Vector2
|
|
1956
|
-
* @param {Function} [callbackFunction] - Calls this function on every object that passes the test
|
|
1957
|
-
* @param {Array} [objects=engineObjects] - List of objects to check
|
|
1958
|
-
* @memberof Engine */
|
|
1959
|
-
export function engineObjectsCallback(pos?: Vector2, size?: number, callbackFunction?: Function, objects?: any[]): void;
|
|
1960
2003
|
}
|