d&&(d=e),tu&&(u=t)),c+=4;return p=Math.floor(p/o),u=Math.floor(u/o),l=Math.floor(l/o),d=Math.floor(d/o),s=s.get(l,p,d-l+1,u-p+1),t.pop(),s.url=e,s},this.spriteArt=(e,i,s)=>{i??=1,"number"==typeof s&&(s=t.p5play.palettes[s]),s??=t.p5play.palettes[0];let r=e;"string"==typeof e&&(r=(e=(e=(e=e.trim()).replace(/\r*\n\t+/g,"\n")).replace(/\s+$/g,"")).split("\n"));let o=0;for(let t of r)t.length>o&&(o=t.length);let h=r.length,a=t.createImage(o*i,h*i);a.loadPixels();for(let t=0;tnew Promise(t?e=>{setTimeout(e,t)}:requestAnimationFrame),this.sleep=e=>e?t.delay(e):new Promise((e=>{if(t.canvas.dispatchEvent){t.canvas.addEventListener("p5play_worldStepped",(function i(){t.canvas.removeEventListener("p5play_worldStepped",i),e()}))}else setTimeout(e,1e3*t.world._timeStep)})),this.play=t=>{if(!t?.play)throw new Error("Tried to play your sound but it wasn't a sound object.");return new Promise((e=>{t.play(),t.onended((()=>e()))}))},window.location){let e=location.hostname;switch(e){case"":case"127.0.0.1":case"localhost":case"p5play.org":case"editor.p5js.org":case"codepen.io":case"codera.app":case"aug4th.com":case"cdpn.io":case"glitch.com":case"replit.com":case"stackblitz.com":case"jsfiddle.net":case"aijs.io":case"preview-aijs.web.app":case"quinton-ashley.github.io":break;default:if(/^[\d\.]+$/.test(e)||e.endsWith("stackblitz.io")||e.endsWith("glitch.me")||e.endsWith("replit.dev")||e.endsWith("codehs.com")||e.endsWith("openprocessing.org")||location.origin.endsWith("preview.p5js.org"))break;!async function(){if(document.getElementById("p5play-intro"))return;t._incrementPreload();let e=document.createElement("div");e.id="p5play-intro",e.style="position: absolute; width: 100%; height: 100%; top: 0; left: 0; z-index: 1000; background-color: black;";let i=document.createElement("img");i.style="position: absolute; top: 50%; left: 50%; width: 80vmin; height: 40vmin; margin-left: -40vmin; margin-top: -20vmin; z-index: 1001; opacity: 1; scale: 1; transition: scale 1.5s, opacity 0.4s ease-in-out;",i.onerror=()=>{i.style.imageRendering="pixelated",i.src="data:image/png;base64,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"};let s=window._p5play_intro_image;""==s||s?.includes("made_with_p5play")?((s.includes("bit.")||s.includes("pixel"))&&(i.style.imageRendering="pixelated"),i.src=s):i.src="https://p5play.org/assets/made_with_p5play.webp",await new Promise((t=>i.onload=t)),e.append(i),document.body.append(e),await t.delay(),i.offsetHeight,i.style.scale=1.2,await t.delay(1100),i.style.opacity=0,await t.delay(400),e.style.display="none",e.remove(),document.getElementById("p5play-intro")?.remove(),t._decrementPreload()}()}}let g=p5.disableFriendlyErrors;p5.disableFriendlyErrors=!0;const f=t.createCanvas;this.createCanvas=function(){let e,i,s,r=[...arguments];if("string"==typeof r[0])if(r[0].includes(":")){let t=r[0].split(":"),i=Number(t[0]),s=Number(t[1]),o=window.innerWidth,h=window.innerWidth*(s/i);h>window.innerHeight&&(o=window.innerHeight*(i/s),h=window.innerHeight),r[0]=Math.round(o),r.splice(1,0,Math.round(h)),e="fullscreen"}else r=[0,0,...r];if(r[0]||(r[0]=window.innerWidth,r[1]=window.innerHeight,e="fullscreen"),"string"==typeof r[2]){let t=r[2].toLowerCase().split(" ");"pixelated"==t[0]?(i="pixelated",t[1]?(e="centered",s=Number(t[1].slice(1))):e="fullscreen",r.splice(2,1)):"fullscreen"==t[0]&&(e="fullscreen",r.splice(2,1))}let o=f.call(t,...r);t.ctx=t.drawingContext;let h=o.canvas||o;return o.GL&&(h.renderer="webgl"),"webgpu"!=h.renderer&&(h.renderer="2d"),h.tabIndex=0,h.w=r[0],h.h=r[1],h.addEventListener&&(h.addEventListener("keydown",(function(t){" "!=t.key&&"/"!=t.key&&"ArrowUp"!=t.key&&"ArrowDown"!=t.key&&"ArrowLeft"!=t.key&&"ArrowRight"!=t.key||t.preventDefault()})),h.addEventListener("mouseover",(()=>{this.mouse.isOnCanvas=!0,this.mouse.isActive=!0})),h.addEventListener("mouseleave",(()=>{this.mouse.isOnCanvas=!1})),h.addEventListener("touchstart",(t=>t.preventDefault())),h.addEventListener("contextmenu",(t=>t.preventDefault()))),h.save??=t.saveCanvas.bind(t),h.resize??=t.resizeCanvas.bind(t),h.hw=.5*h.w,h.hh=.5*h.h,h.mouse={x:t.mouseX,y:t.mouseY},"2d"!=h.renderer||t._webgpuFallback?(t.camera.x=0,t.camera.y=0,"webgl"==h.renderer&&(t._textCache=!1),t._webgpuFallback||(t.p5play._renderStats={x:10-h.hw,y:20-h.hh})):(t.camera.x=t.camera.ogX=h.hw,t.camera.y=t.camera.ogY=h.hh),g||(p5.disableFriendlyErrors=!1),t.displayMode(e,i,s),o},this.Canvas=class{constructor(t,e,i,s){this.w,this.width,this.h,this.height,this.hw,this.hh,this.mouse}resize(){}save(){}},this.canvas=t.canvas,t.Canvas=function(){return t.createCanvas(...arguments).canvas};const m=t.resizeCanvas;this.resizeCanvas=(e,i)=>{e??=window.innerWidth,i??=window.innerHeight,m.call(t,e,i);let s=t.canvas;s.w=s.width/t.pixelDensity(),s.h=s.height/t.pixelDensity(),s.hw=.5*s.w,s.hh=.5*s.h,s.fullscreen&&(s.w/s.h>window.innerWidth/window.innerHeight?(s.style.width="100%!important",s.style.height="auto!important"):(s.style.width="auto!important",s.style.height="100%!important")),"2d"==s.renderer?(t.camera.x=s.hw,t.camera.y=s.hh):(t.camera.x=0,t.camera.y=0)};const y=t.frameRate;this.frameRate=function(e){let i=y.call(t,e);return e&&t.world._updateTimeStep(),i};const w=t.background;this.background=function(){let e=arguments;1==e.length&&1==e[0]?.length?w.call(t,t.colorPal(e[0])):w.call(t,...e)};const v=t.fill;this.fill=function(){let e=arguments;1==e.length&&1==e[0]?.length?v.call(t,t.colorPal(e[0])):v.call(t,...e)};const x=t.stroke;this.stroke=function(){let e=arguments;1==e.length&&1==e[0]?.length?x.call(t,t.colorPal(e[0])):x.call(t,...e)};const b=t.loadImage;this.loadImage=this.loadImg=function(){if(t.p5play.disableImages)return t._decrementPreload(),{w:16,width:16,h:16,height:16,pixels:[]};let e,i=arguments,s=i[0],r=t.p5play.images[s];if("function"==typeof i[i.length-1]&&(e=i[i.length-1]),r)return r.width<=1&&r.height<=1||!r.pixels.length?e?(r.cbs.push(e),r.calls++):t._decrementPreload():(e&&e(),t._decrementPreload()),r;return r=b.call(t,s,(e=>{if(e.w||(Object.defineProperty(e,"w",{get:function(){return this.width}}),Object.defineProperty(e,"h",{get:function(){return this.height}})),e.cbs){for(let t of e.cbs)t(e);for(let i=1;i\nhtml, body {\n\tmargin: 0;\n\tpadding: 0;\n}\nbody.hasFrameBorder {\n\tdisplay: block;\n}\n.p5Canvas {\n\toutline: none;\n\t-webkit-touch-callout: none;\n\t-webkit-text-size-adjust: none;\n\t-webkit-user-select: none;\n\toverscroll-behavior: none;\n}\n.p5-pixelated {\n\timage-rendering: pixelated;\n\tfont-smooth: never;\n\t-webkit-font-smoothing: none;\n}\n.p5-centered,\n.p5-maxed,\n.p5-fullscreen {\n display: flex;\n\talign-items: center;\n\tjustify-content: center;\n}\nmain.p5-centered,\nmain.p5-maxed,\n.p5-fullscreen {\n\theight: 100vh;\n}\nmain {\n\toverscroll-behavior: none;\n}\n"),t._adjustDisplay=()=>{let e=t.canvas,i=e.style,s=e.parentElement;i&&s&&e.displayMode&&("pixelated"==e.renderQuality&&(e.classList.add("p5-pixelated"),t.pixelDensity(1),t.noSmooth&&t.noSmooth(),t.textFont&&t.textFont("monospace")),"normal"==e.displayMode?(s.classList.remove("p5-centered","p5-maxed","p5-fullscreen"),i.width=e.w*e.displayScale+"px",i.height=e.h*e.displayScale+"px"):(s.classList.add("p5-"+e.displayMode),s=s.getBoundingClientRect(),e.w/e.h>s.width/s.height?("centered"==e.displayMode?(i.width=e.w*e.displayScale+"px",i.maxWidth="100%"):i.width="100%",i.height="auto",i.maxHeight=""):(i.width="auto",i.maxWidth="","centered"==e.displayMode?(i.height=e.h*e.displayScale+"px",i.maxHeight="100%"):i.height="100%")))},t.displayMode=(e="normal",i="default",s=1)=>{let r=t.canvas;"string"==typeof s&&(s=parseFloat(s.slice(1))),Object.assign(r,{displayMode:e,renderQuality:i,displayScale:s}),t._adjustDisplay()});let A={generic:["Ah! I found an error","Oh no! Something went wrong","Oof! Something went wrong","Houston, we have a problem","Whoops, having trouble here"],Sprite:{constructor:{base:"Sorry I'm unable to make a new Sprite",0:"What is $0 for? If you're trying to specify the x position of the sprite, please specify the y position as well.",1:"If you're trying to specify points for a chain Sprite, please use an array of position arrays.\n$0",2:"Invalid input parameters: $0"},hw:{0:"I can't change the halfWidth of a Sprite directly, change the sprite's width instead."},hh:{1:"I can't change the halfHeight of a Sprite directly, change the sprite's height instead."},rotate:{0:"Can't use this function on a sprite with a static collider, try changing the sprite's collider type to kinematic.",1:'Can\'t use "$0" for the angle of rotation, it must be a number.'},rotateTo:{},rotateMinTo:{},rotateTowards:{},changeAnimation:'I can\'t find any animation named "$0".',collide:{0:"I can't make that sprite collide with $0. Sprites can only collide with another sprite or a group.",1:"The collision callback has to be a function.",2:"You're trying to check for an collision with a sprite or group that doesn't exist!"},overlap:{0:"I can't make that sprite overlap with $0. Sprites can only overlap with another sprite or a group.",1:"The overlap callback has to be a function.",2:"You're trying to check for an overlap with a sprite or group that doesn't exist!"}},Ani:{constructor:{base:"Hey so, I tried to make a new Ani but couldn't",1:"The name of the animation must be the first input parameter."},frame:"Index $0 out of bounds. That means there is no frame $0 in this animation. It only has $1 frames!"},Group:{constructor:{base:"Hmm awkward! Well it seems I can't make that new Group you wanted"}}};A.Group.collide=A.Sprite.collide,A.Group.overlap=A.Sprite.overlap,A.Sprite.rotateTo[0]=A.Sprite.rotateMinTo[0]=A.Sprite.rotateTowards[0]=A.Sprite.rotate[0];class C extends Error{constructor(t,e,i){super(),"string"!=typeof t&&(i=e,e=t,t=(t=this.stack.match(/\n\s*at ([^\(]*)/)[1]).slice(0,-1)),"number"!=typeof e&&(i=e,e=void 0),"new"==t.slice(0,3)&&(t=t.slice(4));let s=(t=t.split("."))[0];t=t[1]||"constructor";let r=this.stack.match(/\/([^p\/][^5][^\/:]*:[^\/:]+):/);r&&(r=r[1].split(":"),r=" in "+r[0]+" at line "+r[1]),r=" using "+s+"."+t+". ",i=i||[];let o,h=A[s][t];o=h.base?h.base+r:A.generic[Math.floor(Math.random()*A.generic.length)]+r,void 0!==e&&(h=h[e]),h&&(h=h.replace(/\$([0-9]+)/g,((t,e)=>i[e])),o+=h),p5._friendlyError(o,t)}}this.allSprites=new t.Group,this.world=new t.World,this.camera=new t.Camera,this.InputDevice=class{constructor(){this.holdThreshold=12,this._default=0}_ac(t){return t}presses(t){return t??=this._default,void 0===this[t]&&(t=this._ac(t)),1==this[t]||-3==this[t]}pressing(t){return t??=this._default,void 0===this[t]&&(t=this._ac(t)),-3==this[t]?1:this[t]>0?this[t]:0}pressed(t){return this.released(t)}holds(t){return t??=this._default,void 0===this[t]&&(t=this._ac(t)),this[t]==this.holdThreshold}holding(t){return t??=this._default,void 0===this[t]&&(t=this._ac(t)),this[t]>=this.holdThreshold?this[t]:0}held(t){return t??=this._default,void 0===this[t]&&(t=this._ac(t)),-2==this[t]}released(t){return t??=this._default,void 0===this[t]&&(t=this._ac(t)),this[t]<=-1}releases(t){return this.released(t)}},this._Mouse=class extends t.InputDevice{constructor(){super(),this._default="left";let e=this;this._pos=t.createVector.call(t),Object.defineProperty(this._pos,"x",{get:()=>e.x,set(t){e.x=t}}),Object.defineProperty(this._pos,"y",{get:()=>e.y,set(t){e.y=t}}),this.x=0,this.y=0,this.canvasPos={},this.left=0,this.center=0,this.right=0,this.drag={left:0,center:0,right:0},this._dragFrame={left:!1,center:!1,right:!1},this.isOnCanvas=!1,this.isActive=!1,this._visible=!0,this._cursor="default",this._ogX=0,this._ogY=0}_ac(t){return"left"==(t=t.toLowerCase()).slice(0,4)?t="left":"right"==t.slice(0,5)?t="right":"middle"==t.slice(0,6)&&(t="center"),t}_update(){t.mouse.canvasPos.x=t.mouseX,t.mouse.canvasPos.y=t.mouseY,t.camera.x==t.camera.ogX&&t.camera.y==t.camera.ogY&&1==t.camera.zoom?(this.x=t.mouseX,this.y=t.mouseY):"webgpu"!=t.canvas.renderer?(this.x=(t.mouseX-t.canvas.hw)/t.camera.zoom+t.camera.x,this.y=(t.mouseY-t.canvas.hh)/t.camera.zoom+t.camera.y):(this.x=t.mouseX/t.camera.zoom+t.camera.x,this.y=t.mouseY/t.camera.zoom+t.camera.y)}get pos(){return this._pos}get position(){return this._pos}get cursor(){return t.canvas.style.cursor}set cursor(e){e!=this._cursor&&(t.cursor(e),this._cursor=e)}get visible(){return this._visible}set visible(e){this._visible=e,t.canvas.style.cursor=e?"default":"none"}drags(t){return t??=this._default,1==this.drag[t]}dragging(t){return t??=this._default,this.drag[t]>0?this.drag[t]:0}dragged(t){return t??=this._default,this.drag[t]<=-1}},this.mouse=new t._Mouse,this._SpriteMouse=class extends t._Mouse{constructor(){super(),delete this.canvasPos,this.hover=0}hovers(){return 1==this.hover}hovering(){return this.hover>0?this.hover:0}hovered(){return this.hover<=-1}};const k=function(e){if(t.mouse.isActive=!0,t.mouse[e]++,t.world.mouseSprites.length){let i=t.world.mouseSprite?.mouse;i&&(i[e]=0,i.hover=0,i.drag[e]=0),ms=t.world.mouseSprites[0],t.world.mouseSprite=ms,i=ms.mouse,i[e]=1,i.hover<=0&&(i.hover=1)}},M=t._onmousedown;t._onmousedown=function(e){if(!t._setupDone)return;let i="left";1===e.button?i="center":2===e.button&&(i="right"),k.call(t,i),M.call(t,e)};const z=function(e){let i=t.mouse;i[e]>0&&(i._dragFrame[e]=!0)},T=t._onmousemove;t._onmousemove=function(e){if(!t._setupDone)return;let i="left";1===e.button?i="center":2===e.button&&(i="right"),z.call(t,i),T.call(t,e)};const j=function(e){let i=t.mouse;i[e]>=i.holdThreshold?i[e]=-2:i[e]>1?i[e]=-1:i[e]=-3,i.drag[e]>0&&(i.drag[e]=-1);let s=t.world.mouseSprite?.mouse;s&&(s.hover>1?(s[e]>=t.mouse.holdThreshold?s[e]=-2:s[e]>1?s[e]=-1:s[e]=-3,s.drag[e]>0&&(s.drag[e]=-1)):(s[e]=0,s.drag[e]=0))},O=t._onmouseup;if(t._onmouseup=function(e){if(!t._setupDone)return;let i="left";1===e.button?i="center":2===e.button&&(i="right"),j.call(t,i),O.call(t,e)},this._Touch=class extends t.InputDevice{constructor(e){super(),this.x,this.y,this.id=e.identifier,this._default="duration",this.holdThreshold=t.touches.holdThreshold,this.duration=1,this.drag=0,this._dragFrame=!1,this.canvasPos={},this._update(e)}_update(e){let i=t.canvas;const s=i.getBoundingClientRect(),r=i.scrollWidth/i.w||1,o=i.scrollHeight/i.h||1,h=this.canvasPos.x=(e.clientX-s.left)/r,a=this.canvasPos.y=(e.clientY-s.top)/o;t.camera.x==i.hw&&t.camera.y==i.hh&&1==t.camera.zoom?(this.x=h,this.y=a):(this.x=(h-i.hw)/t.camera.zoom+t.camera.x,this.y=(a-i.hh)/t.camera.zoom+t.camera.y),this.force=e.force}},this.touches=[],t.touches.holdThreshold=12,t._ontouchstart=function(e){if(t._setupDone){t.getAudioContext&&"suspended"==t.getAudioContext()?.state&&t.userStartAudio();for(let i of e.changedTouches)t.touches.push(new t._Touch(i)),1==t.touches.length&&(t.mouseX=t.touches[0].x,t.mouseY=t.touches[0].y,t.mouse._update(),t.world.mouseSprites=t.world.getMouseSprites(),t._onmousedown(e));t.touchStarted&&!t.touchStarted(e)&&e.preventDefault()}},t._ontouchmove=function(e){if(t._setupDone){for(let i of e.changedTouches){let s=t.touches.find((t=>t.id==i.identifier));s._update(i),s._dragFrame=!0,s.id==t.touches[0].id&&(t.mouseX=t.touches[0].x,t.mouseY=t.touches[0].y,t.mouse._update(),t._onmousemove(e))}t.touchMoved&&!t.touchMoved(e)&&e.preventDefault()}},t._ontouchend=function(e){if(t._setupDone){for(let i of e.changedTouches){let s=t.touches.find((t=>t.id==i.identifier));s._update(i),s.duration>=s.holdThreshold?s.duration=-2:s.duration>1?s.duration=-1:s.duration=-3,s.drag>0&&(s.drag=-1),s.id==t.touches[0].id&&(t.mouseX=t.touches[0].x,t.mouseY=t.touches[0].y,t.mouse._update(),t._onmouseup(e))}t.touchEnded&&!t.touchEnded(e)&&e.preventDefault()}},this._Keyboard=class extends t.InputDevice{constructor(){super(),this._default=" ",this.alt=0,this.arrowUp=0,this.arrowDown=0,this.arrowLeft=0,this.arrowRight=0,this.backspace=0,this.capsLock=0,this.control=0,this.enter=0,this.meta=0,this.shift=0,this.tab=0;let t=this._simpleKeyControls={arrowUp:"up",arrowDown:"down",arrowLeft:"left",arrowRight:"right"};t.w=t.W="up",t.s=t.S="down",t.a=t.A="left",t.d=t.D="right",t.i=t.I="up2",t.k=t.K="down2",t.j=t.J="left2",t.l=t.L="right2"}get visible(){return this._inp==document.activeElement}set visible(t){this._inp||(this._inp=Object.assign(document.createElement("input"),{type:"text",style:"position: fixed; height: 0; padding: 0; border: none; opacity: 0.0001; pointer-events: none;"}),document.body.appendChild(this._inp)),this._visible=t,t?this._inp.focus():this._inp.blur()}_ac(t){if(1!=t.length){if(!isNaN(t)){if(38==t)return"arrowUp";if(40==t)return"arrowDown";if(37==t)return"arrowLeft";if(39==t)return"arrowRight";if(t>=10)throw new Error("Use key names with the keyboard input functions, not keyCode numbers!");return t}t=t.replaceAll(/[ _-]/g,"")}if(1!=(t=t.toLowerCase()).length){if("arrowup"==t)return"arrowUp";if("arrowdown"==t)return"arrowDown";if("arrowleft"==t)return"arrowLeft";if("arrowright"==t)return"arrowRight";if("capslock"==t)return"capsLock"}return t}_pre(t){(!this[t]||this[t]<0)&&(this[t]=1)}_rel(t){this[t]>=this.holdThreshold?this[t]=-2:this[t]>1?this[t]=-1:this[t]=-3}get cmd(){return this.meta}get command(){return this.meta}get ctrl(){return this.control}get space(){return this[" "]}get spacebar(){return this[" "]}get opt(){return this.alt}get option(){return this.alt}get win(){return this.meta}get windows(){return this.meta}},this.kb=new t._Keyboard,this.keyboard=t.kb,"object"==typeof navigator&&navigator.keyboard){const e=navigator.keyboard;window==window.top?e.getLayoutMap().then((e=>{"w"!=e.get("KeyW")&&(t.p5play.standardizeKeyboard=!0)})):t.p5play.standardizeKeyboard=!0}else t.p5play.standardizeKeyboard=!0;function P(t){let e=t.code;return 4==e.length&&"Key"==e.slice(0,3)?e[3].toLowerCase():t.key}const F=t._onkeydown;t._onkeydown=function(t){let e=t.key;if(this.p5play.standardizeKeyboard&&(e=P(t)),e.length>1)e=e[0].toLowerCase()+e.slice(1);else{let t=e.toLowerCase(),i=e.toUpperCase();t!=i&&(e!=i?this.kb._pre(i):this.kb._pre(t))}this.kb._pre(e);let i=this.kb._simpleKeyControls[e];i&&this.kb._pre(i),F.call(this,t)};const I=t._onkeyup;t._onkeyup=function(t){let e=t.key;if(this.p5play.standardizeKeyboard&&(e=P(t)),e.length>1)e=e[0].toLowerCase()+e.slice(1);else{let t=e.toLowerCase(),i=e.toUpperCase();t!=i&&(e!=i?this.kb._rel(i):this.kb._rel(t))}this.kb._rel(e);let i=this.kb._simpleKeyControls[e];if(i&&this.kb._rel(i),t.shiftKey){let t=e.toLowerCase();this.kb[t]>0&&this.kb._rel(t)}I.call(this,t)},this.Contro=class extends t.InputDevice{constructor(t){super(),this._default="a",this.connected=!0,this.a=0,this.b=0,this.x=0,this.y=0,this.l=0,this.r=0,this.lt=0,this.rt=0,this.select=0,this.start=0,this.lsb=0,this.rsb=0,this.up=0,this.down=0,this.left=0,this.right=0,this.leftStick={x:0,y:0},this.rightStick={x:0,y:0},this.leftTrigger=0,this.rightTrigger=0,this.buttonMapping={a:0,b:1,x:2,y:3,l:4,r:5,lt:6,rt:7,select:8,start:9,lsb:10,rsb:11,up:12,down:13,left:14,right:15},this.axeMapping={leftStick:{x:0,y:1},rightStick:{x:2,y:3},leftTrigger:4,rightTrigger:5},this.isMock=!1,"string"!=typeof t?(this.gamepad=t,this.id=t.id):(this.gamepad={},this.id=t,this.isMock=!0),this._axeTriggers=this.gamepad.axes&&void 0!==this.gamepad.axes[this.axeMapping.leftTrigger],this.hasAnalogTriggers=this._axeTriggers||void 0,this.id.includes("GuliKit")&&(this.buttonMapping.a=1,this.buttonMapping.b=0,this.buttonMapping.x=3,this.buttonMapping.y=2)}_ac(t){return"lb"==(t=t.toLowerCase())?t="l":"rb"==t?t="r":"leftstickbutton"==t?t="lsb":"rightstickbutton"==t&&(t="rsb"),t}_update(){if(this.isMock)return;if(this.gamepad=navigator.getGamepads()[this.gamepad.index],!this.gamepad?.connected)return;let t=this.gamepad;for(let e in this.buttonMapping){let i=this.buttonMapping[e],s=t.buttons[i];s&&(s.pressed?this[e]++:this[e]=this[e]>0?-1:0)}return this.leftStick.x=t.axes[this.axeMapping.leftStick.x],this.leftStick.y=t.axes[this.axeMapping.leftStick.y],this.rightStick.x=t.axes[this.axeMapping.rightStick.x],this.rightStick.y=t.axes[this.axeMapping.rightStick.y],this._axeTriggers?(this.leftTrigger=t.axes[this.axeMapping.leftTrigger],this.rightTrigger=t.axes[this.axeMapping.rightTrigger]):(this.leftTrigger=t.buttons[this.buttonMapping.lt].value,this.rightTrigger=t.buttons[this.buttonMapping.rt].value,void 0===this.hasAnalogTriggers&&(this.leftTrigger||this.rightTrigger)&&(this.hasAnalogTriggers=!Number.isInteger(this.leftTrigger)||!Number.isInteger(this.rightTrigger))),!0}_reset(){for(let t in this.buttonMapping)this[t]=0;this.leftStick.x=0,this.leftStick.y=0,this.rightStick.x=0,this.rightStick.y=0,this.leftTrigger=0,this.rightTrigger=0}get cross(){return this.a}get circle(){return this.b}get square(){return this.x}get triangle(){return this.y}get ls(){return this.leftStick}get rs(){return this.rightStick}get lb(){return this.l}get rb(){return this.r}get l1(){return this.l}get r1(){return this.r}get zl(){return this.lt}get zr(){return this.rt}get l2(){return this.leftTrigger}get r2(){return this.rightTrigger}get leftStickButton(){return this.lsb}get rightStickButton(){return this.rsb}get l3(){return this.lsb}get r3(){return this.rsb}},this._Contros=class extends Array{constructor(){if(super(),window&&(window.addEventListener("gamepadconnected",(t=>{this._onConnect(t.gamepad)})),window.addEventListener("gamepaddisconnected",(t=>{this._onDisconnect(t.gamepad)}))),"object"!=typeof navigator||!navigator.getGamepads)return;let t=navigator.getGamepads();for(let e of t)e&&this._onConnect(e)}swap(e,i){let s=this[e];this[e]=this[i],this[i]=s,0!=e&&0!=i||(t.contro=this[0],!t._q5&&t._isGlobal&&(window.contro=this[0]))}remove(t){this[t]=null}onConnect(t){return!0}onDisconnect(t){return!1}_onConnect(e){if(e){for(let t=0;tt.p5play._fps,this.renderStats=(t,e)=>{console.error("p5play: renderStats() function is deprecated. Use `p5play.renderStats = true` instead.")}})),p5.prototype.registerMethod("pre",(function(){const t=this;t._q5||(t.p5play._preDrawFrameTime=performance.now()),t.p5play.spritesDrawn=0,t.mouse._update(),t.contros._update()})),p5.prototype.registerMethod("post",(function(){const t=this;if(t.p5play._inPostDraw=!0,t.allSprites.autoCull&&t.allSprites.cull(1e4),t.allSprites._autoDraw&&(t.camera.on(),t.allSprites.draw(),t.camera.off()),t.allSprites._autoDraw??=!0,t.p5play.renderStats){let e=t.p5play._renderStats;if(e.fontSize||(1==t.allSprites.tileSize||t.allSprites.tileSize>16?e.fontSize=16:e.fontSize=10,e.gap=1.25*e.fontSize),!t.p5play._fpsAvg||t.frameCount%20==0){let e=0,i=t.p5play._fpsArr.length;for(let s=0;s55?t.color(30,255,30):r>25?t.color(255,100,30):t.color(255,30,30),t.p5play._statsColor=s}t.p5play._fpsArr.push(t.getFPS()),t.push(),t.fill(0,0,0,128),t.rect(e.x-5,e.y-e.fontSize,8.5*e.fontSize,5*e.gap+5),t.fill(t.p5play._statsColor),t.textAlign("left"),t.textSize(e.fontSize),e.font&&t.textFont(e.font);let i=e.x,s=e.y;t.text("sprites: "+t.p5play.spritesDrawn,i,s),t.text("display: "+Math.round(t.frameRate())+"hz",i,s+e.gap),t.text("fps avg: "+t.p5play._fpsAvg,i,s+2*e.gap),t.text("fps min: "+t.p5play._fpsMin,i,s+3*e.gap),t.text("fps max: "+t.p5play._fpsMax,i,s+4*e.gap),t.pop(),e.show=!1}t.world.autoStep&&t.world.timeScale>0&&t.world.step(),t.world.autoStep??=!0,t.allSprites._autoUpdate&&t.allSprites.update(),t.allSprites._autoUpdate??=!0;for(let e of t.allSprites)e.autoDraw??=!0,e.autoUpdate??=!0;for(let e in t.kb)"holdThreshold"!=e&&(t.kb[e]<0?t.kb[e]=0:t.kb[e]>0&&t.kb[e]++);for(let e=0;e0&&e[t]++,i?.hover&&(i[t]=e[t]),e._dragFrame[t]?(e.drag[t]++,i&&(i.drag[t]=e.drag[t]),e._dragFrame[t]=!1):e.drag[t]<0&&(e.drag[t]=0,i&&(i.drag[t]=0));if(t.world.mouseTracking&&t.mouse.isActive){let s=t.world.getMouseSprites();for(let t=0;t0?e.mouse.hover=-1:e.mouse.hover<0&&(e.mouse.hover=0)}e.left<=0&&e.center<=0&&e.right<=0&&(t.world.mouseSprite=null);let r=t.world.mouseSprite,o=e.drag.left>0||e.drag.center>0||e.drag.right>0;for(let e of t.world.mouseSprites)if(!s.includes(e)){let i=e.mouse;i.hover>0&&(i.hover=-1,i.left=i.center=i.right=0),o||e!=r||(t.world.mouseSprite=r=null)}r&&(s.includes(r)||s.push(r),i.x=r.x-e.x,i.y=r.y-e.y),t.world.mouseSprites=s}t.camera.off(),t._q5||(t.p5play._postDrawFrameTime=performance.now(),t.p5play._fps=Math.round(1e3/(t.p5play._postDrawFrameTime-t.p5play._preDrawFrameTime))||1),t.p5play._inPostDraw=!1}));
diff --git a/v3/q5.js b/v3/q5.js
index 9d2ad186..e0900633 100644
--- a/v3/q5.js
+++ b/v3/q5.js
@@ -1,6 +1,6 @@
/**
* q5.js
- * @version 2.11
+ * @version 2.12
* @author quinton-ashley, Tezumie, and LingDong-
* @license LGPL-3.0
* @class Q5
diff --git a/v3/q5.min.js b/v3/q5.min.js
index 748d2641..3017b4b3 100644
--- a/v3/q5.min.js
+++ b/v3/q5.min.js
@@ -1,6 +1,6 @@
/**
* q5.js
- * @version 2.11
+ * @version 2.12
* @author quinton-ashley, Tezumie, and LingDong-
* @license LGPL-3.0
* @class Q5