littlejsengine 1.11.10 → 1.11.13

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.
@@ -1030,6 +1030,7 @@ let fontDefault = 'arial';
1030
1030
  let showSplashScreen = false;
1031
1031
 
1032
1032
  /** Disables all rendering, audio, and input for servers
1033
+ * - Must be set before startup to take effect
1033
1034
  * @type {boolean}
1034
1035
  * @default
1035
1036
  * @memberof Settings */
@@ -1039,12 +1040,14 @@ let headlessMode = false;
1039
1040
  // WebGL settings
1040
1041
 
1041
1042
  /** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
1043
+ * - Must be set before startup to take effect
1042
1044
  * @type {boolean}
1043
1045
  * @default
1044
1046
  * @memberof Settings */
1045
1047
  let glEnable = true;
1046
1048
 
1047
1049
  /** Fixes slow rendering in some browsers by not compositing the WebGL canvas
1050
+ * - Must be set before startup to take effect
1048
1051
  * @type {boolean}
1049
1052
  * @default
1050
1053
  * @memberof Settings */
@@ -1145,6 +1148,7 @@ let inputWASDEmulateDirection = true;
1145
1148
 
1146
1149
  /** True if touch input is enabled for mobile devices
1147
1150
  * - Touch events will be routed to mouse events
1151
+ * - Must be set before startup to take effect
1148
1152
  * @type {boolean}
1149
1153
  * @default
1150
1154
  * @memberof Settings */
@@ -1152,7 +1156,7 @@ let touchInputEnable = true;
1152
1156
 
1153
1157
  /** True if touch gamepad should appear on mobile devices
1154
1158
  * - Supports left analog stick, 4 face buttons and start button (button 9)
1155
- * - Must be set by end of gameInit to be activated
1159
+ * - Must be set before startup to take effect
1156
1160
  * @type {boolean}
1157
1161
  * @default
1158
1162
  * @memberof Settings */
@@ -1230,12 +1234,6 @@ let medalDisplaySlideTime = .5;
1230
1234
  * @memberof Settings */
1231
1235
  let medalDisplaySize = vec2(640, 80);
1232
1236
 
1233
- /** Size of icon in medal display
1234
- * @type {number}
1235
- * @default
1236
- * @memberof Settings */
1237
- let medalDisplayIconSize = 50;
1238
-
1239
1237
  /** Set to stop medals from being unlockable (like if cheats are enabled)
1240
1238
  * @type {boolean}
1241
1239
  * @default
@@ -1440,11 +1438,6 @@ function setMedalDisplaySlideTime(time) { medalDisplaySlideTime = time; }
1440
1438
  * @memberof Settings */
1441
1439
  function setMedalDisplaySize(size) { medalDisplaySize = size; }
1442
1440
 
1443
- /** Set size of icon in medal display
1444
- * @param {number} size
1445
- * @memberof Settings */
1446
- function setMedalDisplayIconSize(size) { medalDisplayIconSize = size; }
1447
-
1448
1441
  /** Set to stop medals from being unlockable
1449
1442
  * @param {boolean} preventUnlock
1450
1443
  * @memberof Settings */
@@ -1634,7 +1627,8 @@ class EngineObject
1634
1627
  if (this.groundObject)
1635
1628
  {
1636
1629
  // apply friction in local space of ground object
1637
- const groundSpeed = this.groundObject.velocity ? this.groundObject.velocity.x : 0;
1630
+ const groundSpeed = this.groundObject != this && this.groundObject.velocity ?
1631
+ this.groundObject.velocity.x : 0;
1638
1632
  this.velocity.x = groundSpeed + (this.velocity.x - groundSpeed) * this.friction;
1639
1633
  this.groundObject = undefined;
1640
1634
  //debugOverlay && debugPhysics && debugPoint(this.pos.subtract(vec2(0,this.size.y/2)), '#0f0');
@@ -1761,6 +1755,7 @@ class EngineObject
1761
1755
  this.pos.y = (oldPos.y-this.size.y/2|0)+this.size.y/2+epsilon;
1762
1756
 
1763
1757
  // set ground object to self for tile collision
1758
+ // TODO: rework system so tile collision is its own object
1764
1759
  this.groundObject = this;
1765
1760
  }
1766
1761
  else
@@ -2640,10 +2635,16 @@ let mouseWheel = 0;
2640
2635
  * @memberof Input */
2641
2636
  let isUsingGamepad = false;
2642
2637
 
2643
- /** Prevents input continuing to the default browser handling (false by default)
2638
+ /** Prevents input continuing to the default browser handling (true by default)
2644
2639
  * @type {boolean}
2645
2640
  * @memberof Input */
2646
- let preventDefaultInput = false;
2641
+ let inputPreventDefault = true;
2642
+
2643
+ /** Prevents input continuing to the default browser handling
2644
+ * This is useful to disable for html menus so the browser can handle input normally
2645
+ * @param {boolean} preventDefault
2646
+ * @memberof Input */
2647
+ function setInputPreventDefault(preventDefault) { inputPreventDefault = preventDefault; }
2647
2648
 
2648
2649
  /** Returns true if gamepad button is down
2649
2650
  * @param {number} button
@@ -2723,7 +2724,6 @@ function inputInit()
2723
2724
  if (inputWASDEmulateDirection)
2724
2725
  inputData[0][remapKey(e.code)] = 3;
2725
2726
  }
2726
- preventDefaultInput && e.preventDefault();
2727
2727
  }
2728
2728
 
2729
2729
  onkeyup = (e)=>
@@ -2753,7 +2753,7 @@ function inputInit()
2753
2753
  isUsingGamepad = false;
2754
2754
  inputData[0][e.button] = 3;
2755
2755
  mousePosScreen = mouseEventToScreen(e);
2756
- e.button && e.preventDefault();
2756
+ inputPreventDefault && e.button && e.preventDefault();
2757
2757
  }
2758
2758
  onmouseup = (e)=> inputData[0][e.button] = inputData[0][e.button] & 2 | 4;
2759
2759
  onmousemove = (e)=> mousePosScreen = mouseEventToScreen(e);
@@ -2937,7 +2937,7 @@ function touchInputInit()
2937
2937
  wasTouching = touching;
2938
2938
 
2939
2939
  // prevent default handling like copy and magnifier lens
2940
- if (document.hasFocus()) // allow document to get focus
2940
+ if (inputPreventDefault && document.hasFocus()) // allow document to get focus
2941
2941
  e.preventDefault();
2942
2942
 
2943
2943
  // must return true so the document will get focus
@@ -4513,8 +4513,9 @@ class Medal
4513
4513
  {
4514
4514
  const context = overlayContext;
4515
4515
  const width = min(medalDisplaySize.x, mainCanvas.width);
4516
+ const height = medalDisplaySize.y;
4516
4517
  const x = overlayCanvas.width - width;
4517
- const y = -medalDisplaySize.y*hidePercent;
4518
+ const y = -height*hidePercent;
4518
4519
 
4519
4520
  // draw containing rect and clip to that region
4520
4521
  context.save();
@@ -4522,25 +4523,34 @@ class Medal
4522
4523
  context.fillStyle = new Color(.9,.9,.9).toString();
4523
4524
  context.strokeStyle = new Color(0,0,0).toString();
4524
4525
  context.lineWidth = 3;
4525
- context.rect(x, y, width, medalDisplaySize.y);
4526
+ context.rect(x, y, width, height);
4526
4527
  context.fill();
4527
4528
  context.stroke();
4528
4529
  context.clip();
4529
4530
 
4530
- // draw the icon and text
4531
- this.renderIcon(vec2(x+15+medalDisplayIconSize/2, y+medalDisplaySize.y/2));
4532
- const pos = vec2(x+medalDisplayIconSize+30, y+28);
4533
- drawTextScreen(this.name, pos, 38, new Color(0,0,0), 0, undefined, 'left');
4534
- pos.y += 32;
4535
- drawTextScreen(this.description, pos, 24, new Color(0,0,0), 0, undefined, 'left');
4531
+ // draw the icon
4532
+ const gap = vec2(.1, .05).scale(height);
4533
+ const medalDisplayIconSize = height - 2*gap.x;
4534
+ this.renderIcon(vec2(x + gap.x + medalDisplayIconSize/2, y + height/2), medalDisplayIconSize);
4535
+
4536
+ // draw the name
4537
+ const nameSize = height*.5;
4538
+ const descriptionSize = height*.3;
4539
+ const pos = vec2(x + medalDisplayIconSize + 2*gap.x, y + gap.y*2 + nameSize/2);
4540
+ const textWidth = width - medalDisplayIconSize - 3*gap.x;
4541
+ drawTextScreen(this.name, pos, nameSize, new Color(0,0,0), 0, undefined, 'left', undefined, textWidth);
4542
+
4543
+ // draw the description
4544
+ pos.y = y + height - gap.y*2 - descriptionSize/2;
4545
+ drawTextScreen(this.description, pos, descriptionSize, new Color(0,0,0), 0, undefined, 'left', undefined, textWidth);
4536
4546
  context.restore();
4537
4547
  }
4538
4548
 
4539
4549
  /** Render the icon for a medal
4540
4550
  * @param {Vector2} pos - Screen space position
4541
- * @param {Number} [size=medalDisplayIconSize] - Screen space size
4551
+ * @param {Number} size - Screen space size
4542
4552
  */
4543
- renderIcon(pos, size=medalDisplayIconSize)
4553
+ renderIcon(pos, size)
4544
4554
  {
4545
4555
  // draw the image or icon
4546
4556
  if (this.image)
@@ -4888,7 +4898,7 @@ const engineName = 'LittleJS';
4888
4898
  * @type {string}
4889
4899
  * @default
4890
4900
  * @memberof Engine */
4891
- const engineVersion = '1.11.10';
4901
+ const engineVersion = '1.11.13';
4892
4902
 
4893
4903
  /** Frames per second to update
4894
4904
  * @type {number}
@@ -14,6 +14,16 @@ setShowSplashScreen(true);
14
14
  // sound effects
15
15
  const sound_click = new Sound([1,.5]);
16
16
 
17
+ ///////////////////////////////////////////////////////////////////////////////
18
+
19
+ // html menu system
20
+ const getMenuVisible = ()=> menu.style.visibility != 'hidden';
21
+ function setMenuVisible(visible)
22
+ {
23
+ menu.style.visibility = visible ? 'visible' : 'hidden';
24
+ setInputPreventDefault(!visible); // don't prevent default when menu is visible
25
+ }
26
+
17
27
  ///////////////////////////////////////////////////////////////////////////////
18
28
  function gameInit()
19
29
  {
@@ -38,7 +48,7 @@ function gameUpdatePost()
38
48
 
39
49
  // toggle menu visibility
40
50
  if (keyWasPressed('KeyM'))
41
- setMenuVisible(!menuVisible);
51
+ setMenuVisible(true);
42
52
  }
43
53
 
44
54
  ///////////////////////////////////////////////////////////////////////////////
@@ -24,6 +24,7 @@
24
24
  flex-direction: column;
25
25
  border: 3px solid black;
26
26
  background-color: white;
27
+ visibility: hidden;
27
28
  }
28
29
  </style>
29
30
 
@@ -40,16 +41,6 @@ This is an example menu using html elements.
40
41
  <button onclick="setMenuVisible(false)">Exit Menu</button>
41
42
  </div>
42
43
  </div>
43
- <script>
44
-
45
- // html menu system
46
- const getMenuVisible =()=> menu.style.visibility != 'hidden';
47
- const setMenuVisible =(visible)=> menu.style.visibility = visible ? '' : 'hidden';
48
-
49
- // hide menu at start
50
- setMenuVisible(false);
51
-
52
- </script>
53
44
 
54
45
  <!-- Add your game scripts here -->
55
46
  <script src=../../dist/littlejs.js?1117></script>
@@ -0,0 +1,2 @@
1
+ <!DOCTYPE html><head><title>Little JS Starter Project</title></head><body><script>const h=Math.PI;function aa(t,i=1){return(t%i+i)%i}function k(t,i=0,e=1){return t<i?i:e<t?e:t}function r(t,i,e){return(e-=i)?k((t-i)/e):0}function ba(t,i,e,a=u()){return 2*Math.abs(t.x-e.x)<i.x+a.x&&2*Math.abs(t.y-e.y)<i.y+a.y}function ha(t=ia){return.5*(1-Math.cos(2*t*h))}function v(t=1,i=0){return i+Math.random()*(t-i)}function ja(t=1){return ma(new w,v(2*h),t)}function na(t=1){return 0<t?ja(t*v(0/t,1)**.5):new w}function oa(t=new x,i=new x(0,0,0,1),e=!1){return e?t.la(i,v()):new x(v(t.r,i.r),v(t.j,i.j),v(t.b,i.b),v(t.a,i.a))}function u(t=0,i){return"number"==typeof t?new w(t,null==i?t:i):new w(t.x,t.y)}function ma(t,i=0,e=1){return t.x=e*Math.sin(i),t.y=e*Math.cos(i),t}function pa(t){return t.x**2+t.y**2}function qa(t){var i=t.length();return 1<i?t.scale(1/i):t}function ra(t,i){return 0<=t.x&&0<=t.y&&t.x<i.x&&t.y<i.y}class w{constructor(t=0,i=0){this.x=t,this.y=i}set(t=0,i=0){return this.x=t,this.y=i,this}v(){return new w(this.x,this.y)}add(t){return new w(this.x+t.x,this.y+t.y)}u(t){return new w(this.x-t.x,this.y-t.y)}multiply(t){return new w(this.x*t.x,this.y*t.y)}U(t){return new w(this.x/t.x,this.y/t.y)}scale(t){return new w(this.x*t,this.y*t)}length(){return pa(this)**.5}normalize(t=1){var i=this.length();return i?this.scale(t/i):new w(0,t)}angle(){return Math.atan2(this.x,this.y)}rotate(t){var i=Math.cos(-t);return t=Math.sin(-t),new w(this.x*i-this.y*t,this.x*t+this.y*i)}setDirection(t,i=1){return u((t=aa(t,4))%2?t-1?-i:i:0,t%2?0:t?-i:i)}direction(){return Math.abs(this.x)>Math.abs(this.y)?this.x<0?3:1:this.y<0?2:0}floor(){return new w(Math.floor(this.x),Math.floor(this.y))}la(t,i){return this.add(t.u(this).scale(k(i)))}toString(){}}function y(t=0,i=0,e=1,a=1){var s=new x,h=(t=aa(t,1),i=k(i),e=k(e),(t,i,e)=>6*(e=aa(e,1))<1?t+6*(i-t)*e:2*e<1?i:3*e<2?t+(i-t)*(4-6*e):t);return s.r=h(e=2*e-(i=e<.5?e*(1+i):e+i-e*i),i,t+1/3),s.j=h(e,i,t),s.b=h(e,i,t-1/3),s.a=a,s}function sa(t){return(255*k(t.r)|0)+(255*k(t.j)<<8)+(255*k(t.b)<<16)+(255*k(t.a)<<24)}class x{constructor(t=1,i=1,e=1,a=1){this.r=t,this.j=i,this.b=e,this.a=a}set(t=1,i=1,e=1,a=1){return this.r=t,this.j=i,this.b=e,this.a=a,this}v(){return new x(this.r,this.j,this.b,this.a)}add(t){return new x(this.r+t.r,this.j+t.j,this.b+t.b,this.a+t.a)}u(t){return new x(this.r-t.r,this.j-t.j,this.b-t.b,this.a-t.a)}multiply(t){return new x(this.r*t.r,this.j*t.j,this.b*t.b,this.a*t.a)}U(t){return new x(this.r/t.r,this.j/t.j,this.b/t.b,this.a/t.a)}scale(t,i=t){return new x(this.r*t,this.j*t,this.b*t,this.a*i)}la(t,i){return this.add(t.u(this).scale(k(i)))}toString(t=!0){var i=t=>((t=255*k(t)|0)<16?"0":"")+t.toString(16);return"#"+i(this.r)+i(this.j)+i(this.b)+(t?i(this.a):"")}}let A=u(),B=32,ta=u(1920,1080),ua=u(),va=!1,za=u(16),Aa=0,Ba=0,Ca=u(640,80);function Da(t){var i,e=t.parent;e&&(i=e.o?-1:1,t.i=t.ya.multiply(u(i,1)).rotate(e.angle).add(e.i),t.angle=i*t.xa+e.angle);for(const a of t.children)Da(a)}function Ea(t){if(!t.A){t.A=1,t.parent&&t.parent.removeChild(t);for(const i of t.children)Ea(i,i.parent=0)}}class Fa{constructor(t=u(),i=u(1),e,a=0,s=new x,h=0){this.i=t.v(),this.size=i,this.ua=void 0,this.l=e,this.angle=a,this.color=s,this.sa=void 0,this.o=!1,this.J=this.D=this.h=1,this.s=0,this.W=.8,this.N=1,this.P=h,this.g=u(),this.R=0,this.ra=ia,this.children=[],this.ba=!0,this.parent=this.m=void 0,this.ya=u(),this.xa=0,this.ka=this.ca=this.K=!1,C.push(this)}update(){var t;if(!this.parent&&(this.ba?(this.g.x=k(this.g.x,-1,1),this.g.y=k(this.g.y,-1,1)):1<(t=pa(this.g))&&(this.g.x*=t=1/t**.5,this.g.y*=t),t=this.i.v(),this.g.x*=this.D,this.g.y*=this.D,this.h&&(this.g.y+=Ba*this.N),this.i.x+=this.g.x,this.i.y+=this.g.y,this.angle+=this.R*=this.J,this.h)){var i,e,a,s,h,n,r=this.g.y<0;if(this.m&&(i=this.m.g?this.m.g.x:0,this.g.x=i+(this.g.x-i)*this.W,this.m=void 0),this.ca)for(var o of Ga)!this.ka&&!o.ka||o.A||o.parent||o==this||ba(this.i,this.size,o.i,o.size)&&(ba(t,this.size,o.i,o.size)?(i=(e=(i=t.u(o.i)).length())<.01?ja(.001):i.scale(.001/e),this.g=this.g.add(i),o.h&&(o.g=o.g.u(i))):(e=this.size.add(o.size),a=2*(t.y-o.i.y)>e.y+Ba,s=2*Math.abs(t.y-o.i.y)<e.y,h=2*Math.abs(t.x-o.i.x)<e.x,i=Math.max(this.s,o.s),!a&&!h&&s||(this.i.y=o.i.y+(e.y/2+.001)*Math.sign(t.y-o.i.y),o.m&&r||!o.h?(r&&(this.m=o),this.g.y*=-i):o.h&&(h=(this.h*this.g.y+o.h*o.g.y)/(this.h+o.h),n=o.g.y*(o.h-this.h)/(this.h+o.h)+2*this.g.y*this.h/(this.h+o.h),this.g.y=h+k(i)*(this.g.y*(this.h-o.h)/(this.h+o.h)+2*o.g.y*o.h/(this.h+o.h)-h),o.g.y=h+k(i)*(n-h))),!a&&s&&(this.i.x=o.i.x+(e.x/2+.001)*Math.sign(t.x-o.i.x),o.h?(e=(this.h*this.g.x+o.h*o.g.x)/(this.h+o.h),a=o.g.x*(o.h-this.h)/(this.h+o.h)+2*this.g.x*this.h/(this.h+o.h),this.g.x=e+k(i)*(this.g.x*(this.h-o.h)/(this.h+o.h)+2*o.g.x*o.h/(this.h+o.h)-e),o.g.x=e+k(i)*(a-e)):this.g.x*=-i)));this.K&&Ha(this.i,this.size,this)&&!Ha(t,this.size,this)&&(o=Ha(u(this.i.x,t.y),this.size,this),!Ha(u(t.x,this.i.y),this.size,this)&&o||(this.g.y*=-this.s,r?(this.i.y=(t.y-this.size.y/2|0)+this.size.y/2+1e-4,this.m=this):(this.i.y=t.y,this.m=void 0)),o)&&(this.i.x=t.x,this.g.x*=-this.s)}}C(){Ia(this.i,this.ua||this.size,this.l,this.color,this.angle,this.o,this.sa)}removeChild(t){t.parent==this&&this.children.includes(t),this.children.splice(this.children.indexOf(t),1),t.parent=0}toString(){}}let D,E,G,I,J=u(),K=[];function Ja(t=u(),i=za,e=0,a=0){"number"==typeof i&&(i=u(i));var s=K[e],h=i.add(u(2*a));return"number"==typeof t&&(t=0<(s=s.size.x/h.x|0)?u(t%s,t/s|0):u()),t=u(t.x*h.x+a,t.y*h.y+a),new Ka(t,i,e,a)}class Ka{constructor(t=u(),i=za,e=0,a=0){this.i=t.v(),this.size=i.v(),this.Z=e,this.padding=a}offset(t){return new Ka(this.i.add(t),this.size,this.Z)}frame(t){return this.offset(u(t*(this.size.x+2*this.padding),0))}}class La{constructor(t){this.image=t,this.size=u(t.width,t.height);var i=L.createTexture();L.bindTexture(L.TEXTURE_2D,i),t&&t.width?L.texImage2D(L.TEXTURE_2D,0,L.RGBA,L.RGBA,L.UNSIGNED_BYTE,t):(t=new Uint8Array([255,255,255,255]),L.texImage2D(L.TEXTURE_2D,0,L.RGBA,1,1,0,L.RGBA,L.UNSIGNED_BYTE,t)),t=L.NEAREST,L.texParameteri(L.TEXTURE_2D,L.TEXTURE_MIN_FILTER,t),L.texParameteri(L.TEXTURE_2D,L.TEXTURE_MAG_FILTER,t),this.ja=i}}function Ma(){var t=Pa;return new w((t.x-J.x/2+.5)/B+A.x,(t.y-J.y/2+.5)/-B+A.y)}function Qa(t){return new w((t.x-A.x)*B+J.x/2-.5,(t.y-A.y)*-B+J.y/2-.5)}function Ia(t,i=u(1),h,n=new x,e=0,a,s=new x(0,0,0,0),r=!0){const o=h&&K[h.Z];var l,c,b,d;r?o?(d=u(1).U(o.size),r=h.i.x*d.x,l=h.i.y*d.y,c=h.size.x*d.x,b=h.size.y*d.y,d=d.scale(Aa),Ra(o.ja),Sa(t.x,t.y,a?-i.x:i.x,i.y,e,r+d.x,l+d.y,r-d.x+c,l-d.y+b,sa(n),sa(s))):Sa(t.x,t.y,i.x,i.y,e,0,0,0,0,0,sa(n)):Ta(t,i=u(i.x,-i.y),e,a,t=>{var i,e,a,s;o?(i=h.i.x+Aa,e=h.i.y+Aa,a=h.size.x-2*Aa,s=h.size.y-2*Aa,t.globalAlpha=n.a,t.drawImage(o.image,i,e,a,s,-.5,-.5,1,1),t.globalAlpha=1):(t.fillStyle=n.toString(),t.fillRect(-.5,-.5,1,1))})}function Ta(t,i,e,a,s){var h=E;t=Qa(t),i=i.scale(B),h.save(),h.translate(t.x+.5,t.y+.5),h.rotate(e),h.scale(a?-i.x:i.x,-i.y),s(h),h.restore()}function Ua(t,i,e=1,a=new x,s=0,h=new x(0,0,0),n="center"){var r=I;r.fillStyle=a.toString(),r.lineWidth=s,r.strokeStyle=h.toString(),r.textAlign=n,r.font=e+"px arial",r.textBaseline="middle",r.lineJoin="round",i=i.v(),t=(t+"").split("\n"),i.y-=(t.length-1)*e/2,t.forEach(t=>{s&&r.strokeText(t,i.x,i.y,void 0),r.fillText(t,i.x,i.y,void 0),i.y+=e})}function Va(t,i=0){return O[i]&&!!(1&O[i][t])}let Wa=u(),Pa=u(),Xa=0,Ya=!1;function Za(t,i=0){return Va(t,i+1)}let O=[[]];function $a(){for(const t of O)for(const i in t)t[i]&=1;Xa=0}function ab(){function i(t){return"KeyW"==t?"ArrowUp":"KeyS"==t?"ArrowDown":"KeyA"==t?"ArrowLeft":"KeyD"==t?"ArrowRight":t}onkeydown=t=>{t.repeat||(Ya=!1,O[0][t.code]=3,O[0][i(t.code)]=3)},onkeyup=t=>{O[0][t.code]=4,O[0][i(t.code)]=4},onmousedown=t=>{P&&"running"!=P.state&&P.resume(),Ya=!1,O[0][t.button]=3,Pa=bb(t),t.button&&t.preventDefault()},onmouseup=t=>O[0][t.button]=2&O[0][t.button]|4,onmousemove=t=>Pa=bb(t),onwheel=t=>Xa=t.ctrlKey?0:Math.sign(t.deltaY),oncontextmenu=()=>!1,onblur=()=>{O=[[]]},cb&&db()}function bb(t){var i=D.getBoundingClientRect();return u(r(t.x,i.left,i.right)*D.width,r(t.y,i.top,i.bottom)*D.height)}const eb=[];function fb(){var i,e;if(navigator&&navigator.getGamepads&&document.hasFocus()){var a=navigator.getGamepads();for(let t=a.length;t--;){var s=a[t],h=O[t+1]||(O[t+1]=[]),n=eb[t]||(eb[t]=[]);if(s){for(var o=0;o<s.axes.length-1;o+=2)n[o>>1]=(i=u(s.axes[o],s.axes[o+1]),void 0,qa(u((e=t=>.3<t?r(t,.3,.8):t<-.3?-r(-t,.3,.8):0)(i.x),e(-i.y))));for(o=s.buttons.length;o--;){var l=s.buttons[o],c=Za(o,t);h[o]=l.pressed?c?1:3:c?4:0,Ya||=!t&&l.pressed}pa(s=u((Za(15,t)&&1)-(Za(14,t)&&1),(Za(12,t)&&1)-(Za(13,t)&&1)))&&(n[0]=qa(s))}}}}const cb=void 0!==window.ontouchstart;function db(){function i(t){P&&"running"!=P.state&&P.resume();var i=t.touches.length;return i?(Pa=bb(u(t.touches[0].clientX,t.touches[0].clientY)),e?Ya=!1:O[0][0]=3):e&&(O[0][0]=2&O[0][0]|4),e=i,document.hasFocus()&&t.preventDefault(),!0}document.addEventListener("touchstart",t=>i(t),{passive:!1}),document.addEventListener("touchmove",t=>i(t),{passive:!1}),document.addEventListener("touchend",t=>i(t),{passive:!1}),onmousedown=onmouseup=()=>0;let e}let P=new AudioContext,gb;class hb{constructor(){var t=[1,.5];this.Ba=40,this.Fa=.7,this.O=0,t&&(this.O=null!=t[1]?t[1]:.05,t[1]=0,this.qa=[ib(...t)],this.sampleRate=44100)}play(t,i=1,e=1,a=1,s=!1){if(this.qa){var h;if(t){if(h=this.Ba){var n=A;if(h*h<(n=(A.x-t.x)**2+(n.y-t.y)**2))return;i*=r(n**.5,h,h*this.Fa)}h=2*Qa(t).x/D.width-1}return t=e+e*this.O*a*v(-1,1),this.va=P.createGain(),this.source=jb(this.qa,i,t,h,s,this.sampleRate,this.va)}}stop(){this.source&&this.source.stop(),this.source=void 0}}function jb(t,i=1,e=1,a=0,s=!1,h=44100,n){const r=P.createBuffer(t.length,t[0].length,h),o=P.createBufferSource();return t.forEach((t,i)=>r.getChannelData(i).set(t)),o.buffer=r,o.playbackRate.value=e,o.loop=s,(n=n||P.createGain()).gain.value=i,n.connect(gb),t=new StereoPannerNode(P,{pan:k(a,-1,1)}),o.connect(t).connect(n),"running"!=P.state?P.resume().then(()=>o.start()):o.start(),o}function ib(t=1,i=.05,e=220,a=0,s=0,n=.1,r=0,o=1,u=0,l=0,c=0,b=0,x=0,d=0,y=0,g=0,f=0,m=1,w=0,p=0,L=0){var A=2*h,G=u*=500*A/44100/44100;i=e*=v(1+i,1-i)*A/44100;let E=[],D=0,J=0,R=0,T=1,W=0,_=0,M=0;var S=A*Math.abs(L)*2/44100,B=Math.cos(S),P=1+(z=Math.sin(S)/2/2),S=-2*B/P,z=(1-z)/P;let U=(1+Math.sign(L)*B)/2/P,j=-(Math.sign(L)+B)/P,I=0,C=0,F=0,O=0;for(l*=500*A/44100**3,y*=A/44100,c*=A/44100,b*=44100,x=44100*x|0,P=(a=44100*a+9)+(w*=44100)+(s*=44100)+(n*=44100)+(f*=44100)|0;R<P;E[R++]=M*t)++_%(100*g|0)||(M=r?1<r?2<r?3<r?Math.sin(D**3):k(Math.tan(D),1,-1):1-(2*D/A%2+2)%2:1-4*Math.abs(Math.round(D/A)-D/A):Math.sin(D),M=(x?1-p+p*Math.sin(A*R/x):1)*Math.sign(M)*Math.abs(M)**o*(R<a?R/a:R<a+w?1-(R-a)/w*(1-m):R<a+w+s?m:R<P-f?(P-R-f)/n*m:0),M=f?M/2+(f>R?0:(R<P-f?1:(P-R)/f)*E[R-f|0]/2/t):M,L&&(M=O=U*I+j*(I=C)+U*(C=M)-z*F-S*(F=O))),B=(e+=u+=l)*Math.cos(y*J++),D+=B+B*d*Math.sin(R**5),T&&++T>b&&(e+=c,i+=c,T=0),!x||++W%x||(e=i,u=G,T=T||1);return E}let pb=[],Q=u();function Ha(t,i=u(),e){var a=Math.max(t.x-i.x/2|0,0),s=Math.max(t.y-i.y/2|0,0),h=Math.min(t.x+i.x/2,Q.x);for(t=Math.min(t.y+i.y/2,Q.y);s<t;++s)for(i=a;i<h;++i){var n=pb[s*Q.x+i];if(n&&(!e||0<n))return!0}return!1}class qb{constructor(t,i=0,e=!1,a=new x){this.$=t,this.direction=i,this.o=e,this.color=a}clear(){this.$=this.direction=0,this.o=!1,this.color=new x}}function rb(t,i,e=!0){var a=t.l.size;e&&(e=i.multiply(a),t.context.clearRect(e.x,t.canvas.height-e.y,a.x,-a.y)),null!=(e=t.getData(i)).$&&(i=i.add(u(.5)),t=Ja(e.$,a,t.l.Z,t.l.padding),Ia(i,u(1),t,e.color,e.direction*h/2,e.o))}class sb extends Fa{constructor(t,i=Q){var e=Ja(),a=u(1);for(super(t,i,e,0,void 0,0),this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.scale=a,this.wa=!1,this.data=[],t=this.size,t=Math.abs(t.x*t.y);t--;)this.data.push(new qb)}setData(t,i,e=!1){ra(t,this.size)&&(this.data[(0|t.y)*this.size.x+t.x|0]=i,e)&&rb(this,t)}getData(t){return ra(t,this.size)&&this.data[(0|t.y)*this.size.x+t.x|0]}update(){}C(){let t=Qa(this.i.add(u(0,this.size.y*this.scale.y)));t=t.floor(),(this.wa?I:E).drawImage(this.canvas,t.x,t.y,B*this.size.x*this.scale.x,B*this.size.y*this.scale.y)}}function tb(t){var i="number"==typeof t.V?na(t.V/2):u(v(-.5,.5),v(-.5,.5)).multiply(t.V).rotate(t.angle);let e=v(t.na,-t.na);t.X||(i=t.i.add(i),e+=t.angle);const a=t.O;var s=(o=t=>t+t*v(a,-a))(t.Aa),h=o(t.Y),n=o(t.Da),r=o(t.speed),o=o(t.ta)*(2*Math.floor(v(2,0))-1),l=v(t.ga,-t.ga),c=oa(t.S,t.T,t.pa),b=oa(t.da,t.ea,t.pa),l=t.X?l:t.angle+l;(i=new ub(i,t.l,e,c,b,s,h,n,t.G,t.I,t.H,t.X&&t,t.za)).g=ma(u(),l,r),i.R=o,i.G=t.G,i.D=t.D,i.J=t.J,i.s=t.s,i.W=t.W,i.N=t.N,i.K=t.K,i.P=t.P,i.o=!!Math.floor(v(2,0)),t.oa&&t.oa(i)}class vb extends Fa{constructor(t,i,e=0,a=0,s=100,n=h,r,o=new x,l=new x,c=new x(1,1,1,0),b=new x(1,1,1,0),d=.5,y=.1,g=1,f=.1,v=.05,m=1,w=1,p=0,L=h,A=.1,E=.2,D=!1,R=!1,T=!0,M=R?1e9:0,S=!1){super(t,u(),r,i,void 0,M),this.V=e,this.ia=a,this.ha=s,this.ga=n,this.S=o,this.T=l,this.da=c,this.ea=b,this.pa=T,this.Aa=d,this.Y=y,this.Da=g,this.speed=f,this.ta=v,this.D=m,this.J=w,this.N=p,this.na=L,this.G=A,this.O=E,this.K=D,this.I=R,this.X=S,this.H=0,this.oa=this.za=void 0,this.F=0}update(){if(this.parent&&super.update(),!this.ia||ia-this.ra<=this.ia){if(+this.ha){var t=1/this.ha;for(this.F+=wb;0<this.F;this.F-=t)tb(this)}}else Ea(this)}C(){}}class ub extends Fa{constructor(t,i,e,a,s,h,n,r,o,l,c,b,x){super(t,u(),i,e),this.M=a,this.L=s.u(a),this.ma=h,this.Y=n,this.Ea=r-n,this.G=o,this.I=l,this.H=c,this.B=b,this.fa=x,this.ba=!1}C(){var t=0<this.ma?Math.min((ia-this.ra)/this.ma,1):1,i=u(this.Y+t*this.Ea),e=this.G/2,e=new x(this.M.r+t*this.L.r,this.M.j+t*this.L.j,this.M.b+t*this.L.b,(this.M.a+t*this.L.a)*(t<e?t/e:1-e<t?(1-t)/e:1));this.I&&(xb=!0);let a=this.i;var s,h,n=this.angle;this.B&&(a=this.B.i.add(a.rotate(-this.B.angle)),n+=this.B.angle),this.H?(s=this.g,(n=(s=this.B?s.rotate(-this.B.angle):s).length())&&(s=s.scale(1/n),h=n*this.H,i.y=Math.max(i.x,h),n=s.angle(),Ia(a.add(s.multiply(u(0,-h/2))),i,this.l,e,n,this.o))):Ia(a,i,this.l,e,n,this.o),this.I&&(xb=void 0),1==t&&(this.color=e,this.size=i,this.fa&&this.fa(this),this.A=1)}}const yb={};let zb=[],Ab,Bb;function Cb(i){Object.values(yb).forEach(t=>i(t))}class Db{constructor(){this.id=0,this.name="Example Medal",this.description="Welcome to LittleJS!",this.icon="🏆",this.aa=!1,yb[0]=this}unlock(){this.aa||(localStorage[Ab+"_"+this.id]=this.aa=!0,zb.push(this))}C(t=0){var i=I,e=Math.min(Ca.x,D.width),a=G.width-e;t*=-Ca.y,i.save(),i.beginPath(),i.fillStyle=new x(.9,.9,.9).toString(),i.strokeStyle=new x(0,0,0).toString(),i.lineWidth=3,i.rect(a,t,e,Ca.y),i.fill(),i.stroke(),i.clip(),e=u(a+15+25,t+Ca.y/2),this.image?I.drawImage(this.image,e.x-25,e.y-25,50,50):Ua(this.icon,e,35,new x(0,0,0)),a=u(a+50+30,t+28),Ua(this.name,a,38,new x(0,0,0),0,void 0,"left"),a.y+=32,Ua(this.description,a,24,new x(0,0,0),0,void 0,"left"),i.restore()}}let R,L,Eb,Fb,Gb,Hb,U,Ib,V,xb,Jb;function Kb(){R=document.createElement("canvas"),L=R.getContext("webgl2",{antialias:!0}),D.parentElement.appendChild(R);var t=L.createProgram();L.attachShader(t,Ob("#version 300 es\nprecision highp float;uniform mat4 m;in vec2 g;in vec4 p,u,c,a;in float r;out vec2 v;out vec4 d,e;void main(){vec2 s=(g-.5)*p.zw;gl_Position=m*vec4(p.xy+s*cos(r)-vec2(-s.y,s)*sin(r),1,1);v=mix(u.xw,u.zy,g);d=c;e=a;}",L.VERTEX_SHADER)),L.attachShader(t,Ob("#version 300 es\nprecision highp float;uniform sampler2D s;in vec2 v;in vec4 d,e;out vec4 c;void main(){c=texture(s,v)*d+e;}",L.FRAGMENT_SHADER)),L.linkProgram(t),Eb=t,t=new ArrayBuffer(44e4),U=new Float32Array(t),Ib=new Uint32Array(t),Gb=L.createBuffer(),Hb=L.createBuffer(),t=new Float32Array([V=0,0,1,0,0,1,1,1]),L.bindBuffer(L.ARRAY_BUFFER,Hb),L.bufferData(L.ARRAY_BUFFER,t,L.STATIC_DRAW)}function Pb(){L.viewport(0,0,R.width=D.width,R.height=D.height),L.clear(L.COLOR_BUFFER_BIT),L.useProgram(Eb),L.activeTexture(L.TEXTURE0),K[0]&&L.bindTexture(L.TEXTURE_2D,Fb=K[0].ja);let r=xb=Jb=0;var t=(t,i,e,a)=>{t=L.getAttribLocation(Eb,t);var s=e&&44,h=e&&1,n=1==e;L.enableVertexAttribArray(t),L.vertexAttribPointer(t,a,i,n,s,r),L.vertexAttribDivisor(t,h),r+=a*e},i=(L.bindBuffer(L.ARRAY_BUFFER,Hb),t("g",L.FLOAT,0,2),L.bindBuffer(L.ARRAY_BUFFER,Gb),L.bufferData(L.ARRAY_BUFFER,44e4,L.DYNAMIC_DRAW),t("p",L.FLOAT,4,4),t("u",L.FLOAT,4,4),t("c",L.UNSIGNED_BYTE,1,4),t("a",L.UNSIGNED_BYTE,1,4),t("r",L.FLOAT,4,1),t=u(2*B).U(J),u(-1).u(A.multiply(t)));L.uniformMatrix4fv(L.getUniformLocation(Eb,"m"),!1,[t.x,0,0,0,0,t.y,0,0,1,1,1,1,i.x,i.y,0,0])}function Ra(t){t!=Fb&&(Qb(),L.bindTexture(L.TEXTURE_2D,Fb=t))}function Ob(t,i){return i=L.createShader(i),L.shaderSource(i,t),L.compileShader(i),i}function Qb(){var t;V&&(t=Jb?L.ONE:L.ONE_MINUS_SRC_ALPHA,L.blendFuncSeparate(L.SRC_ALPHA,t,L.ONE,t),L.enable(L.BLEND),L.bufferSubData(L.ARRAY_BUFFER,0,U),L.drawArraysInstanced(L.TRIANGLE_STRIP,0,4,V),V=0,Jb=xb)}function Rb(t=!1){var i=E;(V||t)&&(Qb(),t)&&i.drawImage(R,0,0)}function Sa(t,i,e,a,s,h,n,r,o,u,l=0){(1e4<=V||Jb!=xb)&&Qb();var c=11*V++;U[c++]=t,U[c++]=i,U[c++]=e,U[c++]=a,U[c++]=h,U[c++]=n,U[c++]=r,U[c++]=o,Ib[c++]=u,Ib[c++]=l,U[+c]=s}const wb=1/60;let C=[],Ga=[],Sb=0,ia=0,Tb=0,Ub=0,W=0;const Vb=[],Wb=[];function Xb(t){Vb.includes(void 0),Wb.includes(t),t&&Wb.push(t)}function Yb(){Ga=C.filter(t=>t.ca);for(const t of C)t.parent||(function t(i){if(!i.A){i.update();for(const e of i.children)t(e)}}(t),Da(t));C=C.filter(t=>!t.A)}function Zb(t){const u=I;var e=G.width=innerWidth,a=G.height=innerHeight,s=r(t,1,.8),n=r(t,0,.5),i=u.createRadialGradient(e/2,a/2,0,e/2,a/2,.7*Math.hypot(e,a));i.addColorStop(0,y(0,0,s/2*k(n),s).toString()),i.addColorStop(1,y(0,0,0,s).toString()),u.save(),u.fillStyle=i,u.fillRect(0,0,e,a),i=(t,i,e,a,s)=>{u.beginPath(),u.rect(t,i,e,s?a*l:a),(u.fillStyle=s)?u.fill():u.stroke()},n=(t,i,e,a=0,s=2*h,n,r)=>{var o=(a+s)/2;a=l*(s-a)/2,u.beginPath(),r&&u.lineTo(t,i),u.arc(t,i,e,o-a,o+a),(u.fillStyle=n)?u.fill():u.stroke()},s=(t=0,i=0)=>y([.98,.3,.57,.14][t%4]-10,.8,[0,.3,.5,.8,.9][i]).toString();const l=r(t=ha(t),.1,.5);for(u.translate(e/2,a/2),e=Math.min(6,Math.min(e,a)/99),u.scale(e,e),u.translate(-40,-35),u.lineJoin=u.lineCap="round",u.lineWidth=.1+1.9*l,u.setLineDash([99*r(t,.1,1),99]),i(7,16,18,-8,s(2,2)),i(7,8,18,4,s(2,3)),i(25,8,8,8,s(2,1)),i(25,8,-18,8),i(25,8,8,8),i(25,16,7,23,s()),i(11,39,14,-23,s(1,1)),i(11,16,14,18,s(1,2)),i(11,16,14,8,s(1,3)),i(25,16,-14,24),i(15,29,6,-9,s(2,2)),n(15,21,5,0,h/2,s(2,4),1),i(21,21,-6,9),i(37,14,9,6,s(3,2)),i(37,14,4.5,6,s(3,3)),i(37,14,9,6),i(50,20,10,-8,s(0,1)),i(50,20,6.5,-8,s(0,2)),i(50,20,3.5,-8,s(0,3)),i(50,20,10,-8),n(55,2,11.4,.5,h-.5,s(3,3)),n(55,2,11.4,.5,h/2,s(3,2),1),n(55,2,11.4,.5,h-.5),i(45,7,20,-7,s(0,2)),i(45,-1,20,4,s(0,3)),i(45,-1,20,8),e=5;e--;)n(60-6*e,30,9.9,0,2*h,s(e+2,3)),n(60-6*e,30,10,-.5,h+.5,s(e+2,2)),n(60-6*e,30,10.1,.5,h-.5,s(e+2,1));for(n(36,30,10,h/2,3*h/2),n(48,30,10,h/2,3*h/2),n(60,30,10),u.beginPath(),u.lineTo(36,20),u.lineTo(60,20),u.stroke(),n(60,30,4,h,3*h,s(3,2)),n(60,30,4,h,2*h,s(3,3)),n(60,30,4,h,3*h),e=6;e--;)u.beginPath(),u.lineTo(53,54),u.lineTo(53,40),u.lineTo(53+(1+2.9*e)*l,40),u.lineTo(53+(4+3.5*e)*l,54),u.fillStyle=s(0,e%2+2),u.fill(),e%2&&u.stroke();for(i(6,40,5,5),i(6,40,5,5,s()),i(15,54,38,-14,s()),e=3;e--;)for(a=2;a--;)n(15*e+15,47,a?7:1,h,3*h,s(e,3)),u.stroke(),n(15*e+15,47,a?7:1,0,h,s(e,2)),u.stroke();for(u.beginPath(),u.lineTo(6,40),u.lineTo(68,40),u.stroke(),u.beginPath(),u.lineTo(77,54),u.lineTo(4,54),u.stroke(),u.font="900 16px arial",u.textAlign="center",u.textBaseline="top",u.lineWidth=.1+3.9*l,e=n=0;e<8;++e)n+=u.measureText("LittleJS"[e]).width;for(e=2;e--;)for(let t=0,i=41-n/2;t<8;++t)u.fillStyle=s(t,2),a=u.measureText("LittleJS"[t]).width,u[e?"strokeText":"fillText"]("LittleJS"[t],i+a/2,55.5,17*l),i+=a;u.restore()}va=!0,Aa=.5;const $b=new hb,ac=new Db;Ab="Hello World",Cb(t=>t.aa=!!localStorage[Ab+"_"+t.id]),Xb(function(){var t,i;zb.length&&(t=zb[0],i=Tb-Bb,Bb?5<i?(Bb=0,zb.shift()):t.C(i<.5?1-i/.5:4.5<i?(i-4.5)/.5:0):Bb=Tb)});let Z;!function(i,a,s,h,n,t,e=document.body){function r(t=0){var i=t-Ub;for(Ub=t,Tb+=i/1e3,W+=i,W=Math.min(W,50),o(),t=0,W<0&&-9<W&&(t=W,W=0);0<=W;W-=1e3/60)ia=Sb++/60,cb||document.hasFocus()||(O=[[]]),Wa=Ma(),fb(),a(),Vb.forEach(t=>t()),Yb(),s(),$a();W+=t,J=u(D.width,D.height),I.imageSmoothingEnabled=E.imageSmoothingEnabled=!1,Pb(),h(),C.sort((t,i)=>t.P-i.P);for(const e of C)e.A||e.C();n(),Wb.forEach(t=>t()),Rb(),requestAnimationFrame(r)}function o(){var t,i;ua.x?(D.width=ua.x,D.height=ua.y,t=innerWidth/innerHeight,i=D.width/D.height,(R||D).style.width=D.style.width=G.style.width=t<i?"100%":"",(R||D).style.height=D.style.height=G.style.height=t<i?"":"100%"):(D.width=Math.min(innerWidth,ta.x),D.height=Math.min(innerHeight,ta.y)),G.width=D.width,G.height=D.height,J=u(D.width,D.height)}i||=()=>{},a||=()=>{},s||=()=>{},h||=()=>{},n||=()=>{},e.style.cssText="margin:0;overflow:hidden;width:100vw;height:100vh;display:flex;align-items:center;justify-content:center;background:#000;image-rendering:pixelated;user-select:none;-webkit-user-select:none;touch-action:none;-webkit-touch-callout:none",e.appendChild(D=document.createElement("canvas")),E=D.getContext("2d"),ab(),(gb=P.createGain()).connect(P.destination),gb.gain.value=.3,Kb(),e.appendChild(G=document.createElement("canvas")),I=G.getContext("2d"),D.style.cssText=G.style.cssText="position:absolute",R&&(R.style.cssText="position:absolute"),o(),e=t.map((e,a)=>new Promise(t=>{const i=new Image;i.crossOrigin="anonymous",i.onerror=i.onload=()=>{K[a]=new La(i),t()},i.src=e})),t.length||e.push(new Promise(t=>{K[0]=new La(new Image),t()})),va&&e.push(new Promise(i=>{let e=0;console.log("LittleJS Engine v1.11.10"),function t(){O=[[]],Zb(e+=.01),1<e?i():setTimeout(t,16)}()})),Promise.all(e).then(function(){new Promise(t=>t(i())).then(r)})}(function(){Q=u(32,16);for(var t=(pb=[]).length=Math.abs(Q.x*Q.y);t--;)pb[t]=0;var i,e,a,s=u(),t=new sb(s,Q),n=K[0].image,r=(E.drawImage(n,0,0),E.getImageData(0,0,n.width,n.height).data);for(s.x=Q.x;s.x--;)for(s.y=Q.y;s.y--;)r[4*(s.x+n.width*(15+Q.y-s.y))]&&(i=Math.floor(v(4,0)),e=!Math.floor(v(2,0)),a=oa(),t.setData(s,new qb(1,i,e,a)),ra(s,Q))&&(pb[(0|s.y)*Q.x+s.x|0]=1);for(t.Ca=[D,E,J,A,B],D=t.canvas,E=t.context,J=t.size.multiply(t.l.size),A=t.size.scale(.5),B=t.l.size.x,D.width=J.x,D.height=J.y,t.context.imageSmoothingEnabled=!1,Pb(),s=t.size.x;s--;)for(n=t.size.y;n--;)rb(t,u(s,n),!1);Rb(!0),[D,E,J,A,B]=t.Ca,A=u(16,8),B=32,Ba=-.01,(Z=new vb(u(16,9),0,0,0,500,h,Ja(0,16),y(1,1,1),y(0,0,0),y(0,0,0,0),y(0,0,0,0),2,.2,.2,.1,.05,.99,1,1,h,.05,.5,!0,!0)).s=.3,Z.H=2},function(){O[0]&&2&O[0][0]&&($b.play(Wa),Z.S=y(),Z.T=oa(),Z.da=Z.S.scale(1,0),Z.ea=Z.T.scale(1,0),ac.unlock()),Xa&&(B=k(B-=Math.sign(Xa)*B/5,10,300)),Pa.x&&(Z.i=Wa)},function(){},function(){Ia(u(16,8),u(20,14),void 0,y(0,0,.6),0,!1,void 0,!1),Ia(u(21,5),u(4.5),Ja(3,128))},function(){Ua("LittleJS Demo",u(J.x/2,70),80,y(0,0,1),6,y(0,0,0))},["tiles.png"]);
2
+ </script>
@@ -0,0 +1 @@
1
+ const h=Math.PI;function aa(t,i=1){return(t%i+i)%i}function k(t,i=0,e=1){return t<i?i:e<t?e:t}function r(t,i,e){return(e-=i)?k((t-i)/e):0}function ba(t,i,e,a=u()){return 2*Math.abs(t.x-e.x)<i.x+a.x&&2*Math.abs(t.y-e.y)<i.y+a.y}function ha(t=ia){return.5*(1-Math.cos(2*t*h))}function v(t=1,i=0){return i+Math.random()*(t-i)}function ja(t=1){return ma(new w,v(2*h),t)}function na(t=1){return 0<t?ja(t*v(0/t,1)**.5):new w}function oa(t=new x,i=new x(0,0,0,1),e=!1){return e?t.la(i,v()):new x(v(t.r,i.r),v(t.j,i.j),v(t.b,i.b),v(t.a,i.a))}function u(t=0,i){return"number"==typeof t?new w(t,null==i?t:i):new w(t.x,t.y)}function ma(t,i=0,e=1){return t.x=e*Math.sin(i),t.y=e*Math.cos(i),t}function pa(t){return t.x**2+t.y**2}function qa(t){var i=t.length();return 1<i?t.scale(1/i):t}function ra(t,i){return 0<=t.x&&0<=t.y&&t.x<i.x&&t.y<i.y}class w{constructor(t=0,i=0){this.x=t,this.y=i}set(t=0,i=0){return this.x=t,this.y=i,this}v(){return new w(this.x,this.y)}add(t){return new w(this.x+t.x,this.y+t.y)}u(t){return new w(this.x-t.x,this.y-t.y)}multiply(t){return new w(this.x*t.x,this.y*t.y)}U(t){return new w(this.x/t.x,this.y/t.y)}scale(t){return new w(this.x*t,this.y*t)}length(){return pa(this)**.5}normalize(t=1){var i=this.length();return i?this.scale(t/i):new w(0,t)}angle(){return Math.atan2(this.x,this.y)}rotate(t){var i=Math.cos(-t);return t=Math.sin(-t),new w(this.x*i-this.y*t,this.x*t+this.y*i)}setDirection(t,i=1){return u((t=aa(t,4))%2?t-1?-i:i:0,t%2?0:t?-i:i)}direction(){return Math.abs(this.x)>Math.abs(this.y)?this.x<0?3:1:this.y<0?2:0}floor(){return new w(Math.floor(this.x),Math.floor(this.y))}la(t,i){return this.add(t.u(this).scale(k(i)))}toString(){}}function y(t=0,i=0,e=1,a=1){var s=new x,h=(t=aa(t,1),i=k(i),e=k(e),(t,i,e)=>6*(e=aa(e,1))<1?t+6*(i-t)*e:2*e<1?i:3*e<2?t+(i-t)*(4-6*e):t);return s.r=h(e=2*e-(i=e<.5?e*(1+i):e+i-e*i),i,t+1/3),s.j=h(e,i,t),s.b=h(e,i,t-1/3),s.a=a,s}function sa(t){return(255*k(t.r)|0)+(255*k(t.j)<<8)+(255*k(t.b)<<16)+(255*k(t.a)<<24)}class x{constructor(t=1,i=1,e=1,a=1){this.r=t,this.j=i,this.b=e,this.a=a}set(t=1,i=1,e=1,a=1){return this.r=t,this.j=i,this.b=e,this.a=a,this}v(){return new x(this.r,this.j,this.b,this.a)}add(t){return new x(this.r+t.r,this.j+t.j,this.b+t.b,this.a+t.a)}u(t){return new x(this.r-t.r,this.j-t.j,this.b-t.b,this.a-t.a)}multiply(t){return new x(this.r*t.r,this.j*t.j,this.b*t.b,this.a*t.a)}U(t){return new x(this.r/t.r,this.j/t.j,this.b/t.b,this.a/t.a)}scale(t,i=t){return new x(this.r*t,this.j*t,this.b*t,this.a*i)}la(t,i){return this.add(t.u(this).scale(k(i)))}toString(t=!0){var i=t=>((t=255*k(t)|0)<16?"0":"")+t.toString(16);return"#"+i(this.r)+i(this.j)+i(this.b)+(t?i(this.a):"")}}let A=u(),B=32,ta=u(1920,1080),ua=u(),va=!1,za=u(16),Aa=0,Ba=0,Ca=u(640,80);function Da(t){var i,e=t.parent;e&&(i=e.o?-1:1,t.i=t.ya.multiply(u(i,1)).rotate(e.angle).add(e.i),t.angle=i*t.xa+e.angle);for(const a of t.children)Da(a)}function Ea(t){if(!t.A){t.A=1,t.parent&&t.parent.removeChild(t);for(const i of t.children)Ea(i,i.parent=0)}}class Fa{constructor(t=u(),i=u(1),e,a=0,s=new x,h=0){this.i=t.v(),this.size=i,this.ua=void 0,this.l=e,this.angle=a,this.color=s,this.sa=void 0,this.o=!1,this.J=this.D=this.h=1,this.s=0,this.W=.8,this.N=1,this.P=h,this.g=u(),this.R=0,this.ra=ia,this.children=[],this.ba=!0,this.parent=this.m=void 0,this.ya=u(),this.xa=0,this.ka=this.ca=this.K=!1,C.push(this)}update(){var t;if(!this.parent&&(this.ba?(this.g.x=k(this.g.x,-1,1),this.g.y=k(this.g.y,-1,1)):1<(t=pa(this.g))&&(this.g.x*=t=1/t**.5,this.g.y*=t),t=this.i.v(),this.g.x*=this.D,this.g.y*=this.D,this.h&&(this.g.y+=Ba*this.N),this.i.x+=this.g.x,this.i.y+=this.g.y,this.angle+=this.R*=this.J,this.h)){var i,e,a,s,h,n,r=this.g.y<0;if(this.m&&(i=this.m.g?this.m.g.x:0,this.g.x=i+(this.g.x-i)*this.W,this.m=void 0),this.ca)for(var o of Ga)!this.ka&&!o.ka||o.A||o.parent||o==this||ba(this.i,this.size,o.i,o.size)&&(ba(t,this.size,o.i,o.size)?(i=(e=(i=t.u(o.i)).length())<.01?ja(.001):i.scale(.001/e),this.g=this.g.add(i),o.h&&(o.g=o.g.u(i))):(e=this.size.add(o.size),a=2*(t.y-o.i.y)>e.y+Ba,s=2*Math.abs(t.y-o.i.y)<e.y,h=2*Math.abs(t.x-o.i.x)<e.x,i=Math.max(this.s,o.s),!a&&!h&&s||(this.i.y=o.i.y+(e.y/2+.001)*Math.sign(t.y-o.i.y),o.m&&r||!o.h?(r&&(this.m=o),this.g.y*=-i):o.h&&(h=(this.h*this.g.y+o.h*o.g.y)/(this.h+o.h),n=o.g.y*(o.h-this.h)/(this.h+o.h)+2*this.g.y*this.h/(this.h+o.h),this.g.y=h+k(i)*(this.g.y*(this.h-o.h)/(this.h+o.h)+2*o.g.y*o.h/(this.h+o.h)-h),o.g.y=h+k(i)*(n-h))),!a&&s&&(this.i.x=o.i.x+(e.x/2+.001)*Math.sign(t.x-o.i.x),o.h?(e=(this.h*this.g.x+o.h*o.g.x)/(this.h+o.h),a=o.g.x*(o.h-this.h)/(this.h+o.h)+2*this.g.x*this.h/(this.h+o.h),this.g.x=e+k(i)*(this.g.x*(this.h-o.h)/(this.h+o.h)+2*o.g.x*o.h/(this.h+o.h)-e),o.g.x=e+k(i)*(a-e)):this.g.x*=-i)));this.K&&Ha(this.i,this.size,this)&&!Ha(t,this.size,this)&&(o=Ha(u(this.i.x,t.y),this.size,this),!Ha(u(t.x,this.i.y),this.size,this)&&o||(this.g.y*=-this.s,r?(this.i.y=(t.y-this.size.y/2|0)+this.size.y/2+1e-4,this.m=this):(this.i.y=t.y,this.m=void 0)),o)&&(this.i.x=t.x,this.g.x*=-this.s)}}C(){Ia(this.i,this.ua||this.size,this.l,this.color,this.angle,this.o,this.sa)}removeChild(t){t.parent==this&&this.children.includes(t),this.children.splice(this.children.indexOf(t),1),t.parent=0}toString(){}}let D,E,G,I,J=u(),K=[];function Ja(t=u(),i=za,e=0,a=0){"number"==typeof i&&(i=u(i));var s=K[e],h=i.add(u(2*a));return"number"==typeof t&&(t=0<(s=s.size.x/h.x|0)?u(t%s,t/s|0):u()),t=u(t.x*h.x+a,t.y*h.y+a),new Ka(t,i,e,a)}class Ka{constructor(t=u(),i=za,e=0,a=0){this.i=t.v(),this.size=i.v(),this.Z=e,this.padding=a}offset(t){return new Ka(this.i.add(t),this.size,this.Z)}frame(t){return this.offset(u(t*(this.size.x+2*this.padding),0))}}class La{constructor(t){this.image=t,this.size=u(t.width,t.height);var i=L.createTexture();L.bindTexture(L.TEXTURE_2D,i),t&&t.width?L.texImage2D(L.TEXTURE_2D,0,L.RGBA,L.RGBA,L.UNSIGNED_BYTE,t):(t=new Uint8Array([255,255,255,255]),L.texImage2D(L.TEXTURE_2D,0,L.RGBA,1,1,0,L.RGBA,L.UNSIGNED_BYTE,t)),t=L.NEAREST,L.texParameteri(L.TEXTURE_2D,L.TEXTURE_MIN_FILTER,t),L.texParameteri(L.TEXTURE_2D,L.TEXTURE_MAG_FILTER,t),this.ja=i}}function Ma(){var t=Pa;return new w((t.x-J.x/2+.5)/B+A.x,(t.y-J.y/2+.5)/-B+A.y)}function Qa(t){return new w((t.x-A.x)*B+J.x/2-.5,(t.y-A.y)*-B+J.y/2-.5)}function Ia(t,i=u(1),h,n=new x,e=0,a,s=new x(0,0,0,0),r=!0){const o=h&&K[h.Z];var l,c,b,d;r?o?(d=u(1).U(o.size),r=h.i.x*d.x,l=h.i.y*d.y,c=h.size.x*d.x,b=h.size.y*d.y,d=d.scale(Aa),Ra(o.ja),Sa(t.x,t.y,a?-i.x:i.x,i.y,e,r+d.x,l+d.y,r-d.x+c,l-d.y+b,sa(n),sa(s))):Sa(t.x,t.y,i.x,i.y,e,0,0,0,0,0,sa(n)):Ta(t,i=u(i.x,-i.y),e,a,t=>{var i,e,a,s;o?(i=h.i.x+Aa,e=h.i.y+Aa,a=h.size.x-2*Aa,s=h.size.y-2*Aa,t.globalAlpha=n.a,t.drawImage(o.image,i,e,a,s,-.5,-.5,1,1),t.globalAlpha=1):(t.fillStyle=n.toString(),t.fillRect(-.5,-.5,1,1))})}function Ta(t,i,e,a,s){var h=E;t=Qa(t),i=i.scale(B),h.save(),h.translate(t.x+.5,t.y+.5),h.rotate(e),h.scale(a?-i.x:i.x,-i.y),s(h),h.restore()}function Ua(t,i,e=1,a=new x,s=0,h=new x(0,0,0),n="center"){var r=I;r.fillStyle=a.toString(),r.lineWidth=s,r.strokeStyle=h.toString(),r.textAlign=n,r.font=e+"px arial",r.textBaseline="middle",r.lineJoin="round",i=i.v(),t=(t+"").split("\n"),i.y-=(t.length-1)*e/2,t.forEach(t=>{s&&r.strokeText(t,i.x,i.y,void 0),r.fillText(t,i.x,i.y,void 0),i.y+=e})}function Va(t,i=0){return O[i]&&!!(1&O[i][t])}let Wa=u(),Pa=u(),Xa=0,Ya=!1;function Za(t,i=0){return Va(t,i+1)}let O=[[]];function $a(){for(const t of O)for(const i in t)t[i]&=1;Xa=0}function ab(){function i(t){return"KeyW"==t?"ArrowUp":"KeyS"==t?"ArrowDown":"KeyA"==t?"ArrowLeft":"KeyD"==t?"ArrowRight":t}onkeydown=t=>{t.repeat||(Ya=!1,O[0][t.code]=3,O[0][i(t.code)]=3)},onkeyup=t=>{O[0][t.code]=4,O[0][i(t.code)]=4},onmousedown=t=>{P&&"running"!=P.state&&P.resume(),Ya=!1,O[0][t.button]=3,Pa=bb(t),t.button&&t.preventDefault()},onmouseup=t=>O[0][t.button]=2&O[0][t.button]|4,onmousemove=t=>Pa=bb(t),onwheel=t=>Xa=t.ctrlKey?0:Math.sign(t.deltaY),oncontextmenu=()=>!1,onblur=()=>{O=[[]]},cb&&db()}function bb(t){var i=D.getBoundingClientRect();return u(r(t.x,i.left,i.right)*D.width,r(t.y,i.top,i.bottom)*D.height)}const eb=[];function fb(){var i,e;if(navigator&&navigator.getGamepads&&document.hasFocus()){var a=navigator.getGamepads();for(let t=a.length;t--;){var s=a[t],h=O[t+1]||(O[t+1]=[]),n=eb[t]||(eb[t]=[]);if(s){for(var o=0;o<s.axes.length-1;o+=2)n[o>>1]=(i=u(s.axes[o],s.axes[o+1]),void 0,qa(u((e=t=>.3<t?r(t,.3,.8):t<-.3?-r(-t,.3,.8):0)(i.x),e(-i.y))));for(o=s.buttons.length;o--;){var l=s.buttons[o],c=Za(o,t);h[o]=l.pressed?c?1:3:c?4:0,Ya||=!t&&l.pressed}pa(s=u((Za(15,t)&&1)-(Za(14,t)&&1),(Za(12,t)&&1)-(Za(13,t)&&1)))&&(n[0]=qa(s))}}}}const cb=void 0!==window.ontouchstart;function db(){function i(t){P&&"running"!=P.state&&P.resume();var i=t.touches.length;return i?(Pa=bb(u(t.touches[0].clientX,t.touches[0].clientY)),e?Ya=!1:O[0][0]=3):e&&(O[0][0]=2&O[0][0]|4),e=i,document.hasFocus()&&t.preventDefault(),!0}document.addEventListener("touchstart",t=>i(t),{passive:!1}),document.addEventListener("touchmove",t=>i(t),{passive:!1}),document.addEventListener("touchend",t=>i(t),{passive:!1}),onmousedown=onmouseup=()=>0;let e}let P=new AudioContext,gb;class hb{constructor(){var t=[1,.5];this.Ba=40,this.Fa=.7,this.O=0,t&&(this.O=null!=t[1]?t[1]:.05,t[1]=0,this.qa=[ib(...t)],this.sampleRate=44100)}play(t,i=1,e=1,a=1,s=!1){if(this.qa){var h;if(t){if(h=this.Ba){var n=A;if(h*h<(n=(A.x-t.x)**2+(n.y-t.y)**2))return;i*=r(n**.5,h,h*this.Fa)}h=2*Qa(t).x/D.width-1}return t=e+e*this.O*a*v(-1,1),this.va=P.createGain(),this.source=jb(this.qa,i,t,h,s,this.sampleRate,this.va)}}stop(){this.source&&this.source.stop(),this.source=void 0}}function jb(t,i=1,e=1,a=0,s=!1,h=44100,n){const r=P.createBuffer(t.length,t[0].length,h),o=P.createBufferSource();return t.forEach((t,i)=>r.getChannelData(i).set(t)),o.buffer=r,o.playbackRate.value=e,o.loop=s,(n=n||P.createGain()).gain.value=i,n.connect(gb),t=new StereoPannerNode(P,{pan:k(a,-1,1)}),o.connect(t).connect(n),"running"!=P.state?P.resume().then(()=>o.start()):o.start(),o}function ib(t=1,i=.05,e=220,a=0,s=0,n=.1,r=0,o=1,u=0,l=0,c=0,b=0,x=0,d=0,y=0,g=0,f=0,m=1,w=0,p=0,L=0){var A=2*h,G=u*=500*A/44100/44100;i=e*=v(1+i,1-i)*A/44100;let E=[],D=0,J=0,R=0,T=1,W=0,_=0,M=0;var S=A*Math.abs(L)*2/44100,B=Math.cos(S),P=1+(z=Math.sin(S)/2/2),S=-2*B/P,z=(1-z)/P;let U=(1+Math.sign(L)*B)/2/P,j=-(Math.sign(L)+B)/P,I=0,C=0,F=0,O=0;for(l*=500*A/44100**3,y*=A/44100,c*=A/44100,b*=44100,x=44100*x|0,P=(a=44100*a+9)+(w*=44100)+(s*=44100)+(n*=44100)+(f*=44100)|0;R<P;E[R++]=M*t)++_%(100*g|0)||(M=r?1<r?2<r?3<r?Math.sin(D**3):k(Math.tan(D),1,-1):1-(2*D/A%2+2)%2:1-4*Math.abs(Math.round(D/A)-D/A):Math.sin(D),M=(x?1-p+p*Math.sin(A*R/x):1)*Math.sign(M)*Math.abs(M)**o*(R<a?R/a:R<a+w?1-(R-a)/w*(1-m):R<a+w+s?m:R<P-f?(P-R-f)/n*m:0),M=f?M/2+(f>R?0:(R<P-f?1:(P-R)/f)*E[R-f|0]/2/t):M,L&&(M=O=U*I+j*(I=C)+U*(C=M)-z*F-S*(F=O))),B=(e+=u+=l)*Math.cos(y*J++),D+=B+B*d*Math.sin(R**5),T&&++T>b&&(e+=c,i+=c,T=0),!x||++W%x||(e=i,u=G,T=T||1);return E}let pb=[],Q=u();function Ha(t,i=u(),e){var a=Math.max(t.x-i.x/2|0,0),s=Math.max(t.y-i.y/2|0,0),h=Math.min(t.x+i.x/2,Q.x);for(t=Math.min(t.y+i.y/2,Q.y);s<t;++s)for(i=a;i<h;++i){var n=pb[s*Q.x+i];if(n&&(!e||0<n))return!0}return!1}class qb{constructor(t,i=0,e=!1,a=new x){this.$=t,this.direction=i,this.o=e,this.color=a}clear(){this.$=this.direction=0,this.o=!1,this.color=new x}}function rb(t,i,e=!0){var a=t.l.size;e&&(e=i.multiply(a),t.context.clearRect(e.x,t.canvas.height-e.y,a.x,-a.y)),null!=(e=t.getData(i)).$&&(i=i.add(u(.5)),t=Ja(e.$,a,t.l.Z,t.l.padding),Ia(i,u(1),t,e.color,e.direction*h/2,e.o))}class sb extends Fa{constructor(t,i=Q){var e=Ja(),a=u(1);for(super(t,i,e,0,void 0,0),this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.scale=a,this.wa=!1,this.data=[],t=this.size,t=Math.abs(t.x*t.y);t--;)this.data.push(new qb)}setData(t,i,e=!1){ra(t,this.size)&&(this.data[(0|t.y)*this.size.x+t.x|0]=i,e)&&rb(this,t)}getData(t){return ra(t,this.size)&&this.data[(0|t.y)*this.size.x+t.x|0]}update(){}C(){let t=Qa(this.i.add(u(0,this.size.y*this.scale.y)));t=t.floor(),(this.wa?I:E).drawImage(this.canvas,t.x,t.y,B*this.size.x*this.scale.x,B*this.size.y*this.scale.y)}}function tb(t){var i="number"==typeof t.V?na(t.V/2):u(v(-.5,.5),v(-.5,.5)).multiply(t.V).rotate(t.angle);let e=v(t.na,-t.na);t.X||(i=t.i.add(i),e+=t.angle);const a=t.O;var s=(o=t=>t+t*v(a,-a))(t.Aa),h=o(t.Y),n=o(t.Da),r=o(t.speed),o=o(t.ta)*(2*Math.floor(v(2,0))-1),l=v(t.ga,-t.ga),c=oa(t.S,t.T,t.pa),b=oa(t.da,t.ea,t.pa),l=t.X?l:t.angle+l;(i=new ub(i,t.l,e,c,b,s,h,n,t.G,t.I,t.H,t.X&&t,t.za)).g=ma(u(),l,r),i.R=o,i.G=t.G,i.D=t.D,i.J=t.J,i.s=t.s,i.W=t.W,i.N=t.N,i.K=t.K,i.P=t.P,i.o=!!Math.floor(v(2,0)),t.oa&&t.oa(i)}class vb extends Fa{constructor(t,i,e=0,a=0,s=100,n=h,r,o=new x,l=new x,c=new x(1,1,1,0),b=new x(1,1,1,0),d=.5,y=.1,g=1,f=.1,v=.05,m=1,w=1,p=0,L=h,A=.1,E=.2,D=!1,R=!1,T=!0,M=R?1e9:0,S=!1){super(t,u(),r,i,void 0,M),this.V=e,this.ia=a,this.ha=s,this.ga=n,this.S=o,this.T=l,this.da=c,this.ea=b,this.pa=T,this.Aa=d,this.Y=y,this.Da=g,this.speed=f,this.ta=v,this.D=m,this.J=w,this.N=p,this.na=L,this.G=A,this.O=E,this.K=D,this.I=R,this.X=S,this.H=0,this.oa=this.za=void 0,this.F=0}update(){if(this.parent&&super.update(),!this.ia||ia-this.ra<=this.ia){if(+this.ha){var t=1/this.ha;for(this.F+=wb;0<this.F;this.F-=t)tb(this)}}else Ea(this)}C(){}}class ub extends Fa{constructor(t,i,e,a,s,h,n,r,o,l,c,b,x){super(t,u(),i,e),this.M=a,this.L=s.u(a),this.ma=h,this.Y=n,this.Ea=r-n,this.G=o,this.I=l,this.H=c,this.B=b,this.fa=x,this.ba=!1}C(){var t=0<this.ma?Math.min((ia-this.ra)/this.ma,1):1,i=u(this.Y+t*this.Ea),e=this.G/2,e=new x(this.M.r+t*this.L.r,this.M.j+t*this.L.j,this.M.b+t*this.L.b,(this.M.a+t*this.L.a)*(t<e?t/e:1-e<t?(1-t)/e:1));this.I&&(xb=!0);let a=this.i;var s,h,n=this.angle;this.B&&(a=this.B.i.add(a.rotate(-this.B.angle)),n+=this.B.angle),this.H?(s=this.g,(n=(s=this.B?s.rotate(-this.B.angle):s).length())&&(s=s.scale(1/n),h=n*this.H,i.y=Math.max(i.x,h),n=s.angle(),Ia(a.add(s.multiply(u(0,-h/2))),i,this.l,e,n,this.o))):Ia(a,i,this.l,e,n,this.o),this.I&&(xb=void 0),1==t&&(this.color=e,this.size=i,this.fa&&this.fa(this),this.A=1)}}const yb={};let zb=[],Ab,Bb;function Cb(i){Object.values(yb).forEach(t=>i(t))}class Db{constructor(){this.id=0,this.name="Example Medal",this.description="Welcome to LittleJS!",this.icon="🏆",this.aa=!1,yb[0]=this}unlock(){this.aa||(localStorage[Ab+"_"+this.id]=this.aa=!0,zb.push(this))}C(t=0){var i=I,e=Math.min(Ca.x,D.width),a=G.width-e;t*=-Ca.y,i.save(),i.beginPath(),i.fillStyle=new x(.9,.9,.9).toString(),i.strokeStyle=new x(0,0,0).toString(),i.lineWidth=3,i.rect(a,t,e,Ca.y),i.fill(),i.stroke(),i.clip(),e=u(a+15+25,t+Ca.y/2),this.image?I.drawImage(this.image,e.x-25,e.y-25,50,50):Ua(this.icon,e,35,new x(0,0,0)),a=u(a+50+30,t+28),Ua(this.name,a,38,new x(0,0,0),0,void 0,"left"),a.y+=32,Ua(this.description,a,24,new x(0,0,0),0,void 0,"left"),i.restore()}}let R,L,Eb,Fb,Gb,Hb,U,Ib,V,xb,Jb;function Kb(){R=document.createElement("canvas"),L=R.getContext("webgl2",{antialias:!0}),D.parentElement.appendChild(R);var t=L.createProgram();L.attachShader(t,Ob("#version 300 es\nprecision highp float;uniform mat4 m;in vec2 g;in vec4 p,u,c,a;in float r;out vec2 v;out vec4 d,e;void main(){vec2 s=(g-.5)*p.zw;gl_Position=m*vec4(p.xy+s*cos(r)-vec2(-s.y,s)*sin(r),1,1);v=mix(u.xw,u.zy,g);d=c;e=a;}",L.VERTEX_SHADER)),L.attachShader(t,Ob("#version 300 es\nprecision highp float;uniform sampler2D s;in vec2 v;in vec4 d,e;out vec4 c;void main(){c=texture(s,v)*d+e;}",L.FRAGMENT_SHADER)),L.linkProgram(t),Eb=t,t=new ArrayBuffer(44e4),U=new Float32Array(t),Ib=new Uint32Array(t),Gb=L.createBuffer(),Hb=L.createBuffer(),t=new Float32Array([V=0,0,1,0,0,1,1,1]),L.bindBuffer(L.ARRAY_BUFFER,Hb),L.bufferData(L.ARRAY_BUFFER,t,L.STATIC_DRAW)}function Pb(){L.viewport(0,0,R.width=D.width,R.height=D.height),L.clear(L.COLOR_BUFFER_BIT),L.useProgram(Eb),L.activeTexture(L.TEXTURE0),K[0]&&L.bindTexture(L.TEXTURE_2D,Fb=K[0].ja);let r=xb=Jb=0;var t=(t,i,e,a)=>{t=L.getAttribLocation(Eb,t);var s=e&&44,h=e&&1,n=1==e;L.enableVertexAttribArray(t),L.vertexAttribPointer(t,a,i,n,s,r),L.vertexAttribDivisor(t,h),r+=a*e},i=(L.bindBuffer(L.ARRAY_BUFFER,Hb),t("g",L.FLOAT,0,2),L.bindBuffer(L.ARRAY_BUFFER,Gb),L.bufferData(L.ARRAY_BUFFER,44e4,L.DYNAMIC_DRAW),t("p",L.FLOAT,4,4),t("u",L.FLOAT,4,4),t("c",L.UNSIGNED_BYTE,1,4),t("a",L.UNSIGNED_BYTE,1,4),t("r",L.FLOAT,4,1),t=u(2*B).U(J),u(-1).u(A.multiply(t)));L.uniformMatrix4fv(L.getUniformLocation(Eb,"m"),!1,[t.x,0,0,0,0,t.y,0,0,1,1,1,1,i.x,i.y,0,0])}function Ra(t){t!=Fb&&(Qb(),L.bindTexture(L.TEXTURE_2D,Fb=t))}function Ob(t,i){return i=L.createShader(i),L.shaderSource(i,t),L.compileShader(i),i}function Qb(){var t;V&&(t=Jb?L.ONE:L.ONE_MINUS_SRC_ALPHA,L.blendFuncSeparate(L.SRC_ALPHA,t,L.ONE,t),L.enable(L.BLEND),L.bufferSubData(L.ARRAY_BUFFER,0,U),L.drawArraysInstanced(L.TRIANGLE_STRIP,0,4,V),V=0,Jb=xb)}function Rb(t=!1){var i=E;(V||t)&&(Qb(),t)&&i.drawImage(R,0,0)}function Sa(t,i,e,a,s,h,n,r,o,u,l=0){(1e4<=V||Jb!=xb)&&Qb();var c=11*V++;U[c++]=t,U[c++]=i,U[c++]=e,U[c++]=a,U[c++]=h,U[c++]=n,U[c++]=r,U[c++]=o,Ib[c++]=u,Ib[c++]=l,U[+c]=s}const wb=1/60;let C=[],Ga=[],Sb=0,ia=0,Tb=0,Ub=0,W=0;const Vb=[],Wb=[];function Xb(t){Vb.includes(void 0),Wb.includes(t),t&&Wb.push(t)}function Yb(){Ga=C.filter(t=>t.ca);for(const t of C)t.parent||(function t(i){if(!i.A){i.update();for(const e of i.children)t(e)}}(t),Da(t));C=C.filter(t=>!t.A)}function Zb(t){const u=I;var e=G.width=innerWidth,a=G.height=innerHeight,s=r(t,1,.8),n=r(t,0,.5),i=u.createRadialGradient(e/2,a/2,0,e/2,a/2,.7*Math.hypot(e,a));i.addColorStop(0,y(0,0,s/2*k(n),s).toString()),i.addColorStop(1,y(0,0,0,s).toString()),u.save(),u.fillStyle=i,u.fillRect(0,0,e,a),i=(t,i,e,a,s)=>{u.beginPath(),u.rect(t,i,e,s?a*l:a),(u.fillStyle=s)?u.fill():u.stroke()},n=(t,i,e,a=0,s=2*h,n,r)=>{var o=(a+s)/2;a=l*(s-a)/2,u.beginPath(),r&&u.lineTo(t,i),u.arc(t,i,e,o-a,o+a),(u.fillStyle=n)?u.fill():u.stroke()},s=(t=0,i=0)=>y([.98,.3,.57,.14][t%4]-10,.8,[0,.3,.5,.8,.9][i]).toString();const l=r(t=ha(t),.1,.5);for(u.translate(e/2,a/2),e=Math.min(6,Math.min(e,a)/99),u.scale(e,e),u.translate(-40,-35),u.lineJoin=u.lineCap="round",u.lineWidth=.1+1.9*l,u.setLineDash([99*r(t,.1,1),99]),i(7,16,18,-8,s(2,2)),i(7,8,18,4,s(2,3)),i(25,8,8,8,s(2,1)),i(25,8,-18,8),i(25,8,8,8),i(25,16,7,23,s()),i(11,39,14,-23,s(1,1)),i(11,16,14,18,s(1,2)),i(11,16,14,8,s(1,3)),i(25,16,-14,24),i(15,29,6,-9,s(2,2)),n(15,21,5,0,h/2,s(2,4),1),i(21,21,-6,9),i(37,14,9,6,s(3,2)),i(37,14,4.5,6,s(3,3)),i(37,14,9,6),i(50,20,10,-8,s(0,1)),i(50,20,6.5,-8,s(0,2)),i(50,20,3.5,-8,s(0,3)),i(50,20,10,-8),n(55,2,11.4,.5,h-.5,s(3,3)),n(55,2,11.4,.5,h/2,s(3,2),1),n(55,2,11.4,.5,h-.5),i(45,7,20,-7,s(0,2)),i(45,-1,20,4,s(0,3)),i(45,-1,20,8),e=5;e--;)n(60-6*e,30,9.9,0,2*h,s(e+2,3)),n(60-6*e,30,10,-.5,h+.5,s(e+2,2)),n(60-6*e,30,10.1,.5,h-.5,s(e+2,1));for(n(36,30,10,h/2,3*h/2),n(48,30,10,h/2,3*h/2),n(60,30,10),u.beginPath(),u.lineTo(36,20),u.lineTo(60,20),u.stroke(),n(60,30,4,h,3*h,s(3,2)),n(60,30,4,h,2*h,s(3,3)),n(60,30,4,h,3*h),e=6;e--;)u.beginPath(),u.lineTo(53,54),u.lineTo(53,40),u.lineTo(53+(1+2.9*e)*l,40),u.lineTo(53+(4+3.5*e)*l,54),u.fillStyle=s(0,e%2+2),u.fill(),e%2&&u.stroke();for(i(6,40,5,5),i(6,40,5,5,s()),i(15,54,38,-14,s()),e=3;e--;)for(a=2;a--;)n(15*e+15,47,a?7:1,h,3*h,s(e,3)),u.stroke(),n(15*e+15,47,a?7:1,0,h,s(e,2)),u.stroke();for(u.beginPath(),u.lineTo(6,40),u.lineTo(68,40),u.stroke(),u.beginPath(),u.lineTo(77,54),u.lineTo(4,54),u.stroke(),u.font="900 16px arial",u.textAlign="center",u.textBaseline="top",u.lineWidth=.1+3.9*l,e=n=0;e<8;++e)n+=u.measureText("LittleJS"[e]).width;for(e=2;e--;)for(let t=0,i=41-n/2;t<8;++t)u.fillStyle=s(t,2),a=u.measureText("LittleJS"[t]).width,u[e?"strokeText":"fillText"]("LittleJS"[t],i+a/2,55.5,17*l),i+=a;u.restore()}va=!0,Aa=.5;const $b=new hb,ac=new Db;Ab="Hello World",Cb(t=>t.aa=!!localStorage[Ab+"_"+t.id]),Xb(function(){var t,i;zb.length&&(t=zb[0],i=Tb-Bb,Bb?5<i?(Bb=0,zb.shift()):t.C(i<.5?1-i/.5:4.5<i?(i-4.5)/.5:0):Bb=Tb)});let Z;!function(i,a,s,h,n,t,e=document.body){function r(t=0){var i=t-Ub;for(Ub=t,Tb+=i/1e3,W+=i,W=Math.min(W,50),o(),t=0,W<0&&-9<W&&(t=W,W=0);0<=W;W-=1e3/60)ia=Sb++/60,cb||document.hasFocus()||(O=[[]]),Wa=Ma(),fb(),a(),Vb.forEach(t=>t()),Yb(),s(),$a();W+=t,J=u(D.width,D.height),I.imageSmoothingEnabled=E.imageSmoothingEnabled=!1,Pb(),h(),C.sort((t,i)=>t.P-i.P);for(const e of C)e.A||e.C();n(),Wb.forEach(t=>t()),Rb(),requestAnimationFrame(r)}function o(){var t,i;ua.x?(D.width=ua.x,D.height=ua.y,t=innerWidth/innerHeight,i=D.width/D.height,(R||D).style.width=D.style.width=G.style.width=t<i?"100%":"",(R||D).style.height=D.style.height=G.style.height=t<i?"":"100%"):(D.width=Math.min(innerWidth,ta.x),D.height=Math.min(innerHeight,ta.y)),G.width=D.width,G.height=D.height,J=u(D.width,D.height)}i||=()=>{},a||=()=>{},s||=()=>{},h||=()=>{},n||=()=>{},e.style.cssText="margin:0;overflow:hidden;width:100vw;height:100vh;display:flex;align-items:center;justify-content:center;background:#000;image-rendering:pixelated;user-select:none;-webkit-user-select:none;touch-action:none;-webkit-touch-callout:none",e.appendChild(D=document.createElement("canvas")),E=D.getContext("2d"),ab(),(gb=P.createGain()).connect(P.destination),gb.gain.value=.3,Kb(),e.appendChild(G=document.createElement("canvas")),I=G.getContext("2d"),D.style.cssText=G.style.cssText="position:absolute",R&&(R.style.cssText="position:absolute"),o(),e=t.map((e,a)=>new Promise(t=>{const i=new Image;i.crossOrigin="anonymous",i.onerror=i.onload=()=>{K[a]=new La(i),t()},i.src=e})),t.length||e.push(new Promise(t=>{K[0]=new La(new Image),t()})),va&&e.push(new Promise(i=>{let e=0;console.log("LittleJS Engine v1.11.10"),function t(){O=[[]],Zb(e+=.01),1<e?i():setTimeout(t,16)}()})),Promise.all(e).then(function(){new Promise(t=>t(i())).then(r)})}(function(){Q=u(32,16);for(var t=(pb=[]).length=Math.abs(Q.x*Q.y);t--;)pb[t]=0;var i,e,a,s=u(),t=new sb(s,Q),n=K[0].image,r=(E.drawImage(n,0,0),E.getImageData(0,0,n.width,n.height).data);for(s.x=Q.x;s.x--;)for(s.y=Q.y;s.y--;)r[4*(s.x+n.width*(15+Q.y-s.y))]&&(i=Math.floor(v(4,0)),e=!Math.floor(v(2,0)),a=oa(),t.setData(s,new qb(1,i,e,a)),ra(s,Q))&&(pb[(0|s.y)*Q.x+s.x|0]=1);for(t.Ca=[D,E,J,A,B],D=t.canvas,E=t.context,J=t.size.multiply(t.l.size),A=t.size.scale(.5),B=t.l.size.x,D.width=J.x,D.height=J.y,t.context.imageSmoothingEnabled=!1,Pb(),s=t.size.x;s--;)for(n=t.size.y;n--;)rb(t,u(s,n),!1);Rb(!0),[D,E,J,A,B]=t.Ca,A=u(16,8),B=32,Ba=-.01,(Z=new vb(u(16,9),0,0,0,500,h,Ja(0,16),y(1,1,1),y(0,0,0),y(0,0,0,0),y(0,0,0,0),2,.2,.2,.1,.05,.99,1,1,h,.05,.5,!0,!0)).s=.3,Z.H=2},function(){O[0]&&2&O[0][0]&&($b.play(Wa),Z.S=y(),Z.T=oa(),Z.da=Z.S.scale(1,0),Z.ea=Z.T.scale(1,0),ac.unlock()),Xa&&(B=k(B-=Math.sign(Xa)*B/5,10,300)),Pa.x&&(Z.i=Wa)},function(){},function(){Ia(u(16,8),u(20,14),void 0,y(0,0,.6),0,!1,void 0,!1),Ia(u(21,5),u(4.5),Ja(3,128))},function(){Ua("LittleJS Demo",u(J.x/2,70),80,y(0,0,1),6,y(0,0,0))},["tiles.png"]);
Binary file
@@ -9,6 +9,7 @@
9
9
  const PROGRAM_TITLE = 'Little JS Starter Project';
10
10
  const PROGRAM_NAME = 'game';
11
11
  const BUILD_FOLDER = 'build';
12
+ const USE_ROADROLLER = false; // enable for extra compression
12
13
  const sourceFiles =
13
14
  [
14
15
  '../../dist/littlejs.release.js',
@@ -42,7 +43,9 @@ Build
42
43
  (
43
44
  `${BUILD_FOLDER}/index.js`,
44
45
  sourceFiles,
45
- [closureCompilerStep, uglifyBuildStep, htmlBuildStep, zipBuildStep]
46
+ USE_ROADROLLER ?
47
+ [closureCompilerStep, uglifyBuildStep, roadrollerBuildStep, htmlBuildStep, zipBuildStep] :
48
+ [closureCompilerStep, uglifyBuildStep, htmlBuildStep, zipBuildStep]
46
49
  );
47
50
 
48
51
  console.log('');
@@ -72,6 +75,7 @@ function closureCompilerStep(filename)
72
75
  {
73
76
  console.log(`Running closure compiler...`);
74
77
 
78
+ // use closer compiler to minify the code
75
79
  const filenameTemp = filename + '.tmp';
76
80
  fs.copyFileSync(filename, filenameTemp);
77
81
  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'});
@@ -84,6 +88,12 @@ function uglifyBuildStep(filename)
84
88
  child_process.execSync(`npx uglifyjs ${filename} -c -m -o ${filename}`, {stdio: 'inherit'});
85
89
  };
86
90
 
91
+ function roadrollerBuildStep(filename)
92
+ {
93
+ console.log(`Running roadroller...`);
94
+ child_process.execSync(`npx roadroller ${filename} -o ${filename}`, {stdio: 'inherit'});
95
+ };
96
+
87
97
  function htmlBuildStep(filename)
88
98
  {
89
99
  console.log(`Building html...`);
@@ -106,7 +116,7 @@ function zipBuildStep(filename)
106
116
  {
107
117
  console.log(`Zipping...`);
108
118
 
109
- const ect = '../../../node_modules/ect-bin/vendor/win32/ect.exe';
119
+ // zip the build folder using ect
110
120
  const args = ['-9', '-strip', '-zip', `../${PROGRAM_NAME}.zip`, 'index.html', ...dataFiles];
111
- child_process.spawnSync(ect, args, {stdio: 'inherit', cwd: BUILD_FOLDER});
121
+ child_process.spawnSync('ect', args, {stdio: 'inherit', cwd: BUILD_FOLDER});
112
122
  };
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "littlejsengine",
3
- "version": "1.11.10",
3
+ "version": "1.11.13",
4
4
  "description": "LittleJS - Tiny and Fast HTML5 Game Engine",
5
5
  "main": "dist/littlejs.esm.js",
6
6
  "types": "dist/littlejs.d.ts",
@@ -166,7 +166,12 @@ class Newgrounds
166
166
  const xmlHttp = new XMLHttpRequest();
167
167
  const url = 'https://newgrounds.io/gateway_v3.php';
168
168
  xmlHttp.open('POST', url, !debugMedals && async);
169
- xmlHttp.send(formData);
169
+ try { xmlHttp.send(formData); }
170
+ catch(e)
171
+ {
172
+ debugMedals && console.log('newgrounds call failed', e);
173
+ return;
174
+ }
170
175
  debugMedals && console.log(xmlHttp.responseText);
171
176
  return xmlHttp.responseText && JSON.parse(xmlHttp.responseText);
172
177
  }
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.11.10';
33
+ const engineVersion = '1.11.13';
34
34
 
35
35
  /** Frames per second to update
36
36
  * @type {number}
@@ -82,7 +82,6 @@ export
82
82
  medalDisplayTime,
83
83
  medalDisplaySlideTime,
84
84
  medalDisplaySize,
85
- medalDisplayIconSize,
86
85
 
87
86
  // Setters for globals
88
87
  setCameraPos,
@@ -123,7 +122,6 @@ export
123
122
  setMedalDisplayTime,
124
123
  setMedalDisplaySlideTime,
125
124
  setMedalDisplaySize,
126
- setMedalDisplayIconSize,
127
125
  setMedalsPreventUnlock,
128
126
  setShowWatermark,
129
127
  setDebugKey,
@@ -97,10 +97,16 @@ let mouseWheel = 0;
97
97
  * @memberof Input */
98
98
  let isUsingGamepad = false;
99
99
 
100
- /** Prevents input continuing to the default browser handling (false by default)
100
+ /** Prevents input continuing to the default browser handling (true by default)
101
101
  * @type {boolean}
102
102
  * @memberof Input */
103
- let preventDefaultInput = false;
103
+ let inputPreventDefault = true;
104
+
105
+ /** Prevents input continuing to the default browser handling
106
+ * This is useful to disable for html menus so the browser can handle input normally
107
+ * @param {boolean} preventDefault
108
+ * @memberof Input */
109
+ function setInputPreventDefault(preventDefault) { inputPreventDefault = preventDefault; }
104
110
 
105
111
  /** Returns true if gamepad button is down
106
112
  * @param {number} button
@@ -180,7 +186,6 @@ function inputInit()
180
186
  if (inputWASDEmulateDirection)
181
187
  inputData[0][remapKey(e.code)] = 3;
182
188
  }
183
- preventDefaultInput && e.preventDefault();
184
189
  }
185
190
 
186
191
  onkeyup = (e)=>
@@ -210,7 +215,7 @@ function inputInit()
210
215
  isUsingGamepad = false;
211
216
  inputData[0][e.button] = 3;
212
217
  mousePosScreen = mouseEventToScreen(e);
213
- e.button && e.preventDefault();
218
+ inputPreventDefault && e.button && e.preventDefault();
214
219
  }
215
220
  onmouseup = (e)=> inputData[0][e.button] = inputData[0][e.button] & 2 | 4;
216
221
  onmousemove = (e)=> mousePosScreen = mouseEventToScreen(e);
@@ -394,7 +399,7 @@ function touchInputInit()
394
399
  wasTouching = touching;
395
400
 
396
401
  // prevent default handling like copy and magnifier lens
397
- if (document.hasFocus()) // allow document to get focus
402
+ if (inputPreventDefault && document.hasFocus()) // allow document to get focus
398
403
  e.preventDefault();
399
404
 
400
405
  // must return true so the document will get focus
@@ -134,8 +134,9 @@ class Medal
134
134
  {
135
135
  const context = overlayContext;
136
136
  const width = min(medalDisplaySize.x, mainCanvas.width);
137
+ const height = medalDisplaySize.y;
137
138
  const x = overlayCanvas.width - width;
138
- const y = -medalDisplaySize.y*hidePercent;
139
+ const y = -height*hidePercent;
139
140
 
140
141
  // draw containing rect and clip to that region
141
142
  context.save();
@@ -143,25 +144,34 @@ class Medal
143
144
  context.fillStyle = new Color(.9,.9,.9).toString();
144
145
  context.strokeStyle = new Color(0,0,0).toString();
145
146
  context.lineWidth = 3;
146
- context.rect(x, y, width, medalDisplaySize.y);
147
+ context.rect(x, y, width, height);
147
148
  context.fill();
148
149
  context.stroke();
149
150
  context.clip();
150
151
 
151
- // draw the icon and text
152
- this.renderIcon(vec2(x+15+medalDisplayIconSize/2, y+medalDisplaySize.y/2));
153
- const pos = vec2(x+medalDisplayIconSize+30, y+28);
154
- drawTextScreen(this.name, pos, 38, new Color(0,0,0), 0, undefined, 'left');
155
- pos.y += 32;
156
- drawTextScreen(this.description, pos, 24, new Color(0,0,0), 0, undefined, 'left');
152
+ // draw the icon
153
+ const gap = vec2(.1, .05).scale(height);
154
+ const medalDisplayIconSize = height - 2*gap.x;
155
+ this.renderIcon(vec2(x + gap.x + medalDisplayIconSize/2, y + height/2), medalDisplayIconSize);
156
+
157
+ // draw the name
158
+ const nameSize = height*.5;
159
+ const descriptionSize = height*.3;
160
+ const pos = vec2(x + medalDisplayIconSize + 2*gap.x, y + gap.y*2 + nameSize/2);
161
+ const textWidth = width - medalDisplayIconSize - 3*gap.x;
162
+ drawTextScreen(this.name, pos, nameSize, new Color(0,0,0), 0, undefined, 'left', undefined, textWidth);
163
+
164
+ // draw the description
165
+ pos.y = y + height - gap.y*2 - descriptionSize/2;
166
+ drawTextScreen(this.description, pos, descriptionSize, new Color(0,0,0), 0, undefined, 'left', undefined, textWidth);
157
167
  context.restore();
158
168
  }
159
169
 
160
170
  /** Render the icon for a medal
161
171
  * @param {Vector2} pos - Screen space position
162
- * @param {Number} [size=medalDisplayIconSize] - Screen space size
172
+ * @param {Number} size - Screen space size
163
173
  */
164
- renderIcon(pos, size=medalDisplayIconSize)
174
+ renderIcon(pos, size)
165
175
  {
166
176
  // draw the image or icon
167
177
  if (this.image)
@@ -173,7 +173,8 @@ class EngineObject
173
173
  if (this.groundObject)
174
174
  {
175
175
  // apply friction in local space of ground object
176
- const groundSpeed = this.groundObject.velocity ? this.groundObject.velocity.x : 0;
176
+ const groundSpeed = this.groundObject != this && this.groundObject.velocity ?
177
+ this.groundObject.velocity.x : 0;
177
178
  this.velocity.x = groundSpeed + (this.velocity.x - groundSpeed) * this.friction;
178
179
  this.groundObject = undefined;
179
180
  //debugOverlay && debugPhysics && debugPoint(this.pos.subtract(vec2(0,this.size.y/2)), '#0f0');
@@ -300,6 +301,7 @@ class EngineObject
300
301
  this.pos.y = (oldPos.y-this.size.y/2|0)+this.size.y/2+epsilon;
301
302
 
302
303
  // set ground object to self for tile collision
304
+ // TODO: rework system so tile collision is its own object
303
305
  this.groundObject = this;
304
306
  }
305
307
  else
@@ -64,6 +64,7 @@ let fontDefault = 'arial';
64
64
  let showSplashScreen = false;
65
65
 
66
66
  /** Disables all rendering, audio, and input for servers
67
+ * - Must be set before startup to take effect
67
68
  * @type {boolean}
68
69
  * @default
69
70
  * @memberof Settings */
@@ -73,12 +74,14 @@ let headlessMode = false;
73
74
  // WebGL settings
74
75
 
75
76
  /** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
77
+ * - Must be set before startup to take effect
76
78
  * @type {boolean}
77
79
  * @default
78
80
  * @memberof Settings */
79
81
  let glEnable = true;
80
82
 
81
83
  /** Fixes slow rendering in some browsers by not compositing the WebGL canvas
84
+ * - Must be set before startup to take effect
82
85
  * @type {boolean}
83
86
  * @default
84
87
  * @memberof Settings */
@@ -179,6 +182,7 @@ let inputWASDEmulateDirection = true;
179
182
 
180
183
  /** True if touch input is enabled for mobile devices
181
184
  * - Touch events will be routed to mouse events
185
+ * - Must be set before startup to take effect
182
186
  * @type {boolean}
183
187
  * @default
184
188
  * @memberof Settings */
@@ -186,7 +190,7 @@ let touchInputEnable = true;
186
190
 
187
191
  /** True if touch gamepad should appear on mobile devices
188
192
  * - Supports left analog stick, 4 face buttons and start button (button 9)
189
- * - Must be set by end of gameInit to be activated
193
+ * - Must be set before startup to take effect
190
194
  * @type {boolean}
191
195
  * @default
192
196
  * @memberof Settings */
@@ -264,12 +268,6 @@ let medalDisplaySlideTime = .5;
264
268
  * @memberof Settings */
265
269
  let medalDisplaySize = vec2(640, 80);
266
270
 
267
- /** Size of icon in medal display
268
- * @type {number}
269
- * @default
270
- * @memberof Settings */
271
- let medalDisplayIconSize = 50;
272
-
273
271
  /** Set to stop medals from being unlockable (like if cheats are enabled)
274
272
  * @type {boolean}
275
273
  * @default
@@ -474,11 +472,6 @@ function setMedalDisplaySlideTime(time) { medalDisplaySlideTime = time; }
474
472
  * @memberof Settings */
475
473
  function setMedalDisplaySize(size) { medalDisplaySize = size; }
476
474
 
477
- /** Set size of icon in medal display
478
- * @param {number} size
479
- * @memberof Settings */
480
- function setMedalDisplayIconSize(size) { medalDisplayIconSize = size; }
481
-
482
475
  /** Set to stop medals from being unlockable
483
476
  * @param {boolean} preventUnlock
484
477
  * @memberof Settings */