littlejsengine 1.13.1 → 1.14.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.
Files changed (83) hide show
  1. package/README.md +15 -11
  2. package/copyToGithub.bat +28 -0
  3. package/dist/littlejs.d.ts +430 -304
  4. package/dist/littlejs.esm.js +1745 -982
  5. package/dist/littlejs.esm.min.js +1 -1
  6. package/dist/littlejs.js +1716 -965
  7. package/dist/littlejs.min.js +1 -1
  8. package/dist/littlejs.release.js +1673 -922
  9. package/examples/box2d/game.js +2 -2
  10. package/examples/box2d/gameObjects.js +2 -2
  11. package/examples/box2d/scenes.js +1 -1
  12. package/examples/breakout/game.js +30 -25
  13. package/examples/breakoutTutorial/README.md +44 -41
  14. package/examples/breakoutTutorial/game.js +2 -2
  15. package/examples/electron/build.bat +7 -0
  16. package/examples/electron/build.js +124 -0
  17. package/examples/electron/electron.js +35 -0
  18. package/examples/electron/game.js +140 -0
  19. package/examples/electron/index.html +13 -0
  20. package/examples/electron/package.json +12 -0
  21. package/examples/electron/tiles.png +0 -0
  22. package/examples/empty/game.js +1 -0
  23. package/examples/htmlMenu/game.js +1 -1
  24. package/examples/index.html +332 -160
  25. package/examples/module/game.js +5 -2
  26. package/examples/particles/index.html +12 -3
  27. package/examples/platformer/gameEffects.js +20 -19
  28. package/examples/platformer/gameLevel.js +6 -1
  29. package/examples/shorts/base.html +1 -1
  30. package/examples/shorts/blending.js +9 -5
  31. package/examples/shorts/box2d.js +1 -1
  32. package/examples/shorts/box2dCar.js +1 -1
  33. package/examples/shorts/clock.js +1 -1
  34. package/examples/shorts/colors.js +2 -2
  35. package/examples/shorts/flappyGame.js +2 -1
  36. package/examples/shorts/helloWorld.js +1 -1
  37. package/examples/shorts/maze.js +1 -1
  38. package/examples/shorts/music.js +106 -0
  39. package/examples/shorts/nineSlice.js +9 -9
  40. package/examples/shorts/parallax.js +71 -0
  41. package/examples/shorts/piano.js +9 -10
  42. package/examples/shorts/postProcess.js +25 -8
  43. package/examples/shorts/raycasting.js +2 -2
  44. package/examples/shorts/shapes.js +7 -15
  45. package/examples/shorts/slidingPuzzle.js +2 -2
  46. package/examples/shorts/song.mp3 +0 -0
  47. package/examples/shorts/starfield.js +5 -7
  48. package/examples/shorts/systemFont.js +1 -1
  49. package/examples/shorts/uiSystem.js +16 -8
  50. package/examples/starter/build.js +9 -8
  51. package/examples/starter/game.js +5 -2
  52. package/examples/starter/index.html +2 -2
  53. package/examples/stress/index.html +13 -8
  54. package/examples/style.css +19 -6
  55. package/examples/typescript/build.js +1 -1
  56. package/examples/typescript/game.js +2 -2
  57. package/examples/typescript/game.ts +5 -2
  58. package/examples/uiSystem/game.js +13 -12
  59. package/package.json +2 -2
  60. package/plugins/box2d.js +24 -97
  61. package/plugins/drawUtilities.js +29 -23
  62. package/plugins/newgrounds.js +6 -6
  63. package/plugins/pluginExport.js +1 -1
  64. package/plugins/postProcess.js +7 -0
  65. package/plugins/uiSystem.js +106 -82
  66. package/plugins/zzfxm.js +10 -10
  67. package/reference.md +90 -54
  68. package/src/engine.js +28 -23
  69. package/src/engineAudio.js +285 -110
  70. package/src/engineBuild.js +9 -9
  71. package/src/engineDebug.js +28 -28
  72. package/src/engineDraw.js +346 -202
  73. package/src/engineExport.js +28 -16
  74. package/src/engineInput.js +58 -68
  75. package/src/engineMedals.js +29 -29
  76. package/src/engineObject.js +28 -25
  77. package/src/engineParticles.js +67 -60
  78. package/src/engineRelease.js +1 -1
  79. package/src/engineSettings.js +70 -16
  80. package/src/engineTileLayer.js +34 -34
  81. package/src/engineUtilities.js +69 -62
  82. package/src/engineWebGL.js +467 -65
  83. /package/examples/shorts/{playSound.js → sound.js} +0 -0
package/plugins/box2d.js CHANGED
@@ -61,7 +61,7 @@ class Box2dObject extends EngineObject
61
61
  bodyDef.set_angle(-angle);
62
62
  this.body = box2d.world.CreateBody(bodyDef);
63
63
  this.body.object = this;
64
- this.outlineColor = BLACK;
64
+ this.lineColor = BLACK;
65
65
  }
66
66
 
67
67
  /** Destroy this object and it's physics body */
@@ -88,27 +88,27 @@ class Box2dObject extends EngineObject
88
88
  if (this.tileInfo)
89
89
  super.render();
90
90
  else
91
- this.drawFixtures(this.color, this.outlineColor, this.lineWidth, mainContext);
91
+ this.drawFixtures(this.color, this.lineColor, this.lineWidth);
92
92
  }
93
93
 
94
94
  /** Render debug info */
95
95
  renderDebugInfo()
96
96
  {
97
97
  const isAsleep = !this.getIsAwake();
98
- const isStatic = this.getBodyType() == box2d.bodyTypeStatic;
98
+ const isStatic = this.getBodyType() === box2d.bodyTypeStatic;
99
99
  const color = rgb(isAsleep?1:0, isAsleep?1:0, isStatic?1:0, .5);
100
100
  this.drawFixtures(color);
101
101
  }
102
102
 
103
103
  /** Draws all this object's fixtures
104
104
  * @param {Color} [color]
105
- * @param {Color} [outlineColor]
105
+ * @param {Color} [lineColor]
106
106
  * @param {number} [lineWidth]
107
107
  * @param {CanvasRenderingContext2D} [context] */
108
- drawFixtures(color=WHITE, outlineColor, lineWidth=.1, context)
108
+ drawFixtures(color=WHITE, lineColor, lineWidth=.1, context)
109
109
  {
110
110
  this.getFixtureList().forEach(fixture=>
111
- box2d.drawFixture(fixture, this.pos, this.angle, color, outlineColor, lineWidth, context));
111
+ box2d.drawFixture(fixture, this.pos, this.angle, color, lineColor, lineWidth, context));
112
112
  }
113
113
 
114
114
  ///////////////////////////////////////////////////////////////////////////////
@@ -1563,7 +1563,7 @@ class Box2dPlugin
1563
1563
  queryCallback.ReportFixture = function(fixturePointer)
1564
1564
  {
1565
1565
  const fixture = box2d.instance.wrapPointer(fixturePointer, box2d.instance.b2Fixture);
1566
- if (dynamicOnly && fixture.GetBody().GetType() != box2d.instance.b2_dynamicBody)
1566
+ if (dynamicOnly && fixture.GetBody().GetType() !== box2d.instance.b2_dynamicBody)
1567
1567
  return true; // continue getting results
1568
1568
  if (!fixture.TestPoint(box2d.vec2dTo(pos)))
1569
1569
  return true; // continue getting results
@@ -1589,10 +1589,10 @@ class Box2dPlugin
1589
1589
  * @param {Vector2} pos
1590
1590
  * @param {number} angle
1591
1591
  * @param {Color} [color]
1592
- * @param {Color} [outlineColor]
1592
+ * @param {Color} [lineColor]
1593
1593
  * @param {number} [lineWidth]
1594
1594
  * @param {CanvasRenderingContext2D} [context] */
1595
- drawFixture(fixture, pos, angle, color=WHITE, outlineColor=BLACK, lineWidth=.1, context=drawContext)
1595
+ drawFixture(fixture, pos, angle, color=WHITE, lineColor=BLACK, lineWidth=.1, context)
1596
1596
  {
1597
1597
  const shape = box2d.castObjectType(fixture.GetShape());
1598
1598
  switch (shape.GetType())
@@ -1602,101 +1602,25 @@ class Box2dPlugin
1602
1602
  let points = [];
1603
1603
  for (let i=shape.GetVertexCount(); i--;)
1604
1604
  points.push(box2d.vec2From(shape.GetVertex(i)));
1605
- box2d.drawPoly(pos, angle, points, color, outlineColor, lineWidth, context);
1605
+ drawPoly(points, color, lineWidth, lineColor, pos, angle);
1606
1606
  break;
1607
1607
  }
1608
1608
  case box2d.instance.b2Shape.e_circle:
1609
1609
  {
1610
1610
  const radius = shape.get_m_radius();
1611
- box2d.drawCircle(pos, radius, color, outlineColor, lineWidth, context);
1611
+ drawCircle(pos, radius, color, lineWidth, lineColor);
1612
1612
  break;
1613
1613
  }
1614
1614
  case box2d.instance.b2Shape.e_edge:
1615
1615
  {
1616
1616
  const v1 = box2d.vec2From(shape.get_m_vertex1());
1617
1617
  const v2 = box2d.vec2From(shape.get_m_vertex2());
1618
- box2d.drawLine(pos, angle, v1, v2, color, lineWidth, context);
1618
+ drawLine(v1, v2, lineWidth, lineColor, pos, angle);
1619
1619
  break;
1620
1620
  }
1621
1621
  }
1622
1622
  }
1623
1623
 
1624
- /** draws a circle
1625
- * @param {Vector2} pos
1626
- * @param {number} radius
1627
- * @param {Color} [color]
1628
- * @param {Color} [outlineColor]
1629
- * @param {number} [lineWidth]
1630
- * @param {CanvasRenderingContext2D} [context] */
1631
- drawCircle(pos, radius, color=WHITE, outlineColor=BLACK, lineWidth=.1, context=drawContext)
1632
- {
1633
- drawCanvas2D(pos, vec2(1), 0, 0, context=>
1634
- {
1635
- context.beginPath();
1636
- context.arc(0, 0, radius, 0, 9);
1637
- box2d.drawFillStroke(color, outlineColor, lineWidth, context);
1638
- }, 0, context);
1639
- }
1640
-
1641
- /** draws a polygon
1642
- * @param {Vector2} pos
1643
- * @param {number} angle
1644
- * @param {Array<Vector2>} points
1645
- * @param {Color} [color]
1646
- * @param {Color} [outlineColor]
1647
- * @param {number} [lineWidth]
1648
- * @param {CanvasRenderingContext2D} [context] */
1649
- drawPoly(pos, angle, points, color=WHITE, outlineColor=BLACK, lineWidth=.1, context=drawContext)
1650
- {
1651
- drawCanvas2D(pos, vec2(1), angle, 0, context=>
1652
- {
1653
- context.beginPath();
1654
- points.forEach(p=>context.lineTo(p.x, p.y));
1655
- context.closePath();
1656
- box2d.drawFillStroke(color, outlineColor, lineWidth, context);
1657
- }, 0, context);
1658
- }
1659
-
1660
- /** draws a line
1661
- * @param {Vector2} pos
1662
- * @param {number} angle
1663
- * @param {Vector2} posA
1664
- * @param {Vector2} posB
1665
- * @param {Color} [color]
1666
- * @param {number} [lineWidth]
1667
- * @param {CanvasRenderingContext2D} [context] */
1668
- drawLine(pos, angle, posA, posB, color=WHITE, lineWidth=.1, context=drawContext)
1669
- {
1670
- drawCanvas2D(pos, vec2(1), angle, 0, context=>
1671
- {
1672
- context.beginPath();
1673
- context.lineTo(posA.x, posA.y);
1674
- context.lineTo(posB.x, posB.y);
1675
- box2d.drawFillStroke(0, color, lineWidth, context);
1676
- }, 0, context);
1677
- }
1678
-
1679
- /** performs a fill or stroke as a helper to the other draw functions
1680
- * @param {Color} [color]
1681
- * @param {Color} [outlineColor]
1682
- * @param {number} [lineWidth]
1683
- * @param {CanvasRenderingContext2D} [context] */
1684
- drawFillStroke(color=WHITE, outlineColor=BLACK, lineWidth=.1, context=drawContext)
1685
- {
1686
- if (color)
1687
- {
1688
- context.fillStyle = color.toString();
1689
- context.fill();
1690
- }
1691
- if (outlineColor && lineWidth)
1692
- {
1693
- context.lineWidth = lineWidth;
1694
- context.lineJoin = context.lineCap = 'round';
1695
- context.strokeStyle = outlineColor.toString();
1696
- context.stroke();
1697
- }
1698
- }
1699
-
1700
1624
  ///////////////////////////////////////////////////////////////////////////////
1701
1625
  // helper functions
1702
1626
 
@@ -1770,7 +1694,9 @@ class Box2dPlugin
1770
1694
  }
1771
1695
 
1772
1696
  ///////////////////////////////////////////////////////////////////////////////
1773
- /** Box2d Init - Call with await before starting LittleJS to init box2d
1697
+ /** Box2d Init - Call with await to init box2d
1698
+ * @example
1699
+ * await box2dInit();
1774
1700
  * @return {Promise<Box2dPlugin>}
1775
1701
  * @memberof Box2D */
1776
1702
  async function box2dInit()
@@ -1797,6 +1723,7 @@ async function box2dInit()
1797
1723
  function setupDebugDraw()
1798
1724
  {
1799
1725
  // setup debug draw
1726
+ const debugLineWidth = .1;
1800
1727
  const debugDraw = new box2d.instance.JSDraw();
1801
1728
  const box2dColor = (c)=> new Color(c.get_r(), c.get_g(), c.get_b());
1802
1729
  const box2dColorPointer = (c)=>
@@ -1814,33 +1741,33 @@ async function box2dInit()
1814
1741
  color = getDebugColor(color);
1815
1742
  point1 = box2d.vec2FromPointer(point1);
1816
1743
  point2 = box2d.vec2FromPointer(point2);
1817
- box2d.drawLine(vec2(), 0, point1, point2, color, undefined, overlayContext);
1744
+ drawLine(point1, point2, debugLineWidth, color, vec2(), 0, false, false, overlayContext);
1818
1745
  };
1819
1746
  debugDraw.DrawPolygon = function(vertices, vertexCount, color)
1820
1747
  {
1821
1748
  color = getDebugColor(color);
1822
1749
  const points = getPointsList(vertices, vertexCount);
1823
- box2d.drawPoly(vec2(), 0, points, undefined, color, undefined, overlayContext);
1750
+ drawPoly(points, CLEAR_WHITE, debugLineWidth, color, vec2(), 0, false, false, overlayContext);
1824
1751
  };
1825
1752
  debugDraw.DrawSolidPolygon = function(vertices, vertexCount, color)
1826
1753
  {
1827
1754
  color = getDebugColor(color);
1828
1755
  const points = getPointsList(vertices, vertexCount);
1829
- box2d.drawPoly(vec2(), 0, points, color, color, undefined, overlayContext);
1756
+ drawPoly(points, color, 0, color, vec2(), 0, false, false, overlayContext);
1830
1757
  };
1831
1758
  debugDraw.DrawCircle = function(center, radius, color)
1832
1759
  {
1833
1760
  color = getDebugColor(color);
1834
1761
  center = box2d.vec2FromPointer(center);
1835
- box2d.drawCircle(center, radius, undefined, color, undefined, overlayContext);
1762
+ drawCircle(center, radius, CLEAR_WHITE, debugLineWidth, color, false, false, overlayContext);
1836
1763
  };
1837
1764
  debugDraw.DrawSolidCircle = function(center, radius, axis, color)
1838
1765
  {
1839
1766
  color = getDebugColor(color);
1840
1767
  center = box2d.vec2FromPointer(center);
1841
1768
  axis = box2d.vec2FromPointer(axis).scale(radius);
1842
- box2d.drawCircle(center, radius, color, color, undefined, overlayContext);
1843
- box2d.drawLine(center, 0, vec2(), axis, color, undefined, overlayContext);
1769
+ drawCircle(center, radius, color, debugLineWidth, color, false, false, overlayContext);
1770
+ drawLine(vec2(), axis, debugLineWidth, color, center, 0, false, false, overlayContext);
1844
1771
  };
1845
1772
  debugDraw.DrawTransform = function(transform)
1846
1773
  {
@@ -1849,8 +1776,8 @@ async function box2dInit()
1849
1776
  const angle = -transform.get_q().GetAngle();
1850
1777
  const p1 = vec2(1,0), c1 = rgb(.75,0,0,.8);
1851
1778
  const p2 = vec2(0,1), c2 = rgb(0,.75,0,.8);
1852
- box2d.drawLine(pos, angle, vec2(), p1, c1, undefined, overlayContext);
1853
- box2d.drawLine(pos, angle, vec2(), p2, c2, undefined, overlayContext);
1779
+ drawLine(vec2(), p1, debugLineWidth, c1, pos, angle, false, false, overlayContext);
1780
+ drawLine(vec2(), p2, debugLineWidth, c2, pos, angle, false, false, overlayContext);
1854
1781
  }
1855
1782
 
1856
1783
  debugDraw.AppendFlags(box2d.instance.b2Draw.e_shapeBit);
@@ -16,14 +16,15 @@
16
16
  * @param {TileInfo} startTile - Starting tile for the nine-slice pattern
17
17
  * @param {number} [borderSize] - Width of the border sections
18
18
  * @param {number} [extraSpace] - Extra spacing adjustment
19
+ * @param {number} [angle] - Angle to rotate by
19
20
  * @memberof DrawUtilities */
20
- function drawNineSliceScreen(pos, size, startTile, borderSize=32, extraSpace=1)
21
+ function drawNineSliceScreen(pos, size, startTile, borderSize=32, extraSpace=2, angle=0)
21
22
  {
22
- drawNineSlice(pos, size, startTile, WHITE, borderSize, BLACK, extraSpace, false, true, overlayContext);
23
+ drawNineSlice(pos, size, startTile, WHITE, borderSize, BLACK, extraSpace, angle, false, true, overlayContext);
23
24
  }
24
25
 
25
26
  /** Draw a scalable nine-slice UI element in world space
26
- * This function can apply color and additive color if webgl is enabled
27
+ * This function can apply color and additive color if WebGL is enabled
27
28
  * @param {Vector2} pos - World space position
28
29
  * @param {Vector2} size - World space size
29
30
  * @param {TileInfo} startTile - Starting tile for the nine-slice pattern
@@ -31,11 +32,12 @@ function drawNineSliceScreen(pos, size, startTile, borderSize=32, extraSpace=1)
31
32
  * @param {number} [borderSize] - Width of the border sections
32
33
  * @param {Color} [additiveColor] - Additive color
33
34
  * @param {number} [extraSpace] - Extra spacing adjustment
35
+ * @param {number} [angle] - Angle to rotate by
34
36
  * @param {boolean} [useWebGL=glEnable] - Use WebGL for rendering
35
37
  * @param {boolean} [screenSpace] - Use screen space coordinates
36
38
  * @param {CanvasRenderingContext2D} [context] - Canvas context to use
37
39
  * @memberof DrawUtilities */
38
- function drawNineSlice(pos, size, startTile, color, borderSize=1, additiveColor, extraSpace=.01, useWebGL=glEnable, screenSpace, context)
40
+ function drawNineSlice(pos, size, startTile, color, borderSize=1, additiveColor, extraSpace=.05, angle=0, useWebGL=glEnable, screenSpace, context)
39
41
  {
40
42
  // setup nine slice tiles
41
43
  const centerTile = startTile.offset(startTile.size);
@@ -43,26 +45,27 @@ function drawNineSlice(pos, size, startTile, color, borderSize=1, additiveColor,
43
45
  const cornerSize = vec2(borderSize);
44
46
  const cornerOffset = size.scale(.5).subtract(cornerSize.scale(.5));
45
47
  const flip = screenSpace ? -1 : 1;
48
+ const rotateAngle = screenSpace ? -angle : angle;
46
49
 
47
50
  // center
48
- drawTile(pos, centerSize, centerTile, color, 0, false, additiveColor, useWebGL, screenSpace, context);
49
- for(let i=4; i--;)
51
+ drawTile(pos, centerSize, centerTile, color, angle, false, additiveColor, useWebGL, screenSpace, context);
52
+ for (let i=4; i--;)
50
53
  {
51
54
  // sides
52
55
  const horizontal = i%2;
53
- const sidePos = cornerOffset.multiply(vec2(horizontal?i==1?1:-1:0, horizontal?0:i?-1:1));
56
+ const sidePos = cornerOffset.multiply(vec2(horizontal?i===1?1:-1:0, horizontal?0:i?-1:1));
54
57
  const sideSize = vec2(horizontal ? borderSize : centerSize.x, horizontal ? centerSize.y : borderSize);
55
- const sideTile = centerTile.offset(startTile.size.multiply(vec2(i==1?1:i==3?-1:0,i==0?-flip:i==2?flip:0)))
56
- drawTile(pos.add(sidePos), sideSize, sideTile, color, 0, false, additiveColor, useWebGL, screenSpace, context);
58
+ const sideTile = centerTile.offset(startTile.size.multiply(vec2(i===1?1:i===3?-1:0,i===0?-flip:i===2?flip:0)))
59
+ drawTile(pos.add(sidePos.rotate(rotateAngle)), sideSize, sideTile, color, angle, false, additiveColor, useWebGL, screenSpace, context);
57
60
  }
58
- for(let i=4; i--;)
61
+ for (let i=4; i--;)
59
62
  {
60
63
  // corners
61
64
  const flipX = i>1;
62
65
  const flipY = i && i<3;
63
66
  const cornerPos = cornerOffset.multiply(vec2(flipX?-1:1, flipY?-1:1));
64
67
  const cornerTile = centerTile.offset(startTile.size.multiply(vec2(flipX?-1:1,flipY?flip:-flip)));
65
- drawTile(pos.add(cornerPos), cornerSize, cornerTile, color, 0, false, additiveColor, useWebGL, screenSpace, context);
68
+ drawTile(pos.add(cornerPos.rotate(rotateAngle)), cornerSize, cornerTile, color, angle, false, additiveColor, useWebGL, screenSpace, context);
66
69
  }
67
70
  }
68
71
 
@@ -73,14 +76,15 @@ function drawNineSlice(pos, size, startTile, color, borderSize=1, additiveColor,
73
76
  * @param {TileInfo} startTile - Starting tile for the three-slice pattern
74
77
  * @param {number} [borderSize] - Width of the border sections
75
78
  * @param {number} [extraSpace] - Extra spacing adjustment
79
+ * @param {number} [angle] - Angle to rotate by
76
80
  * @memberof DrawUtilities */
77
- function drawThreeSliceScreen(pos, size, startTile, borderSize=32, extraSpace=1)
81
+ function drawThreeSliceScreen(pos, size, startTile, borderSize=32, extraSpace=2, angle=0)
78
82
  {
79
- drawThreeSlice(pos, size, startTile, WHITE, borderSize, BLACK, extraSpace, false, true, overlayContext);
83
+ drawThreeSlice(pos, size, startTile, WHITE, borderSize, BLACK, extraSpace, angle, false, true, overlayContext);
80
84
  }
81
85
 
82
86
  /** Draw a scalable three-slice UI element in world space
83
- * This function can apply color and additive color if webgl is enabled
87
+ * This function can apply color and additive color if WebGL is enabled
84
88
  * @param {Vector2} pos - World space position
85
89
  * @param {Vector2} size - World space size
86
90
  * @param {TileInfo} startTile - Starting tile for the three-slice pattern
@@ -88,11 +92,12 @@ function drawThreeSliceScreen(pos, size, startTile, borderSize=32, extraSpace=1)
88
92
  * @param {number} [borderSize] - Width of the border sections
89
93
  * @param {Color} [additiveColor] - Additive color
90
94
  * @param {number} [extraSpace] - Extra spacing adjustment
95
+ * @param {number} [angle] - Angle to rotate by
91
96
  * @param {boolean} [useWebGL=glEnable] - Use WebGL for rendering
92
97
  * @param {boolean} [screenSpace] - Use screen space coordinates
93
98
  * @param {CanvasRenderingContext2D} [context] - Canvas context to use
94
99
  * @memberof DrawUtilities */
95
- function drawThreeSlice(pos, size, startTile, color, borderSize=1, additiveColor, extraSpace=.01, useWebGL=glEnable, screenSpace, context)
100
+ function drawThreeSlice(pos, size, startTile, color, borderSize=1, additiveColor, extraSpace=.05, angle=0, useWebGL=glEnable, screenSpace, context)
96
101
  {
97
102
  // setup three slice tiles
98
103
  const cornerTile = startTile.frame(0);
@@ -102,25 +107,26 @@ function drawThreeSlice(pos, size, startTile, color, borderSize=1, additiveColor
102
107
  const cornerSize = vec2(borderSize);
103
108
  const cornerOffset = size.scale(.5).subtract(cornerSize.scale(.5));
104
109
  const flip = screenSpace ? -1 : 1;
110
+ const rotateAngle = screenSpace ? -angle : angle;
105
111
 
106
112
  // center
107
- drawTile(pos, centerSize, centerTile, color, 0, false, additiveColor, useWebGL, screenSpace, context);
108
- for(let i=4; i--;)
113
+ drawTile(pos, centerSize, centerTile, color, angle, false, additiveColor, useWebGL, screenSpace, context);
114
+ for (let i=4; i--;)
109
115
  {
110
116
  // sides
111
- const angle = i*PI/2;
117
+ const a = angle + i*PI/2;
112
118
  const horizontal = i%2;
113
- const sidePos = cornerOffset.multiply(vec2(horizontal?i==1?1:-1:0, horizontal?0:i?-flip:flip));
119
+ const sidePos = cornerOffset.multiply(vec2(horizontal?i===1?1:-1:0, horizontal?0:i?-flip:flip));
114
120
  const sideSize = vec2(horizontal ? centerSize.y : centerSize.x, borderSize);
115
- drawTile(pos.add(sidePos), sideSize, sideTile, color, angle, false, additiveColor, useWebGL, screenSpace, context);
121
+ drawTile(pos.add(sidePos.rotate(rotateAngle)), sideSize, sideTile, color, a, false, additiveColor, useWebGL, screenSpace, context);
116
122
  }
117
- for(let i=4; i--;)
123
+ for (let i=4; i--;)
118
124
  {
119
125
  // corners
120
- const angle = i*PI/2;
126
+ const a = angle + i*PI/2;
121
127
  const flipX = !i || i>2;
122
128
  const flipY = i>1;
123
129
  const cornerPos = cornerOffset.multiply(vec2(flipX?-1:1, flipY?-flip:flip));
124
- drawTile(pos.add(cornerPos), cornerSize, cornerTile, color, angle, false, additiveColor, useWebGL, screenSpace, context);
130
+ drawTile(pos.add(cornerPos.rotate(rotateAngle)), cornerSize, cornerTile, color, a, false, additiveColor, useWebGL, screenSpace, context);
125
131
  }
126
132
  }
@@ -23,11 +23,11 @@ let newgrounds;
23
23
  class NewgroundsMedal extends Medal
24
24
  {
25
25
  /** Create a newgrounds medal object and adds it to the list of medals
26
- * @param {Number} id - The unique identifier of the medal
27
- * @param {String} name - Name of the medal
28
- * @param {String} [description] - Description of the medal
29
- * @param {String} [icon] - Icon for the medal
30
- * @param {String} [src] - Image location for the medal
26
+ * @param {number} id - The unique identifier of the medal
27
+ * @param {string} name - Name of the medal
28
+ * @param {string} [description] - Description of the medal
29
+ * @param {string} [icon] - Icon for the medal
30
+ * @param {string} [src] - Image location for the medal
31
31
  */
32
32
  constructor(id, name, description, icon, src)
33
33
  { super(id, name, description, icon, src); }
@@ -119,7 +119,7 @@ class NewgroundsPlugin
119
119
  * @param {number} id - The scoreboard id
120
120
  * @param {string} [user] - A user's id or name
121
121
  * @param {number} [social] - If true, only social scores will be loaded
122
- * @param {number} [skip] - Number of scores to skip before start
122
+ * @param {number} [skip] - Number of scores to skip over
123
123
  * @param {number} [limit] - Number of scores to include in the list
124
124
  * @return {Object} - The response JSON object
125
125
  */
@@ -53,4 +53,4 @@ export
53
53
  drawNineSliceScreen,
54
54
  drawThreeSlice,
55
55
  drawThreeSliceScreen,
56
- };
56
+ }
@@ -32,6 +32,13 @@ class PostProcessPlugin
32
32
  postProcess = this;
33
33
 
34
34
  if (headlessMode) return;
35
+
36
+ if (!glEnable)
37
+ {
38
+ console.warn('PostProcessPlugin: WebGL not enabled!');
39
+ return;
40
+ }
41
+
35
42
  if (!shaderCode) // default shader pass through
36
43
  shaderCode = 'void mainImage(out vec4 c,vec2 p){c=texture(iChannel0,p/iResolution.xy);}';
37
44