littlejsengine 1.16.1 → 1.16.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.
@@ -32,10 +32,11 @@ function medalsInit(saveName)
32
32
 
33
33
  // engine automatically renders medals
34
34
  engineAddPlugin(undefined, medalsRender);
35
+
36
+ // plugin functions
35
37
  function medalsRender()
36
38
  {
37
- if (!medalsDisplayQueue.length)
38
- return;
39
+ if (!medalsDisplayQueue.length) return;
39
40
 
40
41
  // update first medal in queue
41
42
  const medal = medalsDisplayQueue[0];
@@ -125,8 +126,7 @@ class Medal
125
126
  /** Unlocks a medal if not already unlocked */
126
127
  unlock()
127
128
  {
128
- if (medalsPreventUnlock || this.unlocked)
129
- return;
129
+ if (medalsPreventUnlock || this.unlocked) return;
130
130
 
131
131
  // save the medal
132
132
  ASSERT(medalsSaveName, 'save name must be set');
@@ -511,8 +511,7 @@ class EngineObject
511
511
  /** Render debug info for this object */
512
512
  renderDebugInfo()
513
513
  {
514
- if (!debug)
515
- return;
514
+ if (!debug) return;
516
515
 
517
516
  // show object info for debugging
518
517
  const size = vec2(max(this.size.x, .2), max(this.size.y, .2));
@@ -22,6 +22,7 @@ function LOG (){}
22
22
  function debugInit (){}
23
23
  function debugUpdate (){}
24
24
  function debugRender (){}
25
+ function debugRenderPost (){}
25
26
  function debugRect (){}
26
27
  function debugPoly (){}
27
28
  function debugCircle (){}
@@ -31,9 +32,6 @@ function debugOverlap (){}
31
32
  function debugText (){}
32
33
  function debugClear (){}
33
34
  function debugScreenshot (){}
34
- function debugSaveCanvas (){}
35
- function debugSaveText (){}
36
- function debugSaveDataURL(){}
37
35
  function debugShowErrors(){}
38
36
  function debugVideoCaptureIsActive(){ return false; }
39
37
  function debugVideoCaptureStart (){}
@@ -37,7 +37,7 @@ let cameraScale = 32;
37
37
  * @memberof Settings */
38
38
  let canvasColorTiles = true;
39
39
 
40
- /** Color to clear the canvas to before render
40
+ /** Color to clear the canvas to before render, does not clear if alpha is 0
41
41
  * @type {Color}
42
42
  * @memberof Draw */
43
43
  let canvasClearColor = CLEAR_BLACK;
@@ -346,7 +346,7 @@ function setCameraScale(scale) { cameraScale = scale; }
346
346
  * @memberof Settings */
347
347
  function setCanvasColorTiles(colorTiles) { canvasColorTiles = colorTiles; }
348
348
 
349
- /** Set color to clear the canvas to before render
349
+ /** Set color to clear the canvas to before render, does not clear if alpha is 0
350
350
  * @param {Color} color
351
351
  * @memberof Settings */
352
352
  function setCanvasClearColor(color) { canvasClearColor = color.copy(); }
@@ -443,12 +443,11 @@ class TileLayer extends CanvasLayer
443
443
  if (!this.context) return;
444
444
 
445
445
  // save current render settings
446
- /** @type {[HTMLCanvasElement|OffscreenCanvas, CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, Color]} */
447
- this.savedRenderSettings = [drawCanvas, drawContext, mainCanvasSize, cameraPos, cameraScale, canvasClearColor];
446
+ /** @type {[CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, Color]} */
447
+ this.savedRenderSettings = [drawContext, mainCanvasSize, cameraPos, cameraScale, canvasClearColor];
448
448
 
449
449
  // set the draw canvas and context to this layer
450
450
  // use camera settings to match this layer's canvas
451
- drawCanvas = this.canvas;
452
451
  drawContext = this.context;
453
452
  cameraPos = this.size.scale(.5);
454
453
  const tileSize = this.tileInfo ? this.tileInfo.size : vec2(1);
@@ -458,8 +457,8 @@ class TileLayer extends CanvasLayer
458
457
  if (clear)
459
458
  {
460
459
  // clear and set size
461
- drawCanvas.width = mainCanvasSize.x;
462
- drawCanvas.height = mainCanvasSize.y;
460
+ this.canvas.width = mainCanvasSize.x;
461
+ this.canvas.height = mainCanvasSize.y;
463
462
  }
464
463
 
465
464
  // disable smoothing for pixel art
@@ -476,10 +475,10 @@ class TileLayer extends CanvasLayer
476
475
 
477
476
  ASSERT(drawContext === this.context, 'must call redrawStart() before drawing tiles');
478
477
  glCopyToContext(drawContext);
479
- //debugSaveCanvas(this.canvas);
478
+ //saveCanvas(this.canvas);
480
479
 
481
480
  // set stuff back to normal
482
- [drawCanvas, drawContext, mainCanvasSize, cameraPos, cameraScale, canvasClearColor] = this.savedRenderSettings;
481
+ [drawContext, mainCanvasSize, cameraPos, cameraScale, canvasClearColor] = this.savedRenderSettings;
483
482
  }
484
483
 
485
484
  /** Draw the tile at a given position in the tile grid
@@ -547,8 +546,7 @@ class TileCollisionLayer extends TileLayer
547
546
  /** Destroy this tile layer */
548
547
  destroy()
549
548
  {
550
- if (this.destroyed)
551
- return;
549
+ if (this.destroyed) return;
552
550
 
553
551
  // remove from collision layers array and destroy
554
552
  const index = tileCollisionLayers.indexOf(this);