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.
Files changed (61) hide show
  1. package/README.md +61 -41
  2. package/build/littlejs.d.ts +160 -165
  3. package/build/littlejs.esm.js +451 -367
  4. package/build/littlejs.esm.min.js +1 -1
  5. package/build/littlejs.js +408 -314
  6. package/build/littlejs.min.js +1 -1
  7. package/build/littlejs.release.js +2573 -2470
  8. package/examples/breakout/game.js +5 -1
  9. package/examples/breakout/index.html +5 -5
  10. package/examples/breakoutTutorial/README.md +6 -6
  11. package/examples/breakoutTutorial/game.js +3 -0
  12. package/examples/breakoutTutorial/index.html +3 -3
  13. package/examples/electron/build.js +105 -0
  14. package/examples/electron/game.js +4 -2
  15. package/examples/electron/index.html +13 -2
  16. package/examples/electron/package.json +5 -3
  17. package/examples/empty/game.js +3 -1
  18. package/examples/empty/index.html +1 -1
  19. package/examples/favicon.png +0 -0
  20. package/examples/js13k/build.bat +2 -0
  21. package/examples/js13k/build.js +110 -0
  22. package/examples/js13k/game.js +109 -0
  23. package/examples/js13k/index.html +18 -0
  24. package/examples/js13k/tiles.png +0 -0
  25. package/examples/module/game.js +9 -3
  26. package/examples/module/index.html +2 -2
  27. package/examples/particles/index.html +7 -13
  28. package/examples/platformer/game.js +5 -2
  29. package/examples/platformer/gameEffects.js +1 -2
  30. package/examples/platformer/gamePlayer.js +2 -2
  31. package/examples/platformer/index.html +8 -8
  32. package/examples/puzzle/game.js +6 -4
  33. package/examples/puzzle/index.html +4 -4
  34. package/examples/starter/build.bat +2 -78
  35. package/examples/starter/build.js +109 -0
  36. package/examples/starter/game.js +4 -1
  37. package/examples/starter/index.html +15 -18
  38. package/examples/stress/index.html +2 -4
  39. package/examples/typescript/build.bat +2 -14
  40. package/examples/typescript/build.js +31 -0
  41. package/examples/typescript/game.js +94 -89
  42. package/examples/typescript/game.ts +9 -3
  43. package/examples/typescript/index.html +2 -2
  44. package/package.json +3 -3
  45. package/src/engine.js +30 -31
  46. package/src/engineAudio.js +44 -20
  47. package/src/engineBuild.bat +2 -132
  48. package/src/engineBuild.js +143 -0
  49. package/src/engineDebug.js +21 -32
  50. package/src/engineDraw.js +36 -28
  51. package/src/engineExport.js +41 -51
  52. package/src/engineInput.js +33 -20
  53. package/src/engineMedals.js +31 -8
  54. package/src/engineObject.js +34 -32
  55. package/src/engineParticles.js +9 -12
  56. package/src/engineRelease.js +18 -20
  57. package/src/engineSettings.js +4 -4
  58. package/src/engineTileLayer.js +49 -32
  59. package/src/engineUtilities.js +96 -74
  60. package/src/engineWebGL.js +8 -8
  61. package/examples/electron/build.bat +0 -52
@@ -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
- * <br> - Press ~ to show debug overlay with mouse pick
9
- * <br> - Number keys toggle debug functions
10
- * <br> - +/- apply time scale
11
- * <br> - Debug primitive rendering
12
- * <br> - Save a 2d canvas as an image
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
- const ASSERT = enableAsserts ? (...assert)=> console.assert(...assert) : ()=>{};
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
- const debugRect = (pos, size=vec2(), color='#fff', time=0, angle=0, fill=false)=>
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
- const debugCircle = (pos, radius=0, color='#fff', time=0, fill=false)=>
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
- const debugPoint = (pos, color, time, angle)=> debugRect(pos, 0, color, time, angle);
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
- const debugLine = (posA, posB, color, thickness=.1, time)=>
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
- const debugAABB = (pA, sA, pB, sB, color)=>
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
- const debugText = (text, pos, size=1, color='#fff', time=0, angle=0, font='monospace')=>
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
- const debugClear = ()=> debugPrimitives = [];
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
- const debugSaveCanvas = (canvas, filename = engineName + '.png') =>
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
- const debugInit = ()=>
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
- const debugUpdate = ()=>
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
- godMode = !godMode;
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
- const debugRender = ()=>
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 = godMode ? '#f00' : '#fff';
368
- overlayContext.fillText('4: God Mode', x, y += h);
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(godMode ? 'God Mode' : '', x, y += h);
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
- * <br> - Hybrid with both Canvas2D and WebGL available
4
- * <br> - Super fast tile sheet rendering with WebGL
5
- * <br> - Can apply rotation, mirror, color and additive color
6
- * <br> - Many useful utility functions
7
- * <br>
8
- * <br>LittleJS uses a hybrid rendering solution with the best of both Canvas2D and WebGL.
9
- * <br>There are 3 canvas/contexts available to draw to...
10
- * <br> - mainCanvas - 2D background canvas, non WebGL stuff like tile layers are drawn here.
11
- * <br> - glCanvas - Used by the accelerated WebGL batch rendering system.
12
- * <br> - overlayCanvas - Another 2D canvas that appears on top of the other 2 canvases.
13
- * <br>
14
- * <br>The WebGL rendering system is very fast with some caveats...
15
- * <br> - The default setup supports only 1 tile sheet, to support more call glCreateTexture and glSetTexture
16
- * <br> - Switching blend modes (additive) or textures causes another draw call which is expensive in excess
17
- * <br> - Group additive rendering together using renderOrder to mitigate this issue
18
- * <br>
19
- * <br>The LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!
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
- const screenToWorld = (screenPos)=>
63
+ function screenToWorld(screenPos)
64
64
  {
65
65
  ASSERT(mainCanvasSize.x && mainCanvasSize.y, 'mainCanvasSize is invalid');
66
- return screenPos.add(vec2(.5)).subtract(mainCanvasSize.scale(.5)).multiply(vec2(1/cameraScale,-1/cameraScale)).add(cameraPos);
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
- const worldToScreen = (worldPos)=>
78
+ function worldToScreen(worldPos)
75
79
  {
76
80
  ASSERT(mainCanvasSize.x && mainCanvasSize.y, 'mainCanvasSize is invalid');
77
- return worldPos.subtract(cameraPos).multiply(vec2(cameraScale,-cameraScale)).add(mainCanvasSize.scale(.5)).subtract(vec2(.5));
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, angle=0, mirror,
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
- * <br> - 96 characters (from space to tilde) are stored in an image
284
- * <br> - Uses a default 8x8 font if none is supplied
285
- * <br> - You can also use fonts from the main tile sheet
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 = !cavasPixelated;
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
- const isFullscreen = ()=> document.fullscreenElement;
379
+ function isFullscreen() { return document.fullscreenElement; }
372
380
 
373
381
  /** Toggle fullsceen mode
374
382
  * @memberof Draw */
@@ -1,205 +1,197 @@
1
1
  /**
2
2
  * LittleJS Module Export
3
- * <br> - Export engine as a module with extra functions where necessary
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
- const setCameraPos = (pos)=> cameraPos = pos;
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
- const setCameraScale = (scale)=> cameraScale = scale;
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
- const setCanvasMaxSize = (size)=> canvasMaxSize = size;
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
- const setCanvasFixedSize = (size)=> canvasFixedSize = size;
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
- const setCavasPixelated = (pixelated)=> cavasPixelated = pixelated;
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
- const setFontDefault = (font)=> fontDefault = font;
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
- const setGlEnable = (enable)=> glEnable = enable;
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
- const setGlOverlay = (overlay)=> glOverlay = overlay;
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
- const setTileSizeDefault = (size)=> tileSizeDefault = size;
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
- const setTileFixBleedScale = (scale)=> tileFixBleedScale = scale;
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
- const setEnablePhysicsSolver = (enable)=> enablePhysicsSolver = enable;
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
- const setObjectDefaultMass = (mass)=> objectDefaultMass = mass;
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
- const setObjectDefaultDamping = (damp)=> objectDefaultDamping = damp;
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
- const setObjectDefaultAngleDamping = (damp)=> objectDefaultAngleDamping = damp;
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
- const setObjectDefaultElasticity = (elasticity)=> objectDefaultElasticity = elasticity;
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
- const setObjectDefaultFriction = (friction)=> objectDefaultFriction = friction;
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
- const setObjectMaxSpeed = (speed)=> objectMaxSpeed = speed;
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
- const setGravity = (g)=> gravity = g;
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
- const setParticleEmitRateScale = (scale)=> particleEmitRateScale = scale;
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
- const setGamepadsEnable = (enable)=> gamepadsEnable = enable;
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
- const setGamepadDirectionEmulateStick = (enable)=> gamepadDirectionEmulateStick = enable;
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
- const setInputWASDEmulateDirection = (enable)=> inputWASDEmulateDirection = enable;
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
- const setTouchGamepadEnable = (enable)=> touchGamepadEnable = enable;
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
- const setTouchGamepadAnalog = (analog)=> touchGamepadAnalog = analog;
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
- const setTouchGamepadSize = (size)=> touchGamepadSize = size;
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
- const setTouchGamepadAlpha = (alpha)=> touchGamepadAlpha = alpha;
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
- const setVibrateEnable = (enable)=> vibrateEnable = enable;
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
- const setSoundEnable = (enable)=> soundEnable = enable;
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
- const setSoundVolume = (volume)=> soundVolume = volume;
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
- const setSoundDefaultRange = (range)=> soundDefaultRange = range;
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
- const setSoundDefaultTaper = (taper)=> soundDefaultTaper = taper;
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
- const setMedalDisplayTime = (time)=> medalDisplayTime = time;
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
- const setMedalDisplaySlideTime = (time)=> medalDisplaySlideTime = time;
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
- const setMedalDisplaySize = (size)=> medalDisplaySize = size;
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
- const setMedalDisplayIconSize = (size)=> medalDisplayIconSize = size;
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
- const setMedalsPreventUnlock = (prevent)=> medalsPreventUnlock = prevent;
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
- 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;
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
- const setDebugKey = (key)=> debugKey = key;
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
- setCavasPixelated,
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
- cavasPixelated,
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,