littlejsengine 1.9.8 → 1.9.9

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.
@@ -5,21 +5,8 @@
5
5
  <link rel=icon type=image/png href=../favicon.png>
6
6
  </head><body>
7
7
 
8
- <!-- LittleJS Engine -->
9
- <script src=../../src/engineDebug.js?196></script>
10
- <script src=../../src/engineUtilities.js?196></script>
11
- <script src=../../src/engineSettings.js?196></script>
12
- <script src=../../src/engineObject.js?196></script>
13
- <script src=../../src/engineDraw.js?196></script>
14
- <script src=../../src/engineInput.js?196></script>
15
- <script src=../../src/engineAudio.js?196></script>
16
- <script src=../../src/engineTileLayer.js?196></script>
17
- <script src=../../src/engineParticles.js?196></script>
18
- <script src=../../src/engineMedals.js?196></script>
19
- <script src=../../src/engineWebGL.js?196></script>
20
- <script src=../../src/engine.js?196></script>
21
-
22
- <script src=../../plugins/Box2D_v2.3.1_min.wasm.js?196></script>
23
- <script src=../../plugins/box2d.js?196></script>
24
- <script src=scenes.js?196></script>
25
- <script src=game.js?196></script>
8
+ <script src=../../dist/littlejs.js></script>
9
+ <script src=../../plugins/Box2D_v2.3.1_min.wasm.js?197></script>
10
+ <script src=../../plugins/box2d.js?197></script>
11
+ <script src=scenes.js?197></script>
12
+ <script src=game.js?197></script>
@@ -44,17 +44,17 @@ function loadScene(_scene)
44
44
  if (scene == 2)
45
45
  {
46
46
  sceneName = 'Dominoes';
47
- spawnDominoes(vec2(11,11), 12);
48
- spawnDominoes(vec2(2,0), 16, vec2(1,3));
47
+ spawnDominoes(vec2(11,11), 11);
48
+ spawnDominoes(vec2(2,0), 13, vec2(1,3));
49
49
  spawnCircle(vec2(10,20), 2, randColor());
50
- spawnCircle(vec2(31,12), 2, randColor());
50
+ spawnCircle(vec2(31.7,12), 2, randColor());
51
51
  spawnBox(vec2(16,11), vec2(32,1), randColor(), box2dBodyTypeStatic, false);
52
52
  spawnBox(vec2(24,6.5), vec2(32,1), randColor(), box2dBodyTypeStatic, false, -.15);
53
53
  }
54
54
  if (scene == 3)
55
55
  {
56
56
  sceneName = 'Car';
57
- spawnCar(vec2(10,5));
57
+ spawnCar(vec2(10,2));
58
58
  spawnBox(vec2(20,0), vec2(10,2), randColor(), box2dBodyTypeStatic, false, -.2);
59
59
  spawnPyramid(vec2(32,0), 6);
60
60
  }
@@ -77,7 +77,7 @@ function loadScene(_scene)
77
77
  }
78
78
  if (scene == 5)
79
79
  {
80
- sceneName = 'Raycast';
80
+ sceneName = 'Raycasts';
81
81
  spawnRandomEdges();
82
82
  for (let i=100;i--;)
83
83
  spawnRandomObject(vec2(rand(1,39), rand(20)), 2, box2dBodyTypeStatic, rand(PI*2));
@@ -262,7 +262,7 @@ function loadScene(_scene)
262
262
  function spawnDominoes(pos, count, size=vec2(.5,2))
263
263
  {
264
264
  for (let i=count; i--;)
265
- spawnBox(pos.add(vec2(i*size.y*.8,size.y/2)), size, randColor());
265
+ spawnBox(pos.add(vec2(i*size.y*.9,size.y/2)), size, randColor());
266
266
  }
267
267
  function spawnCar(pos)
268
268
  {
@@ -373,7 +373,7 @@ function spawnRandomObject(pos, scale=1, type=box2dBodyTypeDynamic, angle=0)
373
373
  const sound_click = new Sound([,.1]);
374
374
  const sound_explosion = new Sound([,.2,72,.01,.01,.2,4,,,,,,,1,,.5,.1,.5,.02]);
375
375
 
376
- function explosion(pos, radius=3, strength=500)
376
+ function explosion(pos, radius=3, strength=300)
377
377
  {
378
378
  sound_explosion.play(pos);
379
379
  const objects = box2dCircleCastAll(pos, (radius*2));
@@ -5,7 +5,7 @@
5
5
  <link rel=icon type=image/png href=../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../dist/littlejs.js?196></script>
8
+ <script src=../../dist/littlejs.js?197></script>
9
9
  <script src=../../plugins/postProcess.js></script>
10
- <script src=gameObjects.js?196></script>
11
- <script src=game.js?196></script>
10
+ <script src=gameObjects.js?197></script>
11
+ <script src=game.js?197></script>
@@ -5,5 +5,5 @@
5
5
  <link rel=icon type=image/png href=../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../dist/littlejs.js?196></script>
9
- <script src=game.js?196></script>
8
+ <script src=../../dist/littlejs.js?197></script>
9
+ <script src=game.js?197></script>
@@ -68,7 +68,7 @@ function closureCompilerStep(filename)
68
68
 
69
69
  const filenameTemp = filename + '.tmp';
70
70
  fs.copyFileSync(filename, filenameTemp);
71
- child_process.execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --compilation_level=ADVANCED --language_out=ECMASCRIPT_2021 --warning_level=VERBOSE --jscomp_off=* --assume_function_wrapper`, {stdio: 'inherit'});
71
+ child_process.execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --compilation_level=ADVANCED --warning_level=VERBOSE --jscomp_off=* --assume_function_wrapper`, {stdio: 'inherit'});
72
72
  fs.rmSync(filenameTemp);
73
73
  };
74
74
 
@@ -6,7 +6,7 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- LittleJS Engine -->
9
- <script src=../../dist/littlejs.js?196></script>
9
+ <script src=../../dist/littlejs.js?197></script>
10
10
 
11
11
  <!-- Add your game scripts here -->
12
- <script src=game.js?196></script>
12
+ <script src=game.js?197></script>
@@ -42,6 +42,7 @@ Build
42
42
  `${BUILD_FOLDER}/index.js`,
43
43
  sourceFiles,
44
44
  [closureCompilerStep, uglifyBuildStep, roadrollerBuildStep, htmlBuildStep, zipBuildStep]
45
+ //[closureCompilerSimpleStep, htmlBuildStep] // for build debugging
45
46
  );
46
47
 
47
48
  console.log(``);
@@ -73,7 +74,17 @@ function closureCompilerStep(filename)
73
74
 
74
75
  const filenameTemp = filename + '.tmp';
75
76
  fs.copyFileSync(filename, filenameTemp);
76
- child_process.execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --compilation_level=ADVANCED --language_out=ECMASCRIPT_2021 --warning_level=VERBOSE --jscomp_off=* --assume_function_wrapper`, {stdio: 'inherit'});
77
+ child_process.execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --compilation_level=ADVANCED --warning_level=VERBOSE --jscomp_off=* --assume_function_wrapper`, {stdio: 'inherit'});
78
+ fs.rmSync(filenameTemp);
79
+ };
80
+
81
+ function closureCompilerSimpleStep(filename)
82
+ {
83
+ console.log(`Running closure compiler in simple mode...`);
84
+
85
+ const filenameTemp = filename + '.tmp';
86
+ fs.copyFileSync(filename, filenameTemp);
87
+ child_process.execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --compilation_level=SIMPLE --warning_level=VERBOSE --jscomp_off=* --assume_function_wrapper`, {stdio: 'inherit'});
77
88
  fs.rmSync(filenameTemp);
78
89
  };
79
90
 
@@ -89,6 +100,13 @@ function roadrollerBuildStep(filename)
89
100
  child_process.execSync(`npx roadroller ${filename} -o ${filename}`, {stdio: 'inherit'});
90
101
  };
91
102
 
103
+ function roadrollerExtremeBuildStep(filename)
104
+ {
105
+ // this takes over a minute to run but might be a little smaller
106
+ console.log(`Running roadroller extreme...`);
107
+ child_process.execSync(`npx roadroller ${filename} -o ${filename} --optimize 2`, {stdio: 'inherit'});
108
+ };
109
+
92
110
  function htmlBuildStep(filename)
93
111
  {
94
112
  console.log(`Building html...`);
@@ -1,18 +1,18 @@
1
1
  <head><title>LittleJS JS13K Project</title></head><body>
2
2
 
3
3
  <!-- LittleJS Engine -->
4
- <script src=../../src/engineDebug.js?196></script>
5
- <script src=../../src/engineUtilities.js?196></script>
6
- <script src=../../src/engineSettings.js?196></script>
7
- <script src=../../src/engineObject.js?196></script>
8
- <script src=../../src/engineDraw.js?196></script>
9
- <script src=../../src/engineInput.js?196></script>
10
- <script src=../../src/engineAudio.js?196></script>
11
- <script src=../../src/engineTileLayer.js?196></script>
12
- <script src=../../src/engineParticles.js?196></script>
13
- <script src=../../src/engineMedals.js?196></script>
14
- <script src=../../src/engineWebGL.js?196></script>
15
- <script src=../../src/engine.js?196></script>
4
+ <script src=../../src/engineDebug.js?197></script>
5
+ <script src=../../src/engineUtilities.js?197></script>
6
+ <script src=../../src/engineSettings.js?197></script>
7
+ <script src=../../src/engineObject.js?197></script>
8
+ <script src=../../src/engineDraw.js?197></script>
9
+ <script src=../../src/engineInput.js?197></script>
10
+ <script src=../../src/engineAudio.js?197></script>
11
+ <script src=../../src/engineTileLayer.js?197></script>
12
+ <script src=../../src/engineParticles.js?197></script>
13
+ <script src=../../src/engineMedals.js?197></script>
14
+ <script src=../../src/engineWebGL.js?197></script>
15
+ <script src=../../src/engine.js?197></script>
16
16
 
17
17
  <!-- Add your game scripts here -->
18
- <script src=game.js?196></script>
18
+ <script src=game.js?197></script>
@@ -6,4 +6,4 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- Add your game scripts here -->
9
- <script src=game.js?196 type=module></script>
9
+ <script src=game.js?197 type=module></script>
@@ -9,7 +9,7 @@ button { margin:1px; }
9
9
  </style>
10
10
  </head><body>
11
11
 
12
- <script src=../../dist/littlejs.js?196></script>
12
+ <script src=../../dist/littlejs.js?197></script>
13
13
  <script>
14
14
 
15
15
  'use strict';
@@ -6,11 +6,11 @@
6
6
  <link rel=icon type=image/png href=../favicon.png>
7
7
  </head><body>
8
8
 
9
- <script src=../../dist/littlejs.js?196></script>
10
- <script src=gameObjects.js?196></script>
11
- <script src=gameCharacter.js?196></script>
12
- <script src=gamePlayer.js?196></script>
13
- <script src=gameEffects.js?196></script>
14
- <script src=gameLevel.js?196></script>
15
- <script src=gameLevelData.js?196></script>
16
- <script src=game.js?196></script>
9
+ <script src=../../dist/littlejs.js?197></script>
10
+ <script src=gameObjects.js?197></script>
11
+ <script src=gameCharacter.js?197></script>
12
+ <script src=gamePlayer.js?197></script>
13
+ <script src=gameEffects.js?197></script>
14
+ <script src=gameLevel.js?197></script>
15
+ <script src=gameLevelData.js?197></script>
16
+ <script src=game.js?197></script>
@@ -5,5 +5,5 @@
5
5
  <link rel=icon type=image/png href=../favicon.png>
6
6
  </head><body>
7
7
 
8
- <script src=../../dist/littlejs.js?196></script>
9
- <script src=game.js?196></script>
8
+ <script src=../../dist/littlejs.js?197></script>
9
+ <script src=game.js?197></script>
@@ -74,7 +74,7 @@ function closureCompilerStep(filename)
74
74
 
75
75
  const filenameTemp = filename + '.tmp';
76
76
  fs.copyFileSync(filename, filenameTemp);
77
- child_process.execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --compilation_level=ADVANCED --language_out=ECMASCRIPT_2021 --warning_level=VERBOSE --jscomp_off=* --assume_function_wrapper`, {stdio: 'inherit'});
77
+ child_process.execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --compilation_level=ADVANCED --warning_level=VERBOSE --jscomp_off=* --assume_function_wrapper`, {stdio: 'inherit'});
78
78
  fs.rmSync(filenameTemp);
79
79
  };
80
80
 
@@ -6,18 +6,18 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- LittleJS Engine -->
9
- <script src=../../src/engineDebug.js?196></script>
10
- <script src=../../src/engineUtilities.js?196></script>
11
- <script src=../../src/engineSettings.js?196></script>
12
- <script src=../../src/engineObject.js?196></script>
13
- <script src=../../src/engineDraw.js?196></script>
14
- <script src=../../src/engineInput.js?196></script>
15
- <script src=../../src/engineAudio.js?196></script>
16
- <script src=../../src/engineTileLayer.js?196></script>
17
- <script src=../../src/engineParticles.js?196></script>
18
- <script src=../../src/engineMedals.js?196></script>
19
- <script src=../../src/engineWebGL.js?196></script>
20
- <script src=../../src/engine.js?196></script>
9
+ <script src=../../src/engineDebug.js?197></script>
10
+ <script src=../../src/engineUtilities.js?197></script>
11
+ <script src=../../src/engineSettings.js?197></script>
12
+ <script src=../../src/engineObject.js?197></script>
13
+ <script src=../../src/engineDraw.js?197></script>
14
+ <script src=../../src/engineInput.js?197></script>
15
+ <script src=../../src/engineAudio.js?197></script>
16
+ <script src=../../src/engineTileLayer.js?197></script>
17
+ <script src=../../src/engineParticles.js?197></script>
18
+ <script src=../../src/engineMedals.js?197></script>
19
+ <script src=../../src/engineWebGL.js?197></script>
20
+ <script src=../../src/engine.js?197></script>
21
21
 
22
22
  <!-- Add your game scripts here -->
23
- <script src=game.js?196></script>
23
+ <script src=game.js?197></script>
@@ -6,7 +6,7 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- LittleJS Engine -->
9
- <script src=../../dist/littlejs.min.js?196></script>
9
+ <script src=../../dist/littlejs.min.js?197></script>
10
10
  <script>
11
11
 
12
12
  /*
@@ -6,4 +6,4 @@
6
6
  </head><body>
7
7
 
8
8
  <!-- Add your game scripts here -->
9
- <script src=game.js?196 type=module></script>
9
+ <script src=game.js?197 type=module></script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "littlejsengine",
3
- "version": "1.9.8",
3
+ "version": "1.9.9",
4
4
  "description": "LittleJS - Tiny and Fast HTML5 Game Engine",
5
5
  "main": "dist/littlejs.esm.js",
6
6
  "types": "dist/littlejs.d.ts",
package/plugins/box2d.js CHANGED
@@ -638,6 +638,13 @@ function box2dCastObject(object)
638
638
  ASSERT(false, 'Unknown object type');
639
639
  }
640
640
 
641
+ function box2dWarmup(frames=100)
642
+ {
643
+ // run the sim for a few frames to let objects settle
644
+ for(let i=frames; i--;)
645
+ box2dWorld.Step(timeDelta, box2dStepIterations, box2dStepIterations);
646
+ }
647
+
641
648
  ///////////////////////////////////////////////////////////////////////////////
642
649
  // Box2D Drawing
643
650
 
@@ -792,17 +799,16 @@ function box2dEngineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameR
792
799
  box2dWorld.SetDebugDraw(box2dDebugDraw);
793
800
 
794
801
  // hook up box2d plugin to update and render
795
- addPluginUpdate(function()
802
+ engineAddPlugin(box2dUpdate, box2dRender);
803
+ function box2dUpdate()
796
804
  {
797
- const velocityIterations = box2dStepIterations;
798
- const positionIterations = box2dStepIterations;
799
- box2dWorld.Step(timeDelta, velocityIterations, positionIterations);
800
- });
801
- addPluginRender(function()
805
+ box2dWorld.Step(timeDelta, box2dStepIterations, box2dStepIterations);
806
+ }
807
+ function box2dRender()
802
808
  {
803
809
  if (box2dDebug || debugPhysics && debugOverlay)
804
810
  box2dWorld.DrawDebugData();
805
- });
811
+ }
806
812
 
807
813
  // start littlejs
808
814
  engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, imageSources);
@@ -55,7 +55,8 @@ function initPostProcess(shaderCode, includeOverlay=false)
55
55
  overlayCanvas.style.visibility = 'hidden';
56
56
 
57
57
  // Render the post processing shader, called automatically by the engine
58
- addPluginRender(function()
58
+ engineAddPlugin(undefined, postProcessRender);
59
+ function postProcessRender()
59
60
  {
60
61
  if (headlessMode) return;
61
62
 
@@ -97,5 +98,5 @@ function initPostProcess(shaderCode, includeOverlay=false)
97
98
  glContext.uniform1f(uniformLocation('iTime'), time);
98
99
  glContext.uniform3f(uniformLocation('iResolution'), mainCanvas.width, mainCanvas.height, 1);
99
100
  glContext.drawArrays(gl_TRIANGLE_STRIP, 0, 4);
100
- });
101
+ }
101
102
  }
package/src/engine.js CHANGED
@@ -30,7 +30,7 @@ const engineName = 'LittleJS';
30
30
  * @type {String}
31
31
  * @default
32
32
  * @memberof Engine */
33
- const engineVersion = '1.9.8';
33
+ const engineVersion = '1.9.9';
34
34
 
35
35
  /** Frames per second to update
36
36
  * @type {Number}
@@ -89,14 +89,14 @@ let frameTimeLastMS = 0, frameTimeBufferMS = 0, averageFPS = 0;
89
89
  const pluginUpdateList = [], pluginRenderList = [];
90
90
 
91
91
  /** Add a new update function for a plugin
92
- * @param {Function} updateFunction
92
+ * @param {Function} [updateFunction]
93
+ * @param {Function} [renderFunction]
93
94
  * @memberof Engine */
94
- function addPluginUpdate(updateFunction) { pluginUpdateList.push(updateFunction); }
95
-
96
- /** Add a new render function for a plugin
97
- * @param {Function} renderFunction
98
- * @memberof Engine */
99
- function addPluginRender(renderFunction) { pluginRenderList.push(renderFunction); }
95
+ function engineAddPlugin(updateFunction, renderFunction)
96
+ {
97
+ updateFunction && pluginUpdateList.push(updateFunction);
98
+ renderFunction && pluginRenderList.push(renderFunction);
99
+ }
100
100
 
101
101
  ///////////////////////////////////////////////////////////////////////////////
102
102
  // Main engine functions
@@ -269,10 +269,11 @@ function engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRender
269
269
  const styleBody =
270
270
  'margin:0;overflow:hidden;' + // fill the window
271
271
  'background:#000;' + // set background color
272
- 'touch-action:none;' + // prevent mobile pinch to resize
273
- 'user-select:none;' + // prevent mobile hold to select
272
+ 'user-select:none;' + // prevent hold to select
274
273
  '-webkit-user-select:none;' + // compatibility for ios
275
- '-webkit-touch-callout:none'; // compatibility for ios
274
+ (!touchInputEnable ? '' : // no touch css setttings
275
+ 'touch-action:none;' + // prevent mobile pinch to resize
276
+ '-webkit-touch-callout:none');// compatibility for ios
276
277
  document.body.style.cssText = styleBody;
277
278
  document.body.appendChild(mainCanvas = document.createElement('canvas'));
278
279
  mainContext = mainCanvas.getContext('2d');
@@ -137,7 +137,7 @@ function closureCompilerStep(filename)
137
137
  fs.copyFileSync(filename, filenameTemp);
138
138
  try
139
139
  {
140
- child_process.execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --language_out=ECMASCRIPT_2021 --warning_level=VERBOSE --jscomp_off=*`);
140
+ child_process.execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --warning_level=VERBOSE --jscomp_off=*`);
141
141
  fs.rmSync(filenameTemp);
142
142
  }
143
143
  catch (e) { handleError(e, 'Failed to run Closure Compiler step!'); }
@@ -20,6 +20,7 @@ export {
20
20
  engineObjectsUpdate,
21
21
  engineObjectsDestroy,
22
22
  engineObjectsCallback,
23
+ engineAddPlugin,
23
24
 
24
25
  // Globals
25
26
  debug,
@@ -101,6 +102,7 @@ export {
101
102
  setObjectMaxSpeed,
102
103
  setGravity,
103
104
  setParticleEmitRateScale,
105
+ setTouchInputEnable,
104
106
  setGamepadsEnable,
105
107
  setGamepadDirectionEmulateStick,
106
108
  setInputWASDEmulateDirection,
@@ -3,6 +3,7 @@
3
3
  * - Tracks keyboard down, pressed, and released
4
4
  * - Tracks mouse buttons, position, and wheel
5
5
  * - Tracks multiple analog gamepads
6
+ * - Touch input is handled as mouse input
6
7
  * - Virtual gamepad for touch devices
7
8
  * @namespace Input
8
9
  */
@@ -136,7 +137,8 @@ function inputUpdate()
136
137
  if (headlessMode) return;
137
138
 
138
139
  // clear input when lost focus (prevent stuck keys)
139
- isTouchDevice || document.hasFocus() || clearInput();
140
+ if(!(touchInputEnable && isTouchDevice) && !document.hasFocus())
141
+ clearInput();
140
142
 
141
143
  // update mouse world space position
142
144
  mousePos = screenToWorld(mousePosScreen);
@@ -208,7 +210,7 @@ function inputInit()
208
210
  oncontextmenu = (e)=> false; // prevent right click menu
209
211
 
210
212
  // init touch input
211
- if (isTouchDevice)
213
+ if (isTouchDevice && touchInputEnable && !headlessMode)
212
214
  touchInputInit();
213
215
  }
214
216
 
@@ -336,12 +338,12 @@ function vibrateStop() { vibrate(0); }
336
338
 
337
339
  /** True if a touch device has been detected
338
340
  * @memberof Input */
339
- const isTouchDevice = !headlessMode && window.ontouchstart !== undefined;
341
+ const isTouchDevice = window.ontouchstart !== undefined;
340
342
 
341
343
  // touch gamepad internal variables
342
344
  let touchGamepadTimer = new Timer, touchGamepadButtons, touchGamepadStick;
343
345
 
344
- // try to enable touch mouse
346
+ // enable touch input mouse passthrough
345
347
  function touchInputInit()
346
348
  {
347
349
  // add non passive touch event listeners
@@ -450,6 +452,7 @@ function touchInputInit()
450
452
  // render the touch gamepad, called automatically by the engine
451
453
  function touchGamepadRender()
452
454
  {
455
+ if (!touchInputEnable || !isTouchDevice || headlessMode) return;
453
456
  if (!touchGamepadEnable || !touchGamepadTimer.isSet())
454
457
  return;
455
458
 
@@ -31,7 +31,8 @@ function medalsInit(saveName)
31
31
  medalsForEach(medal=> medal.unlocked = (localStorage[medal.storageKey()] | 0));
32
32
 
33
33
  // engine automatically renders medals
34
- addPluginRender(function()
34
+ engineAddPlugin(undefined, medalsRender);
35
+ function medalsRender()
35
36
  {
36
37
  if (!medalsDisplayQueue.length)
37
38
  return;
@@ -55,7 +56,7 @@ function medalsInit(saveName)
55
56
  time > slideOffTime ? (time - slideOffTime) / medalDisplaySlideTime : 0;
56
57
  medal.render(hidePercent);
57
58
  }
58
- });
59
+ }
59
60
  }
60
61
 
61
62
  /** Calls a function for each medal
@@ -434,12 +434,15 @@ class EngineObject
434
434
  /** Render debug info for this object */
435
435
  renderDebugInfo()
436
436
  {
437
- // show object info for debugging
438
- const size = vec2(max(this.size.x, .2), max(this.size.y, .2));
439
- const color1 = rgb(this.collideTiles?1:0, this.collideSolidObjects?1:0, this.isSolid?1:0, this.parent?.2:.5);
440
- const color2 = this.parent ? rgb(1,1,1,.5) : rgb(0,0,0,.8);
441
- drawRect(this.pos, size, color1, this.angle, false);
442
- drawRect(this.pos, size.scale(.8), color2, this.angle, false);
443
- this.parent && drawLine(this.pos, this.parent.pos, .1, rgb(0,0,1,.5), false);
437
+ if (debug)
438
+ {
439
+ // show object info for debugging
440
+ const size = vec2(max(this.size.x, .2), max(this.size.y, .2));
441
+ const color1 = rgb(this.collideTiles?1:0, this.collideSolidObjects?1:0, this.isSolid?1:0, this.parent?.2:.5);
442
+ const color2 = this.parent ? rgb(1,1,1,.5) : rgb(0,0,0,.8);
443
+ drawRect(this.pos, size, color1, this.angle, false);
444
+ drawRect(this.pos, size.scale(.8), color2, this.angle, false);
445
+ this.parent && drawLine(this.pos, this.parent.pos, .1, rgb(0,0,1,.5), false);
446
+ }
444
447
  }
445
448
  }
@@ -169,6 +169,13 @@ let gamepadDirectionEmulateStick = true;
169
169
  * @memberof Settings */
170
170
  let inputWASDEmulateDirection = true;
171
171
 
172
+ /** True if touch input is enabled for mobile devices
173
+ * - Touch events will be routed to mouse events
174
+ * @type {Boolean}
175
+ * @default
176
+ * @memberof Settings */
177
+ let touchInputEnable = true;
178
+
172
179
  /** True if touch gamepad should appear on mobile devices
173
180
  * - Supports left analog stick, 4 face buttons and start button (button 9)
174
181
  * - Must be set by end of gameInit to be activated
@@ -384,6 +391,11 @@ function setGamepadDirectionEmulateStick(enable) { gamepadDirectionEmulateStick
384
391
  * @memberof Settings */
385
392
  function setInputWASDEmulateDirection(enable) { inputWASDEmulateDirection = enable; }
386
393
 
394
+ /** Set if touch input is allowed
395
+ * @param {Boolean} enable
396
+ * @memberof Settings */
397
+ function setTouchInputEnable(enable) { touchInputEnable = enable; }
398
+
387
399
  /** Set if touch gamepad should appear on mobile devices
388
400
  * @param {Boolean} enable
389
401
  * @memberof Settings */