t.fraction-e.fraction));let p=[];for(let t of l)t.fraction<=d&&p.push(t.sprite);return p}},this.Camera=class{constructor(){this._pos=t.createVector.call(t),this.__pos={x:0,y:0,rounded:{}},this.isActive=!1,this.bound={min:{x:0,y:0},max:{x:0,y:0}},this._zoomIdx=-1,this._zoom=1,this._destIdx=0}get pos(){return this._pos}set pos(t){this.x=t.x,this.y=t.y}get position(){return this._pos}set position(t){this.x=t.x,this.y=t.y}_calcBoundsX(e){let i=t.canvas.hw/this._zoom;this.bound.min.x=e-i,this.bound.max.x=e+i}_calcBoundsY(e){let i=t.canvas.hh/this._zoom;this.bound.min.y=e-i,this.bound.max.y=e+i}get x(){return this._pos.x}set x(e){if(void 0===e||isNaN(e))return;this._pos.x=e;let i=-e;t._c2d&&(i+=t.canvas.hw/this._zoom),this.__pos.x=i,t.allSprites.pixelPerfect&&(this.__pos.rounded.x=Math.round(i)),this._calcBoundsX(e)}get y(){return this._pos.y}set y(e){if(void 0===e||isNaN(e))return;this._pos.y=e;let i=-e;t._c2d&&(i+=t.canvas.hh/this._zoom),this.__pos.y=i,t.allSprites.pixelPerfect&&(this.__pos.rounded.y=Math.round(i)),this._calcBoundsY(e)}moveTo(e,i,s){if(void 0===e)return;if(isNaN(e)&&(s=i,i=e.y,e=e.x),s??=1,s<=0)return console.warn("camera.moveTo: speed should be a positive number"),Promise.resolve(!1);let r=i-this.y,o=e-this.x,h=Math.sqrt(r*r+o*o),a=s/h,n=o*a,l=r*a;this._destIdx++;let d=this._destIdx,p=Math.ceil(h/s);return(async()=>{for(let e=0;e{for(let e=0;e0&&(e=e<.1?t.map(e,0,.1,30,4):e<.5?t.map(e,.1,.5,4,2.5):e<.8?t.map(e,.5,.8,2.5,1):e<.9?t.map(e,.8,.9,1,.5):t.map(e,.9,1,.5,.2)),this._springiness=e,"wheel"!=this.type)return this._j.setFrequency(e);this._j.setSpringFrequencyHz(e)}get damping(){return"wheel"!=this.type?this._j.getDampingRatio():this._j.getSpringDampingRatio()}set damping(t){"wheel"==this.type?this._j.setSpringDampingRatio(t):this._j.setDampingRatio(t)}get speed(){return this._j.getJointSpeed()}set speed(t){this._j.isMotorEnabled()||this._j.enableMotor(!0),this._j.setMotorSpeed(t)}get motorSpeed(){return this._j.getMotorSpeed()}get enableMotor(){return this._j.isMotorEnabled()}set enableMotor(t){this._j.enableMotor(t)}get maxPower(){return this._j.getMaxMotorTorque()}set maxPower(t){!this._j.isMotorEnabled()&&t&&this._j.enableMotor(!0),this._j.setMaxMotorTorque(t),t||this._j.enableMotor(!1)}get power(){return this._j.getMotorTorque()}get collideConnected(){return this._j.getCollideConnected()}set collideConnected(t){this._j.m_collideConnected=t}get reactionForce(){return this._j.getReactionForce(t.world._timeStep)}get reactionTorque(){return this._j.getReactionTorque(t.world._timeStep)}remove(){this._removed||(this.spriteA.joints.splice(this.spriteA.joints.indexOf(this),1),this.spriteB.joints.splice(this.spriteB.joints.indexOf(this),1),t.world.destroyJoint(this._j),this._removed=!0)}},this.GlueJoint=class extends t.Joint{constructor(t,e){super(...arguments,"glue")}},this.DistanceJoint=class extends t.Joint{constructor(t,i){super(...arguments,"distance");let s=e.DistanceJoint({},t.body,i.body,t.body.getWorldCenter(),i.body.getWorldCenter());this._createJoint(s)}_display(){let t,e;(this.offsetA.x||this.offsetA.y)&&(t=this.spriteA.body.getWorldPoint(this._j.m_localAnchorA),t=a(t.x,t.y,this.spriteA.tileSize)),(this.offsetB.x||this.offsetB.y)&&(e=this.spriteB.body.getWorldPoint(this._j.m_localAnchorB),e=a(e.x,e.y,this.spriteB.tileSize)),this._draw(t?t.x:this.spriteA.x,t?t.y:this.spriteA.y,e?e.x:this.spriteB.x,e?e.y:this.spriteB.y),this.visible=null}},this.WheelJoint=class extends t.Joint{constructor(i,s){super(...arguments,"wheel");let r=e.WheelJoint({maxMotorTorque:1e3,frequencyHz:4,dampingRatio:.7},i.body,s.body,s.body.getWorldCenter(),new e.Vec2(0,1));this._createJoint(r),this._angle=t._angleMode==o?90:1.5707963267948966}_display(){let e,i,s=this.spriteA.x,r=this.spriteA.y;if(this.offsetB.x||this.offsetB.y){let t=this.spriteB.body.getWorldPoint(this._j.m_localAnchorB);t=a(t.x,t.y,this.spriteB.tileSize),e=t.x,i=t.y}else e=this.spriteB.x,i=this.spriteB.y;let o=t.tan(this.spriteA.rotation),h=t.tan(this._angle+this.spriteA.rotation),n=(i-r+o*s-h*e)/(o-h),l=o*(n-s)+r;this._draw(n,l,e,i),this.visible=null}get angle(){return this._angle}set angle(i){i!=this._angle&&(this._angle=i,this._j.m_localXAxisA=new e.Vec2(t.cos(i),t.sin(i)),this._j.m_localXAxisA.normalize(),this._j.m_localYAxisA=e.Vec2.crossNumVec2(1,this._j.m_localXAxisA))}},this.HingeJoint=class extends t.Joint{constructor(t,i){super(...arguments,"hinge");let s=e.RevoluteJoint({},t.body,i.body,t.body.getWorldCenter());this._createJoint(s)}_display(){const e=this.offsetA.x,i=this.offsetA.y,s=this.spriteA.rotation,r=e*t.cos(s)-i*t.sin(s),o=e*t.sin(s)+i*t.cos(s);this._draw(this.spriteA.x+r,this.spriteA.y+o),this.visible=null}get range(){return this.upperLimit-this.lowerLimit}set range(t){t/=2,this.upperLimit=t,this.lowerLimit=-t}get lowerLimit(){let e=this._j.getLowerLimit();return"radians"==t._angleMode?e:t.degrees(e)}set lowerLimit(e){this._j.isLimitEnabled()||this._j.enableLimit(!0),this.spriteA.body.setAwake(!0),this.spriteB.body.setAwake(!0),t._angleMode==o&&(e=t.radians(e)),this._j.m_lowerAngle=e}get upperLimit(){let e=this._j.getUpperLimit();return"radians"==t._angleMode?e:t.degrees(e)}set upperLimit(e){this._j.isLimitEnabled()||this._j.enableLimit(!0),this.spriteA.body.setAwake(!0),this.spriteB.body.setAwake(!0),t._angleMode==o&&(e=t.radians(e)),this._j.m_upperAngle=e}get angle(){let e=this._j.getJointAngle();return"radians"==t._angleMode?e:t.radians(e)}},t.RevoluteJoint=t.HingeJoint,this.SliderJoint=class extends t.Joint{constructor(t,i){super(...arguments,"slider");let s=e.PrismaticJoint({lowerTranslation:-1,upperTranslation:1,enableLimit:!0,maxMotorForce:50,motorSpeed:0,enableMotor:!0},t.body,i.body,t.body.getWorldCenter(),new e.Vec2(1,0));this._createJoint(s),this._angle=0}get angle(){return this._angle}set angle(i){i!=this._angle&&(this._angle=i,this._j.m_localXAxisA=new e.Vec2(t.cos(i),t.sin(i)),this._j.m_localXAxisA.normalize(),this._j.m_localYAxisA=e.Vec2.crossNumVec2(1,this._j.m_localXAxisA))}get range(){return this.upperLimit-this.lowerLimit}set range(t){t/=2,this.upperLimit=t,this.lowerLimit=-t}get lowerLimit(){return this._j.getLowerLimit()/this.spriteA.tileSize*t.world.meterSize}set lowerLimit(e){this._j.isLimitEnabled()||this._j.enableLimit(!0),e=e*this.spriteA.tileSize/t.world.meterSize,this._j.setLimits(e,this._j.getUpperLimit())}get upperLimit(){return this._j.getUpperLimit()/this.spriteA.tileSize*t.world.meterSize}set upperLimit(e){this._j.isLimitEnabled()||this._j.enableLimit(!0),e=e*this.spriteA.tileSize/t.world.meterSize,this._j.setLimits(this._j.getLowerLimit(),e)}},t.PrismaticJoint=t.SliderJoint,this.RopeJoint=class extends t.Joint{constructor(t,i){super(...arguments,"rope");let s=e.RopeJoint({maxLength:1},t.body,i.body,t.body.getWorldCenter());this._createJoint(s),this._j.m_localAnchorB.x=0,this._j.m_localAnchorB.y=0}get maxLength(){return e=this._j.getMaxLength(),i=this.spriteA.tileSize,e/i*t.world.meterSize;var e,i}set maxLength(e){var i,s;this._j.setMaxLength((i=e,s=this.spriteA.tileSize,i*s/t.world.meterSize))}},this.GrabberJoint=class extends this.Joint{constructor(t){super(t,t,"grab"),this._target={x:0,y:0},this.__target=new e.Vec2(0,0);let i=e.MouseJoint({maxForce:1e3,frequencyHz:3,dampingRatio:.9,target:t.body.getPosition()},t.body,t.body);this._createJoint(i)}_draw(){t.line(this.spriteA.x,this.spriteA.y,this._target.x,this._target.y)}get target(){return this._target}set target(e){this._target.x=e.x,this._target.y=e.y,this.__target.x=e.x/t.world.meterSize,this.__target.y=e.y/t.world.meterSize,this._j.setTarget(this.__target)}get maxForce(){return this._j.getMaxForce()}set maxForce(t){this._j.setMaxForce(t)}};class y{constructor(){let t=this;Object.defineProperties(this,{x:{get:()=>t._x,set(e){e!=t._x&&(t._x=e,t._avg=.5*(t._x+t._y))},configurable:!0,enumerable:!0},y:{get:()=>t._y,set(e){e!=t._y&&(t._y=e,t._avg=.5*(t._x+t._y))},configurable:!0,enumerable:!0},_x:{value:1,enumerable:!1,writable:!0},_y:{value:1,enumerable:!1,writable:!0},_avg:{value:1,enumerable:!1,writable:!0}})}valueOf(){return this._avg}}function m(t){return!/^(?:(?:\/\*[^(?:\*\/)]*\*\/\s*)|(?:\/\/[^\r\n]*))*\s*(?:(?:(?:async\s(?:(?:\/\*[^(?:\*\/)]*\*\/\s*)|(?:\/\/[^\r\n]*))*\s*)?function|class)(?:\s|(?:(?:\/\*[^(?:\*\/)]*\*\/\s*)|(?:\/\/[^\r\n]*))*)|(?:[_$\w][\w0-9_$]*\s*(?:\/\*[^(?:\*\/)]*\*\/\s*)*\s*\()|(?:\[\s*(?:\/\*[^(?:\*\/)]*\*\/\s*)*\s*(?:(?:['][^']+['])|(?:["][^"]+["]))\s*(?:\/\*[^(?:\*\/)]*\*\/\s*)*\s*\]\())/.test(t.toString())}function w(t,e){let i=t,s=e.toLowerCase();if("triangle"==s?i=[i,-120,3]:"square"==s?i=[i,-90,4]:"pentagon"==s?i=[i,-72,5]:"hexagon"==s?i=[i,-60,6]:"septagon"==s?i=[i,-51.4285714286,7]:"octagon"==s?i=[i,-45,8]:"enneagon"==s?i=[i,-40,9]:"decagon"==s?i=[i,-36,10]:"hendecagon"==s?i=[i,-32.7272727273,11]:"dodecagon"==s&&(i=[i,-30,12]),i==t)throw new Error("Invalid, not a regular polygon: "+e);return i}if(t.p5play.palettes=[{a:"aqua",b:"black",c:"crimson",d:"darkviolet",e:"peachpuff",f:"olive",g:"green",h:"hotpink",i:"indigo",j:"navy",k:"khaki",l:"lime",m:"magenta",n:"brown",o:"orange",p:"pink",q:"turquoise",r:"red",s:"skyblue",t:"tan",u:"blue",v:"violet",w:"white",x:"gold",y:"yellow",z:"gray"}],this.colorPal=(e,i)=>{if(e instanceof p5.Color)return e;"number"==typeof i&&(i=t.p5play.palettes[i]),i??=t.p5play.palettes[0];let s=i[e];return s?t.color(s):t.color(0,0,0,0)},this.EmojiImage=function(e,i){let s=1.25*(i*=t.p5play.emojiScale),r=t.createGraphics(s,s,t.P2D);r.textSize(i),r.textAlign(t.CENTER),r.textFont(t.canvas.webgpu?t._g.textFont():t.textFont()),r.text(e,s/2,i);let o=r.drawingContext,h=r._pixelDensity||1,a=r.canvas.width,n=r.canvas.height,l=o.getImageData(0,0,a,n).data,d=a,p=0,u=n,c=0,_=3;for(let t=0;tp&&(p=e),tc&&(c=t)),_+=4;return u=Math.floor(u/h),c=Math.floor(c/h),d=Math.floor(d/h),p=Math.floor(p/h),r=r.get(d,u,p-d+1,c-u+1),r.url=e,r},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(".lan")||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;r||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(),r||t._decrementPreload()}()}}const v=t.createCanvas;this.createCanvas=function(){let e,s,r,o=[...arguments];if("string"==typeof o[0])if(o[0].includes(":")){let t=o[0].split(":"),i=Number(t[0]),s=Number(t[1]),r=window.innerWidth,h=window.innerWidth*(s/i);h>window.innerHeight&&(r=window.innerHeight*(i/s),h=window.innerHeight),o[0]=Math.round(r),o.splice(1,0,Math.round(h)),e="fullscreen"}else o=[0,0,...o];if(o[0]||(o[0]=window.innerWidth,o[1]=window.innerHeight,e="fullscreen"),"string"==typeof o[2]){let t=o[2].toLowerCase().split(" ");"pixelated"==t[0]?(s="pixelated",t[1]?(e="centered",r=Number(t[1].slice(1))):e="fullscreen",o.splice(2,1)):"fullscreen"==t[0]&&(e="fullscreen",o.splice(2,1))}let h=v.call(t,...o);t.ctx=t.drawingContext;let a=h.canvas||h;window.canvas=a,h.GL?(a.renderer="webgl",t._webgl=!0):t._webgpu||(t._c2d=!0),a.tabIndex=0,a.w=o[0],a.h=o[1],a.addEventListener&&(a.addEventListener("keydown",(function(t){" "!=t.key&&"/"!=t.key&&"ArrowUp"!=t.key&&"ArrowDown"!=t.key&&"ArrowLeft"!=t.key&&"ArrowRight"!=t.key||t.preventDefault()})),a.addEventListener("mouseover",(()=>{this.mouse.isOnCanvas=!0,this.mouse.isActive=!0})),a.addEventListener("mouseleave",(()=>{this.mouse.isOnCanvas=!1})),a.addEventListener("touchstart",(t=>t.preventDefault())),a.addEventListener("contextmenu",(t=>t.preventDefault()))),a.save??=t.saveCanvas.bind(t),a.resize??=t.resizeCanvas.bind(t),a.hw=.5*a.w,a.hh=.5*a.h,a.mouse={x:t.mouseX,y:t.mouseY},t._c2d?(t.camera.x=t.camera.ogX=a.hw,t.camera.y=t.camera.ogY=a.hh):(t.camera.x=0,t.camera.y=0,t._webgpu&&(t.p5play._renderStats={x:10-a.hw,y:20-a.hh})),p5.disableFriendlyErrors=i,t.displayMode(e,s,r);let n=window.PointerEvent?"pointer":"mouse";return a.addEventListener(n+"down",z),window&&(window.addEventListener(n+"move",j),window.addEventListener(n+"up",P)),h},this.Canvas=class{constructor(t,e,i){this.w,this.width,this.h,this.height,this.hw,this.hh,this.mouse}resize(){}save(){}},t.Canvas=function(){return t.createCanvas(...arguments).canvas};const x=t.resizeCanvas;this.resizeCanvas=(e,i)=>{e??=window.innerWidth,i??=window.innerHeight,x.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")),t._c2d?(t.camera.x=s.hw,t.camera.y=s.hh):(t.camera.x=0,t.camera.y=0)};const b=t.frameRate;this.frameRate=function(e){let i=b.call(t,e);return e&&t.world._setTimeStep(),i};const S=t.background;this.background=function(){let e=arguments;1==e.length&&1==e[0]?.length?S.call(t,t.colorPal(e[0])):S.call(t,...e)};const A=t.fill;this.fill=function(){let e=arguments;1==e.length&&1==e[0]?.length?A.call(t,t.colorPal(e[0])):A.call(t,...e)};const C=t.stroke;if(this.stroke=function(){let e=arguments;1==e.length&&1==e[0]?.length?C.call(t,t.colorPal(e[0])):C.call(t,...e)},!r){const e=t.loadImage;this.loadImage=this.loadImg=function(){if(t.p5play.disableImages)return t._q5||t._decrementPreload(),{w:16,width:16,h:16,height:16,pixels:[]};let i,s=arguments,r=s[0],o=t.p5play.images[r];if("function"==typeof s[s.length-1]&&(i=s[s.length-1]),o)return o.width<=1&&o.height<=1?i?(o.cbs.push(i),o.calls++):t._q5||t._decrementPreload():(i&&i(),t._q5||t._decrementPreload()),o;return o=e.call(t,r,(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);if(!t._q5)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 k={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"}}};k.Group.collide=k.Sprite.collide,k.Group.overlap=k.Sprite.overlap,k.Sprite.rotateTo[0]=k.Sprite.rotateMinTo[0]=k.Sprite.rotateTowards[0]=k.Sprite.rotate[0];class M 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=k[s][t];o=h.base?h.base+r:k.generic[Math.floor(Math.random()*k.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):t._webgpu?(this.x=t.mouseX/t.camera.zoom+t.camera.x,this.y=t.mouseY/t.camera.zoom+t.camera.y):(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)}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}};let T=0,z=function(e){if(!t._setupDone)return;T++,!t._isQ5&&t.userStartAudio&&t.userStartAudio();let i="left";if(1===e.button?i="center":2===e.button&&(i="right"),t.mouse.isActive=!0,t.mouse[i]++,t.world.mouseSprites.length){let e=t.world.mouseSprite?.mouse;e&&(e[i]=0,e.hover=0,e.drag[i]=0);let s=t.world.mouseSprites[0];t.world.mouseSprite=s,e=s.mouse,e[i]=1,e.hover<=0&&(e.hover=1)}},j=function(e){if(!t._setupDone)return;let i="left";1===e.button?i="center":2===e.button&&(i="right");let s=t.mouse;s[i]>0&&(s._dragFrame[i]=!0)},P=function(e){if(!t._setupDone)return;if(!(T>0))return;T--;let i="left";1===e.button?i="center":2===e.button&&(i="right");let s=t.mouse;s[i]>=s.holdThreshold?s[i]=-2:s[i]>1?s[i]=-1:s[i]=-3,s.drag[i]>0&&(s.drag[i]=-1);let r=t.world.mouseSprite?.mouse;r&&(r.hover>1?(r[i]>=t.mouse.holdThreshold?r[i]=-2:r[i]>1?r[i]=-1:r[i]=-3,r.drag[i]>0&&(r.drag[i]=-1)):(r[i]=0,r.drag[i]=0))};if(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}},t.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(),s&&t._onmousedown(e));t.touchStarted&&!t.touchStarted(e)&&e.preventDefault()}},t._ontouchmove=function(e){if(t._setupDone){for(let i of e.changedTouches){let r=t.touches.find((t=>t.id==i.identifier));r._update(i),r._dragFrame=!0,r.id==t.touches[0].id&&(t.mouseX=t.touches[0].x,t.mouseY=t.touches[0].y,t.mouse._update(),s&&t._onmousemove(e))}t.touchMoved&&!t.touchMoved(e)&&e.preventDefault()}},t._ontouchend=function(e){if(t._setupDone){for(let i of e.changedTouches){let r=t.touches.find((t=>t.id==i.identifier));r._update(i),r.duration>=r.holdThreshold?r.duration=-2:r.duration>1?r.duration=-1:r.duration=-3,r.drag>0&&(r.drag=-1),r.id==t.touches[0].id&&(t.mouseX=t.touches[0].x,t.mouseY=t.touches[0].y,t.mouse._update(),s&&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 O(t){let e=t.code;return 4==e.length&&"Key"==e.slice(0,3)?e[3].toLowerCase():t.key}let F=function(t){let e=t.key;if(this.p5play.standardizeKeyboard&&(e=O(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)},D=function(t){let e=t.key;if(this.p5play.standardizeKeyboard&&(e=O(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)}};window&&(window.addEventListener("keydown",F.bind(this)),window.addEventListener("keyup",D.bind(this))),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,t.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,4*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("fps avg: "+t.p5play._fpsAvg,i,s+e.gap),t.text("fps min: "+t.p5play._fpsMin,i,s+2*e.gap),t.text("fps max: "+t.p5play._fpsMax,i,s+3*e.gap),t.pop()}},p5playAfterSetup=function(){const t=this;t._isGlobal&&window.update&&(t.update=window.update,t._q5||(window.draw=()=>{})),t._isGlobal&&window.drawFrame&&(t.drawFrame=window.drawFrame),this.update??=()=>{},this.drawFrame??=()=>{},t._setupDone=!0},p5playPreDraw=function(){const t=this;t._q5||(t.p5play._preDrawFrameTime=performance.now()),t.p5play.spritesDrawn=0,t.mouse._update(),t.contros._update(),t.update(),t.allSprites._autoUpdate&&t.allSprites.update(),t.allSprites._autoUpdate??=!0},p5playPostDraw=function(){const t=this;t.p5play._inPostDraw=!0,t.allSprites.autoCull&&t.allSprites.cull(1e4),t.world.autoStep&&t.world.timeScale>0&&t.world.physicsUpdate(),t.world.autoStep??=!0,t.drawFrame(),t.allSprites._autoDraw&&(t.camera.on(),t.allSprites.draw()),t.allSprites._autoDraw??=!0,t.camera.off(),t.allSprites.postDraw(),t.p5play.renderStats&&t.renderStats();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._q5||(t.p5play._postDrawFrameTime=performance.now(),t.p5play._fps=Math.round(1e3/(t.p5play._postDrawFrameTime-t.p5play._preDrawFrameTime))||1),t.p5play._inPostDraw=!1};null==p5.prototype?.registerMethod?(console.error("p5play is not compatible with p5.js v2. Please use p5.js v1 or q5.js. https://q5js.org"),p5.registerAddon(((t,e,i)=>{let s={loadImage:()=>new t.Image(1,1),loadModel:()=>new t.Geometry,loadJSON:()=>{},loadStrings:()=>[],loadFont:e=>new t.Font(e,new FontFace("default","default.woff"))};t.isPreloadSupported=()=>!0;let r=[],o={};for(let t in s){let i=e[t];o[t]=i,e[t]=function(...e){if(!this._isInPreload)return i.apply(this,e);let o=s[t](this),h=i.apply(this,e).then((t=>{for(let e in t)o[e]=t[e]}));return r.push(h),o}}delete e.code,i.presetup=async function(){const t=this;if(t.createCanvas.call(t,100,100),p5playInit.call(t),t._isGlobal){let e=["p5play","DYN","DYNAMIC","STA","STATIC","KIN","KINEMATIC","Sprite","Ani","Anis","Group","World","world","createCanvas","Canvas","canvas","displayMode","Camera","camera","Tiles","Joint","GlueJoint","DistanceJoint","WheelJoint","HingeJoint","SliderJoint","RopeJoint","GrabberJoint","kb","keyboard","mouse","touches","allSprites","camera","contro","contros","controllers","spriteArt","EmojiImage","getFPS"];for(let i of e)window[i]=t[i]}window.preload&&(t._isInPreload=!0,window.preload(),t._isInPreload=!1,await Promise.all(r))},i.postsetup=p5playAfterSetup,i.predraw=p5playPreDraw,i.postdraw=p5playPostDraw}))):(p5.prototype.registerMethod("init",p5playInit),p5.prototype.registerMethod("afterSetup",p5playAfterSetup),p5.prototype.registerMethod("pre",p5playPreDraw),p5.prototype.registerMethod("post",p5playPostDraw));
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "p5play",
3 | "author": "quinton-ashley ",
4 | "bugs": {
5 | "url": "https://github.com/quinton-ashley/p5play/issues"
6 | },
7 | "contributors": [
8 | "Paolo Pedercini "
9 | ],
10 | "description": "A JavaScript game engine that uses p5.js for graphics and Box2D for physics.",
11 | "funding": [
12 | {
13 | "type": "patreon",
14 | "url": "https://www.patreon.com/q5play"
15 | },
16 | {
17 | "type": "ko-fi",
18 | "url": "https://ko-fi.com/q5play"
19 | },
20 | {
21 | "type": "github",
22 | "url": "https://github.com/sponsors/quinton-ashley"
23 | }
24 | ],
25 | "keywords": [
26 | "p5.play",
27 | "p5.js",
28 | "p5js",
29 | "p5",
30 | "q5",
31 | "box2d",
32 | "physics",
33 | "physics engine",
34 | "physics simulation",
35 | "game engine",
36 | "games",
37 | "animation",
38 | "user input",
39 | "controller",
40 | "gamepad"
41 | ],
42 | "license": "p5play Personal License",
43 | "main": "p5play.js",
44 | "types": "p5play.d.ts",
45 | "homepage": "https://p5play.org",
46 | "repository": {
47 | "type": "git",
48 | "url": "git+https://github.com/quinton-ashley/p5play.git"
49 | },
50 | "scripts": {
51 | "min": "terser p5play.js --compress ecma=2025 --mangle > p5play.min.js",
52 | "v": "npm version patch --force",
53 | "V": "npm version minor --force",
54 | "version": "git add -A",
55 | "postversion": "git push"
56 | },
57 | "version": "3.30.2"
58 | }
59 |
--------------------------------------------------------------------------------