59 lines
161 KiB
JavaScript
59 lines
161 KiB
JavaScript
|
var ir=Object.defineProperty,Hi=Object.defineProperties;var zi=Object.getOwnPropertyDescriptors;var rr=Object.getOwnPropertySymbols;var Ji=Object.prototype.hasOwnProperty,Qi=Object.prototype.propertyIsEnumerable;var Nt=(i,t,l)=>t in i?ir(i,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[t]=l,P=(i,t)=>{for(var l in t||(t={}))Ji.call(t,l)&&Nt(i,l,t[l]);if(rr)for(var l of rr(t))Qi.call(t,l)&&Nt(i,l,t[l]);return i},D=(i,t)=>Hi(i,zi(t));var a=(i,t)=>ir(i,"name",{value:t,configurable:!0});var b=(i,t,l)=>(Nt(i,typeof t!="symbol"?t+"":t,l),l);var sr=(i,t,l)=>new Promise((w,U)=>{var p=q=>{try{A(l.next(q))}catch(V){U(V)}},S=q=>{try{A(l.throw(q))}catch(V){U(V)}},A=q=>q.done?w(q.value):Promise.resolve(q.value).then(p,S);A((l=l.apply(i,t)).next())});var or=(()=>{for(var i=new Uint8Array(128),t=0;t<64;t++)i[t<26?t+65:t<52?t+71:t<62?t-4:t*4-205]=t;return l=>{for(var w=l.length,U=new Uint8Array((w-(l[w-1]=="=")-(l[w-2]=="="))*3/4|0),p=0,S=0;p<w;){var A=i[l.charCodeAt(p++)],q=i[l.charCodeAt(p++)],V=i[l.charCodeAt(p++)],j=i[l.charCodeAt(p++)];U[S++]=A<<2|q>>4,U[S++]=q<<4|V>>2,U[S++]=V<<6|j}return U}})();var $=class extends Map{constructor(...t){super(...t);b(this,"_lastID");this._lastID=0}push(t){let l=this._lastID;return this.set(l,t),this._lastID++,l}pushd(t){let l=this.push(t);return()=>this.delete(l)}};a($,"IDList");function jt(i,t){let l=typeof i,w=typeof t;if(l!==w)return!1;if(l==="object"&&w==="object"){let U=Object.keys(i),p=Object.keys(t);if(U.length!==p.length)return!1;for(let S of U){let A=i[S],q=t[S];if(!(typeof A=="function"&&typeof q=="function")&&!jt(A,q))return!1}return!0}return i===t}a(jt,"deepEq");function Yt(i,t){let l=document.createElement("a");document.body.appendChild(l),l.setAttribute("style","display: none"),l.href=i,l.download=t,l.click(),document.body.removeChild(l)}a(Yt,"downloadURL");function ur(i,t){let l=URL.createObjectURL(i);Yt(l,t),URL.revokeObjectURL(l)}a(ur,"downloadBlob");function cr(i){return i.match(/^data:\w+\/\w+;base64,.+/)}a(cr,"isDataURL");var lr=(()=>{let i=0;return()=>i++})(),ar=new Set;function B(i,t){ar.has(i)||(ar.add(i),console.warn(`${i} is deprecated. Use ${t} instead.`))}a(B,"deprecateMsg");var T=a((i,t,l)=>(...w)=>(B(i,t),l(...w)),"deprecate");function he(i){return i*Math.PI/180}a(he,"deg2rad");function Xt(i){return i*180/Math.PI}a(Xt,"rad2deg");function z(i,t,l){return t>l?z(i,l,t):Math.min(Math.max(i,t),l)}a(z,"clamp");function Ve(i,t,l){return i+(t-i)*l}a(Ve,"lerp");function dt(i,t,l,w,U){return w+(i-t)/(l-t)*(U-w)}a(dt,"map");function dr(i,t,l,w,U){return z(dt(i,t,l,w,U),w,U)}a(dr,"mapc");var N=class{constructor(t=0,l=t){b(this,"x",0);b(this,"y",0);this.x=t,this.y=l}static fromAngle(t){let l=he(t);return new N(Math.cos(l),Math.sin(l))}clone(){return new N(this.x,this.y)}add(...t){let l=f(...t);return new N(this.x+l.x,this.y+l.y)}sub(...t){let l=f(...t);return new N(this.x-l.x,this.y-l.y)}scale(...t){let l=f(...t);return new N(this.x*l.x,this.y*l.y)}dist(...t){let l=f(...t);return Math.sqrt((this.x-l.x)*(this.x-l.x)+(this.y-l.y)*(this.y-l.y))}len(){return this.dist(new N(0,0))}unit(){return this.scale(1/this.len())}normal(){return new N(this.y,-this.x)}dot(t){return this.x*t.x+this.y*t.y}angle(...t){let l=f(...t);return Xt(Math.atan2(this.y-l.y,this.x-l.x))}lerp(t,l){return new N(Ve(this.x,t.x,l),Ve(this.y,t.y,l))}toFixed(t){return new N(Number(this.x.toFixed(t)),Number(this.y.toFixed(t)))}eq(t){return this.x===t.x&&this.y===t.y}toString(){return`(${this.x.toFixed(2)}, ${this.y.toFixed(2)})`}str(){return this.toString()}},L=N;a(L,"Vec2"),b(L,"LEFT",new N(-1,0)),b(L,"RIGHT",new N(1,0)),b(L,"UP",new N(0,-1)),b(L,"DOWN",new N(0,1));function f(...i){if(i.length===1){if(i[0]instanceof L)return f(i[0].x,i[0].y);if(Array.isArray(i[0])&&i[0].length===2)return f.apply(null,i[0])}return new L(...i)}a(f,"vec2");var Fe=class{constructor(t,l,w){b(this,"x",0);b(this,"y",0);b(this,"z",0);this.x=t,this.y=l,this.z=w}xy(){return f(this.x,this.y)}};a(Fe,"Vec3");var de=a((i,t,l)=>new Fe(i,t,l),"vec3"),ue=class{constructor(t,l,w){b(this,"r",255);b(this,"g",255);b(this,"b",255);this.r=z(t,0,255
|
||
|
attribute vec3 a_pos;
|
||
|
attribute vec2 a_uv;
|
||
|
attribute vec4 a_color;
|
||
|
|
||
|
varying vec3 v_pos;
|
||
|
varying vec2 v_uv;
|
||
|
varying vec4 v_color;
|
||
|
|
||
|
vec4 def_vert() {
|
||
|
return vec4(a_pos, 1.0);
|
||
|
}
|
||
|
|
||
|
{{user}}
|
||
|
|
||
|
void main() {
|
||
|
vec4 pos = vert(a_pos, a_uv, a_color);
|
||
|
v_pos = a_pos;
|
||
|
v_uv = a_uv;
|
||
|
v_color = a_color;
|
||
|
gl_Position = pos;
|
||
|
}
|
||
|
`,Us=`
|
||
|
precision mediump float;
|
||
|
|
||
|
varying vec3 v_pos;
|
||
|
varying vec2 v_uv;
|
||
|
varying vec4 v_color;
|
||
|
|
||
|
uniform sampler2D u_tex;
|
||
|
|
||
|
vec4 def_frag() {
|
||
|
return v_color * texture2D(u_tex, v_uv);
|
||
|
}
|
||
|
|
||
|
{{user}}
|
||
|
|
||
|
void main() {
|
||
|
gl_FragColor = frag(v_pos, v_uv, v_color, u_tex);
|
||
|
if (gl_FragColor.a == 0.0) {
|
||
|
discard;
|
||
|
}
|
||
|
}
|
||
|
`,sn=`
|
||
|
vec4 vert(vec3 pos, vec2 uv, vec4 color) {
|
||
|
return def_vert();
|
||
|
}
|
||
|
`,on=`
|
||
|
vec4 frag(vec3 pos, vec2 uv, vec4 color, sampler2D tex) {
|
||
|
return def_frag();
|
||
|
}
|
||
|
`,ys=new Set(["id","require"]),bs=new Set(["add","load","update","draw","destroy","inspect"]);function kr(i){return i==="pressed"||i==="rpressed"?"down":i==="released"?"up":i}a(kr,"processButtonState");function xs(i){i.requestFullscreen?i.requestFullscreen():i.webkitRequestFullscreen&&i.webkitRequestFullscreen()}a(xs,"enterFullscreen");function vs(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullScreen&&document.webkitExitFullScreen()}a(vs,"exitFullscreen");function Es(){return document.fullscreenElement||document.webkitFullscreenElement}a(Es,"getFullscreenElement");function Ye(i){switch(i){case"topleft":return f(-1,-1);case"top":return f(0,-1);case"topright":return f(1,-1);case"left":return f(-1,0);case"center":return f(0,0);case"right":return f(1,0);case"botleft":return f(-1,1);case"bot":return f(0,1);case"botright":return f(1,1);default:return i}}a(Ye,"originPt");function Gr(){return new AudioBuffer({length:1,numberOfChannels:1,sampleRate:44100})}a(Gr,"createEmptyAudioBuffer");var no=a((i={})=>{let t=(()=>{var s,o,d;let e=(s=i.root)!=null?s:document.body;e===document.body&&(document.body.style.width="100%",document.body.style.height="100%",document.body.style.margin="0px",document.documentElement.style.width="100%",document.documentElement.style.height="100%");let n=(o=i.canvas)!=null?o:(()=>{let h=document.createElement("canvas");return e.appendChild(h),h})(),r=(d=i.scale)!=null?d:1;i.width&&i.height&&!i.stretch&&!i.letterbox?(n.width=i.width*r,n.height=i.height*r):(n.width=n.parentElement.offsetWidth,n.height=n.parentElement.offsetHeight);let u=["outline: none","cursor: default"];i.crisp&&(u.push("image-rendering: pixelated"),u.push("image-rendering: crisp-edges")),n.style=u.join(";"),n.setAttribute("tabindex","0");let c=n.getContext("webgl",{antialias:!0,depth:!0,stencil:!0,alpha:!0,preserveDrawingBuffer:!0});return{canvas:n,scale:r,gl:c,keyStates:{},mouseStates:{},charInputted:[],isMouseMoved:!1,isKeyPressed:!1,isKeyPressedRepeat:!1,isKeyReleased:!1,mousePos:f(0,0),mouseDeltaPos:f(0,0),time:0,realTime:0,skipTime:!1,dt:0,numFrames:0,isTouch:"ontouchstart"in window||navigator.maxTouchPoints>0,loopID:null,stopped:!1,paused:!1,fpsCounter:new Be,loaded:!1}})(),l=(()=>{var d;let e=t.gl,n=cn(sn,on),r=Ke(new ImageData(new Uint8ClampedArray([255,255,255,255]),1,1)),u=(d=i.background)!=null?d:E(0,0,0);if(i.background){let h=v.fromArray(i.background);e.clearColor(h.r/255,h.g/255,h.b/255,1)}e.enable(e.BLEND),e.enable(e.SCISSOR_TEST),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);let c=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,c),e.vertexAttribPointer(0,3,e.FLOAT,!1,je*4,0),e.enableVertexAttribArray(0),e.vertexAttribPointer(1,2,e.FLOAT,!1,je*4,12),e.enableVertexAttribArray(1),e.vertexAttribPointer(2,4,e.FLOAT,!1,je*4,20),e.enableVertexAttribArray(2),e.bufferData(e.ARRAY_BUFFER,bt*4,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null);let s=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,s),e.bufferData(e.ELEMENT_ARRAY_BUFFER,bt*2,e.DYNAMIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null);let o=Ke(new ImageData(new Uint8ClampedArray([128,128,128,255,190,190,190,255,190,190,190,255,128,128,128,255]),2,2),{wrap:"repeat",filter:"nearest"});return{drawCalls:0,lastDrawCalls:0,defShader:n,curShader:n,defTex:r,curTex:r,curUniform:{},vbuf:c,ibuf:s,vqueue:[],iqueue:[],transform:new R,transformStack:[],bgTex:o,width:i.width,height:i.height,viewport:{x:0,y:0,width:e.drawingBufferWidth,height:e.drawingBufferHeight}}})();Un();let w=(()=>{let e=new(window.AudioContext||window.webkitAudioContext),n=e.createGain();n.connect(e.destination);let r={buf:Gr()};return e.decodeAudioData(Mr.buffer.slice(0),u=>{r.buf=u},()=>{throw new Error("Failed to load burp.")}),{ctx:e,masterNode:n,burpSnd:r}})(),U={numLoading:0,numLoaded:0,urlPrefix:"",sprites:{},sounds:{},shaders:{},fonts:{}},p={events:{},objEvents:{},root:En([]),timers:new $,layers:{},defLayer:null,gravity:Vr,on(e,n){return this.events[e]||(this.events[e]=new $),this.events[e].pushd(n)},trigger(e,...n){this.events[e]&&this.events
|
||
|
`)throw new Error(u);return{bind(){r.useProgram(h)},unbind(){r.useProgram(null)},send(m){this.bind();for(let g in m){let y=m[g],x=r.getUniformLocation(h,g);typeof y=="number"?r.uniform1f(x,y):y instanceof R?r.uniformMatrix4fv(x,!1,new Float32Array(y.m)):y instanceof v?r.uniform4f(x,y.r,y.g,y.b,y.a):y instanceof Fe?r.uniform3f(x,y.x,y.y,y.z):y instanceof L&&r.uniform2f(x,y.x,y.y)}this.unbind()}}}a(cn,"makeShader");function Nr(e,n,r,u){let c=e.width/n,s=e.height/r,o=1/c,d=1/s,h={},m=u.split("").entries();for(let[g,y]of m)h[y]=f(g%c*o,Math.floor(g/c)*d);return{tex:e,map:h,qw:o,qh:d}}a(Nr,"makeFont");function Tt(e,n,r,u=l.defTex,c=l.defShader,s={}){u=u!=null?u:l.defTex,c=c!=null?c:l.defShader,(u!==l.curTex||c!==l.curShader||!jt(l.curUniform,s)||l.vqueue.length+e.length*je>bt||l.iqueue.length+n.length>bt)&&ln();for(let o of e){let d=r?l.transform:p.cam.transform.mult(l.transform),h=jr(d.multVec2(o.pos.xy()));l.vqueue.push(h.x,h.y,o.pos.z,o.uv.x,o.uv.y,o.color.r/255,o.color.g/255,o.color.b/255,o.opacity)}for(let o of n)l.iqueue.push(o+l.vqueue.length/je-e.length);l.curTex=u,l.curShader=c,l.curUniform=s}a(Tt,"drawRaw");function ln(){if(!l.curTex||!l.curShader||l.vqueue.length===0||l.iqueue.length===0)return;let e=t.gl;l.curShader.send(l.curUniform),e.bindBuffer(e.ARRAY_BUFFER,l.vbuf),e.bufferSubData(e.ARRAY_BUFFER,0,new Float32Array(l.vqueue)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l.ibuf),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,new Uint16Array(l.iqueue)),l.curShader.bind(),l.curTex.bind(),e.drawElements(e.TRIANGLES,l.iqueue.length,e.UNSIGNED_SHORT,0),l.curTex.unbind(),l.curShader.unbind(),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),l.iqueue=[],l.vqueue=[],l.drawCalls++}a(ln,"flush");function He(){t.gl.clear(t.gl.COLOR_BUFFER_BIT),i.background||pe({width:F(),height:G(),quad:new k(0,0,F()*t.scale/Fr,G()*t.scale/Fr),tex:l.bgTex,fixed:!0}),l.drawCalls=0,l.transformStack=[],l.transform=new R}a(He,"frameStart");function ze(){ln(),l.lastDrawCalls=l.drawCalls}a(ze,"frameEnd");function Ts(){return l.lastDrawCalls}a(Ts,"drawCalls");function jr(e){return f(e.x/F()*2-1,-e.y/G()*2+1)}a(jr,"screen2ndc");function Ss(e){return f((e.x+1)/2*F(),-(e.y-1)/2*G())}a(Ss,"ndc2screen");function Cs(e){l.transform=e.clone()}a(Cs,"applyMatrix");function I(...e){if(e[0]===void 0)return;let n=f(...e);n.x===0&&n.y===0||(l.transform=l.transform.translate(n))}a(I,"pushTranslate");function ne(...e){if(e[0]===void 0)return;let n=f(...e);n.x===1&&n.y===1||(l.transform=l.transform.scale(n))}a(ne,"pushScale");function Rs(e){!e||(l.transform=l.transform.rotateX(e))}a(Rs,"pushRotateX");function Ws(e){!e||(l.transform=l.transform.rotateY(e))}a(Ws,"pushRotateY");function Je(e){!e||(l.transform=l.transform.rotateZ(e))}a(Je,"pushRotateZ");function re(){l.transformStack.push(l.transform.clone())}a(re,"pushTransform");function ie(){l.transformStack.length>0&&(l.transform=l.transformStack.pop())}a(ie,"popTransform");function pe(e){var h;if(e.width===void 0||e.height===void 0)throw new Error('drawUVQuad() requires property "width" and "height".');if(e.width<=0||e.height<=0)return;let n=e.width,r=e.height,c=Ye(e.origin||Ne).scale(f(n,r).scale(-.5)),s=e.quad||new k(0,0,1,1),o=e.color||E(255,255,255),d=(h=e.opacity)!=null?h:1;re(),I(e.pos),Je(e.angle),ne(e.scale),I(c),Tt([{pos:de(-n/2,r/2,0),uv:f(e.flipX?s.x+s.w:s.x,e.flipY?s.y:s.y+s.h),color:o,opacity:d},{pos:de(-n/2,-r/2,0),uv:f(e.flipX?s.x+s.w:s.x,e.flipY?s.y+s.h:s.y),color:o,opacity:d},{pos:de(n/2,-r/2,0),uv:f(e.flipX?s.x:s.x+s.w,e.flipY?s.y+s.h:s.y),color:o,opacity:d},{pos:de(n/2,r/2,0),uv:f(e.flipX?s.x:s.x+s.w,e.flipY?s.y:s.y+s.h),color:o,opacity:d}],[0,1,3,1,2,3],e.fixed,e.tex,e.shader,e.uniform),ie()}a(pe,"drawUVQuad");function Yr(e){var s;if(!e.tex)throw new Error('drawTexture() requires property "tex".');let n=(s=e.quad)!=null?s:new k(0,0,1,1),r=e.tex.width*n.w,u=e.tex.height*n.h,c=f(1);if(e.tiled){let o=Math.ceil((e.width||r)/r),d=Math.ceil((e.height||u)/u),m=Ye(e.origin||Ne).add(f(1,1)).scale(.5).scale(o*r,d*u);for(let g=0;g<o;g++)for(let y=0;y<d;y++)pe(D(P({},e),{pos:(e.pos||f(0)).ad
|
||
|
`?(x+=g,y=0,ee=null,M.push(oe),O.push(M),M=[]):(e.width?y+m>e.width:!1)&&(x+=g,y=0,ee!=null&&(te-=M.length-ee,oe=c[te],M=M.slice(0,ee)),ee=null,O.push(M),M=[]),oe!==`
|
||
|
`&&(M.push(oe),y+=m,oe===" "&&(ee=M.length)),W=Math.max(W,y),te++}O.push(M),e.width&&(W=e.width);let Ae=[],Oe=f(e.pos||0),_=Ye(e.origin||Ne).scale(.5),se=-_.x*m-(_.x+.5)*(W-m),Ie=-_.y*g-(_.y+.5)*(x-g),ut=0;return O.forEach((oe,Bi)=>{let Ni=(W-oe.length*m)*(_.x+.5);oe.forEach((ct,ji)=>{var tr;let Gt=n.map[ct],Yi=ji*m,$i=Bi*g;if(Gt){let _t={tex:n.tex,quad:new k(Gt.x,Gt.y,n.qw,n.qh),ch:ct,pos:f(Oe.x+Yi+se+Ni,Oe.y+$i+Ie),opacity:e.opacity,color:(tr=e.color)!=null?tr:E(255,255,255),scale:h,angle:0,uniform:e.uniform,fixed:e.fixed};if(e.transform){let lt=typeof e.transform=="function"?e.transform(ut,ct):e.transform;lt&&mn(_t,lt)}if(r[ut]){let{styles:lt,localIdx:Xi}=r[ut];for(let Ki of lt){let Bt=e.styles[Ki],nr=typeof Bt=="function"?Bt(Xi,ct):Bt;nr&&mn(_t,nr)}}Ae.push(_t)}ut+=1})}),{width:W,height:x,chars:Ae}}a(me,"formatText");function Xr(e){we(me(e))}a(Xr,"drawText");function we(e){for(let n of e.chars)pe({tex:n.tex,width:n.tex.width*n.quad.w,height:n.tex.height*n.quad.h,pos:n.pos,scale:n.scale,angle:n.angle,color:n.color,opacity:n.opacity,quad:n.quad,origin:"center",uniform:n.uniform,fixed:n.fixed})}a(we,"drawFormattedText");function Un(){let e=t.gl,n=e.drawingBufferWidth,r=e.drawingBufferHeight,u=F(),c=G();if(vn()){let s=window.innerWidth,o=window.innerHeight,d=s/o,h=n/r;if(d>h){let m=window.innerHeight*h;l.viewport={x:(s-m)/2,y:0,width:m,height:o}}else{let m=window.innerWidth/h;l.viewport={x:0,y:(o-m)/2,width:s,height:m}}return}if(i.letterbox){if(!i.width||!i.height)throw new Error("Letterboxing requires width and height defined.");let s=n/r,o=i.width/i.height;if(s>o){i.stretch||(l.width=r*o,l.height=r);let d=r*o,h=r,m=(n-d)/2;e.scissor(m,0,d,h),e.viewport(m,0,d,r),l.viewport={x:m,y:0,width:d,height:r}}else{i.stretch||(l.width=n,l.height=n/o);let d=n,h=n/o,m=(r-h)/2;e.scissor(0,m,d,h),e.viewport(0,m,n,h),l.viewport={x:0,y:m,width:n,height:h}}return}if(i.stretch){if(!i.width||!i.height)throw new Error("Stretching requires width and height defined.");e.viewport(0,0,n,r),l.viewport={x:0,y:0,width:n,height:r};return}l.width=n/t.scale,l.height=r/t.scale,e.viewport(0,0,n,r),l.viewport={x:0,y:0,width:n,height:r}}a(Un,"updateViewport");function F(){return l.width}a(F,"width");function G(){return l.height}a(G,"height"),t.canvas.addEventListener("mousemove",e=>{t.mousePos=f((e.offsetX-l.viewport.x)*F()/l.viewport.width,(e.offsetY-l.viewport.y)*G()/l.viewport.height),t.mouseDeltaPos=f(e.movementX,e.movementY).scale(1/t.scale),t.isMouseMoved=!0}),t.canvas.addEventListener("mousedown",e=>{let n=Dr[e.button];n&&(t.mouseStates[n]="pressed")}),t.canvas.addEventListener("mouseup",e=>{let n=Dr[e.button];n&&(t.mouseStates[n]="released")}),t.canvas.addEventListener("keydown",e=>{let n=Pr[e.key]||e.key.toLowerCase();ls.includes(n)&&e.preventDefault(),n.length===1&&t.charInputted.push(e.key),n==="space"&&t.charInputted.push(" "),e.repeat?(t.isKeyPressedRepeat=!0,t.keyStates[n]="rpressed"):(t.isKeyPressed=!0,t.keyStates[n]="pressed")}),t.canvas.addEventListener("keyup",e=>{let n=Pr[e.key]||e.key.toLowerCase();t.keyStates[n]="released",t.isKeyReleased=!0}),t.canvas.addEventListener("touchstart",e=>{if(!i.touchToMouse)return;e.preventDefault();let n=e.touches[0];t.mousePos=f(n.clientX,n.clientY).scale(1/t.scale),t.mouseStates.left="pressed"}),t.canvas.addEventListener("touchmove",e=>{if(!i.touchToMouse)return;e.preventDefault();let n=e.touches[0];t.mousePos=f(n.clientX,n.clientY).scale(1/t.scale),t.isMouseMoved=!0}),t.canvas.addEventListener("touchend",e=>{!i.touchToMouse||(t.mouseStates.left="released")}),t.canvas.addEventListener("touchcancel",e=>{!i.touchToMouse||(t.mouseStates.left="released")}),t.canvas.addEventListener("touchstart",e=>{[...e.changedTouches].forEach(n=>{p.trigger("onTouchStart",n.identifier,f(n.clientX,n.clientY).scale(1/t.scale))})}),t.canvas.addEventListener("touchmove",e=>{[...e.changedTouches].forEach(n=>{p.trigger("onTouchMove",n.identifier,f(n.clientX,n.clientY).scale(1/t.scale))})}),t.canvas.addEventListener("touchend",e=>{[...e.changedTouches].forEach(n=>{p.trigger("onTouchEnd",n.identifier,f(n.clientX,n.clientY).sca
|
||
|
`))}Hn(f(8/t.scale),`FPS: ${C.fps()}`)}if(C.paused){re(),I(F(),0),ne(1/t.scale),I(-8,8);let r=32;Q({width:r,height:r,origin:"topright",color:E(0,0,0),opacity:.8,radius:4,fixed:!0});for(let u=1;u<=2;u++)Q({width:4,height:r*.6,origin:"center",pos:f(-r/3*u,r*.5),color:E(255,255,255),radius:2,fixed:!0});ie()}if(C.timeScale!==1){re(),I(F(),G()),ne(1/t.scale),I(-8,-8);let r=8,u=me({text:C.timeScale.toFixed(1),font:U.fonts[rn],size:16,color:E(255,255,255),pos:f(-r),origin:"botright",fixed:!0});Q({width:u.width+r*2+r*4,height:u.height+r*2,origin:"botright",color:E(0,0,0),opacity:.8,radius:4,fixed:!0});for(let c=0;c<2;c++){let s=C.timeScale<1;fn({p1:f(-u.width-r*(s?2:3.5),-r),p2:f(-u.width-r*(s?2:3.5),-r-u.height),p3:f(-u.width-r*(s?3.5:2),-r-u.height/2),pos:f(-c*r*1+(s?-r*.5:0),0),color:E(255,255,255),fixed:!0})}we(u),ie()}if(C.curRecording&&(re(),I(0,G()),ne(1/t.scale),I(24,-24),Ct({radius:12,color:E(255,0,0),opacity:Kt(0,1,nt()*4),fixed:!0}),ie()),C.showLog&&p.logs.length>0){re(),I(0,G()),ne(1/t.scale),I(8,-8);let r=8,u=(n=i.logMax)!=null?n:1;p.logs.length>u&&(p.logs=p.logs.slice(0,u));let c=me({text:p.logs.join(`
|
||
|
`),font:U.fonts[rn],pos:f(r,-r),origin:"botleft",size:16,width:F()*t.scale*.6,lineSpacing:r/2,fixed:!0,styles:{time:{color:E(127,127,127)},info:{color:E(255,255,255)},error:{color:E(255,0,127)}}});Q({width:c.width+r*2,height:c.height+r*2,origin:"botleft",color:E(0,0,0),radius:4,opacity:.8,fixed:!0}),we(c),ie()}}a(zn,"drawDebug"),i.debug!==!1&&In(),i.burp&&Vn(),window.addEventListener("error",e=>{C.error(`Error: ${e.error.message}`),zr(),Jn(()=>{A()===1&&(He(),zn(),ze())})});function Jn(e){let n=a(r=>{if(document.visibilityState!=="visible"){t.loopID=requestAnimationFrame(n);return}let u=r/1e3,c=u-t.realTime;t.realTime=u,t.skipTime||(t.dt=c,t.time+=t.dt,t.fpsCounter.tick(t.dt)),t.skipTime=!1,t.numFrames++,e();for(let s in t.keyStates)t.keyStates[s]=kr(t.keyStates[s]);for(let s in t.mouseStates)t.mouseStates[s]=kr(t.mouseStates[s]);t.charInputted=[],t.isMouseMoved=!1,t.isKeyPressed=!1,t.isKeyPressedRepeat=!1,t.isKeyReleased=!1,t.loopID=requestAnimationFrame(n)},"frame");t.stopped=!1,t.loopID=requestAnimationFrame(n)}a(Jn,"run"),Jn(()=>{Un(),t.loaded?(p.trigger("input"),C.paused||Kn(),He(),Gi(),i.debug!==!1&&zn(),ze()):(He(),_i(),ze())}),X("apl386",Tr,45,74),X("apl386o",Sr,45,74),X("sink",Cr,6,8,{chars:"\u2588\u263A\u263B\u2665\u2666\u2663\u2660\u25CF\u25CB\u25AA\u25A1\u25A0\u25D8\u266A\u266B\u2261\u25BA\u25C4\u2302\xDE\xC0\xDF\xD7\xA5\u2191\u2193\u2192\u2190\u25CC\u25CF\u25BC\u25B2 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u03A7\u2591\u2592\u2593\u1E00\u1E01\u1E02\u2502\u252C\u2524\u250C\u2510\u1E03\u1E04\u253C\u1E05\u1E06\u1E07\u1E08\u1E09\u1E0A\u1E0B\u1E0C\u2500\u251C\u2534\u2514\u2518\u1E0D\u1E0E\u205E\u1E0F\u1E10\u1E11\u1E12\u1E13\u1E14\u1E15\u1E16\u1E17\u1E18\u2584\u1E19\u1E1A\u1E1B\u1E1C\u2026\u1E1D\u1E1E\u1E1F\u1E20\u1E21\u1E22\u1E23\u1E24\u1E25\u1E26\u258C\u2590\u1E27\u1E28\u1E29\u1E2A\u1E2B\u1E2C\u1E2D\u1E2E\u1E2F\u1E30\u1E31\u1E32\u1E33\u1E34\u1E35\u1E36\u1E37\u1E38\u1E39\u1E3A\u1E3B\u1E3C\u1E3D\u1E3E\u1E3F\u1E40\u1E41\u1E42\u1E43\u1E44\u1E45\u1E46\u1E47\u1E48\u1E49\u1E4A\u1E4B\u1E4C\u1E4D\u1E4E\u1E4F\u1E50\u1E51\u1E52\u1E53\u1E54\u1E55\u1E56\u1E57\u1E58\u1E59\u1E5A\u1E5B\u1E5C\u1E5D\u1E5E\u1E5F\u1E60\u1E61\u1E62\u1E63\u1E64\u1E65\u1E66\u1E67\u1E68\u1E69\u1E6A\u1E6B\u1E6C\u1E6D\u1E6E\u1E6F\u1E70\u1E71\u1E72\u1E73\u1E74\u1E75\u1E76\u1E77\u1E78\u1E79\u1E7A\u1E7B\u1E7C"}),X("sinko",Rr,8,10),He(),ze();let ye={loadRoot:q,loadSprite:J,loadSpriteAtlas:Ee,loadSound:Ce,loadFont:X,loadShader:Se,loadAseprite:Et,loadPedit:$e,loadBean:_r,load:S,width:F,height:G,center:ot,dt:Z,time:nt,screenshot:bn,record:Nn,isFocused:jn,focus:Di,cursor:xn,regCursor:ii,fullscreen:Hr,isFullscreen:vn,onLoad:Ue,isTouch:()=>t.isTouch,layers:Qr,camPos:Zr,camScale:ei,camRot:ti,shake:ni,toScreen:rt,toWorld:Lt,gravity:Fn,add:kt,readd:Ai,destroy:at,destroyAll:Oi,get:Ii,every:Vi,revery:Fi,pos:it,scale:st,rotate:si,color:oi,opacity:ai,origin:Ot,layer:ui,area:fi,sprite:Vt,text:pi,rect:mi,circle:gi,uvquad:wi,outline:Ui,body:xi,shader:vi,timer:Gn,solid:Ei,fixed:Ti,stay:Ft,health:Si,lifespan:Ci,z:ci,move:hi,outview:It,cleanup:di,follow:li,state:Ri,on:qe,onUpdate:Pe,onDraw:Tn,onCollide:Sn,onClick:Cn,onHover:Rn,onKeyDown:qt,onKeyPress:H,onKeyPressRepeat:Pt,onKeyRelease:Dt,onMouseDown:Mn,onMousePress:At,onMouseRelease:Ln,onMouseMove:qn,onCharInput:Pn,onTouchStart:Dn,onTouchMove:An,onTouchEnd:On,mousePos:K,mouseWorldPos:Jr,mouseDeltaPos:yn,isKeyDown:Mt,isKeyPressed:Le,isKeyPressedRepeat:Wt,isKeyReleased:tt,isMouseDown:Ze,isMousePressed:Me,isMouseReleased:et,isMouseMoved:Rt,loop:ri,wait:Wn,play:Xe,volume:Br,burp:un,audioCtx:w.ctx,Timer:fe,Line:le,Rect:ke,Circle:ht,Vec2:L,Color:v,Mat4:R,Quad:k,RNG:be,rng:mr,rand:Ge,randi:Ht,randSeed:wr,vec2:f,rgb:E,hsl2rgb:fr,quad:pr,choose:Ur,chance:gr,lerp:Ve,map:dt,mapc:dr,wave:Kt,deg2rad:he,rad2deg:Xt,testAreaRect:gt,testAreaLine:Zt,testAreaCircle:en,testAreaPolygon:tn,testAreaPoint:Ut,testAreaArea:nn,testLineLine:ce,testRectRect:zt,testRectLine:ft,testRectPoint:ae,testPolygonPoint:xe,testLinePolygon:_e,testPolygonPolygon:wt,testCircleCircle:Qt,testCirclePoint:mt,testRect
|
||
|
//# sourceMappingURL=kaboom.mjs.map
|