littlejsengine 1.5.0 → 1.5.2
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/build.bat +4 -3
- package/engine/engine.all.js +193 -105
- package/engine/engine.all.min.js +1 -1
- package/engine/engine.all.module.js +388 -181
- package/engine/engine.all.module.min.js +1 -1
- package/engine/engine.all.release.js +186 -103
- package/engine/engine.js +57 -22
- package/engine/engineAudio.js +1 -1
- package/engine/engineDebug.js +7 -2
- package/engine/engineDraw.js +24 -26
- package/engine/engineExport.js +195 -76
- package/engine/engineInput.js +6 -1
- package/engine/engineMedals.js +1 -0
- package/engine/engineObject.js +6 -6
- package/engine/engineParticles.js +5 -5
- package/engine/engineSettings.js +46 -20
- package/engine/engineTileLayer.js +13 -12
- package/engine/engineUtilities.js +14 -8
- package/engine/engineWebGL.js +13 -2
- package/engine/index.d.ts +1796 -1615
- package/examples/breakout/game.js +3 -1
- package/examples/breakout/index.html +3 -3
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +1 -1
- package/examples/platformer/game.js +2 -0
- package/examples/platformer/gameObjects.js +3 -3
- package/examples/platformer/index.html +6 -6
- package/examples/puzzle/index.html +2 -2
- package/examples/stress/index.html +4 -4
- package/examples/typescript/game.js +89 -89
- package/examples/typescript/index.html +1 -1
- package/index.html +13 -13
- package/package.json +7 -7
- package/buildSetup.bat +0 -10
package/engine/engine.js
CHANGED
|
@@ -17,43 +17,71 @@
|
|
|
17
17
|
- Call engineInit() to start it up!
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* LittleJS Engine Globals
|
|
22
|
+
* @namespace Engine
|
|
23
|
+
*/
|
|
24
|
+
|
|
20
25
|
'use strict';
|
|
21
26
|
|
|
22
|
-
/** Name of engine
|
|
27
|
+
/** Name of engine
|
|
28
|
+
* @type {String}
|
|
29
|
+
* @default
|
|
30
|
+
* @memberof Engine */
|
|
23
31
|
const engineName = 'LittleJS';
|
|
24
32
|
|
|
25
|
-
/** Version of engine
|
|
26
|
-
|
|
33
|
+
/** Version of engine
|
|
34
|
+
* @type {String}
|
|
35
|
+
* @default
|
|
36
|
+
* @memberof Engine */
|
|
37
|
+
const engineVersion = '1.5.2';
|
|
27
38
|
|
|
28
39
|
/** Frames per second to update objects
|
|
29
|
-
* @
|
|
40
|
+
* @type {Number}
|
|
41
|
+
* @default
|
|
42
|
+
* @memberof Engine */
|
|
30
43
|
const frameRate = 60;
|
|
31
44
|
|
|
32
45
|
/** How many seconds each frame lasts, engine uses a fixed time step
|
|
33
|
-
* @
|
|
46
|
+
* @type {Number}
|
|
47
|
+
* @default 1/60
|
|
48
|
+
* @memberof Engine */
|
|
34
49
|
const timeDelta = 1/frameRate;
|
|
35
50
|
|
|
36
|
-
/** Array containing all engine objects
|
|
51
|
+
/** Array containing all engine objects
|
|
52
|
+
* @type {Array}
|
|
53
|
+
* @memberof Engine */
|
|
37
54
|
let engineObjects = [];
|
|
38
55
|
|
|
39
|
-
/** Array containing only objects that are set to collide with other objects this frame (for optimization)
|
|
56
|
+
/** Array containing only objects that are set to collide with other objects this frame (for optimization)
|
|
57
|
+
* @type {Array}
|
|
58
|
+
* @memberof Engine */
|
|
40
59
|
let engineObjectsCollide = [];
|
|
41
60
|
|
|
42
|
-
/** Current update frame, used to calculate time
|
|
61
|
+
/** Current update frame, used to calculate time
|
|
62
|
+
* @type {Number}
|
|
63
|
+
* @memberof Engine */
|
|
43
64
|
let frame = 0;
|
|
44
65
|
|
|
45
|
-
/** Current engine time since start in seconds, derived from frame
|
|
66
|
+
/** Current engine time since start in seconds, derived from frame
|
|
67
|
+
* @type {Number}
|
|
68
|
+
* @memberof Engine */
|
|
46
69
|
let time = 0;
|
|
47
70
|
|
|
48
|
-
/** Actual clock time since start in seconds (not affected by pause or frame rate clamping)
|
|
71
|
+
/** Actual clock time since start in seconds (not affected by pause or frame rate clamping)
|
|
72
|
+
* @type {Number}
|
|
73
|
+
* @memberof Engine */
|
|
49
74
|
let timeReal = 0;
|
|
50
75
|
|
|
51
|
-
/** Is the game paused? Causes time and objects to not be updated
|
|
76
|
+
/** Is the game paused? Causes time and objects to not be updated
|
|
77
|
+
* @type {Boolean}
|
|
78
|
+
* @default 0
|
|
79
|
+
* @memberof Engine */
|
|
52
80
|
let paused = 0;
|
|
53
81
|
|
|
54
82
|
/** Set if game is paused
|
|
55
83
|
* @param {Boolean} paused
|
|
56
|
-
*/
|
|
84
|
+
* @memberof Engine */
|
|
57
85
|
function setPaused(_paused) { paused = _paused; }
|
|
58
86
|
|
|
59
87
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -65,7 +93,7 @@ function setPaused(_paused) { paused = _paused; }
|
|
|
65
93
|
* @param {Function} gameRender - Called before objects are rendered, draw any background effects that appear behind objects
|
|
66
94
|
* @param {Function} gameRenderPost - Called after objects are rendered, draw effects or hud that appear above all objects
|
|
67
95
|
* @param {String} [tileImageSource] - Tile image to use, everything starts when the image is finished loading
|
|
68
|
-
*/
|
|
96
|
+
* @memberof Engine */
|
|
69
97
|
function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, tileImageSource)
|
|
70
98
|
{
|
|
71
99
|
// init engine when tiles load or fail to load
|
|
@@ -114,8 +142,8 @@ function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRender
|
|
|
114
142
|
averageFPS = lerp(.05, averageFPS, 1e3/(frameTimeDeltaMS||1));
|
|
115
143
|
const debugSpeedUp = debug && keyIsDown(107); // +
|
|
116
144
|
const debugSpeedDown = debug && keyIsDown(109); // -
|
|
117
|
-
if (debug)
|
|
118
|
-
frameTimeDeltaMS *= debugSpeedUp ? 5 : debugSpeedDown ? .2 : 1;
|
|
145
|
+
if (debug) // +/- to speed/slow time
|
|
146
|
+
frameTimeDeltaMS *= debugSpeedUp ? 5 : debugSpeedDown ? .2 : 1;
|
|
119
147
|
timeReal += frameTimeDeltaMS / 1e3;
|
|
120
148
|
frameTimeBufferMS += !paused * frameTimeDeltaMS;
|
|
121
149
|
if (!debugSpeedUp)
|
|
@@ -124,8 +152,8 @@ function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRender
|
|
|
124
152
|
if (canvasFixedSize.x)
|
|
125
153
|
{
|
|
126
154
|
// clear canvas and set fixed size
|
|
127
|
-
|
|
128
|
-
|
|
155
|
+
mainCanvas.width = canvasFixedSize.x;
|
|
156
|
+
mainCanvas.height = canvasFixedSize.y;
|
|
129
157
|
|
|
130
158
|
// fit to window by adding space on top or bottom if necessary
|
|
131
159
|
const aspect = innerWidth / innerHeight;
|
|
@@ -136,10 +164,14 @@ function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRender
|
|
|
136
164
|
else
|
|
137
165
|
{
|
|
138
166
|
// clear canvas and set size to same as window
|
|
139
|
-
|
|
140
|
-
|
|
167
|
+
mainCanvas.width = min(innerWidth, canvasMaxSize.x);
|
|
168
|
+
mainCanvas.height = min(innerHeight, canvasMaxSize.y);
|
|
141
169
|
}
|
|
142
170
|
|
|
171
|
+
// clear overlay canvas and set size
|
|
172
|
+
overlayCanvas.width = mainCanvas.width;
|
|
173
|
+
overlayCanvas.height = mainCanvas.height;
|
|
174
|
+
|
|
143
175
|
// save canvas size
|
|
144
176
|
mainCanvasSize = vec2(mainCanvas.width, mainCanvas.height);
|
|
145
177
|
|
|
@@ -229,7 +261,8 @@ function enginePreRender()
|
|
|
229
261
|
glEnable && glPreRender();
|
|
230
262
|
}
|
|
231
263
|
|
|
232
|
-
/** Update each engine object, remove destroyed objects, and update time
|
|
264
|
+
/** Update each engine object, remove destroyed objects, and update time
|
|
265
|
+
* @memberof Engine */
|
|
233
266
|
function engineObjectsUpdate()
|
|
234
267
|
{
|
|
235
268
|
// get list of solid objects for physics optimzation
|
|
@@ -255,7 +288,8 @@ function engineObjectsUpdate()
|
|
|
255
288
|
time = ++frame / frameRate;
|
|
256
289
|
}
|
|
257
290
|
|
|
258
|
-
/** Destroy and remove all objects
|
|
291
|
+
/** Destroy and remove all objects
|
|
292
|
+
* @memberof Engine */
|
|
259
293
|
function engineObjectsDestroy()
|
|
260
294
|
{
|
|
261
295
|
for (const o of engineObjects)
|
|
@@ -267,7 +301,8 @@ function engineObjectsDestroy()
|
|
|
267
301
|
* @param {Vector2} [pos] - Center of test area
|
|
268
302
|
* @param {Number} [size] - Radius of circle if float, rectangle size if Vector2
|
|
269
303
|
* @param {Function} [callbackFunction] - Calls this function on every object that passes the test
|
|
270
|
-
* @param {Array} [objects=engineObjects] - List of objects to check
|
|
304
|
+
* @param {Array} [objects=engineObjects] - List of objects to check
|
|
305
|
+
* @memberof Engine */
|
|
271
306
|
function engineObjectsCallback(pos, size, callbackFunction, objects=engineObjects)
|
|
272
307
|
{
|
|
273
308
|
if (!pos) // all objects
|
package/engine/engineAudio.js
CHANGED
package/engine/engineDebug.js
CHANGED
|
@@ -16,26 +16,31 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
/** True if debug is enabled
|
|
19
|
+
* @type {Boolean}
|
|
19
20
|
* @default
|
|
20
21
|
* @memberof Debug */
|
|
21
22
|
const debug = 1;
|
|
22
23
|
|
|
23
24
|
/** True if asserts are enaled
|
|
25
|
+
* @type {Boolean}
|
|
24
26
|
* @default
|
|
25
27
|
* @memberof Debug */
|
|
26
28
|
const enableAsserts = 1;
|
|
27
29
|
|
|
28
30
|
/** Size to render debug points by default
|
|
31
|
+
* @type {Number}
|
|
29
32
|
* @default
|
|
30
33
|
* @memberof Debug */
|
|
31
34
|
const debugPointSize = .5;
|
|
32
35
|
|
|
33
|
-
/** True if watermark with FPS should be
|
|
36
|
+
/** True if watermark with FPS should be shown, false in release builds
|
|
37
|
+
* @type {Boolean}
|
|
34
38
|
* @default
|
|
35
39
|
* @memberof Debug */
|
|
36
40
|
let showWatermark = 1;
|
|
37
41
|
|
|
38
42
|
/** True if god mode is enabled, handle this however you want
|
|
43
|
+
* @type {Boolean}
|
|
39
44
|
* @default
|
|
40
45
|
* @memberof Debug */
|
|
41
46
|
let godMode = 0;
|
|
@@ -55,7 +60,7 @@ const ASSERT = enableAsserts ? (...assert)=> console.assert(...assert) : ()=>{};
|
|
|
55
60
|
|
|
56
61
|
/** Draw a debug rectangle in world space
|
|
57
62
|
* @param {Vector2} pos
|
|
58
|
-
* @param {Vector2} [size=
|
|
63
|
+
* @param {Vector2} [size=Vector2()]
|
|
59
64
|
* @param {String} [color='#fff']
|
|
60
65
|
* @param {Number} [time=0]
|
|
61
66
|
* @param {Number} [angle=0]
|
package/engine/engineDraw.js
CHANGED
|
@@ -78,15 +78,15 @@ const worldToScreen = (worldPos)=>
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/** Draw textured tile centered in world space, with color applied if using WebGL
|
|
81
|
-
* @param {Vector2} pos
|
|
82
|
-
* @param {Vector2} [size=
|
|
83
|
-
* @param {Number} [tileIndex=-1]
|
|
84
|
-
* @param {Vector2} [tileSize=tileSizeDefault]
|
|
85
|
-
* @param {Color} [color=
|
|
86
|
-
* @param {Number} [angle=0]
|
|
87
|
-
* @param {Boolean} [mirror=0]
|
|
88
|
-
* @param {Color} [additiveColor=
|
|
89
|
-
* @param {Boolean} [useWebGL=glEnable]
|
|
81
|
+
* @param {Vector2} pos - Center of the tile in world space
|
|
82
|
+
* @param {Vector2} [size=Vector2(1,1)] - Size of the tile in world space
|
|
83
|
+
* @param {Number} [tileIndex=-1] - Tile index to use, negative is untextured
|
|
84
|
+
* @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
|
|
85
|
+
* @param {Color} [color=Color()] - Color to modulate with
|
|
86
|
+
* @param {Number} [angle=0] - Angle to rotate by
|
|
87
|
+
* @param {Boolean} [mirror=0] - If true image is flipped along the Y axis
|
|
88
|
+
* @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
|
|
89
|
+
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
90
90
|
* @memberof Draw */
|
|
91
91
|
function drawTile(pos, size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, color=new Color, angle=0, mirror,
|
|
92
92
|
additiveColor=new Color(0,0,0,0), useWebGL=glEnable)
|
|
@@ -141,8 +141,8 @@ function drawTile(pos, size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, col
|
|
|
141
141
|
|
|
142
142
|
/** Draw colored rect centered on pos
|
|
143
143
|
* @param {Vector2} pos
|
|
144
|
-
* @param {Vector2} [size=
|
|
145
|
-
* @param {Color} [color=
|
|
144
|
+
* @param {Vector2} [size=Vector2(1,1)]
|
|
145
|
+
* @param {Color} [color=Color()]
|
|
146
146
|
* @param {Number} [angle=0]
|
|
147
147
|
* @param {Boolean} [useWebGL=glEnable]
|
|
148
148
|
* @memberof Draw */
|
|
@@ -153,13 +153,13 @@ function drawRect(pos, size, color, angle, useWebGL)
|
|
|
153
153
|
|
|
154
154
|
/** Draw textured tile centered on pos in screen space
|
|
155
155
|
* @param {Vector2} pos - Center of the tile
|
|
156
|
-
* @param {Vector2} [size=
|
|
156
|
+
* @param {Vector2} [size=Vector2(1,1)] - Size of the tile
|
|
157
157
|
* @param {Number} [tileIndex=-1] - Tile index to use, negative is untextured
|
|
158
158
|
* @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
|
|
159
|
-
* @param {Color} [color=
|
|
159
|
+
* @param {Color} [color=Color()]
|
|
160
160
|
* @param {Number} [angle=0]
|
|
161
161
|
* @param {Boolean} [mirror=0]
|
|
162
|
-
* @param {Color} [additiveColor=
|
|
162
|
+
* @param {Color} [additiveColor=Color(0,0,0,0)]
|
|
163
163
|
* @param {Boolean} [useWebGL=glEnable]
|
|
164
164
|
* @memberof Draw */
|
|
165
165
|
function drawTileScreenSpace(pos, size=vec2(1), tileIndex, tileSize, color, angle, mirror, additiveColor, useWebGL)
|
|
@@ -169,8 +169,8 @@ function drawTileScreenSpace(pos, size=vec2(1), tileIndex, tileSize, color, angl
|
|
|
169
169
|
|
|
170
170
|
/** Draw colored rectangle in screen space
|
|
171
171
|
* @param {Vector2} pos
|
|
172
|
-
* @param {Vector2} [size=
|
|
173
|
-
* @param {Color} [color=
|
|
172
|
+
* @param {Vector2} [size=Vector2(1,1)]
|
|
173
|
+
* @param {Color} [color=Color()]
|
|
174
174
|
* @param {Number} [angle=0]
|
|
175
175
|
* @param {Boolean} [useWebGL=glEnable]
|
|
176
176
|
* @memberof Draw */
|
|
@@ -183,7 +183,7 @@ function drawRectScreenSpace(pos, size, color, angle, useWebGL)
|
|
|
183
183
|
* @param {Vector2} posA
|
|
184
184
|
* @param {Vector2} posB
|
|
185
185
|
* @param {Number} [thickness=.1]
|
|
186
|
-
* @param {Color} [color=
|
|
186
|
+
* @param {Color} [color=Color()]
|
|
187
187
|
* @param {Boolean} [useWebGL=glEnable]
|
|
188
188
|
* @memberof Draw */
|
|
189
189
|
function drawLine(posA, posB, thickness=.1, color, useWebGL)
|
|
@@ -231,9 +231,9 @@ function setBlendMode(additive, useWebGL=glEnable)
|
|
|
231
231
|
* @param {String} text
|
|
232
232
|
* @param {Vector2} pos
|
|
233
233
|
* @param {Number} [size=1]
|
|
234
|
-
* @param {Color} [color=
|
|
234
|
+
* @param {Color} [color=Color()]
|
|
235
235
|
* @param {Number} [lineWidth=0]
|
|
236
|
-
* @param {Color} [lineColor=
|
|
236
|
+
* @param {Color} [lineColor=Color(0,0,0)]
|
|
237
237
|
* @param {String} [textAlign='center']
|
|
238
238
|
* @memberof Draw */
|
|
239
239
|
function drawTextScreen(text, pos, size=1, color=new Color, lineWidth=0, lineColor=new Color(0,0,0), textAlign='center', font=fontDefault, context=overlayContext)
|
|
@@ -260,18 +260,20 @@ function drawTextScreen(text, pos, size=1, color=new Color, lineWidth=0, lineCol
|
|
|
260
260
|
* @param {String} text
|
|
261
261
|
* @param {Vector2} pos
|
|
262
262
|
* @param {Number} [size=1]
|
|
263
|
-
* @param {Color} [color=
|
|
263
|
+
* @param {Color} [color=Color()]
|
|
264
264
|
* @param {Number} [lineWidth=0]
|
|
265
|
-
* @param {Color} [lineColor=
|
|
265
|
+
* @param {Color} [lineColor=Color(0,0,0)]
|
|
266
266
|
* @param {String} [textAlign='center']
|
|
267
267
|
* @memberof Draw */
|
|
268
|
-
function drawText(text, pos, size=1, color, lineWidth, lineColor, textAlign, font)
|
|
268
|
+
function drawText(text, pos, size=1, color, lineWidth=0, lineColor, textAlign, font)
|
|
269
269
|
{
|
|
270
270
|
drawTextScreen(text, worldToScreen(pos), size*cameraScale, color, lineWidth*cameraScale, lineColor, textAlign, font, mainContext);
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
///////////////////////////////////////////////////////////////////////////////
|
|
274
274
|
|
|
275
|
+
let engineFontImage;
|
|
276
|
+
|
|
275
277
|
/**
|
|
276
278
|
* Font Image Object - Draw text on a 2D canvas by using characters in an image
|
|
277
279
|
* <br> - 96 characters (from space to tilde) are stored in an image
|
|
@@ -284,10 +286,6 @@ function drawText(text, pos, size=1, color, lineWidth, lineColor, textAlign, fon
|
|
|
284
286
|
* // draw text
|
|
285
287
|
* font.drawTextScreen("LittleJS\nHello World!", vec2(200, 50));
|
|
286
288
|
*/
|
|
287
|
-
|
|
288
|
-
// default font image created by engine
|
|
289
|
-
let engineFontImage;
|
|
290
|
-
|
|
291
289
|
class FontImage
|
|
292
290
|
{
|
|
293
291
|
/** Create an image font
|
package/engine/engineExport.js
CHANGED
|
@@ -4,43 +4,197 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Setters for all variables that devs will need to modify
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/** Set position of camera in world space
|
|
10
|
+
* @param {Vector2} pos
|
|
11
|
+
* @memberof Settings */
|
|
12
|
+
const setCameraPos = (pos)=> cameraPos = pos;
|
|
13
|
+
|
|
14
|
+
/** Set scale of camera in world space
|
|
15
|
+
* @param {Number} scale
|
|
16
|
+
* @memberof Settings */
|
|
17
|
+
const setCameraScale = (scale)=> cameraScale = scale;
|
|
18
|
+
|
|
19
|
+
/** Set max size of the canvas
|
|
20
|
+
* @param {Vector2} size
|
|
21
|
+
* @memberof Settings */
|
|
22
|
+
const setCanvasMaxSize = (size)=> canvasMaxSize = size;
|
|
23
|
+
|
|
24
|
+
/** Set fixed size of the canvas
|
|
25
|
+
* @param {Vector2} size
|
|
26
|
+
* @memberof Settings */
|
|
27
|
+
const setCanvasFixedSize = (size)=> canvasFixedSize = size;
|
|
28
|
+
|
|
29
|
+
/** Disables anti aliasing for pixel art if true
|
|
30
|
+
* @param {Boolean} pixelated
|
|
31
|
+
* @memberof Settings */
|
|
32
|
+
const setCavasPixelated = (pixelated)=> cavasPixelated = pixelated;
|
|
33
|
+
|
|
34
|
+
/** Set default font used for text rendering
|
|
35
|
+
* @param {String} font
|
|
36
|
+
* @memberof Settings */
|
|
37
|
+
const setFontDefault = (font)=> fontDefault = font;
|
|
38
|
+
|
|
39
|
+
/** Set if webgl rendering is enabled
|
|
40
|
+
* @param {Boolean} enable
|
|
41
|
+
* @memberof Settings */
|
|
42
|
+
const setGlEnable = (enable)=> glEnable = enable;
|
|
43
|
+
|
|
44
|
+
/** Set to not composite the WebGL canvas
|
|
45
|
+
* @param {Boolean} overlay
|
|
46
|
+
* @memberof Settings */
|
|
47
|
+
const setGlOverlay = (overlay)=> glOverlay = overlay;
|
|
48
|
+
|
|
49
|
+
/** Set default size of tiles in pixels
|
|
50
|
+
* @param {Vector2} size
|
|
51
|
+
* @memberof Settings */
|
|
52
|
+
const setTileSizeDefault = (size)=> tileSizeDefault = size;
|
|
53
|
+
|
|
54
|
+
/** Set to prevent tile bleeding from neighbors in pixels
|
|
55
|
+
* @param {Number} scale
|
|
56
|
+
* @memberof Settings */
|
|
57
|
+
const setTileFixBleedScale = (scale)=> tileFixBleedScale = scale;
|
|
58
|
+
|
|
59
|
+
/** Set if collisions between objects are enabled
|
|
60
|
+
* @param {Boolean} enable
|
|
61
|
+
* @memberof Settings */
|
|
62
|
+
const setEnablePhysicsSolver = (enable)=> enablePhysicsSolver = enable;
|
|
63
|
+
|
|
64
|
+
/** Set default object mass for collison calcuations
|
|
65
|
+
* @param {Number} mass
|
|
66
|
+
* @memberof Settings */
|
|
67
|
+
const setObjectDefaultMass = (mass)=> objectDefaultMass = mass;
|
|
68
|
+
|
|
69
|
+
/** Set how much to slow velocity by each frame
|
|
70
|
+
* @param {Number} damping
|
|
71
|
+
* @memberof Settings */
|
|
72
|
+
const setObjectDefaultDamping = (damp)=> objectDefaultDamping = damp;
|
|
73
|
+
|
|
74
|
+
/** Set how much to slow angular velocity each frame
|
|
75
|
+
* @param {Number} damping
|
|
76
|
+
* @memberof Settings */
|
|
77
|
+
const setObjectDefaultAngleDamping = (damp)=> objectDefaultAngleDamping = damp;
|
|
78
|
+
|
|
79
|
+
/** Set how much to bounce when a collision occur
|
|
80
|
+
* @param {Number} elasticity
|
|
81
|
+
* @memberof Settings */
|
|
82
|
+
const setObjectDefaultElasticity = (elasticity)=> objectDefaultElasticity = elasticity;
|
|
83
|
+
|
|
84
|
+
/** Set how much to slow when touching
|
|
85
|
+
* @param {Number} friction
|
|
86
|
+
* @memberof Settings */
|
|
87
|
+
const setObjectDefaultFriction = (friction)=> objectDefaultFriction = friction;
|
|
88
|
+
|
|
89
|
+
/** Set max speed to avoid fast objects missing collisions
|
|
90
|
+
* @param {Number} speed
|
|
91
|
+
* @memberof Settings */
|
|
92
|
+
const setObjectMaxSpeed = (speed)=> objectMaxSpeed = speed;
|
|
93
|
+
|
|
94
|
+
/** Set how much gravity to apply to objects along the Y axis
|
|
95
|
+
* @param {Number} gravity
|
|
96
|
+
* @memberof Settings */
|
|
97
|
+
const setGravity = (g)=> gravity = g;
|
|
98
|
+
|
|
99
|
+
/** Set to scales emit rate of particles
|
|
100
|
+
* @param {Number} scale
|
|
101
|
+
* @memberof Settings */
|
|
102
|
+
const setParticleEmitRateScale = (scale)=> particleEmitRateScale = scale;
|
|
103
|
+
|
|
104
|
+
/** Set if gamepads are enabled
|
|
105
|
+
* @param {Boolean} enable
|
|
106
|
+
* @memberof Settings */
|
|
107
|
+
const setGamepadsEnable = (enable)=> gamepadsEnable = enable;
|
|
108
|
+
|
|
109
|
+
/** Set if the dpad input is also routed to the left analog stick
|
|
110
|
+
* @param {Boolean} enable
|
|
111
|
+
* @memberof Settings */
|
|
112
|
+
const setGamepadDirectionEmulateStick = (enable)=> gamepadDirectionEmulateStick = enable;
|
|
113
|
+
|
|
114
|
+
/** Set if true the WASD keys are also routed to the direction keys
|
|
115
|
+
* @param {Boolean} enable
|
|
116
|
+
* @memberof Settings */
|
|
117
|
+
const setInputWASDEmulateDirection = (enable)=> inputWASDEmulateDirection = enable;
|
|
118
|
+
|
|
119
|
+
/** Set if touch gamepad should appear on mobile devices
|
|
120
|
+
* @param {Boolean} enable
|
|
121
|
+
* @memberof Settings */
|
|
122
|
+
const setTouchGamepadEnable = (enable)=> touchGamepadEnable = enable;
|
|
123
|
+
|
|
124
|
+
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
125
|
+
* @param {Boolean} analog
|
|
126
|
+
* @memberof Settings */
|
|
127
|
+
const setTouchGamepadAnalog = (analog)=> touchGamepadAnalog = analog;
|
|
128
|
+
|
|
129
|
+
/** Set size of virutal gamepad for touch devices in pixels
|
|
130
|
+
* @param {Number} size
|
|
131
|
+
* @memberof Settings */
|
|
132
|
+
const setTouchGamepadSize = (size)=> touchGamepadSize = size;
|
|
133
|
+
|
|
134
|
+
/** Set transparency of touch gamepad overlay
|
|
135
|
+
* @param {Number} alpha
|
|
136
|
+
* @memberof Settings */
|
|
137
|
+
const setTouchGamepadAlpha = (alpha)=> touchGamepadAlpha = alpha;
|
|
138
|
+
|
|
139
|
+
/** Set to allow vibration hardware if it exists
|
|
140
|
+
* @param {Boolean} enable
|
|
141
|
+
* @memberof Settings */
|
|
142
|
+
const setVibrateEnable = (enable)=> vibrateEnable = enable;
|
|
143
|
+
|
|
144
|
+
/** Set to disable all audio code
|
|
145
|
+
* @param {Boolean} enable
|
|
146
|
+
* @memberof Settings */
|
|
147
|
+
const setSoundEnable = (enable)=> soundEnable = enable;
|
|
148
|
+
|
|
149
|
+
/** Set volume scale to apply to all sound, music and speech
|
|
150
|
+
* @param {Number} volume
|
|
151
|
+
* @memberof Settings */
|
|
152
|
+
const setSoundVolume = (volume)=> soundVolume = volume;
|
|
153
|
+
|
|
154
|
+
/** Set default range where sound no longer plays
|
|
155
|
+
* @param {Number} range
|
|
156
|
+
* @memberof Settings */
|
|
157
|
+
const setSoundDefaultRange = (range)=> soundDefaultRange = range;
|
|
158
|
+
|
|
159
|
+
/** Set default range percent to start tapering off sound
|
|
160
|
+
* @param {Number} taper
|
|
161
|
+
* @memberof Settings */
|
|
162
|
+
const setSoundDefaultTaper = (taper)=> soundDefaultTaper = taper;
|
|
163
|
+
|
|
164
|
+
/** Set how long to show medals for in seconds
|
|
165
|
+
* @param {Number} time
|
|
166
|
+
* @memberof Settings */
|
|
167
|
+
const setMedalDisplayTime = (time)=> medalDisplayTime = time;
|
|
168
|
+
|
|
169
|
+
/** Set how quickly to slide on/off medals in seconds
|
|
170
|
+
* @param {Number} time
|
|
171
|
+
* @memberof Settings */
|
|
172
|
+
const setMedalDisplaySlideTime = (time)=> medalDisplaySlideTime = time;
|
|
173
|
+
|
|
174
|
+
/** Set size of medal display
|
|
175
|
+
* @param {Vector2} size
|
|
176
|
+
* @memberof Settings */
|
|
177
|
+
const setMedalDisplaySize = (size)=> medalDisplaySize = size;
|
|
178
|
+
|
|
179
|
+
/** Set size of icon in medal display
|
|
180
|
+
* @param {Number} size
|
|
181
|
+
* @memberof Settings */
|
|
182
|
+
const setMedalDisplayIconSize = (size)=> medalDisplayIconSize = size;
|
|
183
|
+
|
|
184
|
+
/** Set to stop medals from being unlockable
|
|
185
|
+
* @param {Boolean} preventUnlock
|
|
186
|
+
* @memberof Settings */
|
|
187
|
+
const setMedalsPreventUnlock = (prevent)=> medalsPreventUnlock = prevent;
|
|
188
|
+
|
|
189
|
+
/** Set if watermark with FPS should be shown
|
|
190
|
+
* @param {Boolean} show
|
|
191
|
+
* @memberof Debug */
|
|
192
|
+
const setShowWatermark = (show)=> showWatermark = show;
|
|
193
|
+
|
|
194
|
+
/** Set if god mode is enabled
|
|
195
|
+
* @param {Boolean} enable
|
|
196
|
+
* @memberof Debug */
|
|
197
|
+
const setGodMode = (enable)=> godMode = enable;
|
|
44
198
|
|
|
45
199
|
export {
|
|
46
200
|
// Setters for global variables
|
|
@@ -54,7 +208,6 @@ export {
|
|
|
54
208
|
setGlOverlay,
|
|
55
209
|
setTileSizeDefault,
|
|
56
210
|
setTileFixBleedScale,
|
|
57
|
-
setObjectDefaultSize,
|
|
58
211
|
setEnablePhysicsSolver,
|
|
59
212
|
setObjectDefaultMass,
|
|
60
213
|
setObjectDefaultDamping,
|
|
@@ -81,6 +234,8 @@ export {
|
|
|
81
234
|
setMedalDisplaySize,
|
|
82
235
|
setMedalDisplayIconSize,
|
|
83
236
|
setMedalsPreventUnlock,
|
|
237
|
+
setShowWatermark,
|
|
238
|
+
setGodMode,
|
|
84
239
|
|
|
85
240
|
// Settings
|
|
86
241
|
canvasMaxSize,
|
|
@@ -89,7 +244,6 @@ export {
|
|
|
89
244
|
fontDefault,
|
|
90
245
|
tileSizeDefault,
|
|
91
246
|
tileFixBleedScale,
|
|
92
|
-
objectDefaultSize,
|
|
93
247
|
enablePhysicsSolver,
|
|
94
248
|
objectDefaultMass,
|
|
95
249
|
objectDefaultDamping,
|
|
@@ -124,17 +278,9 @@ export {
|
|
|
124
278
|
debug,
|
|
125
279
|
showWatermark,
|
|
126
280
|
godMode,
|
|
281
|
+
|
|
127
282
|
// Debug
|
|
128
|
-
|
|
129
|
-
//debugOverlay,
|
|
130
|
-
//debugPhysics,
|
|
131
|
-
//debugRaycast,
|
|
132
|
-
//debugParticles,
|
|
133
|
-
//debugGamepads,
|
|
134
|
-
//debugMedals,
|
|
135
|
-
//debugTakeScreenshot,
|
|
136
|
-
//downloadLink,
|
|
137
|
-
//ASSERT,
|
|
283
|
+
ASSERT,
|
|
138
284
|
debugRect,
|
|
139
285
|
debugCircle,
|
|
140
286
|
debugPoint,
|
|
@@ -143,9 +289,6 @@ export {
|
|
|
143
289
|
debugText,
|
|
144
290
|
debugClear,
|
|
145
291
|
debugSaveCanvas,
|
|
146
|
-
//debugInit,
|
|
147
|
-
//debugUpdate,
|
|
148
|
-
//debugRender,
|
|
149
292
|
|
|
150
293
|
// Utilities
|
|
151
294
|
PI,
|
|
@@ -225,18 +368,6 @@ export {
|
|
|
225
368
|
gamepadWasPressed,
|
|
226
369
|
gamepadWasReleased,
|
|
227
370
|
gamepadStick,
|
|
228
|
-
//inputData,
|
|
229
|
-
//inputUpdate,
|
|
230
|
-
//inputUpdatePost,
|
|
231
|
-
// onkeydown,
|
|
232
|
-
// onkeyup,
|
|
233
|
-
//remapKeyCode,
|
|
234
|
-
// onmousedown,
|
|
235
|
-
// onmouseup,
|
|
236
|
-
// onmousemove,
|
|
237
|
-
// onwheel,
|
|
238
|
-
// oncontextmenu,
|
|
239
|
-
//stickData,
|
|
240
371
|
mouseToScreen,
|
|
241
372
|
gamepadsUpdate,
|
|
242
373
|
vibrate,
|
|
@@ -253,9 +384,6 @@ export {
|
|
|
253
384
|
audioContext,
|
|
254
385
|
playSamples,
|
|
255
386
|
zzfx,
|
|
256
|
-
//zzfxR,
|
|
257
|
-
//zzfxG,
|
|
258
|
-
//zzfxM,
|
|
259
387
|
|
|
260
388
|
// Tiles
|
|
261
389
|
tileCollision,
|
|
@@ -278,25 +406,17 @@ export {
|
|
|
278
406
|
medalsInit,
|
|
279
407
|
newgroundsInit,
|
|
280
408
|
Medal,
|
|
281
|
-
//medalsRender,
|
|
282
409
|
Newgrounds,
|
|
283
|
-
//CryptoJS,
|
|
284
410
|
|
|
285
411
|
// WebGL
|
|
286
412
|
glCanvas,
|
|
287
413
|
glContext,
|
|
288
|
-
//glInit,
|
|
289
414
|
glSetBlendMode,
|
|
290
415
|
glSetTexture,
|
|
291
416
|
glCompileShader,
|
|
292
417
|
glCreateProgram,
|
|
293
418
|
glCreateTexture,
|
|
294
|
-
//glPreRender,
|
|
295
|
-
//glFlush,
|
|
296
|
-
//glCopyToContext,
|
|
297
|
-
//glDraw,
|
|
298
419
|
glInitPostProcess,
|
|
299
|
-
//glRenderPostProcess,
|
|
300
420
|
|
|
301
421
|
// Engine
|
|
302
422
|
engineName,
|
|
@@ -304,7 +424,6 @@ export {
|
|
|
304
424
|
frameRate,
|
|
305
425
|
timeDelta,
|
|
306
426
|
engineObjects,
|
|
307
|
-
//engineObjectsCollide,
|
|
308
427
|
frame,
|
|
309
428
|
time,
|
|
310
429
|
timeReal,
|