littlejsengine 1.6.4 → 1.6.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -41
- package/build/littlejs.d.ts +160 -165
- package/build/littlejs.esm.js +451 -367
- package/build/littlejs.esm.min.js +1 -1
- package/build/littlejs.js +408 -314
- package/build/littlejs.min.js +1 -1
- package/build/littlejs.release.js +2573 -2470
- package/examples/breakout/game.js +5 -1
- package/examples/breakout/index.html +5 -5
- package/examples/breakoutTutorial/README.md +6 -6
- package/examples/breakoutTutorial/game.js +3 -0
- package/examples/breakoutTutorial/index.html +3 -3
- package/examples/electron/build.js +105 -0
- package/examples/electron/game.js +4 -2
- package/examples/electron/index.html +13 -2
- package/examples/electron/package.json +5 -3
- package/examples/empty/game.js +3 -1
- package/examples/empty/index.html +1 -1
- package/examples/favicon.png +0 -0
- package/examples/js13k/build.bat +2 -0
- package/examples/js13k/build.js +110 -0
- package/examples/js13k/game.js +109 -0
- package/examples/js13k/index.html +18 -0
- package/examples/js13k/tiles.png +0 -0
- package/examples/module/game.js +9 -3
- package/examples/module/index.html +2 -2
- package/examples/particles/index.html +7 -13
- package/examples/platformer/game.js +5 -2
- package/examples/platformer/gameEffects.js +1 -2
- package/examples/platformer/gamePlayer.js +2 -2
- package/examples/platformer/index.html +8 -8
- package/examples/puzzle/game.js +6 -4
- package/examples/puzzle/index.html +4 -4
- package/examples/starter/build.bat +2 -78
- package/examples/starter/build.js +109 -0
- package/examples/starter/game.js +4 -1
- package/examples/starter/index.html +15 -18
- package/examples/stress/index.html +2 -4
- package/examples/typescript/build.bat +2 -14
- package/examples/typescript/build.js +31 -0
- package/examples/typescript/game.js +94 -89
- package/examples/typescript/game.ts +9 -3
- package/examples/typescript/index.html +2 -2
- package/package.json +3 -3
- package/src/engine.js +30 -31
- package/src/engineAudio.js +44 -20
- package/src/engineBuild.bat +2 -132
- package/src/engineBuild.js +143 -0
- package/src/engineDebug.js +21 -32
- package/src/engineDraw.js +36 -28
- package/src/engineExport.js +41 -51
- package/src/engineInput.js +33 -20
- package/src/engineMedals.js +31 -8
- package/src/engineObject.js +34 -32
- package/src/engineParticles.js +9 -12
- package/src/engineRelease.js +18 -20
- package/src/engineSettings.js +4 -4
- package/src/engineTileLayer.js +49 -32
- package/src/engineUtilities.js +96 -74
- package/src/engineWebGL.js +8 -8
- package/examples/electron/build.bat +0 -52
package/src/engineDebug.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
/*
|
|
2
|
-
LittleJS - Debug Build
|
|
3
|
-
MIT License - Copyright 2021 Frank Force
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* LittleJS Debug System
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
3
|
+
* - Press ~ to show debug overlay with mouse pick
|
|
4
|
+
* - Number keys toggle debug functions
|
|
5
|
+
* - +/- apply time scale
|
|
6
|
+
* - Debug primitive rendering
|
|
7
|
+
* - Save a 2d canvas as an image
|
|
13
8
|
* @namespace Debug
|
|
14
9
|
*/
|
|
15
10
|
|
|
@@ -39,12 +34,6 @@ const debugPointSize = .5;
|
|
|
39
34
|
* @memberof Debug */
|
|
40
35
|
let showWatermark = 1;
|
|
41
36
|
|
|
42
|
-
/** True if god mode is enabled, handle this however you want
|
|
43
|
-
* @type {Boolean}
|
|
44
|
-
* @default
|
|
45
|
-
* @memberof Debug */
|
|
46
|
-
let godMode = 0;
|
|
47
|
-
|
|
48
37
|
/** Key code used to toggle debug mode, Esc by default
|
|
49
38
|
* @type {Boolean}
|
|
50
39
|
* @default
|
|
@@ -62,7 +51,7 @@ debugParticles = 0, debugGamepads = 0, debugMedals = 0, debugTakeScreenshot, dow
|
|
|
62
51
|
* @param {Boolean} assertion
|
|
63
52
|
* @param {Object} output
|
|
64
53
|
* @memberof Debug */
|
|
65
|
-
|
|
54
|
+
function ASSERT(...assert) { enableAsserts && console.assert(...assert); }
|
|
66
55
|
|
|
67
56
|
/** Draw a debug rectangle in world space
|
|
68
57
|
* @param {Vector2} pos
|
|
@@ -72,7 +61,7 @@ const ASSERT = enableAsserts ? (...assert)=> console.assert(...assert) : ()=>{};
|
|
|
72
61
|
* @param {Number} [angle=0]
|
|
73
62
|
* @param {Boolean} [fill=false]
|
|
74
63
|
* @memberof Debug */
|
|
75
|
-
|
|
64
|
+
function debugRect(pos, size=vec2(), color='#fff', time=0, angle=0, fill=false)
|
|
76
65
|
{
|
|
77
66
|
ASSERT(typeof color == 'string'); // pass in regular html strings as colors
|
|
78
67
|
debugPrimitives.push({pos, size:vec2(size), color, time:new Timer(time), angle, fill});
|
|
@@ -85,7 +74,7 @@ const debugRect = (pos, size=vec2(), color='#fff', time=0, angle=0, fill=false)=
|
|
|
85
74
|
* @param {Number} [time=0]
|
|
86
75
|
* @param {Boolean} [fill=false]
|
|
87
76
|
* @memberof Debug */
|
|
88
|
-
|
|
77
|
+
function debugCircle(pos, radius=0, color='#fff', time=0, fill=false)
|
|
89
78
|
{
|
|
90
79
|
ASSERT(typeof color == 'string'); // pass in regular html strings as colors
|
|
91
80
|
debugPrimitives.push({pos, size:radius, color, time:new Timer(time), angle:0, fill});
|
|
@@ -97,7 +86,7 @@ const debugCircle = (pos, radius=0, color='#fff', time=0, fill=false)=>
|
|
|
97
86
|
* @param {Number} [time=0]
|
|
98
87
|
* @param {Number} [angle=0]
|
|
99
88
|
* @memberof Debug */
|
|
100
|
-
|
|
89
|
+
function debugPoint(pos, color, time, angle) {debugRect(pos, 0, color, time, angle);}
|
|
101
90
|
|
|
102
91
|
/** Draw a debug line in world space
|
|
103
92
|
* @param {Vector2} posA
|
|
@@ -106,7 +95,7 @@ const debugPoint = (pos, color, time, angle)=> debugRect(pos, 0, color, time, an
|
|
|
106
95
|
* @param {Number} [thickness=.1]
|
|
107
96
|
* @param {Number} [time=0]
|
|
108
97
|
* @memberof Debug */
|
|
109
|
-
|
|
98
|
+
function debugLine(posA, posB, color, thickness=.1, time)
|
|
110
99
|
{
|
|
111
100
|
const halfDelta = vec2((posB.x - posA.x)/2, (posB.y - posA.y)/2);
|
|
112
101
|
const size = vec2(thickness, halfDelta.length()*2);
|
|
@@ -120,7 +109,7 @@ const debugLine = (posA, posB, color, thickness=.1, time)=>
|
|
|
120
109
|
* @param {Vector2} sizeB
|
|
121
110
|
* @param {String} [color='#fff']
|
|
122
111
|
* @memberof Debug */
|
|
123
|
-
|
|
112
|
+
function debugAABB(pA, sA, pB, sB, color)
|
|
124
113
|
{
|
|
125
114
|
const minPos = vec2(min(pA.x - sA.x/2, pB.x - sB.x/2), min(pA.y - sA.y/2, pB.y - sB.y/2));
|
|
126
115
|
const maxPos = vec2(max(pA.x + sA.x/2, pB.x + sB.x/2), max(pA.y + sA.y/2, pB.y + sB.y/2));
|
|
@@ -136,7 +125,7 @@ const debugAABB = (pA, sA, pB, sB, color)=>
|
|
|
136
125
|
* @param {Number} [angle=0]
|
|
137
126
|
* @param {String} [font='monospace']
|
|
138
127
|
* @memberof Debug */
|
|
139
|
-
|
|
128
|
+
function debugText(text, pos, size=1, color='#fff', time=0, angle=0, font='monospace')
|
|
140
129
|
{
|
|
141
130
|
ASSERT(typeof color == 'string'); // pass in regular html strings as colors
|
|
142
131
|
debugPrimitives.push({text, pos, size, color, time:new Timer(time), angle, font});
|
|
@@ -144,13 +133,13 @@ const debugText = (text, pos, size=1, color='#fff', time=0, angle=0, font='monos
|
|
|
144
133
|
|
|
145
134
|
/** Clear all debug primitives in the list
|
|
146
135
|
* @memberof Debug */
|
|
147
|
-
|
|
136
|
+
function debugClear() { debugPrimitives = []; }
|
|
148
137
|
|
|
149
138
|
/** Save a canvas to disk
|
|
150
139
|
* @param {HTMLCanvasElement} canvas
|
|
151
140
|
* @param {String} [filename]
|
|
152
141
|
* @memberof Debug */
|
|
153
|
-
|
|
142
|
+
function debugSaveCanvas(canvas, filename = engineName + '.png')
|
|
154
143
|
{
|
|
155
144
|
downloadLink.download = 'screenshot.png';
|
|
156
145
|
downloadLink.href = canvas.toDataURL('image/png').replace('image/png','image/octet-stream');
|
|
@@ -160,14 +149,14 @@ const debugSaveCanvas = (canvas, filename = engineName + '.png') =>
|
|
|
160
149
|
///////////////////////////////////////////////////////////////////////////////
|
|
161
150
|
// Engine debug function (called automatically)
|
|
162
151
|
|
|
163
|
-
|
|
152
|
+
function debugInit()
|
|
164
153
|
{
|
|
165
154
|
// create link for saving screenshots
|
|
166
155
|
document.body.appendChild(downloadLink = document.createElement('a'));
|
|
167
156
|
downloadLink.style.display = 'none';
|
|
168
157
|
}
|
|
169
158
|
|
|
170
|
-
|
|
159
|
+
function debugUpdate()
|
|
171
160
|
{
|
|
172
161
|
if (!debug)
|
|
173
162
|
return;
|
|
@@ -185,7 +174,7 @@ const debugUpdate = ()=>
|
|
|
185
174
|
if (keyWasPressed(51)) // 3
|
|
186
175
|
debugGamepads = !debugGamepads;
|
|
187
176
|
if (keyWasPressed(52)) // 4
|
|
188
|
-
|
|
177
|
+
debugRaycast = !debugRaycast;
|
|
189
178
|
if (keyWasPressed(53)) // 5
|
|
190
179
|
debugTakeScreenshot = 1;
|
|
191
180
|
//if (keyWasPressed(54)) // 6
|
|
@@ -195,7 +184,7 @@ const debugUpdate = ()=>
|
|
|
195
184
|
}
|
|
196
185
|
}
|
|
197
186
|
|
|
198
|
-
|
|
187
|
+
function debugRender()
|
|
199
188
|
{
|
|
200
189
|
glCopyToContext(mainContext);
|
|
201
190
|
|
|
@@ -364,8 +353,8 @@ const debugRender = ()=>
|
|
|
364
353
|
overlayContext.fillText('2: Debug Particles', x, y += h);
|
|
365
354
|
overlayContext.fillStyle = debugGamepads ? '#f00' : '#fff';
|
|
366
355
|
overlayContext.fillText('3: Debug Gamepads', x, y += h);
|
|
367
|
-
overlayContext.fillStyle =
|
|
368
|
-
overlayContext.fillText('4:
|
|
356
|
+
overlayContext.fillStyle = debugRaycast ? '#f00' : '#fff';
|
|
357
|
+
overlayContext.fillText('4: Debug Raycasts', x, y += h);
|
|
369
358
|
overlayContext.fillStyle = '#fff';
|
|
370
359
|
overlayContext.fillText('5: Save Screenshot', x, y += h);
|
|
371
360
|
|
|
@@ -390,7 +379,7 @@ const debugRender = ()=>
|
|
|
390
379
|
{
|
|
391
380
|
overlayContext.fillText(debugPhysics ? 'Debug Physics' : '', x, y += h);
|
|
392
381
|
overlayContext.fillText(debugParticles ? 'Debug Particles' : '', x, y += h);
|
|
393
|
-
overlayContext.fillText(
|
|
382
|
+
overlayContext.fillText(debugRaycast ? 'Debug Raycasts' : '', x, y += h);
|
|
394
383
|
overlayContext.fillText(debugGamepads ? 'Debug Gamepads' : '', x, y += h);
|
|
395
384
|
}
|
|
396
385
|
|
package/src/engineDraw.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LittleJS Drawing System
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
3
|
+
* - Hybrid with both Canvas2D and WebGL available
|
|
4
|
+
* - Super fast tile sheet rendering with WebGL
|
|
5
|
+
* - Can apply rotation, mirror, color and additive color
|
|
6
|
+
* - Many useful utility functions
|
|
7
|
+
*
|
|
8
|
+
* LittleJS uses a hybrid rendering solution with the best of both Canvas2D and WebGL.
|
|
9
|
+
* There are 3 canvas/contexts available to draw to...
|
|
10
|
+
* mainCanvas - 2D background canvas, non WebGL stuff like tile layers are drawn here.
|
|
11
|
+
* glCanvas - Used by the accelerated WebGL batch rendering system.
|
|
12
|
+
* overlayCanvas - Another 2D canvas that appears on top of the other 2 canvases.
|
|
13
|
+
*
|
|
14
|
+
* The WebGL rendering system is very fast with some caveats...
|
|
15
|
+
* - The default setup supports only 1 tile sheet, to support more call glCreateTexture and glSetTexture
|
|
16
|
+
* - Switching blend modes (additive) or textures causes another draw call which is expensive in excess
|
|
17
|
+
* - Group additive rendering together using renderOrder to mitigate this issue
|
|
18
|
+
*
|
|
19
|
+
* The LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!
|
|
20
20
|
* @namespace Draw
|
|
21
21
|
*/
|
|
22
22
|
|
|
@@ -60,10 +60,14 @@ let tileImageSize, tileImageFixBleed, drawCount;
|
|
|
60
60
|
* @param {Vector2} screenPos
|
|
61
61
|
* @return {Vector2}
|
|
62
62
|
* @memberof Draw */
|
|
63
|
-
|
|
63
|
+
function screenToWorld(screenPos)
|
|
64
64
|
{
|
|
65
65
|
ASSERT(mainCanvasSize.x && mainCanvasSize.y, 'mainCanvasSize is invalid');
|
|
66
|
-
return screenPos
|
|
66
|
+
return screenPos
|
|
67
|
+
.add(vec2(.5))
|
|
68
|
+
.subtract(mainCanvasSize.scale(.5))
|
|
69
|
+
.multiply(vec2(1/cameraScale,-1/cameraScale))
|
|
70
|
+
.add(cameraPos);
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
/** Convert from world to screen space coordinates
|
|
@@ -71,10 +75,14 @@ const screenToWorld = (screenPos)=>
|
|
|
71
75
|
* @param {Vector2} worldPos
|
|
72
76
|
* @return {Vector2}
|
|
73
77
|
* @memberof Draw */
|
|
74
|
-
|
|
78
|
+
function worldToScreen(worldPos)
|
|
75
79
|
{
|
|
76
80
|
ASSERT(mainCanvasSize.x && mainCanvasSize.y, 'mainCanvasSize is invalid');
|
|
77
|
-
return worldPos
|
|
81
|
+
return worldPos
|
|
82
|
+
.subtract(cameraPos)
|
|
83
|
+
.multiply(vec2(cameraScale,-cameraScale))
|
|
84
|
+
.add(mainCanvasSize.scale(.5))
|
|
85
|
+
.subtract(vec2(.5));
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
/** Draw textured tile centered in world space, with color applied if using WebGL
|
|
@@ -88,8 +96,8 @@ const worldToScreen = (worldPos)=>
|
|
|
88
96
|
* @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
|
|
89
97
|
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
90
98
|
* @memberof Draw */
|
|
91
|
-
function drawTile(pos, size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, color=new Color,
|
|
92
|
-
additiveColor=new Color(0,0,0,0), useWebGL=glEnable)
|
|
99
|
+
function drawTile(pos, size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, color=new Color,
|
|
100
|
+
angle=0, mirror, additiveColor=new Color(0,0,0,0), useWebGL=glEnable)
|
|
93
101
|
{
|
|
94
102
|
showWatermark && ++drawCount;
|
|
95
103
|
if (glEnable && useWebGL)
|
|
@@ -280,9 +288,9 @@ let engineFontImage;
|
|
|
280
288
|
|
|
281
289
|
/**
|
|
282
290
|
* Font Image Object - Draw text on a 2D canvas by using characters in an image
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
291
|
+
* - 96 characters (from space to tilde) are stored in an image
|
|
292
|
+
* - Uses a default 8x8 font if none is supplied
|
|
293
|
+
* - You can also use fonts from the main tile sheet
|
|
286
294
|
* @example
|
|
287
295
|
* // use built in font
|
|
288
296
|
* const font = new ImageFont;
|
|
@@ -322,7 +330,7 @@ class FontImage
|
|
|
322
330
|
{
|
|
323
331
|
const context = this.context;
|
|
324
332
|
context.save();
|
|
325
|
-
context.imageSmoothingEnabled = !
|
|
333
|
+
context.imageSmoothingEnabled = !canvasPixelated;
|
|
326
334
|
|
|
327
335
|
const size = this.tileSize;
|
|
328
336
|
const drawSize = size.add(this.paddingSize).scale(scale);
|
|
@@ -368,7 +376,7 @@ class FontImage
|
|
|
368
376
|
/** Returns true if fullscreen mode is active
|
|
369
377
|
* @return {Boolean}
|
|
370
378
|
* @memberof Draw */
|
|
371
|
-
|
|
379
|
+
function isFullscreen() { return document.fullscreenElement; }
|
|
372
380
|
|
|
373
381
|
/** Toggle fullsceen mode
|
|
374
382
|
* @memberof Draw */
|
package/src/engineExport.js
CHANGED
|
@@ -1,205 +1,197 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LittleJS Module Export
|
|
3
|
-
*
|
|
3
|
+
* - Export engine as a module with extra functions where necessary
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// Setters for all variables that devs will need to modify
|
|
7
|
-
|
|
8
|
-
|
|
9
6
|
/** Set position of camera in world space
|
|
10
7
|
* @param {Vector2} pos
|
|
11
8
|
* @memberof Settings */
|
|
12
|
-
|
|
9
|
+
function setCameraPos(pos) { cameraPos = pos; }
|
|
13
10
|
|
|
14
11
|
/** Set scale of camera in world space
|
|
15
12
|
* @param {Number} scale
|
|
16
13
|
* @memberof Settings */
|
|
17
|
-
|
|
14
|
+
function setCameraScale(scale) { cameraScale = scale; }
|
|
18
15
|
|
|
19
16
|
/** Set max size of the canvas
|
|
20
17
|
* @param {Vector2} size
|
|
21
18
|
* @memberof Settings */
|
|
22
|
-
|
|
19
|
+
function setCanvasMaxSize(size) { canvasMaxSize = size; }
|
|
23
20
|
|
|
24
21
|
/** Set fixed size of the canvas
|
|
25
22
|
* @param {Vector2} size
|
|
26
23
|
* @memberof Settings */
|
|
27
|
-
|
|
24
|
+
function setCanvasFixedSize(size) { canvasFixedSize = size; }
|
|
28
25
|
|
|
29
26
|
/** Disables anti aliasing for pixel art if true
|
|
30
27
|
* @param {Boolean} pixelated
|
|
31
28
|
* @memberof Settings */
|
|
32
|
-
|
|
29
|
+
function setCanvasPixelated(pixelated) { canvasPixelated = pixelated; }
|
|
33
30
|
|
|
34
31
|
/** Set default font used for text rendering
|
|
35
32
|
* @param {String} font
|
|
36
33
|
* @memberof Settings */
|
|
37
|
-
|
|
34
|
+
function setFontDefault(font) { fontDefault = font; }
|
|
38
35
|
|
|
39
36
|
/** Set if webgl rendering is enabled
|
|
40
37
|
* @param {Boolean} enable
|
|
41
38
|
* @memberof Settings */
|
|
42
|
-
|
|
39
|
+
function setGlEnable(enable) { glEnable = enable; }
|
|
43
40
|
|
|
44
41
|
/** Set to not composite the WebGL canvas
|
|
45
42
|
* @param {Boolean} overlay
|
|
46
43
|
* @memberof Settings */
|
|
47
|
-
|
|
44
|
+
function setGlOverlay(overlay) { glOverlay = overlay; }
|
|
48
45
|
|
|
49
46
|
/** Set default size of tiles in pixels
|
|
50
47
|
* @param {Vector2} size
|
|
51
48
|
* @memberof Settings */
|
|
52
|
-
|
|
49
|
+
function setTileSizeDefault(size) { tileSizeDefault = size; }
|
|
53
50
|
|
|
54
51
|
/** Set to prevent tile bleeding from neighbors in pixels
|
|
55
52
|
* @param {Number} scale
|
|
56
53
|
* @memberof Settings */
|
|
57
|
-
|
|
54
|
+
function setTileFixBleedScale(scale) { tileFixBleedScale = scale; }
|
|
58
55
|
|
|
59
56
|
/** Set if collisions between objects are enabled
|
|
60
57
|
* @param {Boolean} enable
|
|
61
58
|
* @memberof Settings */
|
|
62
|
-
|
|
59
|
+
function setEnablePhysicsSolver(enable) { enablePhysicsSolver = enable; }
|
|
63
60
|
|
|
64
61
|
/** Set default object mass for collison calcuations
|
|
65
62
|
* @param {Number} mass
|
|
66
63
|
* @memberof Settings */
|
|
67
|
-
|
|
64
|
+
function setObjectDefaultMass(mass) { objectDefaultMass = mass; }
|
|
68
65
|
|
|
69
66
|
/** Set how much to slow velocity by each frame
|
|
70
67
|
* @param {Number} damping
|
|
71
68
|
* @memberof Settings */
|
|
72
|
-
|
|
69
|
+
function setObjectDefaultDamping(damp) { objectDefaultDamping = damp; }
|
|
73
70
|
|
|
74
71
|
/** Set how much to slow angular velocity each frame
|
|
75
72
|
* @param {Number} damping
|
|
76
73
|
* @memberof Settings */
|
|
77
|
-
|
|
74
|
+
function setObjectDefaultAngleDamping(damp) { objectDefaultAngleDamping = damp; }
|
|
78
75
|
|
|
79
76
|
/** Set how much to bounce when a collision occur
|
|
80
77
|
* @param {Number} elasticity
|
|
81
78
|
* @memberof Settings */
|
|
82
|
-
|
|
79
|
+
function setObjectDefaultElasticity(elasticity) { objectDefaultElasticity = elasticity; }
|
|
83
80
|
|
|
84
81
|
/** Set how much to slow when touching
|
|
85
82
|
* @param {Number} friction
|
|
86
83
|
* @memberof Settings */
|
|
87
|
-
|
|
84
|
+
function setObjectDefaultFriction(friction) { objectDefaultFriction = friction; }
|
|
88
85
|
|
|
89
86
|
/** Set max speed to avoid fast objects missing collisions
|
|
90
87
|
* @param {Number} speed
|
|
91
88
|
* @memberof Settings */
|
|
92
|
-
|
|
89
|
+
function setObjectMaxSpeed(speed) { objectMaxSpeed = speed; }
|
|
93
90
|
|
|
94
91
|
/** Set how much gravity to apply to objects along the Y axis
|
|
95
92
|
* @param {Number} gravity
|
|
96
93
|
* @memberof Settings */
|
|
97
|
-
|
|
94
|
+
function setGravity(g) { gravity = g; }
|
|
98
95
|
|
|
99
96
|
/** Set to scales emit rate of particles
|
|
100
97
|
* @param {Number} scale
|
|
101
98
|
* @memberof Settings */
|
|
102
|
-
|
|
99
|
+
function setParticleEmitRateScale(scale) { particleEmitRateScale = scale; }
|
|
103
100
|
|
|
104
101
|
/** Set if gamepads are enabled
|
|
105
102
|
* @param {Boolean} enable
|
|
106
103
|
* @memberof Settings */
|
|
107
|
-
|
|
104
|
+
function setGamepadsEnable(enable) { gamepadsEnable = enable; }
|
|
108
105
|
|
|
109
106
|
/** Set if the dpad input is also routed to the left analog stick
|
|
110
107
|
* @param {Boolean} enable
|
|
111
108
|
* @memberof Settings */
|
|
112
|
-
|
|
109
|
+
function setGamepadDirectionEmulateStick(enable) { gamepadDirectionEmulateStick = enable; }
|
|
113
110
|
|
|
114
111
|
/** Set if true the WASD keys are also routed to the direction keys
|
|
115
112
|
* @param {Boolean} enable
|
|
116
113
|
* @memberof Settings */
|
|
117
|
-
|
|
114
|
+
function setInputWASDEmulateDirection(enable) { inputWASDEmulateDirection = enable; }
|
|
118
115
|
|
|
119
116
|
/** Set if touch gamepad should appear on mobile devices
|
|
120
117
|
* @param {Boolean} enable
|
|
121
118
|
* @memberof Settings */
|
|
122
|
-
|
|
119
|
+
function setTouchGamepadEnable(enable) { touchGamepadEnable = enable; }
|
|
123
120
|
|
|
124
121
|
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
125
122
|
* @param {Boolean} analog
|
|
126
123
|
* @memberof Settings */
|
|
127
|
-
|
|
124
|
+
function setTouchGamepadAnalog(analog) { touchGamepadAnalog = analog; }
|
|
128
125
|
|
|
129
126
|
/** Set size of virutal gamepad for touch devices in pixels
|
|
130
127
|
* @param {Number} size
|
|
131
128
|
* @memberof Settings */
|
|
132
|
-
|
|
129
|
+
function setTouchGamepadSize(size) { touchGamepadSize = size; }
|
|
133
130
|
|
|
134
131
|
/** Set transparency of touch gamepad overlay
|
|
135
132
|
* @param {Number} alpha
|
|
136
133
|
* @memberof Settings */
|
|
137
|
-
|
|
134
|
+
function setTouchGamepadAlpha(alpha) { touchGamepadAlpha = alpha; }
|
|
138
135
|
|
|
139
136
|
/** Set to allow vibration hardware if it exists
|
|
140
137
|
* @param {Boolean} enable
|
|
141
138
|
* @memberof Settings */
|
|
142
|
-
|
|
139
|
+
function setVibrateEnable(enable) { vibrateEnable = enable; }
|
|
143
140
|
|
|
144
141
|
/** Set to disable all audio code
|
|
145
142
|
* @param {Boolean} enable
|
|
146
143
|
* @memberof Settings */
|
|
147
|
-
|
|
144
|
+
function setSoundEnable(enable) { soundEnable = enable; }
|
|
148
145
|
|
|
149
146
|
/** Set volume scale to apply to all sound, music and speech
|
|
150
147
|
* @param {Number} volume
|
|
151
148
|
* @memberof Settings */
|
|
152
|
-
|
|
149
|
+
function setSoundVolume(volume) { soundVolume = volume; }
|
|
153
150
|
|
|
154
151
|
/** Set default range where sound no longer plays
|
|
155
152
|
* @param {Number} range
|
|
156
153
|
* @memberof Settings */
|
|
157
|
-
|
|
154
|
+
function setSoundDefaultRange(range) { soundDefaultRange = range; }
|
|
158
155
|
|
|
159
156
|
/** Set default range percent to start tapering off sound
|
|
160
157
|
* @param {Number} taper
|
|
161
158
|
* @memberof Settings */
|
|
162
|
-
|
|
159
|
+
function setSoundDefaultTaper(taper) { soundDefaultTaper = taper; }
|
|
163
160
|
|
|
164
161
|
/** Set how long to show medals for in seconds
|
|
165
162
|
* @param {Number} time
|
|
166
163
|
* @memberof Settings */
|
|
167
|
-
|
|
164
|
+
function setMedalDisplayTime(time) { medalDisplayTime = time; }
|
|
168
165
|
|
|
169
166
|
/** Set how quickly to slide on/off medals in seconds
|
|
170
167
|
* @param {Number} time
|
|
171
168
|
* @memberof Settings */
|
|
172
|
-
|
|
169
|
+
function setMedalDisplaySlideTime(time) { medalDisplaySlideTime = time; }
|
|
173
170
|
|
|
174
171
|
/** Set size of medal display
|
|
175
172
|
* @param {Vector2} size
|
|
176
173
|
* @memberof Settings */
|
|
177
|
-
|
|
174
|
+
function setMedalDisplaySize(size) { medalDisplaySize = size; }
|
|
178
175
|
|
|
179
176
|
/** Set size of icon in medal display
|
|
180
177
|
* @param {Number} size
|
|
181
178
|
* @memberof Settings */
|
|
182
|
-
|
|
179
|
+
function setMedalDisplayIconSize(size) { medalDisplayIconSize = size; }
|
|
183
180
|
|
|
184
181
|
/** Set to stop medals from being unlockable
|
|
185
182
|
* @param {Boolean} preventUnlock
|
|
186
183
|
* @memberof Settings */
|
|
187
|
-
|
|
184
|
+
function setMedalsPreventUnlock(preventUnlock) { medalsPreventUnlock = preventUnlock; }
|
|
188
185
|
|
|
189
186
|
/** Set if watermark with FPS should be shown
|
|
190
187
|
* @param {Boolean} show
|
|
191
188
|
* @memberof Debug */
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
/** Set if god mode is enabled
|
|
195
|
-
* @param {Boolean} enable
|
|
196
|
-
* @memberof Debug */
|
|
197
|
-
const setGodMode = (enable)=> godMode = enable;
|
|
189
|
+
function setShowWatermark(show) { showWatermark = show; }
|
|
198
190
|
|
|
199
191
|
/** Set key code used to toggle debug mode, Esc by default
|
|
200
192
|
* @param {Number} key
|
|
201
193
|
* @memberof Debug */
|
|
202
|
-
|
|
194
|
+
function setDebugKey(key) { debugKey = key; }
|
|
203
195
|
|
|
204
196
|
export {
|
|
205
197
|
// Setters for global variables
|
|
@@ -207,7 +199,7 @@ export {
|
|
|
207
199
|
setCameraScale,
|
|
208
200
|
setCanvasMaxSize,
|
|
209
201
|
setCanvasFixedSize,
|
|
210
|
-
|
|
202
|
+
setCanvasPixelated,
|
|
211
203
|
setFontDefault,
|
|
212
204
|
setGlEnable,
|
|
213
205
|
setGlOverlay,
|
|
@@ -240,13 +232,12 @@ export {
|
|
|
240
232
|
setMedalDisplayIconSize,
|
|
241
233
|
setMedalsPreventUnlock,
|
|
242
234
|
setShowWatermark,
|
|
243
|
-
setGodMode,
|
|
244
235
|
setDebugKey,
|
|
245
236
|
|
|
246
237
|
// Settings
|
|
247
238
|
canvasMaxSize,
|
|
248
239
|
canvasFixedSize,
|
|
249
|
-
|
|
240
|
+
canvasPixelated,
|
|
250
241
|
fontDefault,
|
|
251
242
|
tileSizeDefault,
|
|
252
243
|
tileFixBleedScale,
|
|
@@ -283,7 +274,6 @@ export {
|
|
|
283
274
|
// Globals
|
|
284
275
|
debug,
|
|
285
276
|
showWatermark,
|
|
286
|
-
godMode,
|
|
287
277
|
|
|
288
278
|
// Debug
|
|
289
279
|
ASSERT,
|