diff --git a/p5play.js b/p5play.js index 717cc0a5..139bfbed 100644 --- a/p5play.js +++ b/p5play.js @@ -1038,9 +1038,7 @@ p5.prototype.registerMethod('init', function p5playInit() { } w = max.x - min.x; - this._hw = w * 0.5; h = max.y - min.y; - this._hh = h * 0.5; if (this._originMode == 'start') { for (let i = 0; i < vecs.length; i++) { @@ -1098,12 +1096,16 @@ p5.prototype.registerMethod('init', function p5playInit() { } } this.shape ??= shape; - this._w = w; - this._hw = w * 0.5; - if (this.__shape != 1) { - this._h = h; - this._hh = h * 0.5; + + if (!this.fixtureList) { + this._w = w; + this._hw = w * 0.5; + if (this.__shape != 1) { + this._h = h; + this._hh = h * 0.5; + } } + return s; } @@ -6022,7 +6024,7 @@ p5.prototype.registerMethod('init', function p5playInit() { */ removeAll() { while (this.length > 0) { - this[0].remove(); + this.at(-1).remove(); } } diff --git a/p5play.min.js b/p5play.min.js index 855f4c41..249160a8 100644 --- a/p5play.min.js +++ b/p5play.min.js @@ -4,4 +4,4 @@ * @author quinton-ashley * @license AGPL-3.0 */ -if("object"!=typeof planck){if("object"!=typeof process)throw"planck.js must be loaded before p5play";global.planck=require("./planck.min.js")}p5.prototype.registerMethod("init",(function(){const t=this,e=planck,i=60;if("object"!=typeof process&&0!=window._p5play_gtagged){let I=document.createElement("script");I.src="https://www.googletagmanager.com/gtag/js?id=G-EHXNCTSYLK",I.async=!0,document.head.append(I),window._p5play_gtagged=!0,I.onload=()=>{window.dataLayer??=[],window.gtag=function(){dataLayer.push(arguments)},gtag("js",new Date),gtag("config","G-EHXNCTSYLK"),gtag("event","p5play_v3_19")}}t.angleMode("degrees");const s=(t,s,r)=>new e.Vec2(t*r/i,s*r/i),r=(t,s,r)=>new e.Vec2(t/r*i,s/r*i),o=t=>Math.abs(t)<=e.Settings.linearSlop,n=(t,i)=>Math.abs(t-Math.round(t))<=(i||e.Settings.linearSlop)?Math.round(t):t,h=(e,i)=>{let s="degrees"==t._angleMode?360:t.TWO_PI,r=(e-i)%s,o=(s-Math.abs(r))*-Math.sign(r);return(Math.abs(r)-1){let e=navigator.userAgent.substring(t+10,t+12);this.os.platform="iOS",this.os.version=e}else{let t=navigator.userAgentData?.platform;!t&&navigator.platform&&(t=navigator.platform.slice(3),"Mac"==t?t="macOS":"Win"==t?t="Windows":"Lin"==t&&(t="Linux")),this.os.platform=t}this._renderStats={},this._fps=60,this._fpsArr=[60],this._collides={},this._colliding={},this._collided={},this._overlaps={},this._overlapping={},this._overlapped={}}onImageLoad(){}},this.p5play=new t.P5Play,delete t.P5Play;const l=console.log;this.log=console.log,this.Sprite=class{constructor(s,r,o,h,a){this._isSprite=!0,this.idNum;let l,c,_=[...arguments];if(void 0!==_[0]&&_[0]._isGroup&&(l=_[0],_=_.slice(1)),void 0!==_[0]&&("string"==typeof _[0]||_[0]instanceof t.SpriteAnimation||_[0]instanceof p5.Image)&&(c=_[0],_=_.slice(1)),1==_.length&&"number"==typeof _[0])throw new A("Sprite",0,[_[0]]);if(Array.isArray(_[0])){if(s=void 0,r=void 0,o=_[0],h=void 0,a=_[1],Array.isArray(a))throw new A("Sprite",1,[`[[${o}], [${h}]]`])}else s=_[0],r=_[1],o=_[2],h=_[3],a=_[4];"string"==typeof o&&(a=o,o=void 0),"string"==typeof h&&(!function(t){if("d"==t||"s"==t||"k"==t||"n"==t)return!0;let e=t.slice(0,2);return"dy"==e||"st"==e||"ki"==e||"no"==e}(h)?o=u(o,h):a=h,h=void 0),this.idNum=t.p5play.spritesCreated,this._uid=1e3+this.idNum,t.p5play.sprites[this._uid]=this,t.p5play.spritesCreated++,this.groups=[],this.animations=new t.SpriteAnimations,this.joints=[],this.joints.removeAll=()=>{for(let t of this.joints)t.remove()},this.watch,this.mod={},this._removed=!1,this._life=2147483647,this._visible=!0,this._pixelPerfect=!1,this._aniChangeCount=0,this._draw=()=>this.__draw(),this._hasOverlap={},this._collisions={},this._overlappers={},l??=t.allSprites,this.tileSize=l.tileSize||1;let f=this;this._position={x:0,y:0},this._pos=t.createVector.call(t),Object.defineProperty(this._pos,"x",{get(){if(!f.body)return f._position.x;let e=f.body.getPosition().x/f.tileSize*i;return t.p5play.friendlyRounding?n(e):e},set(t){if(f.body){let s=new e.Vec2(t*f.tileSize/i,f.body.getPosition().y);f.body.setPosition(s)}f._position.x=t}}),Object.defineProperty(this._pos,"y",{get(){if(!f.body)return f._position.y;let e=f.body.getPosition().y/f.tileSize*i;return t.p5play.friendlyRounding?n(e):e},set(t){if(f.body){let s=new e.Vec2(f.body.getPosition().x,t*f.tileSize/i);f.body.setPosition(s)}f._position.y=t}}),this._velocity={x:0,y:0},this._vel=t.createVector.call(t),Object.defineProperties(this._vel,{x:{get(){let e;return e=f.body?f.body.getLinearVelocity().x:f._velocity.x,e/=f.tileSize,t.p5play.friendlyRounding?n(e):e},set(t){t*=f.tileSize,f.body?f.body.setLinearVelocity(new e.Vec2(t,f.body.getLinearVelocity().y)):f._velocity.x=t}},y:{get(){let e;return e=f.body?f.body.getLinearVelocity().y:f._velocity.y,e/=f.tileSize,t.p5play.friendlyRounding?n(e):e},set(t){t*=f.tileSize,f.body?f.body.setLinearVelocity(new e.Vec2(f.body.getLinearVelocity().x,t)):f._velocity.y=t}}}),this._mirror={_x:1,_y:1,get x(){return this._x<0},set x(t){f.watch&&(f.mod[22]=!0),this._x=t?-1:1},get y(){return this._y<0},set y(t){f.watch&&(f.mod[22]=!0),this._y=t?-1:1}},this._heading="right",this._layer=l._layer,this._layer??=t.allSprites._getTopLayer()+1,l.dynamic&&(a??="dynamic"),l.kinematic&&(a??="kinematic"),l.static&&(a??="static"),a??=l.collider,a&&"string"==typeof a||(a="dynamic"),this.collider=a,s??=l.x,void 0===s&&(s=t.width/this.tileSize/2,o&&(this._vertexMode=!0)),r??=l.y,void 0===r&&(r=t.height/this.tileSize/2);let g=!1;if(void 0===o&&(o=l.w||l.width||l.d||l.diameter||l.v||l.vertices,h||l.d||l.diameter||(h=l.h||l.height,g=!0)),"function"==typeof s&&(s=s(l.length)),"function"==typeof r&&(r=r(l.length)),"function"==typeof o&&(o=o(l.length)),"function"==typeof h&&(h=h(l.length)),this.x=s,this.y=r,!l._isAllSpritesGroup&&!c)for(let t in l.animations){c=t;break}for(let e=l;e;e=t.p5play.groups[e.parent])this.groups.push(e);if(this.groups.reverse(),c){c instanceof p5.Image?this.addAni(c):"string"==typeof c?this._changeAni(c):this._ani=c.clone();let t=this.tileSize;o||1==this._ani.w&&1==this._ani.h||(o=this._ani.w/t,h??=this._ani.h/t)}if(this.groups=[],this.mouse=new t._SpriteMouse,this._angle=0,this._rotationSpeed=0,this._bearing=0,this._scale=new d,Object.defineProperty(this._scale,"x",{get(){return this._x},set(t){if(t==this._x)return;f.watch&&(f.mod[28]=!0);let e=Math.abs(t/this._x);f._w*=e,f._hw*=e,f._resizeColliders({x:e,y:1}),this._x=t,this._avg=.5*(this._x+this._y)}}),Object.defineProperty(this._scale,"y",{get(){return this._y},set(t){if(t==this._y)return;f.watch&&(f.mod[28]=!0);let e=Math.abs(t/this._y);f._h&&(this._h*=e,this._hh*=e),f._resizeColliders({x:1,y:e}),this._y=t,this._avg=.5*(this._x+this._y)}}),this._offset={_x:0,_y:0,get x(){return this._x},set x(t){t!=this._x&&(f.watch&&(f.mod[23]=!0),f._offsetCenterBy(t-this._x,0))},get y(){return this._y},set y(t){t!=this._y&&(f.watch&&(f.mod[23]=!0),f._offsetCenterBy(0,t-this._y))}},this._massUndef=!0,void 0===o&&(this._dimensionsUndef=!0,this._widthUndef=!0,o=this.tileSize>1?1:50,void 0===h&&(this._heightUndef=!0)),g&&(h??=this.tileSize>1?1:50),this._shape=l.shape,3!=this.__collider)this._vertexMode?this.addCollider(o):this.addCollider(0,0,o,h),this.shape=this._shape;else{if(this.w=o,Array.isArray(o))throw new Error('Cannot set the collider type of a sprite with a polygon or chain shape to "none". To achieve the same effect, use .overlaps(allSprites) to have your sprite overlap with the allSprites group.');void 0!==o&&void 0===h?this.shape="circle":(this.shape="box",this.h=h)}this.prevPos={x:s,y:r},this.prevRotation=0,this._dest={x:s,y:r},this._destIdx=0,this._debug=!1,this.text,l._isAllSpritesGroup||t.allSprites.push(this),l.push(this);let m=l.vel.x||0,y=l.vel.y||0;"function"==typeof m&&(m=m(l.length-1)),"function"==typeof y&&(y=y(l.length-1)),this.vel.x=m,this.vel.y=y;let x=["ani","collider","x","y","w","h","d","diameter","dynamic","height","kinematic","static","vel","width"];for(let e of t.Sprite.propsAll){if(x.includes(e))continue;let t=l[e];void 0!==t&&("function"==typeof t&&p(t)&&(t=t(l.length-1)),this[e]="object"==typeof t?Object.assign({},t):t)}x=["add","animation","animations","autoCull","contains","GroupSprite","Group","idNum","length","mod","mouse","p","parent","Sprite","Subgroup","subgroups","velocity"];for(let e=0;e1?1:50,h??=n,d=s(n-.08,h-.08,this.tileSize)),"box"==l)p=e.Box(d.x/2,d.y/2,s(i,r,this.tileSize),0);else if("circle"==l)p=e.Circle(s(i,r,this.tileSize),d.x/2);else if(a){let _,f,g=[{x:0,y:0}],m={x:0,y:0},y={x:0,y:0},x={x:0,y:0},w=Array.isArray(a[0]);function v(){m.xx.x&&(x.x=m.x),m.y>x.y&&(x.y=m.y)}if(w){this._vertexMode&&(_=a[0][0],f=a[0][1],this.fixture&&this._relativeOrigin?(_=this.x-this._relativeOrigin.x,f=this.y-this._relativeOrigin.y,g.pop()):(this.x=_,this.y=f));for(let S=0;S0?1:-1;A=Math.abs(A);let k=0;for(let M=0;Me.Settings.maxPolygonVertices||"chain"==this._shape)&&(l="chain"),"polygon"==l?p=e.Polygon(g):"chain"==l&&(p=e.Chain(g,!1))}return this.shape??=l,this._w=n,this._hw=.5*n,1!=this.__shape&&(this._h=h,this._hh=.5*h),p}removeColliders(){this.body&&(this._removeContacts(0),this._removeFixtures(0))}removeSensors(){this.body&&(this._removeContacts(1),this._removeFixtures(1),this._hasSensors=!1)}_removeFixtures(e){let i;for(let s=this.fixtureList;s;s=s.getNext())if(void 0===e||s.m_isSensor==e){let e=s.m_next;s.destroyProxies(t.world.m_broadPhase),i?i.m_next=e:this.body.m_fixtureList=e}else i=s}_removeContacts(e){if(!this.body)return;let i=this.body.m_contactList;for(;i;){let s=i.contact;i=i.next,void 0!==e&&s.m_fixtureA.m_isSensor!=e||t.world.destroyContact(s)}}_offsetCenterBy(t,e){if(!t&&!e)return;if(this._offset._x+=t,this._offset._y+=e,!this.body)return;let i=s(t,e,this.tileSize);for(let t=this.body.m_fixtureList;t;t=t.m_next){let e=t.m_shape;if("circle"!=e.m_type){let t=e.m_vertices;for(let e of t)e.x+=i.x,e.y+=i.y}else e.m_p.x+=i.x,e.m_p.y+=i.y}}_cloneBodyProps(){let t={},e=["bounciness","density","drag","friction","heading","isSuperFast","rotation","rotationDrag","rotationLock","rotationSpeed","scale","vel","x","y"];this._massUndef&&this._dimensionsUndef||e.push("mass");for(let i of e)"object"==typeof this[i]?t[i]=Object.assign({},this[i]):t[i]=this[i];return t}get animation(){return this._ani}set animation(t){this.changeAni(t)}get ani(){return this._ani}set ani(t){this.changeAni(t)}get anis(){return this.animations}get autoDraw(){return this._autoDraw}set autoDraw(t){this.watch&&(this.mod[6]=!0),this._autoDraw=t}get allowSleeping(){return this.body?.isSleepingAllowed()}set allowSleeping(t){this.watch&&(this.mod[7]=!0),this.body&&this.body.setSleepingAllowed(t)}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){this.watch&&(this.mod[8]=!0),this._autoUpdate=t}get bounciness(){if(this.fixture)return this.fixture.getRestitution()}set bounciness(t){this.watch&&(this.mod[9]=!0);for(let e=this.fixtureList;e;e=e.getNext())e.setRestitution(t)}get centerOfMass(){let e=this.body.getWorldCenter(),i=r(e.x,e.y,this.tileSize);return t.createVector(i.x,i.y)}get collider(){return this._collider}set collider(e){if(e==this._collider)return;let i=(e=e.toLowerCase())[0];if("d"==i&&(e="dynamic"),"s"==i&&(e="static"),"k"==i&&(e="kinematic"),"n"==i&&(e="none"),e==this._collider)return;if("none"==e&&("chain"==this._shape||"polygon"==this._shape))return void console.error('Cannot set the collider type of a polygon or chain collider to "none". To achieve the same effect, use .overlaps(allSprites) to have your sprite overlap with the allSprites group.');if(this._removed)throw new Error("Cannot change the collider type of a sprite that was removed.");let s=this.__collider;this._collider=e,this.__collider=["d","s","k","n"].indexOf(i),this.watch&&(this.mod[10]=!0),void 0!==s&&(3!=this.__collider?(this.body&&this.body.setType(e),3==s&&this.addCollider()):(this.removeColliders(),this.fixture?.m_isSensor?this.body.m_gravityScale=0:(t.world.destroyBody(this.body),this.body=null)))}_parseColor(e){return e instanceof p5.Color?e:"object"!=typeof e?1==e.length?t.colorPal(e):t.color(e):t.color(...e.levels)}get color(){return this._color}set color(t){this.watch&&(this.mod[11]=!0),this._color=this._parseColor(t)}get colour(){return this._color}set colour(t){this.color=t}get fill(){return this._color}set fill(t){this.color=t}get fillColor(){return this._color}set fillColor(t){this.color=t}get stroke(){return this._stroke}set stroke(t){this.watch&&(this.mod[31]=!0),this._stroke=this._parseColor(t)}get strokeColor(){return this._stroke}set strokeColor(t){this.stroke=t}get strokeWeight(){return this._strokeWeight}set strokeWeight(t){this.watch&&(this.mod[32]=!0),this._strokeWeight=t}get textColor(){return this._textFill}set textColor(t){this.watch&&(this.mod[34]=!0),this._textFill=this._parseColor(t)}get textColour(){return this._textFill}set textColour(t){this.textColor=t}get textFill(){return this._textFill}set textFill(t){this.textColor=t}get textSize(){return this._textSize}set textSize(t){this.watch&&(this.mod[40]=!0),this._textSize=t}get textStroke(){return this._textStroke}set textStroke(t){this.watch&&(this.mod[41]=!0),this._textStroke=this._parseColor(t)}get textStrokeWeight(){return this._textStrokeWeight}set textStrokeWeight(t){this.watch&&(this.mod[42]=!0),this._textStrokeWeight=t}get bearing(){return this._bearing}set bearing(t){this.watch&&(this.mod[39]=!0),this._bearing=t}get debug(){return this._debug}set debug(t){this.watch&&(this.mod[12]=!0),this._debug=t}get density(){if(this.fixture)return this.fixture.getDensity()}set density(t){this.watch&&(this.mod[13]=!0);for(let e=this.fixtureList;e;e=e.getNext())e.setDensity(t)}_getDirectionAngle(e){e=e.toLowerCase().replaceAll(/[ _-]/g,"");let i={up:-90,down:90,left:180,right:0,upright:-45,rightup:-45,upleft:-135,leftup:-135,downright:45,rightdown:45,downleft:135,leftdown:135,forward:this.rotation,backward:this.rotation+180}[e];return"radians"==t._angleMode&&(i=t.radians(i)),i}get direction(){return 0!==this.vel.x||0!==this.vel.y?t.atan2(this.vel.y,this.vel.x):void 0===this._direction?this.rotation:this._direction}set direction(e){this.watch&&(this.mod[14]=!0),"string"==typeof e&&(this._heading=e,e=this._getDirectionAngle(e)),this._direction=e;let i=this.speed;this.vel.x=t.cos(e)*i,this.vel.y=t.sin(e)*i}get drag(){return this.body?.getLinearDamping()}set drag(t){this.watch&&(this.mod[15]=!0),this.body&&this.body.setLinearDamping(t)}get draw(){return this._display}set draw(t){this._draw=t}get dynamic(){return this.body?.isDynamic()}set dynamic(t){this.collider=t?"dynamic":"kinematic"}get fixture(){return this.fixtureList}get fixtureList(){return this.body?this.body.m_fixtureList:null}get friction(){if(this.fixture)return this.fixture.getFriction()}set friction(t){this.watch&&(this.mod[16]=!0);for(let e=this.fixtureList;e;e=e.getNext())e.setFriction(t)}get heading(){return this._heading}set heading(t){this.direction=t}get img(){return this._ani?.frameImage}set img(t){this.changeAni(t)}get image(){return this._ani?.frameImage}set image(t){this.changeAni(t)}get isMoving(){return 0!=this.vel.x||0!=this.vel.y}get isSuperFast(){return this.body?.isBullet()}set isSuperFast(t){this.watch&&(this.mod[18]=!0),this.body&&this.body.setBullet(t)}get kinematic(){return this.body?.isKinematic()}set kinematic(t){this.collider=t?"kinematic":"dynamic"}get layer(){return this._layer}set layer(t){this.watch&&(this.mod[19]=!0),this._layer=t}get life(){return this._life}set life(t){this.watch&&(this.mod[20]=!0),this._life=t}get mass(){return this.body?.getMass()}set mass(t){if(!this.body)return;this.watch&&(this.mod[21]=!0);let e=this.massData;e.mass=t>0?t:1e-8,this.body.setMassData(e),delete this._massUndef}get massData(){const t={I:0,center:new e.Vec2(0,0),mass:0};return this.body.getMassData(t),t.center=r(t.center.x,t.center.y,this.tileSize),t}resetMass(){this.body&&(this.watch&&(this.mod[21]=!0),this.body.resetMassData())}get mirror(){return this._mirror}set mirror(t){this.watch&&(this.mod[22]=!0),void 0!==t.x&&(this._mirror.x=t.x),void 0!==t.y&&(this._mirror.y=t.y)}get offset(){return this._offset}set offset(t){t.x??=this._offset._x,t.y??=this._offset._y,t.x==this._offset._x&&t.y==this._offset._y||(this.watch&&(this.mod[23]=!0),this._offsetCenterBy(t.x-this._offset._x,t.y-this._offset._y))}get opacity(){return this._opacity??1}set opacity(t){this.watch&&(this.mod[43]=!0),this._opacity=t}get previousPosition(){return this.prevPos}set previousPosition(t){this.prevPos=t}get previousRotation(){return this.prevRotation}set previousRotation(t){this.prevRotation=t}get pixelPerfect(){return this._pixelPerfect}set pixelPerfect(t){this.watch&&(this.mod[24]=!0),this._pixelPerfect=t}get removed(){return this._removed}set removed(t){t&&!this._removed&&(this.watch&&(this.mod[25]=!0),this._removed=!0,this._remove())}get rotation(){if(!this.body)return this._angle||0;let i=this.body.getAngle();return"degrees"==t._angleMode&&(i=t.degrees(i)),t.p5play.friendlyRounding?n(i,e.Settings.angularSlop):i}set rotation(e){this.body?("degrees"==t._angleMode&&(e=t.radians(e%360)),this.body.setAngle(e),this.body.synchronizeTransform()):this._angle=e}get rotationDrag(){return this.body?.getAngularDamping()}set rotationDrag(t){this.body&&(this.watch&&(this.mod[26]=!0),this.body.setAngularDamping(t))}get rotationLock(){return this.body?.isFixedRotation()}set rotationLock(t){if(!this.body)return;this.watch&&(this.mod[27]=!0);let e=this.mass;this.body.setFixedRotation(t),this.mass=e}get rotationSpeed(){if(this.body){let e=this.body.getAngularVelocity()/60;return"degrees"==t._angleMode?t.degrees(e):e}return this._rotationSpeed}set rotationSpeed(e){this.body?(e*=60,"degrees"==t._angleMode&&(e=t.radians(e)),this.body.setAngularVelocity(e)):this._rotationSpeed=e}get scale(){return this._scale}set scale(t){if(0==t&&(t=.01),"number"==typeof t?t={x:t,y:t}:(t.x??=this._scale._x,t.y??=this._scale._y),t.x==this._scale._x&&t.y==this._scale._y)return;this.watch&&(this.mod[28]=!0);let e={x:Math.abs(t.x/this._scale._x),y:Math.abs(t.y/this._scale._y)};this._w*=e.x,this._hw*=e.x,this._h&&(this._h*=e.y,this._hh*=e.y),this._resizeColliders(e),this._scale._x=t.x,this._scale._y=t.y,this._scale._avg=t.x}get sleeping(){if(this.body)return!this.body.isAwake()}set sleeping(t){this.body&&(this.watch&&(this.mod[30]=!0),this.body.setAwake(!t))}get speed(){return t.createVector(this.vel.x,this.vel.y).mag()}set speed(e){let i=this.direction;this.vel.x=t.cos(i)*e,this.vel.y=t.sin(i)*e}get static(){return this.body?.isStatic()}set static(t){this.collider=t?"static":"dynamic"}get tint(){return this._tint}set tint(t){this.watch&&(this.mod[44]=!0),this._tint=this._parseColor(t)}get tintColor(){return this._tint}set tintColor(t){this.tint=t}set vertices(t){if(3==this.__collider)throw new Error('Cannot set vertices of a sprite with collider type of "none".');this.watch&&(this.mod[29]=!0),this._removeFixtures(),this._originMode="start",this.addCollider(t),this._hasSensors&&this.addDefaultSensors()}get vertices(){return this._getVertices()}_getVertices(e){let s=this.fixture.getShape(),r=[...s.m_vertices];"polygon"==s.m_type&&r.unshift(r.at(-1));let o=this.x,h=this.y;for(let s=0;s=2)return void console.error('Cannot set the collider shape to chain or polygon if the sprite has a collider type of "none". To achieve the same effect, use .overlaps(allSprites) to have your sprite overlap with the allSprites group.');if(1==this.__shape&&0!=i)return void console.error("Cannot change a circle collider into a chain or polygon shape.");let s,r,o=this.__shape;if(this.__shape=i,this._shape=e,this.watch&&(this.mod[29]=!0),void 0===o)return;0==this.__shape?(this._h=this._w,this._hh=this._hw):(this._h=void 0,this._hh=void 0),1!=o&&1!=this.__shape?s=this._getVertices(!0):r=this._w,this._removeFixtures(),3!=this.__collider&&(s?(this._originMode??="center",this.addCollider(s)):this.addCollider()),this._hasSensors&&this.addDefaultSensors();let n=this._offset._x,h=this._offset._y;(n||h)&&(this._offset._x=0,this._offset._y=0,this._offsetCenterBy(n,h))}get update(){return this._update}set update(t){this._customUpdate=t}get vel(){return this._vel}set vel(t){this.vel.x=t.x,this.vel.y=t.y}set velocity(t){this.vel=t}get velocity(){return this._vel}_update(){this._ani?.update&&this._ani.update();for(let t in this.mouse)-1==this.mouse[t]&&(this.mouse[t]=0);this._customUpdate&&this._customUpdate(),this.autoUpdate&&(this.autoUpdate=null)}_step(){this.life-=t.world.timeScale,2147483647!=this._life&&this._life<=0&&this.remove(),this.body||this._removed||(this.rotation+=this._rotationSpeed,this.x+=this.vel.x,this.y+=this.vel.y),this.watch&&(this.x!=this.prevX&&(this.mod[0]=this.mod[2]=!0),this.y!=this.prevY&&(this.mod[1]=this.mod[2]=!0),this.rotation!=this.prevRotation&&(this.mod[3]=this.mod[4]=!0)),(this.body||this._removed)&&this.__step()}__draw(){if(this._ani&&"colliders"!=this.debug&&!t.p5play.disableImages&&this._ani.draw(this._offset._x,this._offset._y,0,this._scale._x,this._scale._y),!this._ani||this.debug||t.p5play.disableImages)if(this.debug&&(t.noFill(),t.stroke(0,255,0),t.line(0,-2,0,2),t.line(-2,0,2,0)),3!=this.__collider){this.debug||0===this._strokeWeight||(2==this.__shape?t.stroke(this.stroke||this.color):this._stroke&&t.stroke(this._stroke));for(let e=this.fixtureList;e;e=e.getNext()){if(this.debug)e.m_isSensor?t.stroke(255,255,0):t.stroke(0,255,0);else if(e.m_isSensor)continue;this._drawFixture(e)}}else 0!==this._strokeWeight&&t.stroke(this._stroke||120),0==this.__shape?t.rect(this._offset._x,this._offset._y,this.w*this.tileSize,this.h*this.tileSize):1==this.__shape&&t.circle(this._offset._x,this._offset._y,this.d*this.tileSize);void 0!==this.text&&(t.textAlign(t.CENTER,t.CENTER),t.fill(this._textFill),this._textStrokeWeight&&t.strokeWeight(this._textStrokeWeight),this._textStroke?t.stroke(this._textStroke):t.noStroke(),t.textSize(this.textSize*this.tileSize),t.text(this.text,0,0))}_display(){let e=this.x*this.tileSize+t.world.origin.x,i=this.y*this.tileSize+t.world.origin.y,s=Math.max(this._w,this._h);if("chain"!=this.shape&&t.camera.isActive&&(e+st.camera.bound.max.x||i+st.camera.bound.max.y))this._visible=null;else{if(this._visible=!0,t.p5play.spritesDrawn++,this._pixelPerfect){let s,r;this.ani&&!t.p5play.disableImages?(s=this.ani[this.ani._frame].w,r=this.ani[this.ani._frame].h):(s=this._w,r=this._h),e=s%2==0?Math.round(e):Math.round(e-.5)+.5,i=r%2==0?Math.round(i):Math.round(i-.5)+.5}else e=n(e),i=n(i);for(let t of this.joints)t.visible?this._uid==t.spriteA._uid?(!t.spriteB._visible||this.layer<=t.spriteB.layer)&&t._display():(!t.spriteA._visible||this.layer{let s,r;do{if(await t.sleep(),c!=this._destIdx)return!1;if(u&&(this.direction<=a||this.direction>=l)||Math.abs(this.vel.x)<=d&&Math.abs(this.vel.y)<=d)return!1;e&&(s=this.vel.x>0?this._dest.x-this.x:this.x-this._dest.x),i&&(r=this.vel.y>0?this._dest.y-this.y:this.y-this._dest.y)}while(e&&s>p||i&&r>p);return this.x=this._dest.x,this.y=this._dest.y,this.vel.x=0,this.vel.y=0,!0})()}rotateTowards(t,e){if(1==this.__collider)throw new A(0);let i,s,r,o=arguments;"number"!=typeof o[0]?(i=o[0].x,s=o[0].y,e=o[1],r=o[2]):arguments.length>2&&(i=o[0],s=o[1],e=o[2],r=o[3]),void 0!==i?t=this.angleToFace(i,s,r):t-=this.rotation,e??=.1,this.rotationSpeed=t*e}angleTo(e,i){if("object"==typeof e){let s=e;if(s==t.mouse&&!t.mouse.isActive)return 0;if(void 0===s.x||void 0===s.y)return console.error("sprite.angleTo ERROR: rotation destination not defined, object given with no x or y properties"),0;i=s.y,e=s.x}return t.atan2(i-this.y,e-this.x)}rotationToFace(t,e,i){return"object"==typeof t&&(i=e,e=t.y,t=t.x),Math.abs(t-this.x)<.01&&Math.abs(e-this.y)<.01?0:this.angleTo(t,e)+(i||0)}angleToFace(t,e,i){let s=this.rotationToFace(t,e,i);return h(s,this.rotation)}rotateTo(e,i,s){if(1==this.__collider)throw new A(0);let r=arguments;if("number"!=typeof r[0]?e=this.rotationToFace(r[0].x,r[0].y,s):r.length>2&&(s=r[3],i=r[2],e=this.rotationToFace(r[0],r[1],s)),e==this.rotation)return;let o="degrees"==t._angleMode?360:t.TWO_PI;return(e=(e-this.rotation)%o)<0&&i>0&&(e+=o),e>0&&i<0&&(e-=o),i??=this.rotationSpeed||Math.sign(e),this.rotate(e,i)}rotateMinTo(t,e,i){if(1==this.__collider)throw new A(0);let s=arguments;if("number"!=typeof s[0]?t=this.rotationToFace(s[0].x,s[0].y,i):s.length>2&&(i=s[3],e=s[2],t=this.rotationToFace(s[0],s[1],i)),t!=this.rotation)return t=h(t,this.rotation),e??=this.rotationSpeed||Math.sign(t),e=Math.abs(e)*Math.sign(t),this.rotate(t,e)}rotate(e,i){if(1==this.__collider)throw new A(0);if(isNaN(e))throw new A(1,[e]);if(0==e)return;i??=this.rotationSpeed||1;let s=e>0&&i>0;s||(e=-Math.abs(e),i=-Math.abs(i)),this.rotationSpeed=i;let r=this.rotation+e;this._rotateIdx??=0,this._rotateIdx++;let o=this._rotateIdx;return(async()=>{let e=.01,i=Math.abs(this.rotationSpeed)+e;do{if(await t.sleep(),this._rotateIdx!=o)return!1;if(s&&this.rotationSpeed-.01)return!1}while((s&&r>this.rotation||!s&&r1)e=[...arguments];else if(e instanceof t.SpriteAnimation){if(e==this._ani)return;e=[e]}else if(!Array.isArray(e)){if(e==this._ani?.name)return;e=[e]}let i,s;this._aniChangeCount++;for(let r=0;r1&&("!"==o.name[0]&&(o.name=o.name.slice(1),o.start=-1,o.end=0),"<"!=o.name[0]&&">"!=o.name[0]||(o.name=o.name.slice(1),o.flipX=!0),"^"==o.name[0]&&(o.name=o.name.slice(1),o.flipY=!0),"**"==o.name&&(i=!0,e=e.slice(0,-1)),";;"==o.name&&(s=!0,e=e.slice(0,-1)))}let r=this._aniChangeCount;do{for(let t=0;t1&&(i.start=0),await this._playSequencedAni(i)}}while(i&&r==this._aniChangeCount);1!=e.length&&s&&this._ani.stop()}_playSequencedAni(t){return new Promise((e=>{let{name:i,start:s,end:r,flipX:o,flipY:n}=t;this._changeAni(i),o&&(this._ani.scale.x=-this._ani.scale.x),n&&(this._ani.scale.y=-this._ani.scale.y),s<0&&(s=this._ani.length+s),void 0!==s&&(this._ani._frame=s),void 0!==r?this._ani.goToFrame(r):this._ani._frame==this._ani.lastFrame&&e(),this._ani._onComplete=this._ani._onChange=()=>{o&&(this._ani.scale.x=-this._ani.scale.x),n&&(this._ani.scale.y=-this._ani.scale.y),this._ani._onComplete=this._ani._onChange=null,e()}}))}changeAnimation(){return this.changeAni(...arguments)}_changeAni(e){this._ani?._onChange&&this._ani._onChange(),this._ani?.onChange&&this._ani.onChange();let i=this.animations[e];if(!i)for(let t=this.groups.length-1;t>=0;t--){if(i=this.groups[t].animations[e],i){i=i.clone();break}}if(!i)throw t.noLoop(),new A("Sprite.changeAnimation",[e]);this._ani=i,this._ani.name=e,this.resetAnimationsOnChange&&(this._ani._frame=0)}remove(){this.removed=!0}_remove(){this.body&&t.world.destroyBody(this.body),this.body=null;for(let t of this.groups)t.remove(this)}toString(){return"s"+this.idNum}_setContactCB(e,i,s,r){let o;o=0==s?a._collisions[r]:a._overlappers[r];let n=t.p5play[o],h=n[this._uid]??={};h[e._uid]!=i&&(h[e._uid]=i,h=n[e._uid],h&&h[this._uid]&&(delete h[this._uid],0==Object.keys(h).length&&delete n[e._uid]))}_validateCollideParams(t,e){if(!t)throw new A("Sprite.collide",2);if(!t._isSprite&&!t._isGroup)throw new A("Sprite.collide",0,[t]);if(e&&"function"!=typeof e)throw new A("Sprite.collide",1,[e])}_ensureCollide(t,e,i){if(!1!==this._hasOverlap[t._uid]&&(this._hasOverlap[t._uid]=!1),!1!==t._hasOverlap[this._uid]&&(t._hasOverlap[this._uid]=!1,t._isGroup))for(let e of t)e._hasOverlap[this._uid]=!1,this._hasOverlap[e._uid]=!1}collide(t,e){return this.collides(t,e)}collides(t,e){return this._validateCollideParams(t,e),this._ensureCollide(t),e&&this._setContactCB(t,e,0,0),1==this._collisions[t._uid]||this._collisions[t._uid]<=-3}colliding(t,e){this._validateCollideParams(t,e),this._ensureCollide(t),e&&this._setContactCB(t,e,0,1);let i=this._collisions[t._uid];return i<=-3?1:i>0?i:0}collided(t,e){return this._validateCollideParams(t,e),this._ensureCollide(t),e&&this._setContactCB(t,e,0,2),this._collisions[t._uid]<=-1}_validateOverlapParams(t,e){if(!t)throw new A("Sprite.overlap",2);if(!t._isSprite&&!t._isGroup)throw new A("Sprite.overlap",0,[t]);if(e&&"function"!=typeof e)throw new A("Sprite.overlap",1,[e])}_ensureOverlap(t){if(this._hasSensors||this.addDefaultSensors(),!t._hasSensors)if(t._isSprite)t.addDefaultSensors();else{for(let e of t)e._hasSensors||e.addDefaultSensors();t._hasSensors=!0}if(this._hasOverlap[t._uid]||(this._removeContactsWith(t),this._hasOverlap[t._uid]=!0),!t._hasOverlap[this._uid]&&(t._removeContactsWith(this),t._hasOverlap[this._uid]=!0,t._isGroup))for(let e of t)e._hasOverlap[this._uid]=!0,this._hasOverlap[e._uid]=!0}overlap(t,e){return this.overlaps(t,e)}overlaps(t,e){return this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,0),1==this._overlappers[t._uid]||this._overlappers[t._uid]<=-3}overlapping(t,e){this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,1);let i=this._overlappers[t._uid];return i<=-3?1:i>0?i:0}overlapped(t,e){return this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,2),this._overlappers[t._uid]<=-1}_removeContactsWith(t){if(t._isGroup)for(let e of t)this._removeContactsWith(e);else this.__removeContactsWith(t)}__removeContactsWith(e){if(this.body)for(let i=this.body.getContactList();i;i=i.next){let s=i.contact;s.m_fixtureA.m_body.sprite._uid!=e._uid&&s.m_fixtureB.m_body.sprite._uid!=e._uid||t.world.destroyContact(s)}}_sortFixtures(){let t,e,i=null,s=null;for(let r=this.fixtureList;r;r=r.getNext())r.m_isSensor?(s?s.m_next=r:s=r,e=r):(i?i.m_next=r:i=r,t=r);s&&(e.m_next=null),i&&(t.m_next=s),this.body.m_fixtureList=i||s}addDefaultSensors(){if(this._hasSensors)return;let t;if(this.body&&this.fixtureList){for(let e=this.fixtureList;e;e=e.getNext())e.m_isSensor||(t=e.m_shape,this.body.createFixture({shape:t,isSensor:!0}));this._sortFixtures()}else this.addSensor();this._hasSensors=!0}},t.Sprite.propTypes={x:"Float64",y:"Float64",vel:"Vec2",rotation:"number",rotationSpeed:"number",ani:"string",autoDraw:"boolean",allowSleeping:"boolean",autoUpdate:"boolean",bounciness:"number",collider:"Uint8",color:"color",debug:"boolean",density:"number",direction:"number",drag:"number",friction:"number",h:"number",isSuperFast:"boolean",layer:"number",life:"Int32",mass:"number",mirror:"Vec2_boolean",offset:"Vec2",pixelPerfect:"boolean",removed:"boolean",rotationDrag:"number",rotationLock:"boolean",scale:"Vec2",shape:"Uint8",sleeping:"boolean",stroke:"color",strokeWeight:"number",text:"string",textColor:"color",tile:"string",tileSize:"number",visible:"boolean",w:"number",bearing:"number",textSize:"number",textStroke:"color",textStrokeWeight:"number",opacity:"number"},t.Sprite.props=Object.keys(t.Sprite.propTypes),t.Sprite.propsAll=t.Sprite.props.concat(["d","diameter","dynamic","fill","height","heading","kinematic","resetAnimationsOnChange","speed","spriteSheet","static","width"]),t.Sprite.colliderTypes=["d","s","k","n"],t.Sprite.shapeTypes=["box","circle","chain","polygon"],t.Turtle=function(e){if(t.allSprites.tileSize>1)throw new Error("Turtle can't be used when allSprites.tileSize is greater than 1.");e??=25;let i=new t.Sprite(e,e,[[e,.4*e],[-e,.4*e],[0,.8*-e]]);i.color="green",i._isTurtleSprite=!0,i._prevPos={x:i.x,y:i.y};let s=i.move;return i.move=function(){return this._prevPos.x=this.x,this._prevPos.y=this.y,s.call(this,...arguments)},i},this.SpriteAnimation=class extends Array{constructor(){super();let e,i=[...arguments];if(this.name="default","object"==typeof i[0]&&(i[0]._isSprite||i[0]._isGroup)&&(e=i[0],i=i.slice(1),this._addedToSpriteOrGroup=!0),e??=t.allSprites,"string"!=typeof i[0]||1!=i[0].length&&i[0].includes(".")||(this.name=i[0],i=i.slice(1)),this._frame=0,this._cycles=0,this.targetFrame=-1,this.offset={x:e.anis.offset.x??0,y:e.anis.offset.y??0},this._frameDelay=e.anis.frameDelay||4,this.demoMode=e.anis.demoMode??!1,this.playing=!0,this.visible=!0,this.looping=e.anis.looping??!0,this.endOnFirstFrame=e.anis.endOnFirstFrame??!1,this.frameChanged=!1,this.onComplete=this.onChange=null,this._onComplete=this._onChange=null,this.rotation=e.anis.rotation??0,this._scale=new d,0!=i.length&&"number"!=typeof i[0]){if(e.animations[this.name]=this,e._ani=this,Array.isArray(i[0])&&"string"==typeof i[0][0]&&(i=[...i[0]]),2!=i.length||"string"!=typeof i[0]||"string"!=typeof i[1]&&"number"!=typeof i[1])if("string"==typeof i[i.length-1]||i[i.length-1]instanceof p5.Image)for(let s=0;s=3)throw new A("SpriteAnimation",1);o=i[0],r=i[1]}else r=i[0];let n=this;if(o instanceof p5.Image&&1!=o.width&&1!=o.height)this.spriteSheet=o,h();else{let a;a="string"==typeof o?o:o.url,t._incrementPreload(),this.spriteSheet=t.loadImage(a,(()=>{h(),t._decrementPreload()})),"string"==typeof o&&(e.spriteSheet=this.spriteSheet)}function h(){Array.isArray(r)&&(r=4==r.length?{pos:r.slice(0,2),size:r.slice(2)}:{pos:r});let{w:t,h:i,width:s,height:o,size:h,row:a,col:l,line:d,x:p,y:u,pos:c,frames:_,frameCount:f,frameDelay:g,frameSize:m,delay:y,rotation:x}=r;m??=h||e.anis.frameSize,y&&(n.frameDelay=y),g&&(n.frameDelay=g),x&&(n.rotation=x),_&&Array.isArray(_)?f=_.length:f??=_||1,t??=s||e.anis.w,i??=o||e.anis.h,p??=l||0,u??=d||a||0,c&&(p=c[0],u=c[1]),"number"==typeof m?t=i=m:m&&(t=m[0],i=m[1]);let w=e.tileSize;if(t&&i?(t*=w,i*=w):!e._dimensionsUndef&&e.w&&e.h?(t??=e.w*w,i??=e.h*w):1!=w?(t??=w,i??=w):f?(t??=n.spriteSheet.width/f,i??=n.spriteSheet.height):t=i=n.spriteSheet.width=n.spriteSheet.width&&(p=0,u+=i,u>=n.spriteSheet.height&&(u=0))}}}else{let l,p,u=i[0];if(isNaN(i[1])?l=i[1]:p=Number(i[1]),".png"!=u.slice(-4)||l&&".png"!=l.slice(-4))throw new A("SpriteAnimation",0,[u]);let c=0,_=0;for(let m=u.length-5;m>=0&&!isNaN(u.charAt(m));m--)c++;if(l)for(let y=l.length-5;y>=0&&!isNaN(l.charAt(y));y--)_++;let f,g=u.slice(0,-4-c);if(l&&(f=l.slice(0,-4-_)),l&&g!=f)this.push(t.loadImage(u)),this.push(t.loadImage(l));else{let x,w=parseInt(u.slice(-4-c,-4),10);if(p??=parseInt(l.slice(-4-_,-4),10),p=this.length)throw new A("SpriteAnimation.frame",[t,this.length]);this._frame=t,this._cycles=0}get frameDelay(){return this._frameDelay}set frameDelay(t){t<=0&&(t=1),this._frameDelay=t}get scale(){return this._scale}set scale(t){"number"==typeof t&&(t={x:t,y:t}),this._scale._x=t.x,this._scale._y=t.y,this._scale._avg=t.x}clone(){this.length||console.error(`The animation named "${this.name}" must be loaded before it can be properly copied. Sprites need their own copy of a group's animation. Try loading the animation in the preload function and creating new group sprites in the setup function.`);let e=new t.SpriteAnimation;e.spriteSheet=this.spriteSheet;for(let t=0;tthis._frame&&-1!==this.targetFrame?this._frame++:this.targetFrame=this.lastFrame?this._frame=0:this._frame++:this._frame{this._onComplete=()=>{this._onComplete=null,t()}}))}pause(t){this.playing=!1,t&&(this._frame=t)}stop(t){this.playing=!1,t&&(this._frame=t)}rewind(){return this.looping=!1,this.goToFrame(0)}loop(){this.looping=!0,this.playing=!0}noLoop(){this.looping=!1}nextFrame(){this._frame0?this._frame=this._frame-1:this.looping&&(this._frame=this.length-1),this.targetFrame=-1,this.playing=!1,this._cycles=0}goToFrame(t){if(!(t<0||t>=this.length))return this.targetFrame=t,this._cycles=0,this.targetFrame!==this._frame&&(this.playing=!0),new Promise((t=>{this._onComplete=()=>{this._onComplete=null,t()}}))}get lastFrame(){return this.length-1}get frameImage(){let e=this[this._frame];if(e instanceof p5.Image)return e;let{x:i,y:s,w:r,h:o}=e,n=t.createImage(r,o);return n.copy(this.spriteSheet,this.offset.x,this.offset.y,r,o,i,s,r,o),n}get w(){return this.width}get width(){return this[this._frame]instanceof p5.Image?this[this._frame].width:this[this._frame]?this[this._frame].w:1}get h(){return this.height}get height(){return this[this._frame]instanceof p5.Image?this[this._frame].height:this[this._frame]?this[this._frame].h:1}get frames(){let t=[];for(let e=0;ee.#t[t],set(i){e.#t[t]=i;for(let s in e){let r=e[s];r instanceof SpriteAnimation&&(r[t]=i)}}});for(let t of s){this.#t[t]={_x:0,_y:0};for(let i of["x","y"])Object.defineProperty(this.#t[t],i,{get:()=>e.#t[t]["_"+i],set(s){e.#t[t]["_"+i]=s;for(let r in e){let o=e[r];o instanceof SpriteAnimation&&(o[t][i]=s)}}})}}},this.Group=class extends Array{constructor(...e){let i;if(e[0]instanceof t.Group&&(i=e[0],e=e.slice(1)),super(...e),"number"==typeof e[0])return;for(let e of this)if(!(e instanceof t.Sprite))throw new Error("A group can only contain sprites");if(this._isGroup=!0,this.x,this.y,this.vel,this.rotation,this.rotationSpeed,this.autoDraw,this.allowSleeping,this.autoUpdate,this.bounciness,this.collider,this.color,this.debug,this.density,this.direction,this.drag,this.friction,this.h,this.isSuperFast,this.layer,this.life,this.mass,this.mirror,this.offset,this.pixelPerfect,this.removed,this.rotationDrag,this.rotationLock,this.scale,this.shape,this.sleeping,this.stroke,this.strokeWeight,this.text,this.textColor,this.tile,this.tileSize,this.visible,this.w,this.bearing,this.d,this.diameter,this.dynamic,this.height,this.heading,this.kinematic,this.resetAnimationsOnChange,this.speed,this.static,this.width,this.idNum,t.p5play.groupsCreated<999)this.idNum=t.p5play.groupsCreated;else{for(let e=1;et&&(t=e._layer);return t}get ani(){return this._ani}set ani(t){this.addAni(t);for(let e of this)e.changeAni(t)}get animation(){return this._ani}set animation(t){this.ani=t}get anis(){return this.animations}get img(){return this._ani.frameImage}set img(t){this.ani=t}get image(){return this._ani.frameImage}set image(t){this.ani=t}get amount(){return this.length}set amount(t){let e=t-this.length,i=e>0;e=Math.abs(e);for(let t=0;t0?i:0}collided(t,e){return this._validateCollideParams(t,e),this._ensureCollide(t),e&&this._setContactCB(t,e,0,2),this._collisions[t._uid]<=-1}_validateOverlapParams(t,e){if(e&&"function"!=typeof e)throw new A("Group.overlap",1,[e]);if(!t)throw new A("Group.overlap",2);if(!t._isGroup&&!t._isSprite)throw new A("Group.overlap",0,[t])}_ensureOverlap(t){if(!this._hasSensors){for(let t of this)t._hasSensors||t.addDefaultSensors();this._hasSensors=!0}if(!t._hasSensors)if(t._isSprite)t.addDefaultSensors();else{for(let e of t)e._hasSensors||e.addDefaultSensors();t._hasSensors=!0}if(1!=this._hasOverlap[t._uid]){this._removeContactsWith(t),this._hasOverlap[t._uid]=!0;for(let e of this)if(e._hasOverlap[t._uid]=!0,t._hasOverlap[e._uid]=!0,this._uid==t._uid)for(let i of t)e._hasOverlap[i._uid]=!0,i._hasOverlap[e._uid]=!0}if(1!=t._hasOverlap[this._uid]&&(t._removeContactsWith(this),t._hasOverlap[this._uid]=!0,t._isGroup))for(let e of t){e._hasOverlap[this._uid]=!0,this._hasOverlap[e._uid]=!0;for(let t of this)e._hasOverlap[t._uid]=!0,t._hasOverlap[e._uid]=!0}}overlap(t,e){return this.overlaps(t,e)}overlaps(t,e){return this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,0),1==this._overlappers[t._uid]||this._overlappers[t._uid]<=-3}overlapping(t,e){this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,1);let i=this._overlappers[t._uid];return i<=-3?1:i>0?i:0}overlapped(t,e){return this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,2),this._overlappers[t._uid]<=-1}_removeContactsWith(t){for(let e of this)e._removeContactsWith(t)}applyForce(){for(let t of this)t.applyForce(...arguments)}applyForceScaled(){for(let t of this)t.applyForceScaled(...arguments)}attractTo(){for(let t of this)t.attractTo(...arguments)}applyTorque(){for(let t of this)t.applyTorque(...arguments)}move(t,e,i){let s=[];for(let r of this)s.push(r.move(t,e,i));return Promise.all(s)}moveTo(e,i,s){if("number"!=typeof e){let r=e;if(r==t.mouse&&!t.mouse.isActive)return;s=i,i=r.y,e=r.x}let r=this._resetCentroid(),o=[];for(let t of this){let n={x:t.x-r.x+e,y:t.y-r.y+i};o.push(t.moveTo(n.x,n.y,s))}return Promise.all(o)}moveTowards(e,i,s){if("number"!=typeof e){let r=e;if(r==t.mouse&&!t.mouse.isActive)return;s=i,i=r.y,e=r.x}if(void 0!==e||void 0!==i){this._resetCentroid();for(let t of this){void 0===t.distCentroid&&this._resetDistancesFromCentroid();let r={x:t.distCentroid.x+e,y:t.distCentroid.y+i};t.moveTowards(r.x,r.y,s)}}}moveAway(e,i,s){if("number"!=typeof e){let r=e;if(r==t.mouse&&!t.mouse.isActive)return;s=i,i=r.y,e=r.x}if(void 0!==e||void 0!==i){this._resetCentroid();for(let t of this){void 0===t.distCentroid&&this._resetDistancesFromCentroid();let r={x:t.distCentroid.x+e,y:t.distCentroid.y+i};t.moveAway(r.x,r.y,s)}}}push(...e){this.removed&&(console.warn("Adding a sprite to a group that was removed. Use `group.removeAll()` to remove all of a group's sprites without removing the group itself. Restoring the group in p5play's memory."),t.p5play.groups[this._uid]=this,this.removed=!1);for(let i of e){if(!(i instanceof t.Sprite))throw new Error("You can only add sprites to a group, not "+typeof i);if(i.removed){console.error("Can't add a removed sprite to a group");continue}let e;for(let s in this._hasOverlap){let r=this._hasOverlap[s];r&&!i._hasSensors&&i.addDefaultSensors(),e=s>=1e3?t.p5play.sprites[s]:t.p5play.groups[s],e&&!e.removed&&(r?e._ensureOverlap(i):e._ensureCollide(i))}for(let e in a){let s=a[e];for(let e of s){let s=t.p5play[e],r=s[this._uid];if(!r)continue;let o=s[i._uid]??={};for(let t in r)o[t]=r[t]}}super.push(i),this.parent&&t.p5play.groups[this.parent].push(i),i.groups.push(this)}return this.length}size(){return this.length}toString(){return"g"+this.idNum}cull(e,i,s,r,o){if(void 0===s){o=i,e=i=s=r=e}if(isNaN(e)||isNaN(i)||isNaN(s)||isNaN(r))throw new TypeError("The culling boundary must be defined with numbers");if(o&&"function"!=typeof o)throw new TypeError("The callback to group.cull must be a function");let n=t.camera.x-t.canvas.hw/t.camera.zoom,h=t.camera.y-t.canvas.hh/t.camera.zoom,a=-s+n,l=-e+h,d=t.width+r+n,p=t.height+i+h,u=0;for(let t=0;td||e.y>p)&&(u++,o?o(e,u):e.remove(),e.removed&&t--))}return u}remove(t){if(void 0===t)return this.removeAll(),void(this._isAllSpritesGroup||(this.removed=!0));let e;if(e="number"==typeof t?t>=0?t:this.length+t:this.indexOf(t),-1==e)return;let i=this[e];return this.splice(e,1),i}splice(e,i){let s=super.splice(e,i);if(!s)return;let r=[];for(let t of s){if(t.removed)continue;let e=this._uid;do{r.push(e);let i=t.groups.findIndex((t=>t._uid==e)),s=t.groups.splice(i,1);e=s[0].parent}while(e)}for(let e of r){let i=t.p5play.groups[e];for(let e in a)for(let s in i[e]){if(0==i[e][s])continue;let r;r=s>=1e3?t.p5play.sprites[s]:t.p5play.groups[s];let o=!1;for(let t of i)if(t[e][r._uid]>0){o=!0;break}o||(i[e][r._uid]=-2,r[e][i._uid]=-2)}}return s}pop(){return this.remove(this.length-1)}shift(){return this.remove(0)}unshift(){return console.error("unshift is not supported for groups"),this.length}removeAll(){for(;this.length>0;)this[0].remove()}_step(){this.__step()}draw(){let e=[...this];e.sort(((t,e)=>t._layer-e._layer));for(let i=0;i=1e3){if(i._isGroup||i._uid>=r)continue;e=t.p5play.sprites[r]}else{if(i._isGroup&&i._uid>=r)continue;e=t.p5play.groups[r]}let o=i[s][r]+1;e&&0!=o&&-2!=o?(this[s][r]=o,e[s][i._uid]=o):(delete i[s][r],e&&delete e[s][i._uid])}},t.Sprite.prototype.___step=t.Group.prototype.___step=function(){let e,i,s,r,o=this,n=!0;for(let h in a){for(let l in this[h]){if(l>=1e3){if(o._isGroup||o._uid>=l)continue;e=t.p5play.sprites[l]}else{if(o._isGroup&&o._uid>=l)continue;e=t.p5play.groups[l]}if(o._isGroup||e?._isGroup)continue;if(s=o._hasOverlap[e._uid]??e._hasOverlap[o._uid],n&&!1!==s||!n&&!0!==s)continue;let d=o[h][l];for(let s=0;s<3;s++){if(0==s&&1!=d&&-3!=d)continue;if(1==s&&-1==d)continue;if(2==s&&d>=1)continue;i=a[h][s];let n=t.p5play[i][o._uid];if(n){r=n[e._uid],r&&r.call(o,o,e,d);for(let t of e.groups)r=n[t._uid],r&&r.call(o,o,e,d)}let l=t.p5play[i][e._uid];if(l){r=l[o._uid],r&&r.call(e,e,o,d);for(let t of o.groups)r=l[t._uid],!r||n&&r==n[t._uid]||r.call(e,e,o,d)}}}n=!1}if(this._removed&&0==Object.keys(this._collisions).length&&0==Object.keys(this._overlappers).length){this._isSprite?delete t.p5play.sprites[this._uid]:t.p5play.targetVersion>=16&&delete t.p5play.groups[this._uid];for(let e in a)for(let i of a[e])delete t.p5play[i][this._uid]}},t.Sprite.prototype.addAnimation=t.Group.prototype.addAnimation=t.Sprite.prototype.addAni=t.Group.prototype.addAni=t.Sprite.prototype.addImage=t.Group.prototype.addImage=t.Sprite.prototype.addImg=t.Group.prototype.addImg=function(){if(t.p5play.disableImages)return void(this._ani=new t.SpriteAnimation);let e,i,s=[...arguments];return s[0]instanceof t.SpriteAnimation?(i=s[0],i._addedToSpriteOrGroup&&(i=i.clone()),e=i.name||"default",i.name=e):s[1]instanceof t.SpriteAnimation?(e=s[0],i=s[1],i._addedToSpriteOrGroup&&(i=i.clone()),i.name=e):(i=new t.SpriteAnimation(this,...s),e=i.name),this.animations[e]=i,this._ani=i,i._addedToSpriteOrGroup=!0,!this._dimensionsUndef||1==i.w&&1==i.h||(this.w=i.w,this.h=i.h),i},t.Sprite.prototype.addAnis=t.Group.prototype.addAnis=t.Sprite.prototype.addAnimations=t.Group.prototype.addAnimations=t.Sprite.prototype.addImages=t.Group.prototype.addImages=t.Sprite.prototype.addImgs=t.Group.prototype.addImgs=function(){let t,e=arguments;1==e.length?t=e[0]:(this.spriteSheet=e[0],t=e[1]);for(let e in t){let i=t[e];this.addAni(e,i)}},this.World=class extends planck.World{constructor(){super(new e.Vec2(0,0),!0),this.mod={},this.origin={x:0,y:0},this.contacts=[],this.on("begin-contact",this._beginContact),this.on("end-contact",this._endContact);let i=this;this._gravity={get x(){return i.m_gravity.x},set x(e){if((e=Math.round(e||0))!=i.m_gravity.x){i.mod[0]=!0;for(let e of t.allSprites)e.sleeping=!1;i.m_gravity.x=e}},get y(){return i.m_gravity.y},set y(e){if((e=Math.round(e||0))!=i.m_gravity.y){i.mod[0]=!0;for(let e of t.allSprites)e.sleeping=!1;i.m_gravity.y=e}}},this.timeScale=1,this.velocityIterations=8,this.positionIterations=3,this.velocityThreshold=.19,this.mouseTracking??=!0,this.mouseSprite=null,this.mouseSprites=[],this.autoStep=!0}get gravity(){return this._gravity}set gravity(t){this._gravity.x=t.x,this._gravity.y=t.y}get velocityThreshold(){return e.Settings.velocityThreshold}set velocityThreshold(t){e.Settings.velocityThreshold=t}step(e,i,s){for(let e of t.allSprites)e.prevPos.x=e.x,e.prevPos.y=e.y,e.prevRotation=e.rotation;super.step((e||1/(t._targetFrameRate||60))*this.timeScale,i||this.velocityIterations,s||this.positionIterations);let r=Object.values(t.p5play.sprites),o=Object.values(t.p5play.groups);for(let t of r)t._step();for(let t of o)t._step();for(let t of r)t.___step();for(let t of o)t.___step();t.canvas.dispatchEvent&&t.canvas.dispatchEvent(new window.Event("p5play_world_step")),this.autoStep&&(this.autoStep=null)}getSpritesAt(s,r,o,n){n??=!0;const h=new e.Vec2(s/i,r/i),a=new e.AABB;a.lowerBound=new e.Vec2(h.x-.001,h.y-.001),a.upperBound=new e.Vec2(h.x+.001,h.y+.001);let l=[];if(this.queryAABB(a,(t=>(t.getShape().testPoint(t.getBody().getTransform(),h)&&l.push(t),!0))),0==l.length)return[];o??=t.allSprites;let d=[];for(let t of l){const e=t.m_body.sprite;e._cameraActiveWhenDrawn==n&&(d.find((t=>t._uid==e._uid))||d.push(e))}return d.sort(((t,e)=>-1*(t._layer-e._layer))),d}getSpriteAt(t,e,i){return this.getSpritesAt(t,e,i)[0]}getMouseSprites(){let e=this.getSpritesAt(t.mouse.x,t.mouse.y);if(t.camera._wasOff){let i=this.getSpritesAt(t.mouse.canvasPos.x,t.mouse.canvasPos.y,t.allSprites,!1);i.length&&(e=[...i,...e])}return e}_beginContact(t){let e=t.m_fixtureA,i=t.m_fixtureB,s="_collisions";e.m_isSensor&&(s="_overlappers"),e=e.m_body.sprite,i=i.m_body.sprite,e[s][i._uid]=0,i[s][e._uid]=0;for(let t of i.groups)(!e[s][t._uid]||e[s][t._uid]<0)&&(e[s][t._uid]=0,t[s][e._uid]=0);for(let t of e.groups){(!i[s][t._uid]||i[s][t._uid]<0)&&(i[s][t._uid]=0,t[s][i._uid]=0);for(let e of i.groups)(!t[s][e._uid]||t[s][e._uid]<0)&&(t[s][e._uid]=0,e[s][t._uid]=0)}}_endContact(t){let e=t.m_fixtureA,i=t.m_fixtureB,s="_collisions";e.m_isSensor&&(s="_overlappers"),e=e.m_body.sprite,i=i.m_body.sprite,e[s][i._uid]=0!=e[s][i._uid]?-2:-4,i[s][e._uid]=0!=i[s][e._uid]?-2:-4;for(let t of i.groups){let i=!1;for(let r of t)if(r[s][e._uid]>=0){i=!0;break}i||(t[s][e._uid]=0!=t[s][e._uid]?-2:-4,e[s][t._uid]=0!=e[s][t._uid]?-2:-4)}for(let t of e.groups){let e=!1;for(let r of t)if(r[s][i._uid]>=0){e=!0;break}if(!e){t[s][i._uid]=0!=t[s][i._uid]?-2:-4,i[s][t._uid]=0!=i[s][t._uid]?-2:-4;for(let e of i.groups)t[s][e._uid]=0!=t[s][e._uid]?-2:-4,e[s][t._uid]=0!=e[s][t._uid]?-2:-4}}}_findContact(t,e,i){let s=e[t][i._uid];if(s)return s;for(let r of i.groups)if(s=e[t][r._uid],s)return s;for(let r of e.groups){if(s=r[t][i._uid],s)return s;for(let e of i.groups)if(r._uid==e._uid&&(s=r[t][e._uid],s))return s}return!1}get allowSleeping(){return this.getAllowSleeping()}set allowSleeping(t){this.setAllowSleeping(t)}},this.Camera=class{constructor(){this._pos=t.createVector.call(t),this.__pos={x:0,y:0,rounded:{}},this.mouse={x:t.mouseX,y:t.mouseY},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-100,this.bound.max.x=e+i+100}_calcBoundsY(e){let i=t.canvas.hh/this._zoom;this.bound.min.y=e-i-100,this.bound.max.y=e+i+100}get x(){return this._pos.x}set x(e){if(void 0===e||isNaN(e))return;this._pos.x=e;let i=-e+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.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,n=Math.sqrt(r*r+o*o),h=s/n,a=o*h,l=r*h;this._destIdx++;let d=this._destIdx,p=Math.ceil(n/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?this._j.setSpringFrequencyHz(e):this._j.setFrequency(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}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=r(t.x,t.y,this.spriteA.tileSize)),(this.offsetB.x||this.offsetB.y)&&(e=this.spriteB.body.getWorldPoint(this._j.m_localAnchorB),e=r(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="degrees"==t._angleMode?90:1.5707963267948966}_display(){let e,i,s=this.spriteA.x,o=this.spriteA.y;if(this.offsetB.x||this.offsetB.y){let t=this.spriteB.body.getWorldPoint(this._j.m_localAnchorB);t=r(t.x,t.y,this.spriteB.tileSize),e=t.x,i=t.y}else e=this.spriteB.x,i=this.spriteB.y;let n=t.tan(this.spriteA.rotation),h=t.tan(this._angle+this.spriteA.rotation),a=(i-o+n*s-h*e)/(n-h),l=n*(a-s)+o;this._draw(a,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),"degrees"==t._angleMode&&(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),"degrees"==t._angleMode&&(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*i}set lowerLimit(t){this._j.isLimitEnabled()||this._j.enableLimit(!0),t=t*this.spriteA.tileSize/i,this._j.setLimits(t,this._j.getUpperLimit())}get upperLimit(){return this._j.getUpperLimit()/this.spriteA.tileSize*i}set upperLimit(t){this._j.isLimitEnabled()||this._j.enableLimit(!0),t=t*this.spriteA.tileSize/i,this._j.setLimits(this._j.getLowerLimit(),t)}},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 t=this._j.getMaxLength(),e=this.spriteA.tileSize,t/e*i;var t,e}set maxLength(t){var e,s;this._j.setMaxLength((e=t,s=this.spriteA.tileSize,e*s/i))}};class d{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(){let t=new Float32Array(1),e=new Int32Array(t.buffer)}();function p(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 u(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.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 n=r.length,h=t.createImage(o*i,n*i);h.loadPixels();for(let t=0;tnew Promise(t?e=>{setTimeout(e,t)}:requestAnimationFrame),this.sleep=e=>e?t.delay(e):new Promise((e=>{t.canvas.addEventListener("p5play_world_step",e)})),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 L=location.hostname;switch(L){case"":case"127.0.0.1":case"localhost":case"p5play.org":case"editor.p5js.org":case"codepen.io":case"codera.app":case"cdpn.io":case"glitch.com":case"replit.com":case"stackblitz.com":case"jsfiddle.net":case"aijs.io":case"preview-aijs.web.app":break;default:if(/^[\d\.]+$/.test(L)||L.endsWith("stackblitz.io")||L.endsWith("glitch.me")||L.endsWith("replit.dev")||L.endsWith("codehs.com")||L.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,iVBORw0KGgoAAAANSUhEUgAAAIAAAABACAYAAADS1n9/AAABbGlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAACiRfZC/S0JhGIWfm4VgNkQNDg13igYr0SCXBjWQIkisQG26Xn+C2sfVCKMtWkPoP8igOWgoIgxaGhqCqCGitqamgpaSL+69hS51lvfhcDgcXujxaEKUeoFypWbEo2E1kUypzhcUFCxpelWEYrEFk39vlxT4uLezt+Nm12u7uRvciV6Wj88XNx88k/wvVyZb1YEvwKcLowaKF4ht1ITJW8CwkUimQGmYnLf5wOS0zSdWZjkeAeUaUPWClgHlFfCmu/x8F5dL6/rPMnO9O1tZWTJ7gBFmKVJFUEKjjkqMwB/5KSsfYQ1BHYMieQrUUAkhrIYsKnNU0JnAi4ofH3785p/tuo+7n/95O972M8y0pJRnHW++BUfT4DrteGNBGOyHq1OhGZplOYCeXA7eDmEgCUM34Fqt5gJ+e707DH1PUr6PgnMP2g0pP/elbDfB8QgXlW8Y/mq9pjC8gwAABSxJREFUeJztnb9y2zAMxulcpnbNntfJ3D5n97xO966Z3aNP9NHgBxAgQVmO8bvLNZZIiCI+gH8kpyl4bk7P3gErOJ/PZ0+zp9NpmZ9CAM54O7+wSgQhAEdWOb+wQgSvzZHAj5+/50x9/WkOeRMZwIkm+medXyAi8M4CL82R4KkIATjQRL8nJJN4XysEsAKv9L8DIYAnJyaBk8CUTDLA51/bbP7jHWSQRZPByADeTDp/tM4ozT4AVHSwO1kEMBMY/dTLFNcMcN5oSgTHYHBi2fPrS4qo98Mh/a+C8/ErdyJYw8cbb/bzH/ncGQY8aOYAnpThZ4XGerZdrn209fxIe6rVQw52Oif4NquAfF+d+Y6NSeej9C9F/714WAHkyP5uoxcSCBKSic5WMhwCciTlcnUaRSmVRlw5x0UiVx6VqW1Ru1zbaHl6TXS9Efae3GmuNzpXYDMA7VT6OxKE9nhPKNy1ZlHbEdL/qPNRdHsy2i5WAIk41yt6emM1Jw5OcL12eg4VR1rWmRCGAVEAGjhncseLQ7SOebZV6t4TxWEBcFHHOayO7PoHUcpy/y5FSP+jWJ06KoKRDAUngZxDUXrVlOsdR0jX8vjsxaqI1dilG0ciWdjgHcN4GqgERdcR1/VayjwgBFDzQG/yJEaASKgSIYBnAgg8BKAARRWKvkcjDwMhgAKIjkcACREJlgOuAu5K7Qgwaz0KeQaOOn9vTCsBwLwApMiZdOBROpnj3u2bdX5aPQfwaOBuDIr1HveYryldl30wBO4RZ4AS1aXCbFr2skezTa5b2+7Z7Z2nNjZKh3Jja3HGHtlAcnwyOj+/HIIFUACd0TizbhzTQU1ddAzYg+WYY5d0TM5dXql6A2VzO7n0jUS6kTtXuseVQ4Im01icXxgfApgOuvy8pevPjD3VuRrhRpu29trG2GI7eWPFkKCJerZdzH2UV8NUAsiqR8pnG5YdJjjNZA+8aYvqIq6dQqNfC9N5YofvDNuO3HbQ/tNG+dwVQOmwS8QAg/kY26lABF17Aqq65DgSlSkzMR2ZpM53hmsve32mvehLIvIcoFyIaUB9vhZB3bBmbJ6cLJkfrb4PRj+FmSAeCsbxiXF+0mSAG5WhDtjSfT32S3TtUb6wsMS6Qkd4TtKQoI62b0FTPkW3EQQ6G908KgcB5aA9BKir4WFf59q4ZNneF0eYZ/4SUxtB4lg88rVoLnqEa7CAOqz9J0Y9Caw/N44FnX0zYQPHRXsI4RqQ0Zk/B1iNUB5RYKohgN4svNG8GiApCpbr2QN2uHN08nmBGSK4ttyLkd1D1TBgxGUV4F1OOk/PSWUTENsRqJ3ovo1M5gHo+4A13/YPRd4sS2c7V/m1795WMJvZlNvIUv1RTtzXw2mqncXbnsSSqCJwIuCua3GetX4zBBj+ntDlBCeCYGNg2Vo7UXIeR6nv9fSPE0EIoAdwfs095xis85NeAC/SyWDSCQLXJ6cT9T2Ajo+MQOhkgWTMBMh55iecPSxDQHBLEwCG7WfJkd13CYS6mvpXrJPAoKURQdILATnSkrKbjTJLugc7piGAQWZEkDS7dMIj5utWulQf2SNIzk8hgD6zIoBQRy36n0U0k/sQgAIogjT/Z9saHO1pV3YhACUuImCcNWRPsGVZ1ocAjEAh9JwmOAsyaG9kPycEMAAUQWIcp3CWt71gB84SP34JJ7Gzm0I1A/a0hGomsTigF6VWZ3pEfQjAAY3jLM7yticRAnAEOW7GUd72ECEAZ2qneTjL294NKaX/gKttC9Kft4MAAAAASUVORK5CYII="};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 c=p5.disableFriendlyErrors;p5.disableFriendlyErrors=!0;const _=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(":");r[2]=r[1],e=!0;let i=Number(t[0]),s=Number(t[1]),o=window.innerWidth,n=window.innerWidth*(s/i);n>window.innerHeight&&(o=window.innerHeight*(i/s),n=window.innerHeight),r[0]=Math.round(o),r[1]=Math.round(n)}else r=[0,0,...r];if(r[0]||(r[0]=window.innerWidth,r[1]=window.innerHeight,e=!0),"string"==typeof r[2]){let t=r[2].toLowerCase().split(" ");"pixelated"==t[0]?(i=!0,t[1]?s=Number(t[1].slice(1)):e=!0,r.splice(2,1)):"fullscreen"==t[0]&&(e=!0,r.splice(2,1))}let o=_.call(t,...r);this.ctx??=this.drawingContext;let n=o.canvas||o;n.tabIndex=0,n.w=r[0],n.h=r[1],n.addEventListener&&(n.addEventListener("keydown",(function(t){" "!=t.key&&"/"!=t.key&&"ArrowUp"!=t.key&&"ArrowDown"!=t.key&&"ArrowLeft"!=t.key&&"ArrowRight"!=t.key||t.preventDefault()})),n.addEventListener("mouseover",(()=>{this.mouse.isOnCanvas=!0,this.mouse.isActive=!0})),n.addEventListener("mouseleave",(()=>{this.mouse.isOnCanvas=!1})),n.addEventListener("touchstart",(t=>t.preventDefault())),n.addEventListener("contextmenu",(t=>t.preventDefault()))),n.save??=t.saveCanvas.bind(t),n.resize??=t.resizeCanvas.bind(t),n.hw=.5*n.w,n.hh=.5*n.h,n.mouse={x:t.mouseX,y:t.mouseY},this.camera.x=n.hw,this.camera.y=n.hh,c||(p5.disableFriendlyErrors=!1);let h="\n.p5Canvas, .q5Canvas {\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}\nmain {\n\toverscroll-behavior: none;\n}";e&&(h="html,\nbody,\n"+h,h+="\nhtml, body {\n\tmargin: 0;\n\tpadding: 0;\n\toverflow: hidden;\n\theight: 100%;\n}\nmain {\n\tmargin: auto;\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-content: center;\n\tjustify-content: center;\n\theight: 100%;\n}"),h+=`\n#${n.id} {`,i&&(h+="\n\timage-rendering: pixelated;\n\tfont-smooth: never;\n\t-webkit-font-smoothing: none;\n"),e?(n.fullscreen=!0,n.w/n.h>window.innerWidth/window.innerHeight?h+="width: 100%!important; height: auto!important;":h+="height: 100%!important; width: auto!important;"):s&&(h+=`\n\twidth: ${n.w*s}px!important;\n\theight: ${n.h*s}px!important;\n`),h+="\n}";let a=document.createElement("style");return a.innerHTML=h,document.head.appendChild(a),i&&(t.pixelDensity(1),t.noSmooth(),t.textFont("monospace"),t.ctx.imageSmoothingEnabled=!1),o},this.Canvas=class{constructor(t,e,i,s,r){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 f=t.resizeCanvas;this.resizeCanvas=(e,i)=>{e??=window.innerWidth,i??=window.innerHeight,f.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.camera.x=s.hw,t.camera.y=s.hh};const g=t.background;this.background=function(){let e=arguments;1==e.length&&1==e[0].length?g.call(t,t.colorPal(e[0])):g.call(t,...e)};const m=t.fill;this.fill=function(){let e=arguments;1==e.length&&1==e[0].length?m.call(t,t.colorPal(e[0])):m.call(t,...e)};const y=t.stroke;this.stroke=function(){let e=arguments;1==e.length&&1==e[0].length?y.call(t,t.colorPal(e[0])):y.call(t,...e)};const x=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 1==r.width&&1==r.height||!r.pixels.length?e?(r.cbs.push(e),r.calls++):t._decrementPreload():(e&&e(),t._decrementPreload()),r;return r=x.call(t,s,(e=>{e.w||(Object.defineProperty(e,"w",{get:function(){return this.width}}),Object.defineProperty(e,"h",{get:function(){return this.height}}));for(let t of e.cbs)t(e);for(let i=1;i=190}catch(D){}if(v){function b(e,i,s){const r=t.canvas.getContext("2d"),o=t._renderer;let n=o._textFont;return"string"!=typeof n&&(n=n.font.names.fullName,n=n[Object.keys(n)[0]]),e.slice(0,200)+(o._textStyle||"normal")+o._textSize+n+(o._doFill?r.fillStyle:"")+"_"+(o._doStroke&&o._strokeSet?r.lineWidth+r.strokeStyle+"_":"")+(i||"")+(s?"x"+s:"")}t._textCache=!0,t._TimedCache=class extends Map{constructor(){super(),this.maxSize=500}set(t,e){e.lastAccessed=Date.now(),super.set(t,e),this.size>this.maxSize&&this.gc()}get(t){const e=super.get(t);return e&&(e.lastAccessed=Date.now()),e}gc(){let t,e=1/0,i=0;for(const[s,r]of this.entries())r.lastAccessed(i&&(t._tic.maxSize=i),void 0!==e&&(t._textCache=e),t._textCache),t.createTextImage=(e,i,s)=>{let r=t._textCache;t._textCache=!0,t._useCache=!0,t.text(e,0,0,i,s),t._useCache=!1;let o=b(e,i,s);return t._textCache=r,t._tic.get(o)};const B=t.text;t.text=(e,i,s,r,o)=>{if(void 0===e)return;e=e.toString();const n=t._renderer;if(!n._doFill&&!n._doStroke)return;const h=t.canvas.getContext("2d");let a,l,d,p,u,c,_,f=h.getTransform();if(!(t._useCache||t._textCache&&(0!=f.b||0!=f.c)))return B.call(t,e,i,s,r,o);if(d=b(e,r,o),l=t._tic.get(d),l)return void t.textImage(l,i,s);let g=t.createGraphics.call(t,1,1);g.textFont(t.textFont()),t.textStyle()&&g.textStyle(t.textStyle()),g.textSize(t.textSize()),a=g.canvas.getContext("2d");let m=e.split("\n");p=0,u=n._textLeading*m.length;let y=a.measureText(" ");c=y.fontBoundingBoxAscent,_=y.fontBoundingBoxDescent,o??=u+_,g.resizeCanvas(Math.ceil(g.textWidth(e)),Math.ceil(o)),g.fill(h.fillStyle),n._doStroke?(g.stroke(h.strokeStyle),g.strokeWeight(h.lineWidth)):g.noStroke();for(let t=0;to));t++);l=g.get(),l._ascent=c,l._descent=_,t._tic.set(d,l),t.textImage(l,i,s)},t.textImage=(e,i,s)=>{let r=t._renderer._imageMode;t.imageMode.call(t,"corner");const o=t.canvas.getContext("2d");let n;"center"==o.textAlign?i-=.5*e.width:"right"==o.textAlign&&(i-=e.width),"alphabetic"==o.textBaseline?s-=t._renderer._textLeading:n=t._renderer._textLeading-t._renderer._textSize,"middle"==o.textBaseline?s-=e._descent+.5*e._ascent+n:"bottom"==o.textBaseline?s-=e._ascent+e._descent+n:"top"==o.textBaseline&&(s-=e._descent+n),t.image.call(t,e,i,s),t.imageMode.call(t,r)}}let S={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:{},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!"}},SpriteAnimation:{constructor:{base:"Hey so, I tried to make a new SpriteAnimation but couldn't",0:'I don\'t know how to display this type of image: "$0". I can only use ".png" image files.',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"}}};S.Group.collide=S.Sprite.collide,S.Group.overlap=S.Sprite.overlap,S.Sprite.rotateTo[0]=S.Sprite.rotateTowards[0]=S.Sprite.rotate[0];class A 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,n=S[s][t];o=n.base?n.base+r:S.generic[Math.floor(Math.random()*S.generic.length)]+r,void 0!==e&&(n=n[e]),n=n.replace(/\$([0-9]+)/g,((t,e)=>i[e])),o+=n,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}_init(t){for(let e of t)this[e]=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,this.y,this.canvasPos={},this.left,this.center,this.right;this._init(["x","y","left","center","right"]),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"}_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.camera.mouse.x=t.mouseX,t.mouse.canvasPos.y=t.camera.mouse.y=t.mouseY,t.camera.x==t.canvas.hw&&t.camera.y==t.canvas.hh&&1==t.camera.zoom?(this.x=t.mouseX,this.y=t.mouseY):(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}};const C=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)}},k=t._onmousedown;t._onmousedown=function(e){if(!t._setupDone)return;let i="left";1===e.button?i="center":2===e.button&&(i="right"),C.call(t,i),k.call(t,e)};const M=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"),M.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)},delete t._Mouse,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,n=this.canvasPos.x=(e.clientX-s.left)/r,h=this.canvasPos.y=(e.clientY-s.top)/o;t.camera.x==i.hw&&t.camera.y==i.hh&&1==t.camera.zoom?(this.x=n,this.y=h):(this.x=(n-i.hw)/t.camera.zoom+t.camera.x,this.y=(h-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){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,delete t._Keyboard,this.keyboard=t.kb,navigator.keyboard){const W=navigator.keyboard;window==window.top?W.getLayoutMap().then((e=>{"w"!=e.get("KeyW")&&(t.p5play.standardizeKeyboard=!0)})):t.p5play.standardizeKeyboard=!0}else t.p5play.standardizeKeyboard=!0;function z(t){let e=t.code;return 4==e.length&&"Key"==e.slice(0,3)?e[3].toLowerCase():t.key}const P=t._onkeydown;t._onkeydown=function(t){let e=t.key;if(this.p5play.standardizeKeyboard&&(e=z(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),P.call(this,t)};const F=t._onkeyup;t._onkeyup=function(t){let e=t.key;if(this.p5play.standardizeKeyboard&&(e=z(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)}F.call(this,t)},this._Contro=class extends t.InputDevice{constructor(t){super(),this._default="a",this.connected=!0;this._init(["a","b","x","y","l","r","lt","rt","select","start","lsb","rsb","up","down","left","right","leftTrigger","rightTrigger"]),this.leftStick={x:0,y:0},this.rightStick={x:0,y:0},this._btns={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._axes={leftStick:{x:0,y:1},rightStick:{x:2,y:3},leftTrigger:4,rightTrigger:5},this.gamepad=t,this.id=t.id,this.id.includes("GuliKit")&&(this._btns.a=1,this._btns.b=0,this._btns.x=3,this._btns.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.connected)return;if(this.gamepad=navigator.getGamepads()[this.gamepad.index],!this.gamepad?.connected)return;let t=this.gamepad;for(let e in this._btns){let i=this._btns[e],s=t.buttons[i];s&&(s.pressed?this[e]++:this[e]=this[e]>0?-1:0)}return this.leftStick.x=t.axes[this._axes.leftStick.x],this.leftStick.y=t.axes[this._axes.leftStick.y],this.rightStick.x=t.axes[this._axes.rightStick.x],this.rightStick.y=t.axes[this._axes.rightStick.y],void 0!==t.axes[this._axes.leftTrigger]?(this.leftTrigger=t.axes[this._axes.leftTrigger],this.rightTrigger=t.axes[this._axes.rightTrigger]):(this.leftTrigger=t.buttons[this._btns.lt].value,this.rightTrigger=t.buttons[this._btns.rt].value),!0}get ls(){return this.leftStick}get rs(){return this.rightStick}get lb(){return this.l}get rb(){return this.r}get leftStickButton(){return this.lsb}get rightStickButton(){return this.rsb}},this._Contros=class extends Array{constructor(){super();let t=this;window&&(window.addEventListener("gamepadconnected",(e=>{t._onConnect(e.gamepad)})),window.addEventListener("gamepaddisconnected",(e=>{t._onDisconnect(e.gamepad)}))),this.presses,this.pressing,this.pressed,this.holds,this.holding,this.held,this.released;let e=["presses","pressing","pressed","holds","holding","held","released"];for(let t of e)this[t]=e=>{if(this[0])return this[0][t](e)};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.leftTrigger=0,this.rightTrigger=0,this.lb=0,this.rb=0,this.leftStickButton=0,this.rightStickButton=0;let i=["connected","a","b","x","y","l","r","lt","rt","select","start","lsb","rsb","up","down","left","right","leftTrigger","rightTrigger","lb","rb","leftStickButton","rightStickButton"];for(let e of i)Object.defineProperty(this,e,{get:()=>t[0]?t[0][e]:0});this.leftStick,this.rightStick,i=["leftStick","rightStick"];for(let e of i){this[e]={};for(let i of["x","y"])Object.defineProperty(this[e],i,{get:()=>t[0]?t[0][e][i]:0})}if(!navigator?.getGamepads)return;let s=navigator.getGamepads();for(let t of s)t&&this._onConnect(t)}_onConnect(e){if(!e)return;for(let t=0;tt.p5play._fps,this.renderStats=(e,i)=>{let s=t.p5play._renderStats;void 0===s.show&&(1==t.allSprites.tileSize||t.allSprites.tileSize>16?s.fontSize=16:s.fontSize=10,s.gap=1.25*s.fontSize,t._q5||console.warn("renderStats() produces inaccurate FPS approximations because deltaTime is calculated incorrectly in p5.js. Even if your game runs at a solid 60hz display rate, the fps calculations shown may be lower. Use q5.js or your browser's performance testing tools for accurate results.")),s.x=e||10,s.y=i||20,s.show=!0}})),p5.prototype.registerMethod("pre",(function(){const t=this;t._q5||(t.p5play._preDrawFrameTime=performance.now()),t.p5play.spritesDrawn=0,t.mouse._update(),t.contro._update()})),p5.prototype.registerMethod("post",(function(){const t=this;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;let e=t.p5play._renderStats;if(e.show){if(1==t.frameCount||t.frameCount%60==0){let e,i=0,s=t.p5play._fpsArr.length;for(let e=0;e55?t.color(30,255,30):i>25?t.color(255,100,30):t.color(255,30,30),t.p5play._statsColor=e}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),t.textFont("monospace");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&&i[t]++,s?.hover&&(s[t]=i[t]),i._dragFrame[t]?(i.drag[t]++,s&&(s.drag[t]=i.drag[t]),i._dragFrame[t]=!1):i.drag[t]<0&&(i.drag[t]=0,s&&(s.drag[t]=0));if(t.world.mouseTracking&&t.mouse.isActive){let e=t.world.getMouseSprites();for(let t=0;t0?i.mouse.hover=-1:i.mouse.hover<0&&(i.mouse.hover=0)}i.left<=0&&i.center<=0&&i.right<=0&&(t.world.mouseSprite=null);let r=t.world.mouseSprite,o=i.drag.left>0||i.drag.center>0||i.drag.right>0;for(let i of t.world.mouseSprites)if(!e.includes(i)){let e=i.mouse;e.hover>0&&(e.hover=-1,e.left=e.center=e.right=0),o||i!=r||(t.world.mouseSprite=r=null)}r&&(e.includes(r)||e.push(r),s.x=r.x-i.x,s.y=r.y-i.y),t.world.mouseSprites=e}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})); +if("object"!=typeof planck){if("object"!=typeof process)throw"planck.js must be loaded before p5play";global.planck=require("./planck.min.js")}p5.prototype.registerMethod("init",(function(){const t=this,e=planck,i=60;if("object"!=typeof process&&0!=window._p5play_gtagged){let I=document.createElement("script");I.src="https://www.googletagmanager.com/gtag/js?id=G-EHXNCTSYLK",I.async=!0,document.head.append(I),window._p5play_gtagged=!0,I.onload=()=>{window.dataLayer??=[],window.gtag=function(){dataLayer.push(arguments)},gtag("js",new Date),gtag("config","G-EHXNCTSYLK"),gtag("event","p5play_v3_19")}}t.angleMode("degrees");const s=(t,s,r)=>new e.Vec2(t*r/i,s*r/i),r=(t,s,r)=>new e.Vec2(t/r*i,s/r*i),o=t=>Math.abs(t)<=e.Settings.linearSlop,n=(t,i)=>Math.abs(t-Math.round(t))<=(i||e.Settings.linearSlop)?Math.round(t):t,h=(e,i)=>{let s="degrees"==t._angleMode?360:t.TWO_PI,r=(e-i)%s,o=(s-Math.abs(r))*-Math.sign(r);return(Math.abs(r)-1){let e=navigator.userAgent.substring(t+10,t+12);this.os.platform="iOS",this.os.version=e}else{let t=navigator.userAgentData?.platform;!t&&navigator.platform&&(t=navigator.platform.slice(3),"Mac"==t?t="macOS":"Win"==t?t="Windows":"Lin"==t&&(t="Linux")),this.os.platform=t}this._renderStats={},this._fps=60,this._fpsArr=[60],this._collides={},this._colliding={},this._collided={},this._overlaps={},this._overlapping={},this._overlapped={}}onImageLoad(){}},this.p5play=new t.P5Play,delete t.P5Play;const l=console.log;this.log=console.log,this.Sprite=class{constructor(s,r,o,h,a){this._isSprite=!0,this.idNum;let l,c,_=[...arguments];if(void 0!==_[0]&&_[0]._isGroup&&(l=_[0],_=_.slice(1)),void 0!==_[0]&&("string"==typeof _[0]||_[0]instanceof t.SpriteAnimation||_[0]instanceof p5.Image)&&(c=_[0],_=_.slice(1)),1==_.length&&"number"==typeof _[0])throw new A("Sprite",0,[_[0]]);if(Array.isArray(_[0])){if(s=void 0,r=void 0,o=_[0],h=void 0,a=_[1],Array.isArray(a))throw new A("Sprite",1,[`[[${o}], [${h}]]`])}else s=_[0],r=_[1],o=_[2],h=_[3],a=_[4];"string"==typeof o&&(a=o,o=void 0),"string"==typeof h&&(!function(t){if("d"==t||"s"==t||"k"==t||"n"==t)return!0;let e=t.slice(0,2);return"dy"==e||"st"==e||"ki"==e||"no"==e}(h)?o=u(o,h):a=h,h=void 0),this.idNum=t.p5play.spritesCreated,this._uid=1e3+this.idNum,t.p5play.sprites[this._uid]=this,t.p5play.spritesCreated++,this.groups=[],this.animations=new t.SpriteAnimations,this.joints=[],this.joints.removeAll=()=>{for(let t of this.joints)t.remove()},this.watch,this.mod={},this._removed=!1,this._life=2147483647,this._visible=!0,this._pixelPerfect=!1,this._aniChangeCount=0,this._draw=()=>this.__draw(),this._hasOverlap={},this._collisions={},this._overlappers={},l??=t.allSprites,this.tileSize=l.tileSize||1;let f=this;this._position={x:0,y:0},this._pos=t.createVector.call(t),Object.defineProperty(this._pos,"x",{get(){if(!f.body)return f._position.x;let e=f.body.getPosition().x/f.tileSize*i;return t.p5play.friendlyRounding?n(e):e},set(t){if(f.body){let s=new e.Vec2(t*f.tileSize/i,f.body.getPosition().y);f.body.setPosition(s)}f._position.x=t}}),Object.defineProperty(this._pos,"y",{get(){if(!f.body)return f._position.y;let e=f.body.getPosition().y/f.tileSize*i;return t.p5play.friendlyRounding?n(e):e},set(t){if(f.body){let s=new e.Vec2(f.body.getPosition().x,t*f.tileSize/i);f.body.setPosition(s)}f._position.y=t}}),this._velocity={x:0,y:0},this._vel=t.createVector.call(t),Object.defineProperties(this._vel,{x:{get(){let e;return e=f.body?f.body.getLinearVelocity().x:f._velocity.x,e/=f.tileSize,t.p5play.friendlyRounding?n(e):e},set(t){t*=f.tileSize,f.body?f.body.setLinearVelocity(new e.Vec2(t,f.body.getLinearVelocity().y)):f._velocity.x=t}},y:{get(){let e;return e=f.body?f.body.getLinearVelocity().y:f._velocity.y,e/=f.tileSize,t.p5play.friendlyRounding?n(e):e},set(t){t*=f.tileSize,f.body?f.body.setLinearVelocity(new e.Vec2(f.body.getLinearVelocity().x,t)):f._velocity.y=t}}}),this._mirror={_x:1,_y:1,get x(){return this._x<0},set x(t){f.watch&&(f.mod[22]=!0),this._x=t?-1:1},get y(){return this._y<0},set y(t){f.watch&&(f.mod[22]=!0),this._y=t?-1:1}},this._heading="right",this._layer=l._layer,this._layer??=t.allSprites._getTopLayer()+1,l.dynamic&&(a??="dynamic"),l.kinematic&&(a??="kinematic"),l.static&&(a??="static"),a??=l.collider,a&&"string"==typeof a||(a="dynamic"),this.collider=a,s??=l.x,void 0===s&&(s=t.width/this.tileSize/2,o&&(this._vertexMode=!0)),r??=l.y,void 0===r&&(r=t.height/this.tileSize/2);let g=!1;if(void 0===o&&(o=l.w||l.width||l.d||l.diameter||l.v||l.vertices,h||l.d||l.diameter||(h=l.h||l.height,g=!0)),"function"==typeof s&&(s=s(l.length)),"function"==typeof r&&(r=r(l.length)),"function"==typeof o&&(o=o(l.length)),"function"==typeof h&&(h=h(l.length)),this.x=s,this.y=r,!l._isAllSpritesGroup&&!c)for(let t in l.animations){c=t;break}for(let e=l;e;e=t.p5play.groups[e.parent])this.groups.push(e);if(this.groups.reverse(),c){c instanceof p5.Image?this.addAni(c):"string"==typeof c?this._changeAni(c):this._ani=c.clone();let t=this.tileSize;o||1==this._ani.w&&1==this._ani.h||(o=this._ani.w/t,h??=this._ani.h/t)}if(this.groups=[],this.mouse=new t._SpriteMouse,this._angle=0,this._rotationSpeed=0,this._bearing=0,this._scale=new d,Object.defineProperty(this._scale,"x",{get(){return this._x},set(t){if(t==this._x)return;f.watch&&(f.mod[28]=!0);let e=Math.abs(t/this._x);f._w*=e,f._hw*=e,f._resizeColliders({x:e,y:1}),this._x=t,this._avg=.5*(this._x+this._y)}}),Object.defineProperty(this._scale,"y",{get(){return this._y},set(t){if(t==this._y)return;f.watch&&(f.mod[28]=!0);let e=Math.abs(t/this._y);f._h&&(this._h*=e,this._hh*=e),f._resizeColliders({x:1,y:e}),this._y=t,this._avg=.5*(this._x+this._y)}}),this._offset={_x:0,_y:0,get x(){return this._x},set x(t){t!=this._x&&(f.watch&&(f.mod[23]=!0),f._offsetCenterBy(t-this._x,0))},get y(){return this._y},set y(t){t!=this._y&&(f.watch&&(f.mod[23]=!0),f._offsetCenterBy(0,t-this._y))}},this._massUndef=!0,void 0===o&&(this._dimensionsUndef=!0,this._widthUndef=!0,o=this.tileSize>1?1:50,void 0===h&&(this._heightUndef=!0)),g&&(h??=this.tileSize>1?1:50),this._shape=l.shape,3!=this.__collider)this._vertexMode?this.addCollider(o):this.addCollider(0,0,o,h),this.shape=this._shape;else{if(this.w=o,Array.isArray(o))throw new Error('Cannot set the collider type of a sprite with a polygon or chain shape to "none". To achieve the same effect, use .overlaps(allSprites) to have your sprite overlap with the allSprites group.');void 0!==o&&void 0===h?this.shape="circle":(this.shape="box",this.h=h)}this.prevPos={x:s,y:r},this.prevRotation=0,this._dest={x:s,y:r},this._destIdx=0,this._debug=!1,this.text,l._isAllSpritesGroup||t.allSprites.push(this),l.push(this);let m=l.vel.x||0,y=l.vel.y||0;"function"==typeof m&&(m=m(l.length-1)),"function"==typeof y&&(y=y(l.length-1)),this.vel.x=m,this.vel.y=y;let x=["ani","collider","x","y","w","h","d","diameter","dynamic","height","kinematic","static","vel","width"];for(let e of t.Sprite.propsAll){if(x.includes(e))continue;let t=l[e];void 0!==t&&("function"==typeof t&&p(t)&&(t=t(l.length-1)),this[e]="object"==typeof t?Object.assign({},t):t)}x=["add","animation","animations","autoCull","contains","GroupSprite","Group","idNum","length","mod","mouse","p","parent","Sprite","Subgroup","subgroups","velocity"];for(let e=0;e1?1:50,h??=n,d=s(n-.08,h-.08,this.tileSize)),"box"==l)p=e.Box(d.x/2,d.y/2,s(i,r,this.tileSize),0);else if("circle"==l)p=e.Circle(s(i,r,this.tileSize),d.x/2);else if(a){let _,f,g=[{x:0,y:0}],m={x:0,y:0},y={x:0,y:0},x={x:0,y:0},w=Array.isArray(a[0]);function v(){m.xx.x&&(x.x=m.x),m.y>x.y&&(x.y=m.y)}if(w){this._vertexMode&&(_=a[0][0],f=a[0][1],this.fixture&&this._relativeOrigin?(_=this.x-this._relativeOrigin.x,f=this.y-this._relativeOrigin.y,g.pop()):(this.x=_,this.y=f));for(let S=0;S0?1:-1;A=Math.abs(A);let k=0;for(let M=0;Me.Settings.maxPolygonVertices||"chain"==this._shape)&&(l="chain"),"polygon"==l?p=e.Polygon(g):"chain"==l&&(p=e.Chain(g,!1))}return this.shape??=l,this.fixtureList||(this._w=n,this._hw=.5*n,1!=this.__shape&&(this._h=h,this._hh=.5*h)),p}removeColliders(){this.body&&(this._removeContacts(0),this._removeFixtures(0))}removeSensors(){this.body&&(this._removeContacts(1),this._removeFixtures(1),this._hasSensors=!1)}_removeFixtures(e){let i;for(let s=this.fixtureList;s;s=s.getNext())if(void 0===e||s.m_isSensor==e){let e=s.m_next;s.destroyProxies(t.world.m_broadPhase),i?i.m_next=e:this.body.m_fixtureList=e}else i=s}_removeContacts(e){if(!this.body)return;let i=this.body.m_contactList;for(;i;){let s=i.contact;i=i.next,void 0!==e&&s.m_fixtureA.m_isSensor!=e||t.world.destroyContact(s)}}_offsetCenterBy(t,e){if(!t&&!e)return;if(this._offset._x+=t,this._offset._y+=e,!this.body)return;let i=s(t,e,this.tileSize);for(let t=this.body.m_fixtureList;t;t=t.m_next){let e=t.m_shape;if("circle"!=e.m_type){let t=e.m_vertices;for(let e of t)e.x+=i.x,e.y+=i.y}else e.m_p.x+=i.x,e.m_p.y+=i.y}}_cloneBodyProps(){let t={},e=["bounciness","density","drag","friction","heading","isSuperFast","rotation","rotationDrag","rotationLock","rotationSpeed","scale","vel","x","y"];this._massUndef&&this._dimensionsUndef||e.push("mass");for(let i of e)"object"==typeof this[i]?t[i]=Object.assign({},this[i]):t[i]=this[i];return t}get animation(){return this._ani}set animation(t){this.changeAni(t)}get ani(){return this._ani}set ani(t){this.changeAni(t)}get anis(){return this.animations}get autoDraw(){return this._autoDraw}set autoDraw(t){this.watch&&(this.mod[6]=!0),this._autoDraw=t}get allowSleeping(){return this.body?.isSleepingAllowed()}set allowSleeping(t){this.watch&&(this.mod[7]=!0),this.body&&this.body.setSleepingAllowed(t)}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){this.watch&&(this.mod[8]=!0),this._autoUpdate=t}get bounciness(){if(this.fixture)return this.fixture.getRestitution()}set bounciness(t){this.watch&&(this.mod[9]=!0);for(let e=this.fixtureList;e;e=e.getNext())e.setRestitution(t)}get centerOfMass(){let e=this.body.getWorldCenter(),i=r(e.x,e.y,this.tileSize);return t.createVector(i.x,i.y)}get collider(){return this._collider}set collider(e){if(e==this._collider)return;let i=(e=e.toLowerCase())[0];if("d"==i&&(e="dynamic"),"s"==i&&(e="static"),"k"==i&&(e="kinematic"),"n"==i&&(e="none"),e==this._collider)return;if("none"==e&&("chain"==this._shape||"polygon"==this._shape))return void console.error('Cannot set the collider type of a polygon or chain collider to "none". To achieve the same effect, use .overlaps(allSprites) to have your sprite overlap with the allSprites group.');if(this._removed)throw new Error("Cannot change the collider type of a sprite that was removed.");let s=this.__collider;this._collider=e,this.__collider=["d","s","k","n"].indexOf(i),this.watch&&(this.mod[10]=!0),void 0!==s&&(3!=this.__collider?(this.body&&this.body.setType(e),3==s&&this.addCollider()):(this.removeColliders(),this.fixture?.m_isSensor?this.body.m_gravityScale=0:(t.world.destroyBody(this.body),this.body=null)))}_parseColor(e){return e instanceof p5.Color?e:"object"!=typeof e?1==e.length?t.colorPal(e):t.color(e):t.color(...e.levels)}get color(){return this._color}set color(t){this.watch&&(this.mod[11]=!0),this._color=this._parseColor(t)}get colour(){return this._color}set colour(t){this.color=t}get fill(){return this._color}set fill(t){this.color=t}get fillColor(){return this._color}set fillColor(t){this.color=t}get stroke(){return this._stroke}set stroke(t){this.watch&&(this.mod[31]=!0),this._stroke=this._parseColor(t)}get strokeColor(){return this._stroke}set strokeColor(t){this.stroke=t}get strokeWeight(){return this._strokeWeight}set strokeWeight(t){this.watch&&(this.mod[32]=!0),this._strokeWeight=t}get textColor(){return this._textFill}set textColor(t){this.watch&&(this.mod[34]=!0),this._textFill=this._parseColor(t)}get textColour(){return this._textFill}set textColour(t){this.textColor=t}get textFill(){return this._textFill}set textFill(t){this.textColor=t}get textSize(){return this._textSize}set textSize(t){this.watch&&(this.mod[40]=!0),this._textSize=t}get textStroke(){return this._textStroke}set textStroke(t){this.watch&&(this.mod[41]=!0),this._textStroke=this._parseColor(t)}get textStrokeWeight(){return this._textStrokeWeight}set textStrokeWeight(t){this.watch&&(this.mod[42]=!0),this._textStrokeWeight=t}get bearing(){return this._bearing}set bearing(t){this.watch&&(this.mod[39]=!0),this._bearing=t}get debug(){return this._debug}set debug(t){this.watch&&(this.mod[12]=!0),this._debug=t}get density(){if(this.fixture)return this.fixture.getDensity()}set density(t){this.watch&&(this.mod[13]=!0);for(let e=this.fixtureList;e;e=e.getNext())e.setDensity(t)}_getDirectionAngle(e){e=e.toLowerCase().replaceAll(/[ _-]/g,"");let i={up:-90,down:90,left:180,right:0,upright:-45,rightup:-45,upleft:-135,leftup:-135,downright:45,rightdown:45,downleft:135,leftdown:135,forward:this.rotation,backward:this.rotation+180}[e];return"radians"==t._angleMode&&(i=t.radians(i)),i}get direction(){return 0!==this.vel.x||0!==this.vel.y?t.atan2(this.vel.y,this.vel.x):void 0===this._direction?this.rotation:this._direction}set direction(e){this.watch&&(this.mod[14]=!0),"string"==typeof e&&(this._heading=e,e=this._getDirectionAngle(e)),this._direction=e;let i=this.speed;this.vel.x=t.cos(e)*i,this.vel.y=t.sin(e)*i}get drag(){return this.body?.getLinearDamping()}set drag(t){this.watch&&(this.mod[15]=!0),this.body&&this.body.setLinearDamping(t)}get draw(){return this._display}set draw(t){this._draw=t}get dynamic(){return this.body?.isDynamic()}set dynamic(t){this.collider=t?"dynamic":"kinematic"}get fixture(){return this.fixtureList}get fixtureList(){return this.body?this.body.m_fixtureList:null}get friction(){if(this.fixture)return this.fixture.getFriction()}set friction(t){this.watch&&(this.mod[16]=!0);for(let e=this.fixtureList;e;e=e.getNext())e.setFriction(t)}get heading(){return this._heading}set heading(t){this.direction=t}get img(){return this._ani?.frameImage}set img(t){this.changeAni(t)}get image(){return this._ani?.frameImage}set image(t){this.changeAni(t)}get isMoving(){return 0!=this.vel.x||0!=this.vel.y}get isSuperFast(){return this.body?.isBullet()}set isSuperFast(t){this.watch&&(this.mod[18]=!0),this.body&&this.body.setBullet(t)}get kinematic(){return this.body?.isKinematic()}set kinematic(t){this.collider=t?"kinematic":"dynamic"}get layer(){return this._layer}set layer(t){this.watch&&(this.mod[19]=!0),this._layer=t}get life(){return this._life}set life(t){this.watch&&(this.mod[20]=!0),this._life=t}get mass(){return this.body?.getMass()}set mass(t){if(!this.body)return;this.watch&&(this.mod[21]=!0);let e=this.massData;e.mass=t>0?t:1e-8,this.body.setMassData(e),delete this._massUndef}get massData(){const t={I:0,center:new e.Vec2(0,0),mass:0};return this.body.getMassData(t),t.center=r(t.center.x,t.center.y,this.tileSize),t}resetMass(){this.body&&(this.watch&&(this.mod[21]=!0),this.body.resetMassData())}get mirror(){return this._mirror}set mirror(t){this.watch&&(this.mod[22]=!0),void 0!==t.x&&(this._mirror.x=t.x),void 0!==t.y&&(this._mirror.y=t.y)}get offset(){return this._offset}set offset(t){t.x??=this._offset._x,t.y??=this._offset._y,t.x==this._offset._x&&t.y==this._offset._y||(this.watch&&(this.mod[23]=!0),this._offsetCenterBy(t.x-this._offset._x,t.y-this._offset._y))}get opacity(){return this._opacity??1}set opacity(t){this.watch&&(this.mod[43]=!0),this._opacity=t}get previousPosition(){return this.prevPos}set previousPosition(t){this.prevPos=t}get previousRotation(){return this.prevRotation}set previousRotation(t){this.prevRotation=t}get pixelPerfect(){return this._pixelPerfect}set pixelPerfect(t){this.watch&&(this.mod[24]=!0),this._pixelPerfect=t}get removed(){return this._removed}set removed(t){t&&!this._removed&&(this.watch&&(this.mod[25]=!0),this._removed=!0,this._remove())}get rotation(){if(!this.body)return this._angle||0;let i=this.body.getAngle();return"degrees"==t._angleMode&&(i=t.degrees(i)),t.p5play.friendlyRounding?n(i,e.Settings.angularSlop):i}set rotation(e){this.body?("degrees"==t._angleMode&&(e=t.radians(e%360)),this.body.setAngle(e),this.body.synchronizeTransform()):this._angle=e}get rotationDrag(){return this.body?.getAngularDamping()}set rotationDrag(t){this.body&&(this.watch&&(this.mod[26]=!0),this.body.setAngularDamping(t))}get rotationLock(){return this.body?.isFixedRotation()}set rotationLock(t){if(!this.body)return;this.watch&&(this.mod[27]=!0);let e=this.mass;this.body.setFixedRotation(t),this.mass=e}get rotationSpeed(){if(this.body){let e=this.body.getAngularVelocity()/60;return"degrees"==t._angleMode?t.degrees(e):e}return this._rotationSpeed}set rotationSpeed(e){this.body?(e*=60,"degrees"==t._angleMode&&(e=t.radians(e)),this.body.setAngularVelocity(e)):this._rotationSpeed=e}get scale(){return this._scale}set scale(t){if(0==t&&(t=.01),"number"==typeof t?t={x:t,y:t}:(t.x??=this._scale._x,t.y??=this._scale._y),t.x==this._scale._x&&t.y==this._scale._y)return;this.watch&&(this.mod[28]=!0);let e={x:Math.abs(t.x/this._scale._x),y:Math.abs(t.y/this._scale._y)};this._w*=e.x,this._hw*=e.x,this._h&&(this._h*=e.y,this._hh*=e.y),this._resizeColliders(e),this._scale._x=t.x,this._scale._y=t.y,this._scale._avg=t.x}get sleeping(){if(this.body)return!this.body.isAwake()}set sleeping(t){this.body&&(this.watch&&(this.mod[30]=!0),this.body.setAwake(!t))}get speed(){return t.createVector(this.vel.x,this.vel.y).mag()}set speed(e){let i=this.direction;this.vel.x=t.cos(i)*e,this.vel.y=t.sin(i)*e}get static(){return this.body?.isStatic()}set static(t){this.collider=t?"static":"dynamic"}get tint(){return this._tint}set tint(t){this.watch&&(this.mod[44]=!0),this._tint=this._parseColor(t)}get tintColor(){return this._tint}set tintColor(t){this.tint=t}set vertices(t){if(3==this.__collider)throw new Error('Cannot set vertices of a sprite with collider type of "none".');this.watch&&(this.mod[29]=!0),this._removeFixtures(),this._originMode="start",this.addCollider(t),this._hasSensors&&this.addDefaultSensors()}get vertices(){return this._getVertices()}_getVertices(e){let s=this.fixture.getShape(),r=[...s.m_vertices];"polygon"==s.m_type&&r.unshift(r.at(-1));let o=this.x,h=this.y;for(let s=0;s=2)return void console.error('Cannot set the collider shape to chain or polygon if the sprite has a collider type of "none". To achieve the same effect, use .overlaps(allSprites) to have your sprite overlap with the allSprites group.');if(1==this.__shape&&0!=i)return void console.error("Cannot change a circle collider into a chain or polygon shape.");let s,r,o=this.__shape;if(this.__shape=i,this._shape=e,this.watch&&(this.mod[29]=!0),void 0===o)return;0==this.__shape?(this._h=this._w,this._hh=this._hw):(this._h=void 0,this._hh=void 0),1!=o&&1!=this.__shape?s=this._getVertices(!0):r=this._w,this._removeFixtures(),3!=this.__collider&&(s?(this._originMode??="center",this.addCollider(s)):this.addCollider()),this._hasSensors&&this.addDefaultSensors();let n=this._offset._x,h=this._offset._y;(n||h)&&(this._offset._x=0,this._offset._y=0,this._offsetCenterBy(n,h))}get update(){return this._update}set update(t){this._customUpdate=t}get vel(){return this._vel}set vel(t){this.vel.x=t.x,this.vel.y=t.y}set velocity(t){this.vel=t}get velocity(){return this._vel}_update(){this._ani?.update&&this._ani.update();for(let t in this.mouse)-1==this.mouse[t]&&(this.mouse[t]=0);this._customUpdate&&this._customUpdate(),this.autoUpdate&&(this.autoUpdate=null)}_step(){this.life-=t.world.timeScale,2147483647!=this._life&&this._life<=0&&this.remove(),this.body||this._removed||(this.rotation+=this._rotationSpeed,this.x+=this.vel.x,this.y+=this.vel.y),this.watch&&(this.x!=this.prevX&&(this.mod[0]=this.mod[2]=!0),this.y!=this.prevY&&(this.mod[1]=this.mod[2]=!0),this.rotation!=this.prevRotation&&(this.mod[3]=this.mod[4]=!0)),(this.body||this._removed)&&this.__step()}__draw(){if(this._ani&&"colliders"!=this.debug&&!t.p5play.disableImages&&this._ani.draw(this._offset._x,this._offset._y,0,this._scale._x,this._scale._y),!this._ani||this.debug||t.p5play.disableImages)if(this.debug&&(t.noFill(),t.stroke(0,255,0),t.line(0,-2,0,2),t.line(-2,0,2,0)),3!=this.__collider){this.debug||0===this._strokeWeight||(2==this.__shape?t.stroke(this.stroke||this.color):this._stroke&&t.stroke(this._stroke));for(let e=this.fixtureList;e;e=e.getNext()){if(this.debug)e.m_isSensor?t.stroke(255,255,0):t.stroke(0,255,0);else if(e.m_isSensor)continue;this._drawFixture(e)}}else 0!==this._strokeWeight&&t.stroke(this._stroke||120),0==this.__shape?t.rect(this._offset._x,this._offset._y,this.w*this.tileSize,this.h*this.tileSize):1==this.__shape&&t.circle(this._offset._x,this._offset._y,this.d*this.tileSize);void 0!==this.text&&(t.textAlign(t.CENTER,t.CENTER),t.fill(this._textFill),this._textStrokeWeight&&t.strokeWeight(this._textStrokeWeight),this._textStroke?t.stroke(this._textStroke):t.noStroke(),t.textSize(this.textSize*this.tileSize),t.text(this.text,0,0))}_display(){let e=this.x*this.tileSize+t.world.origin.x,i=this.y*this.tileSize+t.world.origin.y,s=Math.max(this._w,this._h);if("chain"!=this.shape&&t.camera.isActive&&(e+st.camera.bound.max.x||i+st.camera.bound.max.y))this._visible=null;else{if(this._visible=!0,t.p5play.spritesDrawn++,this._pixelPerfect){let s,r;this.ani&&!t.p5play.disableImages?(s=this.ani[this.ani._frame].w,r=this.ani[this.ani._frame].h):(s=this._w,r=this._h),e=s%2==0?Math.round(e):Math.round(e-.5)+.5,i=r%2==0?Math.round(i):Math.round(i-.5)+.5}else e=n(e),i=n(i);for(let t of this.joints)t.visible?this._uid==t.spriteA._uid?(!t.spriteB._visible||this.layer<=t.spriteB.layer)&&t._display():(!t.spriteA._visible||this.layer{let s,r;do{if(await t.sleep(),c!=this._destIdx)return!1;if(u&&(this.direction<=a||this.direction>=l)||Math.abs(this.vel.x)<=d&&Math.abs(this.vel.y)<=d)return!1;e&&(s=this.vel.x>0?this._dest.x-this.x:this.x-this._dest.x),i&&(r=this.vel.y>0?this._dest.y-this.y:this.y-this._dest.y)}while(e&&s>p||i&&r>p);return this.x=this._dest.x,this.y=this._dest.y,this.vel.x=0,this.vel.y=0,!0})()}rotateTowards(t,e){if(1==this.__collider)throw new A(0);let i,s,r,o=arguments;"number"!=typeof o[0]?(i=o[0].x,s=o[0].y,e=o[1],r=o[2]):arguments.length>2&&(i=o[0],s=o[1],e=o[2],r=o[3]),void 0!==i?t=this.angleToFace(i,s,r):t-=this.rotation,e??=.1,this.rotationSpeed=t*e}angleTo(e,i){if("object"==typeof e){let s=e;if(s==t.mouse&&!t.mouse.isActive)return 0;if(void 0===s.x||void 0===s.y)return console.error("sprite.angleTo ERROR: rotation destination not defined, object given with no x or y properties"),0;i=s.y,e=s.x}return t.atan2(i-this.y,e-this.x)}rotationToFace(t,e,i){return"object"==typeof t&&(i=e,e=t.y,t=t.x),Math.abs(t-this.x)<.01&&Math.abs(e-this.y)<.01?0:this.angleTo(t,e)+(i||0)}angleToFace(t,e,i){let s=this.rotationToFace(t,e,i);return h(s,this.rotation)}rotateTo(e,i,s){if(1==this.__collider)throw new A(0);let r=arguments;if("number"!=typeof r[0]?e=this.rotationToFace(r[0].x,r[0].y,s):r.length>2&&(s=r[3],i=r[2],e=this.rotationToFace(r[0],r[1],s)),e==this.rotation)return;let o="degrees"==t._angleMode?360:t.TWO_PI;return(e=(e-this.rotation)%o)<0&&i>0&&(e+=o),e>0&&i<0&&(e-=o),i??=this.rotationSpeed||Math.sign(e),this.rotate(e,i)}rotateMinTo(t,e,i){if(1==this.__collider)throw new A(0);let s=arguments;if("number"!=typeof s[0]?t=this.rotationToFace(s[0].x,s[0].y,i):s.length>2&&(i=s[3],e=s[2],t=this.rotationToFace(s[0],s[1],i)),t!=this.rotation)return t=h(t,this.rotation),e??=this.rotationSpeed||Math.sign(t),e=Math.abs(e)*Math.sign(t),this.rotate(t,e)}rotate(e,i){if(1==this.__collider)throw new A(0);if(isNaN(e))throw new A(1,[e]);if(0==e)return;i??=this.rotationSpeed||1;let s=e>0&&i>0;s||(e=-Math.abs(e),i=-Math.abs(i)),this.rotationSpeed=i;let r=this.rotation+e;this._rotateIdx??=0,this._rotateIdx++;let o=this._rotateIdx;return(async()=>{let e=.01,i=Math.abs(this.rotationSpeed)+e;do{if(await t.sleep(),this._rotateIdx!=o)return!1;if(s&&this.rotationSpeed-.01)return!1}while((s&&r>this.rotation||!s&&r1)e=[...arguments];else if(e instanceof t.SpriteAnimation){if(e==this._ani)return;e=[e]}else if(!Array.isArray(e)){if(e==this._ani?.name)return;e=[e]}let i,s;this._aniChangeCount++;for(let r=0;r1&&("!"==o.name[0]&&(o.name=o.name.slice(1),o.start=-1,o.end=0),"<"!=o.name[0]&&">"!=o.name[0]||(o.name=o.name.slice(1),o.flipX=!0),"^"==o.name[0]&&(o.name=o.name.slice(1),o.flipY=!0),"**"==o.name&&(i=!0,e=e.slice(0,-1)),";;"==o.name&&(s=!0,e=e.slice(0,-1)))}let r=this._aniChangeCount;do{for(let t=0;t1&&(i.start=0),await this._playSequencedAni(i)}}while(i&&r==this._aniChangeCount);1!=e.length&&s&&this._ani.stop()}_playSequencedAni(t){return new Promise((e=>{let{name:i,start:s,end:r,flipX:o,flipY:n}=t;this._changeAni(i),o&&(this._ani.scale.x=-this._ani.scale.x),n&&(this._ani.scale.y=-this._ani.scale.y),s<0&&(s=this._ani.length+s),void 0!==s&&(this._ani._frame=s),void 0!==r?this._ani.goToFrame(r):this._ani._frame==this._ani.lastFrame&&e(),this._ani._onComplete=this._ani._onChange=()=>{o&&(this._ani.scale.x=-this._ani.scale.x),n&&(this._ani.scale.y=-this._ani.scale.y),this._ani._onComplete=this._ani._onChange=null,e()}}))}changeAnimation(){return this.changeAni(...arguments)}_changeAni(e){this._ani?._onChange&&this._ani._onChange(),this._ani?.onChange&&this._ani.onChange();let i=this.animations[e];if(!i)for(let t=this.groups.length-1;t>=0;t--){if(i=this.groups[t].animations[e],i){i=i.clone();break}}if(!i)throw t.noLoop(),new A("Sprite.changeAnimation",[e]);this._ani=i,this._ani.name=e,this.resetAnimationsOnChange&&(this._ani._frame=0)}remove(){this.removed=!0}_remove(){this.body&&t.world.destroyBody(this.body),this.body=null;for(let t of this.groups)t.remove(this)}toString(){return"s"+this.idNum}_setContactCB(e,i,s,r){let o;o=0==s?a._collisions[r]:a._overlappers[r];let n=t.p5play[o],h=n[this._uid]??={};h[e._uid]!=i&&(h[e._uid]=i,h=n[e._uid],h&&h[this._uid]&&(delete h[this._uid],0==Object.keys(h).length&&delete n[e._uid]))}_validateCollideParams(t,e){if(!t)throw new A("Sprite.collide",2);if(!t._isSprite&&!t._isGroup)throw new A("Sprite.collide",0,[t]);if(e&&"function"!=typeof e)throw new A("Sprite.collide",1,[e])}_ensureCollide(t,e,i){if(!1!==this._hasOverlap[t._uid]&&(this._hasOverlap[t._uid]=!1),!1!==t._hasOverlap[this._uid]&&(t._hasOverlap[this._uid]=!1,t._isGroup))for(let e of t)e._hasOverlap[this._uid]=!1,this._hasOverlap[e._uid]=!1}collide(t,e){return this.collides(t,e)}collides(t,e){return this._validateCollideParams(t,e),this._ensureCollide(t),e&&this._setContactCB(t,e,0,0),1==this._collisions[t._uid]||this._collisions[t._uid]<=-3}colliding(t,e){this._validateCollideParams(t,e),this._ensureCollide(t),e&&this._setContactCB(t,e,0,1);let i=this._collisions[t._uid];return i<=-3?1:i>0?i:0}collided(t,e){return this._validateCollideParams(t,e),this._ensureCollide(t),e&&this._setContactCB(t,e,0,2),this._collisions[t._uid]<=-1}_validateOverlapParams(t,e){if(!t)throw new A("Sprite.overlap",2);if(!t._isSprite&&!t._isGroup)throw new A("Sprite.overlap",0,[t]);if(e&&"function"!=typeof e)throw new A("Sprite.overlap",1,[e])}_ensureOverlap(t){if(this._hasSensors||this.addDefaultSensors(),!t._hasSensors)if(t._isSprite)t.addDefaultSensors();else{for(let e of t)e._hasSensors||e.addDefaultSensors();t._hasSensors=!0}if(this._hasOverlap[t._uid]||(this._removeContactsWith(t),this._hasOverlap[t._uid]=!0),!t._hasOverlap[this._uid]&&(t._removeContactsWith(this),t._hasOverlap[this._uid]=!0,t._isGroup))for(let e of t)e._hasOverlap[this._uid]=!0,this._hasOverlap[e._uid]=!0}overlap(t,e){return this.overlaps(t,e)}overlaps(t,e){return this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,0),1==this._overlappers[t._uid]||this._overlappers[t._uid]<=-3}overlapping(t,e){this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,1);let i=this._overlappers[t._uid];return i<=-3?1:i>0?i:0}overlapped(t,e){return this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,2),this._overlappers[t._uid]<=-1}_removeContactsWith(t){if(t._isGroup)for(let e of t)this._removeContactsWith(e);else this.__removeContactsWith(t)}__removeContactsWith(e){if(this.body)for(let i=this.body.getContactList();i;i=i.next){let s=i.contact;s.m_fixtureA.m_body.sprite._uid!=e._uid&&s.m_fixtureB.m_body.sprite._uid!=e._uid||t.world.destroyContact(s)}}_sortFixtures(){let t,e,i=null,s=null;for(let r=this.fixtureList;r;r=r.getNext())r.m_isSensor?(s?s.m_next=r:s=r,e=r):(i?i.m_next=r:i=r,t=r);s&&(e.m_next=null),i&&(t.m_next=s),this.body.m_fixtureList=i||s}addDefaultSensors(){if(this._hasSensors)return;let t;if(this.body&&this.fixtureList){for(let e=this.fixtureList;e;e=e.getNext())e.m_isSensor||(t=e.m_shape,this.body.createFixture({shape:t,isSensor:!0}));this._sortFixtures()}else this.addSensor();this._hasSensors=!0}},t.Sprite.propTypes={x:"Float64",y:"Float64",vel:"Vec2",rotation:"number",rotationSpeed:"number",ani:"string",autoDraw:"boolean",allowSleeping:"boolean",autoUpdate:"boolean",bounciness:"number",collider:"Uint8",color:"color",debug:"boolean",density:"number",direction:"number",drag:"number",friction:"number",h:"number",isSuperFast:"boolean",layer:"number",life:"Int32",mass:"number",mirror:"Vec2_boolean",offset:"Vec2",pixelPerfect:"boolean",removed:"boolean",rotationDrag:"number",rotationLock:"boolean",scale:"Vec2",shape:"Uint8",sleeping:"boolean",stroke:"color",strokeWeight:"number",text:"string",textColor:"color",tile:"string",tileSize:"number",visible:"boolean",w:"number",bearing:"number",textSize:"number",textStroke:"color",textStrokeWeight:"number",opacity:"number"},t.Sprite.props=Object.keys(t.Sprite.propTypes),t.Sprite.propsAll=t.Sprite.props.concat(["d","diameter","dynamic","fill","height","heading","kinematic","resetAnimationsOnChange","speed","spriteSheet","static","width"]),t.Sprite.colliderTypes=["d","s","k","n"],t.Sprite.shapeTypes=["box","circle","chain","polygon"],t.Turtle=function(e){if(t.allSprites.tileSize>1)throw new Error("Turtle can't be used when allSprites.tileSize is greater than 1.");e??=25;let i=new t.Sprite(e,e,[[e,.4*e],[-e,.4*e],[0,.8*-e]]);i.color="green",i._isTurtleSprite=!0,i._prevPos={x:i.x,y:i.y};let s=i.move;return i.move=function(){return this._prevPos.x=this.x,this._prevPos.y=this.y,s.call(this,...arguments)},i},this.SpriteAnimation=class extends Array{constructor(){super();let e,i=[...arguments];if(this.name="default","object"==typeof i[0]&&(i[0]._isSprite||i[0]._isGroup)&&(e=i[0],i=i.slice(1),this._addedToSpriteOrGroup=!0),e??=t.allSprites,"string"!=typeof i[0]||1!=i[0].length&&i[0].includes(".")||(this.name=i[0],i=i.slice(1)),this._frame=0,this._cycles=0,this.targetFrame=-1,this.offset={x:e.anis.offset.x??0,y:e.anis.offset.y??0},this._frameDelay=e.anis.frameDelay||4,this.demoMode=e.anis.demoMode??!1,this.playing=!0,this.visible=!0,this.looping=e.anis.looping??!0,this.endOnFirstFrame=e.anis.endOnFirstFrame??!1,this.frameChanged=!1,this.onComplete=this.onChange=null,this._onComplete=this._onChange=null,this.rotation=e.anis.rotation??0,this._scale=new d,0!=i.length&&"number"!=typeof i[0]){if(e.animations[this.name]=this,e._ani=this,Array.isArray(i[0])&&"string"==typeof i[0][0]&&(i=[...i[0]]),2!=i.length||"string"!=typeof i[0]||"string"!=typeof i[1]&&"number"!=typeof i[1])if("string"==typeof i[i.length-1]||i[i.length-1]instanceof p5.Image)for(let s=0;s=3)throw new A("SpriteAnimation",1);o=i[0],r=i[1]}else r=i[0];let n=this;if(o instanceof p5.Image&&1!=o.width&&1!=o.height)this.spriteSheet=o,h();else{let a;a="string"==typeof o?o:o.url,t._incrementPreload(),this.spriteSheet=t.loadImage(a,(()=>{h(),t._decrementPreload()})),"string"==typeof o&&(e.spriteSheet=this.spriteSheet)}function h(){Array.isArray(r)&&(r=4==r.length?{pos:r.slice(0,2),size:r.slice(2)}:{pos:r});let{w:t,h:i,width:s,height:o,size:h,row:a,col:l,line:d,x:p,y:u,pos:c,frames:_,frameCount:f,frameDelay:g,frameSize:m,delay:y,rotation:x}=r;m??=h||e.anis.frameSize,y&&(n.frameDelay=y),g&&(n.frameDelay=g),x&&(n.rotation=x),_&&Array.isArray(_)?f=_.length:f??=_||1,t??=s||e.anis.w,i??=o||e.anis.h,p??=l||0,u??=d||a||0,c&&(p=c[0],u=c[1]),"number"==typeof m?t=i=m:m&&(t=m[0],i=m[1]);let w=e.tileSize;if(t&&i?(t*=w,i*=w):!e._dimensionsUndef&&e.w&&e.h?(t??=e.w*w,i??=e.h*w):1!=w?(t??=w,i??=w):f?(t??=n.spriteSheet.width/f,i??=n.spriteSheet.height):t=i=n.spriteSheet.width=n.spriteSheet.width&&(p=0,u+=i,u>=n.spriteSheet.height&&(u=0))}}}else{let l,p,u=i[0];if(isNaN(i[1])?l=i[1]:p=Number(i[1]),".png"!=u.slice(-4)||l&&".png"!=l.slice(-4))throw new A("SpriteAnimation",0,[u]);let c=0,_=0;for(let m=u.length-5;m>=0&&!isNaN(u.charAt(m));m--)c++;if(l)for(let y=l.length-5;y>=0&&!isNaN(l.charAt(y));y--)_++;let f,g=u.slice(0,-4-c);if(l&&(f=l.slice(0,-4-_)),l&&g!=f)this.push(t.loadImage(u)),this.push(t.loadImage(l));else{let x,w=parseInt(u.slice(-4-c,-4),10);if(p??=parseInt(l.slice(-4-_,-4),10),p=this.length)throw new A("SpriteAnimation.frame",[t,this.length]);this._frame=t,this._cycles=0}get frameDelay(){return this._frameDelay}set frameDelay(t){t<=0&&(t=1),this._frameDelay=t}get scale(){return this._scale}set scale(t){"number"==typeof t&&(t={x:t,y:t}),this._scale._x=t.x,this._scale._y=t.y,this._scale._avg=t.x}clone(){this.length||console.error(`The animation named "${this.name}" must be loaded before it can be properly copied. Sprites need their own copy of a group's animation. Try loading the animation in the preload function and creating new group sprites in the setup function.`);let e=new t.SpriteAnimation;e.spriteSheet=this.spriteSheet;for(let t=0;tthis._frame&&-1!==this.targetFrame?this._frame++:this.targetFrame=this.lastFrame?this._frame=0:this._frame++:this._frame{this._onComplete=()=>{this._onComplete=null,t()}}))}pause(t){this.playing=!1,t&&(this._frame=t)}stop(t){this.playing=!1,t&&(this._frame=t)}rewind(){return this.looping=!1,this.goToFrame(0)}loop(){this.looping=!0,this.playing=!0}noLoop(){this.looping=!1}nextFrame(){this._frame0?this._frame=this._frame-1:this.looping&&(this._frame=this.length-1),this.targetFrame=-1,this.playing=!1,this._cycles=0}goToFrame(t){if(!(t<0||t>=this.length))return this.targetFrame=t,this._cycles=0,this.targetFrame!==this._frame&&(this.playing=!0),new Promise((t=>{this._onComplete=()=>{this._onComplete=null,t()}}))}get lastFrame(){return this.length-1}get frameImage(){let e=this[this._frame];if(e instanceof p5.Image)return e;let{x:i,y:s,w:r,h:o}=e,n=t.createImage(r,o);return n.copy(this.spriteSheet,this.offset.x,this.offset.y,r,o,i,s,r,o),n}get w(){return this.width}get width(){return this[this._frame]instanceof p5.Image?this[this._frame].width:this[this._frame]?this[this._frame].w:1}get h(){return this.height}get height(){return this[this._frame]instanceof p5.Image?this[this._frame].height:this[this._frame]?this[this._frame].h:1}get frames(){let t=[];for(let e=0;ee.#t[t],set(i){e.#t[t]=i;for(let s in e){let r=e[s];r instanceof SpriteAnimation&&(r[t]=i)}}});for(let t of s){this.#t[t]={_x:0,_y:0};for(let i of["x","y"])Object.defineProperty(this.#t[t],i,{get:()=>e.#t[t]["_"+i],set(s){e.#t[t]["_"+i]=s;for(let r in e){let o=e[r];o instanceof SpriteAnimation&&(o[t][i]=s)}}})}}},this.Group=class extends Array{constructor(...e){let i;if(e[0]instanceof t.Group&&(i=e[0],e=e.slice(1)),super(...e),"number"==typeof e[0])return;for(let e of this)if(!(e instanceof t.Sprite))throw new Error("A group can only contain sprites");if(this._isGroup=!0,this.x,this.y,this.vel,this.rotation,this.rotationSpeed,this.autoDraw,this.allowSleeping,this.autoUpdate,this.bounciness,this.collider,this.color,this.debug,this.density,this.direction,this.drag,this.friction,this.h,this.isSuperFast,this.layer,this.life,this.mass,this.mirror,this.offset,this.pixelPerfect,this.removed,this.rotationDrag,this.rotationLock,this.scale,this.shape,this.sleeping,this.stroke,this.strokeWeight,this.text,this.textColor,this.tile,this.tileSize,this.visible,this.w,this.bearing,this.d,this.diameter,this.dynamic,this.height,this.heading,this.kinematic,this.resetAnimationsOnChange,this.speed,this.static,this.width,this.idNum,t.p5play.groupsCreated<999)this.idNum=t.p5play.groupsCreated;else{for(let e=1;et&&(t=e._layer);return t}get ani(){return this._ani}set ani(t){this.addAni(t);for(let e of this)e.changeAni(t)}get animation(){return this._ani}set animation(t){this.ani=t}get anis(){return this.animations}get img(){return this._ani.frameImage}set img(t){this.ani=t}get image(){return this._ani.frameImage}set image(t){this.ani=t}get amount(){return this.length}set amount(t){let e=t-this.length,i=e>0;e=Math.abs(e);for(let t=0;t0?i:0}collided(t,e){return this._validateCollideParams(t,e),this._ensureCollide(t),e&&this._setContactCB(t,e,0,2),this._collisions[t._uid]<=-1}_validateOverlapParams(t,e){if(e&&"function"!=typeof e)throw new A("Group.overlap",1,[e]);if(!t)throw new A("Group.overlap",2);if(!t._isGroup&&!t._isSprite)throw new A("Group.overlap",0,[t])}_ensureOverlap(t){if(!this._hasSensors){for(let t of this)t._hasSensors||t.addDefaultSensors();this._hasSensors=!0}if(!t._hasSensors)if(t._isSprite)t.addDefaultSensors();else{for(let e of t)e._hasSensors||e.addDefaultSensors();t._hasSensors=!0}if(1!=this._hasOverlap[t._uid]){this._removeContactsWith(t),this._hasOverlap[t._uid]=!0;for(let e of this)if(e._hasOverlap[t._uid]=!0,t._hasOverlap[e._uid]=!0,this._uid==t._uid)for(let i of t)e._hasOverlap[i._uid]=!0,i._hasOverlap[e._uid]=!0}if(1!=t._hasOverlap[this._uid]&&(t._removeContactsWith(this),t._hasOverlap[this._uid]=!0,t._isGroup))for(let e of t){e._hasOverlap[this._uid]=!0,this._hasOverlap[e._uid]=!0;for(let t of this)e._hasOverlap[t._uid]=!0,t._hasOverlap[e._uid]=!0}}overlap(t,e){return this.overlaps(t,e)}overlaps(t,e){return this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,0),1==this._overlappers[t._uid]||this._overlappers[t._uid]<=-3}overlapping(t,e){this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,1);let i=this._overlappers[t._uid];return i<=-3?1:i>0?i:0}overlapped(t,e){return this._validateOverlapParams(t,e),this._ensureOverlap(t),e&&this._setContactCB(t,e,1,2),this._overlappers[t._uid]<=-1}_removeContactsWith(t){for(let e of this)e._removeContactsWith(t)}applyForce(){for(let t of this)t.applyForce(...arguments)}applyForceScaled(){for(let t of this)t.applyForceScaled(...arguments)}attractTo(){for(let t of this)t.attractTo(...arguments)}applyTorque(){for(let t of this)t.applyTorque(...arguments)}move(t,e,i){let s=[];for(let r of this)s.push(r.move(t,e,i));return Promise.all(s)}moveTo(e,i,s){if("number"!=typeof e){let r=e;if(r==t.mouse&&!t.mouse.isActive)return;s=i,i=r.y,e=r.x}let r=this._resetCentroid(),o=[];for(let t of this){let n={x:t.x-r.x+e,y:t.y-r.y+i};o.push(t.moveTo(n.x,n.y,s))}return Promise.all(o)}moveTowards(e,i,s){if("number"!=typeof e){let r=e;if(r==t.mouse&&!t.mouse.isActive)return;s=i,i=r.y,e=r.x}if(void 0!==e||void 0!==i){this._resetCentroid();for(let t of this){void 0===t.distCentroid&&this._resetDistancesFromCentroid();let r={x:t.distCentroid.x+e,y:t.distCentroid.y+i};t.moveTowards(r.x,r.y,s)}}}moveAway(e,i,s){if("number"!=typeof e){let r=e;if(r==t.mouse&&!t.mouse.isActive)return;s=i,i=r.y,e=r.x}if(void 0!==e||void 0!==i){this._resetCentroid();for(let t of this){void 0===t.distCentroid&&this._resetDistancesFromCentroid();let r={x:t.distCentroid.x+e,y:t.distCentroid.y+i};t.moveAway(r.x,r.y,s)}}}push(...e){this.removed&&(console.warn("Adding a sprite to a group that was removed. Use `group.removeAll()` to remove all of a group's sprites without removing the group itself. Restoring the group in p5play's memory."),t.p5play.groups[this._uid]=this,this.removed=!1);for(let i of e){if(!(i instanceof t.Sprite))throw new Error("You can only add sprites to a group, not "+typeof i);if(i.removed){console.error("Can't add a removed sprite to a group");continue}let e;for(let s in this._hasOverlap){let r=this._hasOverlap[s];r&&!i._hasSensors&&i.addDefaultSensors(),e=s>=1e3?t.p5play.sprites[s]:t.p5play.groups[s],e&&!e.removed&&(r?e._ensureOverlap(i):e._ensureCollide(i))}for(let e in a){let s=a[e];for(let e of s){let s=t.p5play[e],r=s[this._uid];if(!r)continue;let o=s[i._uid]??={};for(let t in r)o[t]=r[t]}}super.push(i),this.parent&&t.p5play.groups[this.parent].push(i),i.groups.push(this)}return this.length}size(){return this.length}toString(){return"g"+this.idNum}cull(e,i,s,r,o){if(void 0===s){o=i,e=i=s=r=e}if(isNaN(e)||isNaN(i)||isNaN(s)||isNaN(r))throw new TypeError("The culling boundary must be defined with numbers");if(o&&"function"!=typeof o)throw new TypeError("The callback to group.cull must be a function");let n=t.camera.x-t.canvas.hw/t.camera.zoom,h=t.camera.y-t.canvas.hh/t.camera.zoom,a=-s+n,l=-e+h,d=t.width+r+n,p=t.height+i+h,u=0;for(let t=0;td||e.y>p)&&(u++,o?o(e,u):e.remove(),e.removed&&t--))}return u}remove(t){if(void 0===t)return this.removeAll(),void(this._isAllSpritesGroup||(this.removed=!0));let e;if(e="number"==typeof t?t>=0?t:this.length+t:this.indexOf(t),-1==e)return;let i=this[e];return this.splice(e,1),i}splice(e,i){let s=super.splice(e,i);if(!s)return;let r=[];for(let t of s){if(t.removed)continue;let e=this._uid;do{r.push(e);let i=t.groups.findIndex((t=>t._uid==e)),s=t.groups.splice(i,1);e=s[0].parent}while(e)}for(let e of r){let i=t.p5play.groups[e];for(let e in a)for(let s in i[e]){if(0==i[e][s])continue;let r;r=s>=1e3?t.p5play.sprites[s]:t.p5play.groups[s];let o=!1;for(let t of i)if(t[e][r._uid]>0){o=!0;break}o||(i[e][r._uid]=-2,r[e][i._uid]=-2)}}return s}pop(){return this.remove(this.length-1)}shift(){return this.remove(0)}unshift(){return console.error("unshift is not supported for groups"),this.length}removeAll(){for(;this.length>0;)this.at(-1).remove()}_step(){this.__step()}draw(){let e=[...this];e.sort(((t,e)=>t._layer-e._layer));for(let i=0;i=1e3){if(i._isGroup||i._uid>=r)continue;e=t.p5play.sprites[r]}else{if(i._isGroup&&i._uid>=r)continue;e=t.p5play.groups[r]}let o=i[s][r]+1;e&&0!=o&&-2!=o?(this[s][r]=o,e[s][i._uid]=o):(delete i[s][r],e&&delete e[s][i._uid])}},t.Sprite.prototype.___step=t.Group.prototype.___step=function(){let e,i,s,r,o=this,n=!0;for(let h in a){for(let l in this[h]){if(l>=1e3){if(o._isGroup||o._uid>=l)continue;e=t.p5play.sprites[l]}else{if(o._isGroup&&o._uid>=l)continue;e=t.p5play.groups[l]}if(o._isGroup||e?._isGroup)continue;if(s=o._hasOverlap[e._uid]??e._hasOverlap[o._uid],n&&!1!==s||!n&&!0!==s)continue;let d=o[h][l];for(let s=0;s<3;s++){if(0==s&&1!=d&&-3!=d)continue;if(1==s&&-1==d)continue;if(2==s&&d>=1)continue;i=a[h][s];let n=t.p5play[i][o._uid];if(n){r=n[e._uid],r&&r.call(o,o,e,d);for(let t of e.groups)r=n[t._uid],r&&r.call(o,o,e,d)}let l=t.p5play[i][e._uid];if(l){r=l[o._uid],r&&r.call(e,e,o,d);for(let t of o.groups)r=l[t._uid],!r||n&&r==n[t._uid]||r.call(e,e,o,d)}}}n=!1}if(this._removed&&0==Object.keys(this._collisions).length&&0==Object.keys(this._overlappers).length){this._isSprite?delete t.p5play.sprites[this._uid]:t.p5play.targetVersion>=16&&delete t.p5play.groups[this._uid];for(let e in a)for(let i of a[e])delete t.p5play[i][this._uid]}},t.Sprite.prototype.addAnimation=t.Group.prototype.addAnimation=t.Sprite.prototype.addAni=t.Group.prototype.addAni=t.Sprite.prototype.addImage=t.Group.prototype.addImage=t.Sprite.prototype.addImg=t.Group.prototype.addImg=function(){if(t.p5play.disableImages)return void(this._ani=new t.SpriteAnimation);let e,i,s=[...arguments];return s[0]instanceof t.SpriteAnimation?(i=s[0],i._addedToSpriteOrGroup&&(i=i.clone()),e=i.name||"default",i.name=e):s[1]instanceof t.SpriteAnimation?(e=s[0],i=s[1],i._addedToSpriteOrGroup&&(i=i.clone()),i.name=e):(i=new t.SpriteAnimation(this,...s),e=i.name),this.animations[e]=i,this._ani=i,i._addedToSpriteOrGroup=!0,!this._dimensionsUndef||1==i.w&&1==i.h||(this.w=i.w,this.h=i.h),i},t.Sprite.prototype.addAnis=t.Group.prototype.addAnis=t.Sprite.prototype.addAnimations=t.Group.prototype.addAnimations=t.Sprite.prototype.addImages=t.Group.prototype.addImages=t.Sprite.prototype.addImgs=t.Group.prototype.addImgs=function(){let t,e=arguments;1==e.length?t=e[0]:(this.spriteSheet=e[0],t=e[1]);for(let e in t){let i=t[e];this.addAni(e,i)}},this.World=class extends planck.World{constructor(){super(new e.Vec2(0,0),!0),this.mod={},this.origin={x:0,y:0},this.contacts=[],this.on("begin-contact",this._beginContact),this.on("end-contact",this._endContact);let i=this;this._gravity={get x(){return i.m_gravity.x},set x(e){if((e=Math.round(e||0))!=i.m_gravity.x){i.mod[0]=!0;for(let e of t.allSprites)e.sleeping=!1;i.m_gravity.x=e}},get y(){return i.m_gravity.y},set y(e){if((e=Math.round(e||0))!=i.m_gravity.y){i.mod[0]=!0;for(let e of t.allSprites)e.sleeping=!1;i.m_gravity.y=e}}},this.timeScale=1,this.velocityIterations=8,this.positionIterations=3,this.velocityThreshold=.19,this.mouseTracking??=!0,this.mouseSprite=null,this.mouseSprites=[],this.autoStep=!0}get gravity(){return this._gravity}set gravity(t){this._gravity.x=t.x,this._gravity.y=t.y}get velocityThreshold(){return e.Settings.velocityThreshold}set velocityThreshold(t){e.Settings.velocityThreshold=t}step(e,i,s){for(let e of t.allSprites)e.prevPos.x=e.x,e.prevPos.y=e.y,e.prevRotation=e.rotation;super.step((e||1/(t._targetFrameRate||60))*this.timeScale,i||this.velocityIterations,s||this.positionIterations);let r=Object.values(t.p5play.sprites),o=Object.values(t.p5play.groups);for(let t of r)t._step();for(let t of o)t._step();for(let t of r)t.___step();for(let t of o)t.___step();t.canvas.dispatchEvent&&t.canvas.dispatchEvent(new window.Event("p5play_world_step")),this.autoStep&&(this.autoStep=null)}getSpritesAt(s,r,o,n){n??=!0;const h=new e.Vec2(s/i,r/i),a=new e.AABB;a.lowerBound=new e.Vec2(h.x-.001,h.y-.001),a.upperBound=new e.Vec2(h.x+.001,h.y+.001);let l=[];if(this.queryAABB(a,(t=>(t.getShape().testPoint(t.getBody().getTransform(),h)&&l.push(t),!0))),0==l.length)return[];o??=t.allSprites;let d=[];for(let t of l){const e=t.m_body.sprite;e._cameraActiveWhenDrawn==n&&(d.find((t=>t._uid==e._uid))||d.push(e))}return d.sort(((t,e)=>-1*(t._layer-e._layer))),d}getSpriteAt(t,e,i){return this.getSpritesAt(t,e,i)[0]}getMouseSprites(){let e=this.getSpritesAt(t.mouse.x,t.mouse.y);if(t.camera._wasOff){let i=this.getSpritesAt(t.mouse.canvasPos.x,t.mouse.canvasPos.y,t.allSprites,!1);i.length&&(e=[...i,...e])}return e}_beginContact(t){let e=t.m_fixtureA,i=t.m_fixtureB,s="_collisions";e.m_isSensor&&(s="_overlappers"),e=e.m_body.sprite,i=i.m_body.sprite,e[s][i._uid]=0,i[s][e._uid]=0;for(let t of i.groups)(!e[s][t._uid]||e[s][t._uid]<0)&&(e[s][t._uid]=0,t[s][e._uid]=0);for(let t of e.groups){(!i[s][t._uid]||i[s][t._uid]<0)&&(i[s][t._uid]=0,t[s][i._uid]=0);for(let e of i.groups)(!t[s][e._uid]||t[s][e._uid]<0)&&(t[s][e._uid]=0,e[s][t._uid]=0)}}_endContact(t){let e=t.m_fixtureA,i=t.m_fixtureB,s="_collisions";e.m_isSensor&&(s="_overlappers"),e=e.m_body.sprite,i=i.m_body.sprite,e[s][i._uid]=0!=e[s][i._uid]?-2:-4,i[s][e._uid]=0!=i[s][e._uid]?-2:-4;for(let t of i.groups){let i=!1;for(let r of t)if(r[s][e._uid]>=0){i=!0;break}i||(t[s][e._uid]=0!=t[s][e._uid]?-2:-4,e[s][t._uid]=0!=e[s][t._uid]?-2:-4)}for(let t of e.groups){let e=!1;for(let r of t)if(r[s][i._uid]>=0){e=!0;break}if(!e){t[s][i._uid]=0!=t[s][i._uid]?-2:-4,i[s][t._uid]=0!=i[s][t._uid]?-2:-4;for(let e of i.groups)t[s][e._uid]=0!=t[s][e._uid]?-2:-4,e[s][t._uid]=0!=e[s][t._uid]?-2:-4}}}_findContact(t,e,i){let s=e[t][i._uid];if(s)return s;for(let r of i.groups)if(s=e[t][r._uid],s)return s;for(let r of e.groups){if(s=r[t][i._uid],s)return s;for(let e of i.groups)if(r._uid==e._uid&&(s=r[t][e._uid],s))return s}return!1}get allowSleeping(){return this.getAllowSleeping()}set allowSleeping(t){this.setAllowSleeping(t)}},this.Camera=class{constructor(){this._pos=t.createVector.call(t),this.__pos={x:0,y:0,rounded:{}},this.mouse={x:t.mouseX,y:t.mouseY},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-100,this.bound.max.x=e+i+100}_calcBoundsY(e){let i=t.canvas.hh/this._zoom;this.bound.min.y=e-i-100,this.bound.max.y=e+i+100}get x(){return this._pos.x}set x(e){if(void 0===e||isNaN(e))return;this._pos.x=e;let i=-e+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.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,n=Math.sqrt(r*r+o*o),h=s/n,a=o*h,l=r*h;this._destIdx++;let d=this._destIdx,p=Math.ceil(n/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?this._j.setSpringFrequencyHz(e):this._j.setFrequency(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}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=r(t.x,t.y,this.spriteA.tileSize)),(this.offsetB.x||this.offsetB.y)&&(e=this.spriteB.body.getWorldPoint(this._j.m_localAnchorB),e=r(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="degrees"==t._angleMode?90:1.5707963267948966}_display(){let e,i,s=this.spriteA.x,o=this.spriteA.y;if(this.offsetB.x||this.offsetB.y){let t=this.spriteB.body.getWorldPoint(this._j.m_localAnchorB);t=r(t.x,t.y,this.spriteB.tileSize),e=t.x,i=t.y}else e=this.spriteB.x,i=this.spriteB.y;let n=t.tan(this.spriteA.rotation),h=t.tan(this._angle+this.spriteA.rotation),a=(i-o+n*s-h*e)/(n-h),l=n*(a-s)+o;this._draw(a,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),"degrees"==t._angleMode&&(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),"degrees"==t._angleMode&&(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*i}set lowerLimit(t){this._j.isLimitEnabled()||this._j.enableLimit(!0),t=t*this.spriteA.tileSize/i,this._j.setLimits(t,this._j.getUpperLimit())}get upperLimit(){return this._j.getUpperLimit()/this.spriteA.tileSize*i}set upperLimit(t){this._j.isLimitEnabled()||this._j.enableLimit(!0),t=t*this.spriteA.tileSize/i,this._j.setLimits(this._j.getLowerLimit(),t)}},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 t=this._j.getMaxLength(),e=this.spriteA.tileSize,t/e*i;var t,e}set maxLength(t){var e,s;this._j.setMaxLength((e=t,s=this.spriteA.tileSize,e*s/i))}};class d{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(){let t=new Float32Array(1),e=new Int32Array(t.buffer)}();function p(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 u(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.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 n=r.length,h=t.createImage(o*i,n*i);h.loadPixels();for(let t=0;tnew Promise(t?e=>{setTimeout(e,t)}:requestAnimationFrame),this.sleep=e=>e?t.delay(e):new Promise((e=>{t.canvas.addEventListener("p5play_world_step",e)})),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 L=location.hostname;switch(L){case"":case"127.0.0.1":case"localhost":case"p5play.org":case"editor.p5js.org":case"codepen.io":case"codera.app":case"cdpn.io":case"glitch.com":case"replit.com":case"stackblitz.com":case"jsfiddle.net":case"aijs.io":case"preview-aijs.web.app":break;default:if(/^[\d\.]+$/.test(L)||L.endsWith("stackblitz.io")||L.endsWith("glitch.me")||L.endsWith("replit.dev")||L.endsWith("codehs.com")||L.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,iVBORw0KGgoAAAANSUhEUgAAAIAAAABACAYAAADS1n9/AAABbGlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAACiRfZC/S0JhGIWfm4VgNkQNDg13igYr0SCXBjWQIkisQG26Xn+C2sfVCKMtWkPoP8igOWgoIgxaGhqCqCGitqamgpaSL+69hS51lvfhcDgcXujxaEKUeoFypWbEo2E1kUypzhcUFCxpelWEYrEFk39vlxT4uLezt+Nm12u7uRvciV6Wj88XNx88k/wvVyZb1YEvwKcLowaKF4ht1ITJW8CwkUimQGmYnLf5wOS0zSdWZjkeAeUaUPWClgHlFfCmu/x8F5dL6/rPMnO9O1tZWTJ7gBFmKVJFUEKjjkqMwB/5KSsfYQ1BHYMieQrUUAkhrIYsKnNU0JnAi4ofH3785p/tuo+7n/95O972M8y0pJRnHW++BUfT4DrteGNBGOyHq1OhGZplOYCeXA7eDmEgCUM34Fqt5gJ+e707DH1PUr6PgnMP2g0pP/elbDfB8QgXlW8Y/mq9pjC8gwAABSxJREFUeJztnb9y2zAMxulcpnbNntfJ3D5n97xO966Z3aNP9NHgBxAgQVmO8bvLNZZIiCI+gH8kpyl4bk7P3gErOJ/PZ0+zp9NpmZ9CAM54O7+wSgQhAEdWOb+wQgSvzZHAj5+/50x9/WkOeRMZwIkm+medXyAi8M4CL82R4KkIATjQRL8nJJN4XysEsAKv9L8DIYAnJyaBk8CUTDLA51/bbP7jHWSQRZPByADeTDp/tM4ozT4AVHSwO1kEMBMY/dTLFNcMcN5oSgTHYHBi2fPrS4qo98Mh/a+C8/ErdyJYw8cbb/bzH/ncGQY8aOYAnpThZ4XGerZdrn209fxIe6rVQw52Oif4NquAfF+d+Y6NSeej9C9F/714WAHkyP5uoxcSCBKSic5WMhwCciTlcnUaRSmVRlw5x0UiVx6VqW1Ru1zbaHl6TXS9Efae3GmuNzpXYDMA7VT6OxKE9nhPKNy1ZlHbEdL/qPNRdHsy2i5WAIk41yt6emM1Jw5OcL12eg4VR1rWmRCGAVEAGjhncseLQ7SOebZV6t4TxWEBcFHHOayO7PoHUcpy/y5FSP+jWJ06KoKRDAUngZxDUXrVlOsdR0jX8vjsxaqI1dilG0ciWdjgHcN4GqgERdcR1/VayjwgBFDzQG/yJEaASKgSIYBnAgg8BKAARRWKvkcjDwMhgAKIjkcACREJlgOuAu5K7Qgwaz0KeQaOOn9vTCsBwLwApMiZdOBROpnj3u2bdX5aPQfwaOBuDIr1HveYryldl30wBO4RZ4AS1aXCbFr2skezTa5b2+7Z7Z2nNjZKh3Jja3HGHtlAcnwyOj+/HIIFUACd0TizbhzTQU1ddAzYg+WYY5d0TM5dXql6A2VzO7n0jUS6kTtXuseVQ4Im01icXxgfApgOuvy8pevPjD3VuRrhRpu29trG2GI7eWPFkKCJerZdzH2UV8NUAsiqR8pnG5YdJjjNZA+8aYvqIq6dQqNfC9N5YofvDNuO3HbQ/tNG+dwVQOmwS8QAg/kY26lABF17Aqq65DgSlSkzMR2ZpM53hmsve32mvehLIvIcoFyIaUB9vhZB3bBmbJ6cLJkfrb4PRj+FmSAeCsbxiXF+0mSAG5WhDtjSfT32S3TtUb6wsMS6Qkd4TtKQoI62b0FTPkW3EQQ6G908KgcB5aA9BKir4WFf59q4ZNneF0eYZ/4SUxtB4lg88rVoLnqEa7CAOqz9J0Y9Caw/N44FnX0zYQPHRXsI4RqQ0Zk/B1iNUB5RYKohgN4svNG8GiApCpbr2QN2uHN08nmBGSK4ttyLkd1D1TBgxGUV4F1OOk/PSWUTENsRqJ3ovo1M5gHo+4A13/YPRd4sS2c7V/m1795WMJvZlNvIUv1RTtzXw2mqncXbnsSSqCJwIuCua3GetX4zBBj+ntDlBCeCYGNg2Vo7UXIeR6nv9fSPE0EIoAdwfs095xis85NeAC/SyWDSCQLXJ6cT9T2Ajo+MQOhkgWTMBMh55iecPSxDQHBLEwCG7WfJkd13CYS6mvpXrJPAoKURQdILATnSkrKbjTJLugc7piGAQWZEkDS7dMIj5utWulQf2SNIzk8hgD6zIoBQRy36n0U0k/sQgAIogjT/Z9saHO1pV3YhACUuImCcNWRPsGVZ1ocAjEAh9JwmOAsyaG9kPycEMAAUQWIcp3CWt71gB84SP34JJ7Gzm0I1A/a0hGomsTigF6VWZ3pEfQjAAY3jLM7yticRAnAEOW7GUd72ECEAZ2qneTjL294NKaX/gKttC9Kft4MAAAAASUVORK5CYII="};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 c=p5.disableFriendlyErrors;p5.disableFriendlyErrors=!0;const _=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(":");r[2]=r[1],e=!0;let i=Number(t[0]),s=Number(t[1]),o=window.innerWidth,n=window.innerWidth*(s/i);n>window.innerHeight&&(o=window.innerHeight*(i/s),n=window.innerHeight),r[0]=Math.round(o),r[1]=Math.round(n)}else r=[0,0,...r];if(r[0]||(r[0]=window.innerWidth,r[1]=window.innerHeight,e=!0),"string"==typeof r[2]){let t=r[2].toLowerCase().split(" ");"pixelated"==t[0]?(i=!0,t[1]?s=Number(t[1].slice(1)):e=!0,r.splice(2,1)):"fullscreen"==t[0]&&(e=!0,r.splice(2,1))}let o=_.call(t,...r);this.ctx??=this.drawingContext;let n=o.canvas||o;n.tabIndex=0,n.w=r[0],n.h=r[1],n.addEventListener&&(n.addEventListener("keydown",(function(t){" "!=t.key&&"/"!=t.key&&"ArrowUp"!=t.key&&"ArrowDown"!=t.key&&"ArrowLeft"!=t.key&&"ArrowRight"!=t.key||t.preventDefault()})),n.addEventListener("mouseover",(()=>{this.mouse.isOnCanvas=!0,this.mouse.isActive=!0})),n.addEventListener("mouseleave",(()=>{this.mouse.isOnCanvas=!1})),n.addEventListener("touchstart",(t=>t.preventDefault())),n.addEventListener("contextmenu",(t=>t.preventDefault()))),n.save??=t.saveCanvas.bind(t),n.resize??=t.resizeCanvas.bind(t),n.hw=.5*n.w,n.hh=.5*n.h,n.mouse={x:t.mouseX,y:t.mouseY},this.camera.x=n.hw,this.camera.y=n.hh,c||(p5.disableFriendlyErrors=!1);let h="\n.p5Canvas, .q5Canvas {\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}\nmain {\n\toverscroll-behavior: none;\n}";e&&(h="html,\nbody,\n"+h,h+="\nhtml, body {\n\tmargin: 0;\n\tpadding: 0;\n\toverflow: hidden;\n\theight: 100%;\n}\nmain {\n\tmargin: auto;\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-content: center;\n\tjustify-content: center;\n\theight: 100%;\n}"),h+=`\n#${n.id} {`,i&&(h+="\n\timage-rendering: pixelated;\n\tfont-smooth: never;\n\t-webkit-font-smoothing: none;\n"),e?(n.fullscreen=!0,n.w/n.h>window.innerWidth/window.innerHeight?h+="width: 100%!important; height: auto!important;":h+="height: 100%!important; width: auto!important;"):s&&(h+=`\n\twidth: ${n.w*s}px!important;\n\theight: ${n.h*s}px!important;\n`),h+="\n}";let a=document.createElement("style");return a.innerHTML=h,document.head.appendChild(a),i&&(t.pixelDensity(1),t.noSmooth(),t.textFont("monospace"),t.ctx.imageSmoothingEnabled=!1),o},this.Canvas=class{constructor(t,e,i,s,r){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 f=t.resizeCanvas;this.resizeCanvas=(e,i)=>{e??=window.innerWidth,i??=window.innerHeight,f.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.camera.x=s.hw,t.camera.y=s.hh};const g=t.background;this.background=function(){let e=arguments;1==e.length&&1==e[0].length?g.call(t,t.colorPal(e[0])):g.call(t,...e)};const m=t.fill;this.fill=function(){let e=arguments;1==e.length&&1==e[0].length?m.call(t,t.colorPal(e[0])):m.call(t,...e)};const y=t.stroke;this.stroke=function(){let e=arguments;1==e.length&&1==e[0].length?y.call(t,t.colorPal(e[0])):y.call(t,...e)};const x=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 1==r.width&&1==r.height||!r.pixels.length?e?(r.cbs.push(e),r.calls++):t._decrementPreload():(e&&e(),t._decrementPreload()),r;return r=x.call(t,s,(e=>{e.w||(Object.defineProperty(e,"w",{get:function(){return this.width}}),Object.defineProperty(e,"h",{get:function(){return this.height}}));for(let t of e.cbs)t(e);for(let i=1;i=190}catch(D){}if(v){function b(e,i,s){const r=t.canvas.getContext("2d"),o=t._renderer;let n=o._textFont;return"string"!=typeof n&&(n=n.font.names.fullName,n=n[Object.keys(n)[0]]),e.slice(0,200)+(o._textStyle||"normal")+o._textSize+n+(o._doFill?r.fillStyle:"")+"_"+(o._doStroke&&o._strokeSet?r.lineWidth+r.strokeStyle+"_":"")+(i||"")+(s?"x"+s:"")}t._textCache=!0,t._TimedCache=class extends Map{constructor(){super(),this.maxSize=500}set(t,e){e.lastAccessed=Date.now(),super.set(t,e),this.size>this.maxSize&&this.gc()}get(t){const e=super.get(t);return e&&(e.lastAccessed=Date.now()),e}gc(){let t,e=1/0,i=0;for(const[s,r]of this.entries())r.lastAccessed(i&&(t._tic.maxSize=i),void 0!==e&&(t._textCache=e),t._textCache),t.createTextImage=(e,i,s)=>{let r=t._textCache;t._textCache=!0,t._useCache=!0,t.text(e,0,0,i,s),t._useCache=!1;let o=b(e,i,s);return t._textCache=r,t._tic.get(o)};const B=t.text;t.text=(e,i,s,r,o)=>{if(void 0===e)return;e=e.toString();const n=t._renderer;if(!n._doFill&&!n._doStroke)return;const h=t.canvas.getContext("2d");let a,l,d,p,u,c,_,f=h.getTransform();if(!(t._useCache||t._textCache&&(0!=f.b||0!=f.c)))return B.call(t,e,i,s,r,o);if(d=b(e,r,o),l=t._tic.get(d),l)return void t.textImage(l,i,s);let g=t.createGraphics.call(t,1,1);g.textFont(t.textFont()),t.textStyle()&&g.textStyle(t.textStyle()),g.textSize(t.textSize()),a=g.canvas.getContext("2d");let m=e.split("\n");p=0,u=n._textLeading*m.length;let y=a.measureText(" ");c=y.fontBoundingBoxAscent,_=y.fontBoundingBoxDescent,o??=u+_,g.resizeCanvas(Math.ceil(g.textWidth(e)),Math.ceil(o)),g.fill(h.fillStyle),n._doStroke?(g.stroke(h.strokeStyle),g.strokeWeight(h.lineWidth)):g.noStroke();for(let t=0;to));t++);l=g.get(),l._ascent=c,l._descent=_,t._tic.set(d,l),t.textImage(l,i,s)},t.textImage=(e,i,s)=>{let r=t._renderer._imageMode;t.imageMode.call(t,"corner");const o=t.canvas.getContext("2d");let n;"center"==o.textAlign?i-=.5*e.width:"right"==o.textAlign&&(i-=e.width),"alphabetic"==o.textBaseline?s-=t._renderer._textLeading:n=t._renderer._textLeading-t._renderer._textSize,"middle"==o.textBaseline?s-=e._descent+.5*e._ascent+n:"bottom"==o.textBaseline?s-=e._ascent+e._descent+n:"top"==o.textBaseline&&(s-=e._descent+n),t.image.call(t,e,i,s),t.imageMode.call(t,r)}}let S={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:{},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!"}},SpriteAnimation:{constructor:{base:"Hey so, I tried to make a new SpriteAnimation but couldn't",0:'I don\'t know how to display this type of image: "$0". I can only use ".png" image files.',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"}}};S.Group.collide=S.Sprite.collide,S.Group.overlap=S.Sprite.overlap,S.Sprite.rotateTo[0]=S.Sprite.rotateTowards[0]=S.Sprite.rotate[0];class A 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,n=S[s][t];o=n.base?n.base+r:S.generic[Math.floor(Math.random()*S.generic.length)]+r,void 0!==e&&(n=n[e]),n=n.replace(/\$([0-9]+)/g,((t,e)=>i[e])),o+=n,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}_init(t){for(let e of t)this[e]=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,this.y,this.canvasPos={},this.left,this.center,this.right;this._init(["x","y","left","center","right"]),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"}_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.camera.mouse.x=t.mouseX,t.mouse.canvasPos.y=t.camera.mouse.y=t.mouseY,t.camera.x==t.canvas.hw&&t.camera.y==t.canvas.hh&&1==t.camera.zoom?(this.x=t.mouseX,this.y=t.mouseY):(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}};const C=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)}},k=t._onmousedown;t._onmousedown=function(e){if(!t._setupDone)return;let i="left";1===e.button?i="center":2===e.button&&(i="right"),C.call(t,i),k.call(t,e)};const M=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"),M.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)},delete t._Mouse,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,n=this.canvasPos.x=(e.clientX-s.left)/r,h=this.canvasPos.y=(e.clientY-s.top)/o;t.camera.x==i.hw&&t.camera.y==i.hh&&1==t.camera.zoom?(this.x=n,this.y=h):(this.x=(n-i.hw)/t.camera.zoom+t.camera.x,this.y=(h-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){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,delete t._Keyboard,this.keyboard=t.kb,navigator.keyboard){const W=navigator.keyboard;window==window.top?W.getLayoutMap().then((e=>{"w"!=e.get("KeyW")&&(t.p5play.standardizeKeyboard=!0)})):t.p5play.standardizeKeyboard=!0}else t.p5play.standardizeKeyboard=!0;function z(t){let e=t.code;return 4==e.length&&"Key"==e.slice(0,3)?e[3].toLowerCase():t.key}const P=t._onkeydown;t._onkeydown=function(t){let e=t.key;if(this.p5play.standardizeKeyboard&&(e=z(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),P.call(this,t)};const F=t._onkeyup;t._onkeyup=function(t){let e=t.key;if(this.p5play.standardizeKeyboard&&(e=z(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)}F.call(this,t)},this._Contro=class extends t.InputDevice{constructor(t){super(),this._default="a",this.connected=!0;this._init(["a","b","x","y","l","r","lt","rt","select","start","lsb","rsb","up","down","left","right","leftTrigger","rightTrigger"]),this.leftStick={x:0,y:0},this.rightStick={x:0,y:0},this._btns={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._axes={leftStick:{x:0,y:1},rightStick:{x:2,y:3},leftTrigger:4,rightTrigger:5},this.gamepad=t,this.id=t.id,this.id.includes("GuliKit")&&(this._btns.a=1,this._btns.b=0,this._btns.x=3,this._btns.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.connected)return;if(this.gamepad=navigator.getGamepads()[this.gamepad.index],!this.gamepad?.connected)return;let t=this.gamepad;for(let e in this._btns){let i=this._btns[e],s=t.buttons[i];s&&(s.pressed?this[e]++:this[e]=this[e]>0?-1:0)}return this.leftStick.x=t.axes[this._axes.leftStick.x],this.leftStick.y=t.axes[this._axes.leftStick.y],this.rightStick.x=t.axes[this._axes.rightStick.x],this.rightStick.y=t.axes[this._axes.rightStick.y],void 0!==t.axes[this._axes.leftTrigger]?(this.leftTrigger=t.axes[this._axes.leftTrigger],this.rightTrigger=t.axes[this._axes.rightTrigger]):(this.leftTrigger=t.buttons[this._btns.lt].value,this.rightTrigger=t.buttons[this._btns.rt].value),!0}get ls(){return this.leftStick}get rs(){return this.rightStick}get lb(){return this.l}get rb(){return this.r}get leftStickButton(){return this.lsb}get rightStickButton(){return this.rsb}},this._Contros=class extends Array{constructor(){super();let t=this;window&&(window.addEventListener("gamepadconnected",(e=>{t._onConnect(e.gamepad)})),window.addEventListener("gamepaddisconnected",(e=>{t._onDisconnect(e.gamepad)}))),this.presses,this.pressing,this.pressed,this.holds,this.holding,this.held,this.released;let e=["presses","pressing","pressed","holds","holding","held","released"];for(let t of e)this[t]=e=>{if(this[0])return this[0][t](e)};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.leftTrigger=0,this.rightTrigger=0,this.lb=0,this.rb=0,this.leftStickButton=0,this.rightStickButton=0;let i=["connected","a","b","x","y","l","r","lt","rt","select","start","lsb","rsb","up","down","left","right","leftTrigger","rightTrigger","lb","rb","leftStickButton","rightStickButton"];for(let e of i)Object.defineProperty(this,e,{get:()=>t[0]?t[0][e]:0});this.leftStick,this.rightStick,i=["leftStick","rightStick"];for(let e of i){this[e]={};for(let i of["x","y"])Object.defineProperty(this[e],i,{get:()=>t[0]?t[0][e][i]:0})}if(!navigator?.getGamepads)return;let s=navigator.getGamepads();for(let t of s)t&&this._onConnect(t)}_onConnect(e){if(!e)return;for(let t=0;tt.p5play._fps,this.renderStats=(e,i)=>{let s=t.p5play._renderStats;void 0===s.show&&(1==t.allSprites.tileSize||t.allSprites.tileSize>16?s.fontSize=16:s.fontSize=10,s.gap=1.25*s.fontSize,t._q5||console.warn("renderStats() produces inaccurate FPS approximations because deltaTime is calculated incorrectly in p5.js. Even if your game runs at a solid 60hz display rate, the fps calculations shown may be lower. Use q5.js or your browser's performance testing tools for accurate results.")),s.x=e||10,s.y=i||20,s.show=!0}})),p5.prototype.registerMethod("pre",(function(){const t=this;t._q5||(t.p5play._preDrawFrameTime=performance.now()),t.p5play.spritesDrawn=0,t.mouse._update(),t.contro._update()})),p5.prototype.registerMethod("post",(function(){const t=this;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;let e=t.p5play._renderStats;if(e.show){if(1==t.frameCount||t.frameCount%60==0){let e,i=0,s=t.p5play._fpsArr.length;for(let e=0;e55?t.color(30,255,30):i>25?t.color(255,100,30):t.color(255,30,30),t.p5play._statsColor=e}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),t.textFont("monospace");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&&i[t]++,s?.hover&&(s[t]=i[t]),i._dragFrame[t]?(i.drag[t]++,s&&(s.drag[t]=i.drag[t]),i._dragFrame[t]=!1):i.drag[t]<0&&(i.drag[t]=0,s&&(s.drag[t]=0));if(t.world.mouseTracking&&t.mouse.isActive){let e=t.world.getMouseSprites();for(let t=0;t0?i.mouse.hover=-1:i.mouse.hover<0&&(i.mouse.hover=0)}i.left<=0&&i.center<=0&&i.right<=0&&(t.world.mouseSprite=null);let r=t.world.mouseSprite,o=i.drag.left>0||i.drag.center>0||i.drag.right>0;for(let i of t.world.mouseSprites)if(!e.includes(i)){let e=i.mouse;e.hover>0&&(e.hover=-1,e.left=e.center=e.right=0),o||i!=r||(t.world.mouseSprite=r=null)}r&&(e.includes(r)||e.push(r),s.x=r.x-i.x,s.y=r.y-i.y),t.world.mouseSprites=e}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/package.json b/package.json index 1d1c2314..88cd5f51 100644 --- a/package.json +++ b/package.json @@ -49,5 +49,5 @@ "version": "git add -A", "postversion": "git push" }, - "version": "3.19.16" + "version": "3.19.17" }