UNPKG

phaser-arcade-slopes

Version:

A Phaser CE plugin that brings sloped tile collision handling to Phaser's Arcade Physics engine

11 lines 56.2 kB
/** * Phaser Arcade Slopes v0.3.2 * * A Phaser CE plugin that brings sloped tile collision handling to Phaser's Arcade Physics engine * * @copyright 2016-2021 Chris Andrew <chris@hexus.io> * @license MIT * @see https://github.com/hexus/phaser-arcade-slopes */ Phaser.Plugin.ArcadeSlopes=function(e,o,l){Phaser.Plugin.call(this,e,o);var t={};t[Phaser.Plugin.ArcadeSlopes.SAT]=new Phaser.Plugin.ArcadeSlopes.SatSolver,this.facade=new Phaser.Plugin.ArcadeSlopes.Facade(new Phaser.Plugin.ArcadeSlopes.TileSlopeFactory,t,l||Phaser.Plugin.ArcadeSlopes.SAT),this.facade.plugin=this},Phaser.Plugin.ArcadeSlopes.prototype=Object.create(Phaser.Plugin.prototype),Phaser.Plugin.ArcadeSlopes.prototype.constructor=Phaser.Plugin.ArcadeSlopes,Phaser.Plugin.ArcadeSlopes.VERSION="0.3.2",Phaser.Plugin.ArcadeSlopes.SAT="sat",Phaser.Plugin.ArcadeSlopes.prototype.init=function(){this.game.slopes=this.game.slopes||this.facade,this.originalCollideSpriteVsTilemapLayer=Phaser.Physics.Arcade.prototype.collideSpriteVsTilemapLayer,Phaser.Physics.Arcade.prototype.collideSpriteVsTile=Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTile,Phaser.Physics.Arcade.prototype.collideSpriteVsTiles=Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTiles,Phaser.Physics.Arcade.prototype.collideSpriteVsTilemapLayer=Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTilemapLayer,Phaser.Tilemap.prototype.getTileTopLeft=Phaser.Plugin.ArcadeSlopes.Overrides.getTileTopLeft,Phaser.Tilemap.prototype.getTileTopRight=Phaser.Plugin.ArcadeSlopes.Overrides.getTileTopRight,Phaser.Tilemap.prototype.getTileBottomLeft=Phaser.Plugin.ArcadeSlopes.Overrides.getTileBottomLeft,Phaser.Tilemap.prototype.getTileBottomRight=Phaser.Plugin.ArcadeSlopes.Overrides.getTileBottomRight,this.originalRenderDebug=Phaser.TilemapLayer.prototype.renderDebug,Phaser.TilemapLayer.prototype.getCollisionOffsetX=Phaser.Plugin.ArcadeSlopes.Overrides.getCollisionOffsetX,Phaser.TilemapLayer.prototype.getCollisionOffsetY=Phaser.Plugin.ArcadeSlopes.Overrides.getCollisionOffsetY,Phaser.TilemapLayer.prototype.renderDebug=Phaser.Plugin.ArcadeSlopes.Overrides.renderDebug},Phaser.Plugin.ArcadeSlopes.prototype.destroy=function(){this.game.slopes=null,Phaser.Physics.Arcade.prototype.collideSpriteVsTile=null,Phaser.Physics.Arcade.prototype.collideSpriteVsTiles=null,Phaser.Physics.Arcade.prototype.collideSpriteVsTilemapLayer=this.originalCollideSpriteVsTilemapLayer,Phaser.Tilemap.prototype.getTileTopLeft=null,Phaser.Tilemap.prototype.getTileTopRight=null,Phaser.Tilemap.prototype.getTileBottomLeft=null,Phaser.Tilemap.prototype.getTileBottomRight=null,Phaser.TilemapLayer.prototype.getCollisionOffsetX=null,Phaser.TilemapLayer.prototype.getCollisionOffsetY=null,Phaser.TilemapLayer.prototype.renderDebug=this.originalRenderDebug,Phaser.Plugin.prototype.destroy.call(this)},Phaser.Plugin.ArcadeSlopes.Facade=function(e,o,l){this.factory=e,this.solvers=o,this.defaultSolver=l||Phaser.Plugin.ArcadeSlopes.SAT,this.plugin=null},Phaser.Plugin.ArcadeSlopes.Facade.prototype.enable=function(e){if(Array.isArray(e))for(var o=0;o<e.length;o++)this.enable(e[o]);else e instanceof Phaser.Group?this.enable(e.children):(e.hasOwnProperty("body")&&this.enableBody(e.body),e.hasOwnProperty("children")&&e.children.length>0&&this.enable(e.children))},Phaser.Plugin.ArcadeSlopes.Facade.prototype.enableBody=function(e){e.isCircle?e.polygon=new SAT.Circle(new SAT.Vector(e.x+e.halfWidth,e.y+e.halfHeight),e.radius):e.polygon=new SAT.Box(new SAT.Vector(e.x,e.y),e.width*e.sprite.scale.x,e.height*e.sprite.scale.y).toPolygon(),e.slopes=e.slopes||{debug:!1,friction:new Phaser.Point,preferY:!1,pullUp:0,pullDown:0,pullLeft:0,pullRight:0,pullTopLeft:0,pullTopRight:0,pullBottomLeft:0,pullBottomRight:0,sat:{response:null},skipFriction:!1,tile:null,velocity:new SAT.Vector}},Phaser.Plugin.ArcadeSlopes.Facade.prototype.convertTilemap=function(e,o,l,t){return this.factory.convertTilemap(e,o,l,t)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.convertTilemapLayer=function(e,o,l){return this.factory.convertTilemapLayer(e,o,l)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.collide=function(e,o,l,t,r){return this.solvers.sat.collide(e,o,l,t,r)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.resetCollision=function(e){e.touching.none=!0,e.touching.up=!1,e.touching.down=!1,e.touching.left=!1,e.touching.right=!1,e.blocked.none=!0,e.blocked.up=!1,e.blocked.down=!1,e.blocked.left=!1,e.blocked.right=!1,e.overlapX=0,e.overlapY=0,e.slopes&&(e.slopes.sat.response=null)},Object.defineProperty(Phaser.Plugin.ArcadeSlopes.Facade.prototype,"preferY",{get:function(){return this.solvers.sat.options.preferY},set:function(e){this.solvers.sat.options.preferY=!!e}}),Object.defineProperty(Phaser.Plugin.ArcadeSlopes.Facade.prototype,"heuristics",{get:function(){return this.solvers.sat.options.restrain},set:function(e){this.solvers.sat.options.restrain=!!e}}),Phaser.Plugin.ArcadeSlopes.Overrides={},Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTile=function(e,o,l,t,r,s,i,p){if(!o.body||!l||!t)return!1;if(l.hasOwnProperty("slope")){if(this.game.slopes.collide(e,o.body,l,t,p))return this._total++,r&&r.call(i,o,l),!0}else if(this.separateTile(e,o.body,l,t,p))return this._total++,r&&r.call(i,o,l),!0;return!1},Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTiles=function(e,o,l,t,r,s,i){if(!(e.body&&o&&o.length&&l))return!1;for(var p=!1,n=0;n<o.length;n++)r?r.call(s,e,o[n])&&(p=this.collideSpriteVsTile(n,e,o[n],l,t,r,s,i)||p):p=this.collideSpriteVsTile(n,e,o[n],l,t,r,s,i)||p;return p},Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTilemapLayer=function(e,o,l,t,r,s){if(!e.body||!o)return!1;var i=o.getTiles(e.body.position.x-e.body.tilePadding.x-o.getCollisionOffsetX(),e.body.position.y-e.body.tilePadding.y-o.getCollisionOffsetY(),e.body.width+e.body.tilePadding.x,e.body.height+e.body.tilePadding.y,!0,!1);if(0===i.length)return!1;var p=this.collideSpriteVsTiles(e,i,o,l,t,r,s);return p},Phaser.Plugin.ArcadeSlopes.Overrides.getTileTopLeft=function(e,o,l){return o>0&&l>0?this.layers[e].data[l-1][o-1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getTileTopRight=function(e,o,l){return o<this.layers[e].width-1&&l>0?this.layers[e].data[l-1][o+1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getTileBottomLeft=function(e,o,l){return o>0&&l<this.layers[e].height-1?this.layers[e].data[l+1][o-1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getTileBottomRight=function(e,o,l){return o<this.layers[e].width-1&&l<this.layers[e].height-1?this.layers[e].data[l+1][o+1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getCollisionOffsetX=function(){return this.getTileOffsetX?this.getTileOffsetX():this.fixedToCamera?0:this.position.x},Phaser.Plugin.ArcadeSlopes.Overrides.getCollisionOffsetY=function(){return this.getTileOffsetY?this.getTileOffsetY():this.fixedToCamera?0:this.position.y},Phaser.Plugin.ArcadeSlopes.Overrides.renderDebug=function(){var e=this._mc.scrollX,o=this._mc.scrollY,l=this.context,t=this.canvas.width,r=this.canvas.height,s=this.tileScale?this.tileScale.x:1/this.scale.x,i=this.tileScale?this.tileScale.y:1/this.scale.y,p=this.layer.width,n=this.layer.height,a=this._mc.tileWidth*s,h=this._mc.tileHeight*i,c=a/2,T=h/2,S=a/4,g=h/4,P=this._mc.cw*s,u=this._mc.ch*i,d=this._mc.edgeMidpoint,A=Math.floor(e/a),f=Math.floor((t-1+e)/a),y=Math.floor(o/h),w=Math.floor((r-1+o)/h);this._wrap||(A<=f&&(A=Math.max(0,A),f=Math.min(p-1,f)),y<=w&&(y=Math.max(0,y),w=Math.min(n-1,w)));var R,v,_,E,O,L,I,m,b,H,V,F,N,x,G,B=A*a-e,Q=y*h-o,U=(A+(1<<20)*p)%p,M=(y+(1<<20)*n)%n;for(E=M,L=w-y,v=Q;L>=0;E++,L--,v+=h){E>=n&&(E-=n);var k=this.layer.data[E];for(_=U,O=f-A,R=B;O>=0;_++,O--,R+=a){_>=p&&(_-=p);var Y=k[_];if(Y&&!(Y.index<0)&&Y.collides&&(this.debugSettings.collidingTileOverfill&&(l.fillStyle=this.debugSettings.collidingTileOverfill,l.fillRect(R,v,P,u)),this.debugSettings.facingEdgeStroke&&(l.beginPath(),l.lineWidth=1,l.strokeStyle=this.debugSettings.facingEdgeStroke,Y.faceTop&&(l.moveTo(R,v),l.lineTo(R+P,v)),Y.faceBottom&&(l.moveTo(R,v+u),l.lineTo(R+P,v+u)),Y.faceLeft&&(l.moveTo(R,v),l.lineTo(R,v+u)),Y.faceRight&&(l.moveTo(R+P,v),l.lineTo(R+P,v+u)),l.closePath(),l.stroke(),Y.slope))){if(this.debugSettings.slopeEdgeStroke||this.debugSettings.slopeFill){for(l.beginPath(),l.lineWidth=1,I=Y.slope.polygon,l.moveTo(R+I.points[0].x*s,v+I.points[0].y*i),m=0;m<I.points.length;m++)b=(m+1)%I.points.length,l.lineTo(R+I.points[b].x*s,v+I.points[b].y*i);l.closePath(),this.debugSettings.slopeEdgeStroke&&(l.strokeStyle=this.debugSettings.slopeEdgeStroke,l.stroke()),this.debugSettings.slopeFill&&(l.fillStyle=this.debugSettings.slopeFill,l.fill())}if(this.debugSettings.slopeCollidingEdgeStroke){for(l.beginPath(),l.lineWidth=this.debugSettings.slopeCollidingEdgeStrokeWidth||1,l.strokeStyle=this.debugSettings.slopeCollidingEdgeStroke,I=Y.slope.polygon,m=0;m<I.points.length;m++)I.normals[m].ignore||(b=(m+1)%I.points.length,l.moveTo(R+I.points[m].x*s,v+I.points[m].y*i),l.lineTo(R+I.points[b].x*s,v+I.points[b].y*i));for(l.closePath(),l.stroke(),m=0;m<I.points.length;m++)l.beginPath(),I.normals[m].ignore?(l.lineWidth=this.debugSettings.slopeNormalStrokeWidth,l.strokeStyle=this.debugSettings.slopeNormalStroke):(l.lineWidth=this.debugSettings.slopeCollidingNormalStrokeWidth,l.strokeStyle=this.debugSettings.slopeCollidingNormalStroke),b=(m+1)%I.points.length,H=I.points[m],V=I.points[b],F=I.normals[m],d.x=(H.x+V.x)/2,d.y=(H.y+V.y)/2,l.moveTo(R+d.x*s,v+d.y*i),l.lineTo(R+d.x*s+F.x*S,v+d.y*i+F.y*g),l.closePath(),l.stroke();if(Y.slope.ignormals)for(m=0;m<Y.slope.ignormals.length;m++)l.beginPath(),l.lineWidth=1,l.strokeStyle="rgba(255, 0, 0, 1)",N=Y.slope.ignormals[m].x,x=Y.slope.ignormals[m].y,l.moveTo(R+c,v+T),l.lineTo(R+c+N*S,v+T+x*g),l.closePath(),l.stroke()}this.debugSettings.slopeLineStroke&&Y.slope.line&&(G=Y.slope.line,l.beginPath(),l.lineWidth=this.debugSettings.slopeLineWidth||2,l.strokeStyle=this.debugSettings.slopeLineStroke,l.moveTo(G.start.x-e,G.start.y-o),l.lineTo(G.end.x-e,G.end.y-o),l.closePath(),l.stroke())}}}},Phaser.Plugin.ArcadeSlopes.SatSolver=function(e){this.options=Phaser.Utils.mixin(e||{},{debug:!1,preferY:!1}),this.arrayPool=[];for(var o=0;o<10;o++)this.arrayPool.push([]);for(this.vectorPool=[],o=0;o<20;o++)this.vectorPool.push(new SAT.Vector);for(this.responsePool=[],o=0;o<20;o++)this.responsePool.push(new SAT.Response)},Phaser.Plugin.ArcadeSlopes.SatSolver.prepareResponse=function(e){return e.overlapV.scale(-1),e.overlapN.scale(-1),e},Phaser.Plugin.ArcadeSlopes.SatSolver.resetResponse=function(e){return e.overlapN.x=0,e.overlapN.y=0,e.overlapV.x=0,e.overlapV.y=0,e.clear(),e},Phaser.Plugin.ArcadeSlopes.SatSolver.copyResponse=function(e,o){return o.a=e.a,o.b=e.b,o.aInB=e.aInB,o.bInA=e.bInA,o.overlap=e.overlap,o.overlapN.copy(e.overlapN),o.overlapV.copy(e.overlapV),o},Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetX=function(e){return e.y*e.y/e.x+e.x},Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetY=function(e){return e.x*e.x/e.y+e.y},Phaser.Plugin.ArcadeSlopes.SatSolver.movingAgainstY=function(e,o){return o.overlapV.y<0&&e.velocity.y>0||o.overlapV.y>0&&e.velocity.y<0},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldPreferY=function(e,o){return(this.options.preferY||e.slopes.preferY)&&0!==o.overlapV.y&&0!==o.overlapV.x&&Phaser.Plugin.ArcadeSlopes.SatSolver.movingAgainstY(e,o)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.separate=function(e,o,l,t){return!(!t&&!this.shouldSeparate(o.index,e,o,l))&&(!(o.collisionCallback&&!o.collisionCallback.call(o.collisionCallbackContext,e.sprite,o))&&(!(o.layer.callbacks[o.index]&&!o.layer.callbacks[o.index].callback.call(o.layer.callbacks[o.index].callbackContext,e.sprite,o))&&(this.shouldPreferY(e,l)?e.position.y+=Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetY(l.overlapV):(e.position.x+=l.overlapV.x,e.position.y+=l.overlapV.y),!0)))},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.applyVelocity=function(e,o,l){var t=this.vectorPool.pop().copy(e.slopes.velocity).projectN(l.overlapN),r=this.vectorPool.pop().copy(e.slopes.velocity).sub(t);t.x=t.x*-e.bounce.x,t.y=t.y*-e.bounce.y,r.x=r.x*(1-e.slopes.friction.x-o.slope.friction.x),r.y=r.y*(1-e.slopes.friction.y-o.slope.friction.y),e.velocity.x=t.x+r.x,e.velocity.y=t.y+r.y,this.pull(e,l),this.vectorPool.push(t,r)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.updateValues=function(e){e.polygon.pos.x=e.x,e.polygon.pos.y=e.y,e.slopes.velocity.x=e.velocity.x,e.slopes.velocity.y=e.velocity.y},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.updateFlags=function(e,o){e.touching.up=e.touching.up||o.overlapV.y>0,e.touching.down=e.touching.down||o.overlapV.y<0,e.touching.left=e.touching.left||o.overlapV.x>0,e.touching.right=e.touching.right||o.overlapV.x<0,e.touching.none=!(e.touching.up||e.touching.down||e.touching.left||e.touching.right),e.blocked.up=e.blocked.up||0===o.overlapV.x&&o.overlapV.y>0,e.blocked.down=e.blocked.down||0===o.overlapV.x&&o.overlapV.y<0,e.blocked.left=e.blocked.left||0===o.overlapV.y&&o.overlapV.x>0,e.blocked.right=e.blocked.right||0===o.overlapV.y&&o.overlapV.x<0},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.pull=function(e,o){if(!(e.slopes.pullUp||e.slopes.pullDown||e.slopes.pullLeft||e.slopes.pullRight||e.slopes.pullTopLeft||e.slopes.pullTopRight||e.slopes.pullBottomLeft||e.slopes.pullBottomRight))return!1;var l=o.overlapN.clone().scale(-1);return e.slopes.pullUp&&l.y<0?(pullUp=l.clone().scale(e.slopes.pullUp),e.velocity.x+=pullUp.x,e.velocity.y+=pullUp.y,!0):e.slopes.pullDown&&l.y>0?(pullDown=l.clone().scale(e.slopes.pullDown),e.velocity.x+=pullDown.x,e.velocity.y+=pullDown.y,!0):e.slopes.pullLeft&&l.x<0?(pullLeft=l.clone().scale(e.slopes.pullLeft),e.velocity.x+=pullLeft.x,e.velocity.y+=pullLeft.y,!0):e.slopes.pullRight&&l.x>0?(pullRight=l.clone().scale(e.slopes.pullRight),e.velocity.x+=pullRight.x,e.velocity.y+=pullRight.y,!0):e.slopes.pullTopLeft&&l.x<0&&l.y<0?(pullUp=l.clone().scale(e.slopes.pullTopLeft),e.velocity.x+=pullUp.x,e.velocity.y+=pullUp.y,!0):e.slopes.pullTopRight&&l.x>0&&l.y<0?(pullDown=l.clone().scale(e.slopes.pullTopRight),e.velocity.x+=pullDown.x,e.velocity.y+=pullDown.y,!0):e.slopes.pullBottomLeft&&l.x<0&&l.y>0?(pullLeft=l.clone().scale(e.slopes.pullBottomLeft),e.velocity.x+=pullLeft.x,e.velocity.y+=pullLeft.y,!0):!!(e.slopes.pullBottomRight&&l.x>0&&l.y>0)&&(pullRight=l.clone().scale(e.slopes.pullBottomRight),e.velocity.x+=pullRight.x,e.velocity.y+=pullRight.y,!0)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldCollide=function(e,o){return e.enable&&e.polygon&&e.slopes&&o.collides&&o.slope&&o.slope.polygon},Phaser.Plugin.ArcadeSlopes.SatSolver.flattenPointsOn=function(e,o,l){for(var t=Number.MAX_VALUE,r=-Number.MAX_VALUE,s=e.length,i=0;i<s;i++){var p=e[i].dot(o);p<t&&(t=p),p>r&&(r=p)}l[0]=t,l[1]=r},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.isSeparatingAxis=function(e,o,l,t){var r=e.pos,s=o.pos,i=e.calcPoints,p=o.calcPoints,n=this.arrayPool.pop(),a=this.arrayPool.pop(),h=this.vectorPool.pop().copy(s).sub(r),c=h.dot(l);if(Phaser.Plugin.ArcadeSlopes.SatSolver.flattenPointsOn(i,l,n),Phaser.Plugin.ArcadeSlopes.SatSolver.flattenPointsOn(p,l,a),a[0]+=c,a[1]+=c,n[0]>=a[1]||a[0]>=n[1])return this.vectorPool.push(h),this.arrayPool.push(n),this.arrayPool.push(a),!0;var T,S,g=0;n[0]<a[0]?(t.aInB=!1,n[1]<a[1]&&(t.bInA=!1)):(t.bInA=!1,n[1]>a[1]?(g=n[0]-a[1],t.aInB=!1):(T=n[1]-a[0],S=a[1]-n[0],T>=S&&(g=-S)));var P=Math.abs(g);return P<t.overlap&&(t.overlap=P,t.overlapN.copy(l),g<0&&t.overlapN.reverse()),this.vectorPool.push(h),this.arrayPool.push(n),this.arrayPool.push(a),!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.testPolygonPolygon=function(e,o,l,t,r){var s,i,p,n=e.calcPoints,a=n.length,h=o.calcPoints,c=h.length,T=this.arrayPool.pop(),S=this.arrayPool.pop();for(T.length=0,S.length=0,s=0;s<a;s++)if(T[s]=this.responsePool.pop(),T[s].clear(),S[s]=e.normals[s],this.isSeparatingAxis(e,o,e.normals[s],T[s])){for(p=0;p<T.length;p++)this.responsePool.push(T[p]);return this.arrayPool.push(T,S),!1}for(s=0,i=a;s<c;s++,i++)if(T[i]=this.responsePool.pop(),T[i].clear(),S[i]=o.normals[s],this.isSeparatingAxis(e,o,o.normals[s],T[i])){for(p=0;p<T.length;p++)this.responsePool.push(T[p]);return this.arrayPool.push(T,S),!1}var g=!1,P=!1,u=this.vectorPool.pop();for(s=0;s<T.length;s++)if(T[s].overlap>0&&T[s].overlap<Number.MAX_VALUE&&!(t&&u.copy(T[s].overlapN).scale(-1).dot(t)>0)){for(P=!1,i=0;i<r.length;i++)if(S[s].x===r[i].x&&S[s].y===r[i].y){P=!0;break}P||T[s].overlap<l.overlap&&(g=!0,l.aInB=T[s].aInB,l.bInA=T[s].bInA,l.overlap=T[s].overlap,l.overlapN=T[s].overlapN)}for(g&&(l.a=e,l.b=o,l.overlapV.copy(l.overlapN).scale(l.overlap)),p=0;p<T.length;p++)this.responsePool.push(T[p]);return this.arrayPool.push(T,S),this.vectorPool.push(u),g},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.collide=function(e,o,l,t,r){if(this.updateValues(o),!this.shouldCollide(o,l))return!1;o.isCircle&&(o.polygon.pos.x+=o.halfWidth,o.polygon.pos.y+=o.halfHeight),l.slope.polygon.pos.x=l.worldX+t.getCollisionOffsetX(),l.slope.polygon.pos.y=l.worldY+t.getCollisionOffsetY(),o.slopes.sat.response=o.slopes.sat.response||new SAT.Response;var s=this.responsePool.pop();Phaser.Plugin.ArcadeSlopes.SatSolver.resetResponse(s);var i=o.isCircle&&SAT.testCirclePolygon(o.polygon,l.slope.polygon,s),p=!o.isCircle&&this.testPolygonPolygon(o.polygon,l.slope.polygon,s,o.slopes.velocity,l.slope.ignormals);return i||p?(Phaser.Plugin.ArcadeSlopes.SatSolver.prepareResponse(s),r?(Phaser.Plugin.ArcadeSlopes.SatSolver.copyResponse(s,o.slopes.sat.response),this.responsePool.push(s),!0):this.separate(o,l,s)?(Phaser.Plugin.ArcadeSlopes.SatSolver.copyResponse(s,o.slopes.sat.response),this.responsePool.push(s),s=o.slopes.sat.response,o.overlapX=s.overlapV.x,o.overlapY=s.overlapV.y,o.slopes.tile=l,this.applyVelocity(o,l,s),this.updateFlags(o,s),!0):(this.responsePool.push(s),!1)):(this.responsePool.push(s),!1)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldSeparate=function(e,o,l,t){return!(!o.enable||!t.overlap)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.debug=function(e,o){},Phaser.Plugin.ArcadeSlopes.TileSlope=function(e,o,l,t,r,s,i){this.type=e,this.tile=o,this.polygon=l,this.line=t,this.edges=Phaser.Utils.mixin(r||{},{top:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,left:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,right:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID}),this.axis=s||null,this.ignormals=i||[],this.solver=null,this.friction=new Phaser.Point},Phaser.Plugin.ArcadeSlopes.TileSlope.prototype.meets=function(e){return this.line.start.equals(e.line.end)||this.line.end.equals(e.line.start)},Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType=function(e){return parseInt(e)>=0?e:("string"==typeof e&&(e=e.toUpperCase()),Phaser.Plugin.ArcadeSlopes.TileSlope.hasOwnProperty(e)?Phaser.Plugin.ArcadeSlopes.TileSlope[e]:(console.warn("Unknown slope type '"+e+"'"),Phaser.Plugin.ArcadeSlopes.TileSlope.UNKNOWN))},Object.defineProperty(Phaser.Plugin.ArcadeSlopes.TileSlope.prototype,"slope",{get:function(){return this.line?(this.line.start.y-this.line.end.y)/(this.line.start.x-this.line.end.x):0}}),Object.defineProperty(Phaser.Plugin.ArcadeSlopes.TileSlope.prototype,"typeName",{get:function(){return Phaser.Plugin.ArcadeSlopes.TileSlope.resolveTypeName(this.type)},set:function(e){this.type=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(e)}}),Phaser.Plugin.ArcadeSlopes.TileSlope.resolveTypeName=function(e){return Phaser.Plugin.ArcadeSlopes.TileSlope.typeNames.hasOwnProperty(e)?Phaser.Plugin.ArcadeSlopes.TileSlope.typeNames[e]:Phaser.Plugin.ArcadeSlopes.TileSlope.typeNames[-1]},Phaser.Plugin.ArcadeSlopes.TileSlope.typeNames={"-1":"UNKNOWN",0:"FULL",21:"HALF_BOTTOM",22:"HALF_TOP",23:"HALF_LEFT",24:"HALF_RIGHT",1:"HALF_BOTTOM_LEFT",2:"HALF_BOTTOM_RIGHT",3:"HALF_TOP_LEFT",4:"HALF_TOP_RIGHT",5:"QUARTER_BOTTOM_LEFT_LOW",6:"QUARTER_BOTTOM_LEFT_HIGH",7:"QUARTER_BOTTOM_RIGHT_LOW",8:"QUARTER_BOTTOM_RIGHT_HIGH",9:"QUARTER_LEFT_BOTTOM_LOW",10:"QUARTER_LEFT_BOTTOM_HIGH",11:"QUARTER_RIGHT_BOTTOM_LOW",12:"QUARTER_RIGHT_BOTTOM_HIGH",13:"QUARTER_LEFT_TOP_LOW",14:"QUARTER_LEFT_TOP_HIGH",15:"QUARTER_RIGHT_TOP_LOW",16:"QUARTER_RIGHT_TOP_HIGH",17:"QUARTER_TOP_LEFT_LOW",18:"QUARTER_TOP_LEFT_HIGH",19:"QUARTER_TOP_RIGHT_LOW",20:"QUARTER_TOP_RIGHT_HIGH"},Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY=0,Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID=1,Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING=2,Phaser.Plugin.ArcadeSlopes.TileSlope.UNKNOWN=-1,Phaser.Plugin.ArcadeSlopes.TileSlope.FULL=0,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM=21,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP=22,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_LEFT=23,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_RIGHT=24,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM_LEFT=1,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM_RIGHT=2,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP_LEFT=3,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP_RIGHT=4,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_LEFT_LOW=5,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_LEFT_HIGH=6,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_RIGHT_LOW=7,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_RIGHT_HIGH=8,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_BOTTOM_LOW=9,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_BOTTOM_HIGH=10,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_BOTTOM_LOW=11,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_BOTTOM_HIGH=12,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_TOP_LOW=13,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_TOP_HIGH=14,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_TOP_LOW=15,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_TOP_HIGH=16,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_LEFT_LOW=17,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_LEFT_HIGH=18,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_RIGHT_LOW=19,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_RIGHT_HIGH=20,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory=function(){this.definitions={},this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.FULL]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createFull,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottom,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTop,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_LEFT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfLeft,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_RIGHT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfRight,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM_LEFT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomLeft,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM_RIGHT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomRight,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP_LEFT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopLeft,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP_RIGHT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopRight,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_LEFT_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_LEFT_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_RIGHT_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_RIGHT_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_BOTTOM_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_BOTTOM_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_BOTTOM_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_BOTTOM_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_TOP_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_TOP_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_TOP_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_TOP_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_LEFT_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_LEFT_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_RIGHT_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_RIGHT_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightHigh,this.mappings={},this.mappings[Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.ARCADESLOPES]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapArcadeSlopes,this.mappings[Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.NINJA]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapNinjaPhysics,this.vectorPool=[];for(var e=0;e<100;e++)this.vectorPool.push(new SAT.Vector)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.constructor=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.define=function(e,o){"function"==typeof o&&(this.definitions[e]=o)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.create=function(e,o){var l=e;return e=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(l),this.definitions.hasOwnProperty(e)?"function"!=typeof this.definitions[e]?(console.warn("Slope type definition for type "+l+" is not a function"),null):this.definitions[e].call(this,e,o):(console.warn("Slope type "+l+" not defined"),null)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.convertTilemap=function(e,o,l,t){return o=e.getLayer(o),this.convertTilemapLayer(o,l,t),e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.convertTilemapLayer=function(e,o,l){var t=this;if("string"==typeof o){var r=this.resolveMappingType(o);if(!this.mappings[r])return console.warn("Tilemap could not be converted; mapping type '"+o+"' is unknown"),e;o=this.mappings[r](l)}return e.layer.data.forEach(function(l){l.forEach(function(l){var r;l.properties.type&&(r=t.create(l.properties.type,l)),!r&&o.hasOwnProperty(l.index)&&(r=t.create(o[l.index],l)),r&&(l.slope=r);var s=l.x,i=l.y;l.neighbours=l.neighbours||{},l.neighbours.above=e.map.getTileAbove(e.index,s,i),l.neighbours.below=e.map.getTileBelow(e.index,s,i),l.neighbours.left=e.map.getTileLeft(e.index,s,i),l.neighbours.right=e.map.getTileRight(e.index,s,i),l.neighbours.topLeft=e.map.getTileTopLeft(e.index,s,i),l.neighbours.topRight=e.map.getTileTopRight(e.index,s,i),l.neighbours.bottomLeft=e.map.getTileBottomLeft(e.index,s,i),l.neighbours.bottomRight=e.map.getTileBottomRight(e.index,s,i)})}),this.calculateEdges(e),this.addDebugSettings(e),e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.calculateEdges=function(e){var o,l,t,r,s,i,p,n,a;for(t=e.layer.height,r=e.layer.width,l=0;l<t;l++)for(o=0;o<r;o++)s=e.layer.data[l][o],s&&s.hasOwnProperty("slope")&&(i=e.map.getTileAbove(e.index,o,l),p=e.map.getTileBelow(e.index,o,l),n=e.map.getTileLeft(e.index,o,l),a=e.map.getTileRight(e.index,o,l),i&&i.hasOwnProperty("slope")&&(s.slope.edges.top=this.compareEdges(s.slope.edges.top,i.slope.edges.bottom),s.collideUp=s.slope.edges.top!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(s,i)),p&&p.hasOwnProperty("slope")&&(s.slope.edges.bottom=this.compareEdges(s.slope.edges.bottom,p.slope.edges.top),s.collideDown=s.slope.edges.bottom!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(s,p)),n&&n.hasOwnProperty("slope")&&(s.slope.edges.left=this.compareEdges(s.slope.edges.left,n.slope.edges.right),s.collideLeft=s.slope.edges.left!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(s,n)),a&&a.hasOwnProperty("slope")&&(s.slope.edges.right=this.compareEdges(s.slope.edges.right,a.slope.edges.left),s.collideRight=s.slope.edges.right!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(s,a)));for(l=0;l<t;l++)for(o=0;o<r;o++)s=e.layer.data[l][o],this.flagIgnormals(s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.compareEdges=function(e,o){return e===Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID&&o===Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID?Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY:e===Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID&&o===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY?Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY:e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.flagInternalVertices=function(e,o){if(e.slope.polygon&&o.slope.polygon){var l,t,r=e.slope.polygon,s=o.slope.polygon,i=this.vectorPool.pop(),p=this.vectorPool.pop(),n=this.vectorPool.pop(),a=this.vectorPool.pop(),h=this.vectorPool.pop(),c=this.vectorPool.pop();i.x=e.worldX,i.y=e.worldY,p.x=o.worldX,p.y=o.worldY;for(var T=0;T<r.points.length;T++){n.copy(r.points[T]).add(i),a.copy(r.points[(T+1)%r.points.length]).add(i);for(var S=0;S<s.points.length;S++)h.copy(s.points[S]).add(p),c.copy(s.points[(S+1)%s.points.length]).add(p),l=n.x===h.x&&n.y===h.y&&a.x===c.x&&a.y===c.y,t=n.x===c.x&&n.y===c.y&&a.x===h.x&&a.y===h.y,(l||t)&&(r.normals[T].ignore=!0,s.normals[S].ignore=!0,e.slope.ignormals.push(r.normals[T]),o.slope.ignormals.push(s.normals[S]))}this.vectorPool.push(i,p,n,a,h,c)}},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.flagIgnormals=function(e){if(e.slope&&e.slope.polygon&&e.slope.type!==Phaser.Plugin.ArcadeSlopes.TileSlope.FULL&&e.slope.type!==Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP&&e.slope.type!==Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM&&e.slope.type!==Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_LEFT&&e.slope.type!==Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_RIGHT){var o=(Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING),l=Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,t=e.slope.slope,r=e.neighbours.above,s=e.neighbours.below,i=e.neighbours.left,p=e.neighbours.right,n=e.neighbours.topLeft,a=e.neighbours.topRight,h=e.neighbours.bottomLeft,c=e.neighbours.bottomRight;r&&!r.hasOwnProperty("slope")&&(r=null),s&&!s.hasOwnProperty("slope")&&(s=null),i&&!i.hasOwnProperty("slope")&&(i=null),p&&!p.hasOwnProperty("slope")&&(p=null),n&&!n.hasOwnProperty("slope")&&(n=null),a&&!a.hasOwnProperty("slope")&&(a=null),h&&!h.hasOwnProperty("slope")&&(h=null),c&&!c.hasOwnProperty("slope")&&(c=null);var T=e.slope.edges.top===o,S=e.slope.edges.bottom===o,g=e.slope.edges.left===o,P=e.slope.edges.right===o;T&&(n&&n.slope.edges.right===o&&t===n.slope.slope&&e.slope.meets(n.slope)||a&&a.slope.edges.left===o&&t===a.slope.slope&&e.slope.meets(a.slope)||g&&P&&(i&&i.slope.edges.top!==l&&i.slope.edges.right===o&&t===i.slope.slope&&e.slope.meets(i.slope)||p&&p.slope.edges.top!==l&&p.slope.edges.left===o&&t===p.slope.slope&&e.slope.meets(p.slope)))&&e.slope.ignormals.push(new SAT.Vector(0,(-1))),S&&(h&&h.slope.edges.right===o&&t===h.slope.slope&&e.slope.meets(h.slope)||c&&c.slope.edges.left===o&&t===c.slope.slope&&e.slope.meets(c.slope)||g&&P&&(i&&i.slope.edges.bottom!==l&&i.slope.edges.right===o&&t===i.slope.slope&&e.slope.meets(i.slope)||p&&p.slope.edges.bottom!==l&&p.slope.edges.left===o&&t===p.slope.slope&&e.slope.meets(p.slope)))&&e.slope.ignormals.push(new SAT.Vector(0,1)),g&&(n&&n.slope.edges.bottom===o&&t===n.slope.slope&&e.slope.meets(n.slope)||h&&h.slope.edges.top===o&&t===h.slope.slope&&e.slope.meets(h.slope)||T&&S&&(r&&r.slope.edges.left!==l&&r.slope.edges.bottom===o&&t===r.slope.slope&&e.slope.meets(r.slope)||s&&s.slope.edges.left!==l&&s.slope.edges.top===o&&t===s.slope.slope&&e.slope.meets(s.slope)))&&e.slope.ignormals.push(new SAT.Vector((-1),0)), P&&(a&&a.slope.edges.bottom===o&&t===a.slope.slope&&e.slope.meets(a.slope)||c&&c.slope.edges.top===o&&t===c.slope.slope&&e.slope.meets(c.slope)||T&&S&&(r&&r.slope.edges.right!==l&&r.slope.edges.bottom===o&&t===r.slope.slope&&e.slope.meets(r.slope)||s&&s.slope.edges.right!==l&&s.slope.edges.top===o&&t===s.slope.slope&&e.slope.meets(s.slope)))&&e.slope.ignormals.push(new SAT.Vector(1,0))}},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.addDebugSettings=function(e){e._mc.edgeMidpoint=new SAT.Vector,e.debugSettings.slopeFill="rgba(255, 0, 255, 0.2)",e.debugSettings.slopeEdgeStroke="rgba(255, 0, 255, 0.4)",e.debugSettings.slopeLineStroke="rgba(255, 128, 128, 1)",e.debugSettings.slopeCollidingEdgeStroke="rgba(255, 0, 255, 1)",e.debugSettings.slopeCollidingEdgeStrokeWidth=2,e.debugSettings.slopeNormalStroke="rgba(0, 255, 255, 0.4)",e.debugSettings.slopeNormalStrokeWidth=1,e.debugSettings.slopeCollidingNormalStroke="rgba(0, 255, 255, 1)",e.debugSettings.slopeCollidingNormalStrokeWidth=2},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.resolveMappingType=function(e){return parseInt(e)>=0?e:("string"==typeof e&&(e=e.toUpperCase()),Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.hasOwnProperty(e)&&this.mappings[Phaser.Plugin.ArcadeSlopes.TileSlopeFactory[e]]?Phaser.Plugin.ArcadeSlopes.TileSlopeFactory[e]:(console.warn("Unknown tileset mapping type '"+e+"'"),-1))},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createFull=function(e,o){var l=new SAT.Box(new SAT.Vector(o.worldX,o.worldY),o.width,o.height).toPolygon();return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottom=function(e,o){var l=o.height/2,t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,l),new SAT.Vector(o.width,l),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),r=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.top+o.height/2),s={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING};return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTop=function(e,o){var l=o.height/2,t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,l),new SAT.Vector(0,l)]),r=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.top+o.height/2),s={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING};return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfLeft=function(e,o){var l=o.width/2,t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(l,0),new SAT.Vector(l,o.height),new SAT.Vector(0,o.height)]),r=new Phaser.Line(o.left+l,o.top,o.left+l,o.bottom),s={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING};return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfRight=function(e,o){var l=o.width/2,t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(l,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(l,o.height)]),r=new Phaser.Line(o.left+l,o.top,o.left+l,o.bottom),s={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING};return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomLeft=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.top,o.right,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.7071067811865475,(-.7071067811865475));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomRight=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.bottom,o.right,o.top),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.707106781186548),(-.707106781186548));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopLeft=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.right,o.top,o.left,o.bottom),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.7071067811865475,.7071067811865475);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopRight=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height)]),t=new Phaser.Line(o.right,o.bottom,o.left,o.top),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.7071067811865475),.7071067811865475);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftLow=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,o.height/2),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.4472135954999579,(-.8944271909999159));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftHigh=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,o.height/2),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.top,o.right,o.top+o.height/2),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.4472135954999579,(-.8944271909999159));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightLow=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width,o.height/2),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.bottom,o.right,o.top+o.height/2),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.4472135954999579),(-.8944271909999159));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightHigh=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,o.height/2),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.top),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.4472135954999579),(-.8944271909999159));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomLow=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width/2,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left+o.width/2,o.top,o.right,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.8944271909999159,(-.4472135954999579));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomHigh=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width/2,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.top,o.left+o.width/2,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.8944271909999159,(-.4472135954999579));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomLow=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width/2,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.bottom,o.left+o.width/2,o.top),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.8944271909999159),(-.4472135954999579));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomHigh=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(o.width/2,o.height)]),t=new Phaser.Line(o.left+o.width/2,o.bottom,o.right,o.top),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.8944271909999159),(-.4472135954999579));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopLow=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width/2,0),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.bottom,o.left+o.width/2,o.top),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.8944271909999159,.4472135954999579);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopHigh=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width/2,o.height),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left+o.width/2,o.bottom,o.right,o.top),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.8944271909999159,.4472135954999579);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopLow=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width/2,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height)]),t=new Phaser.Line(o.left+o.width/2,o.top,o.right,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.8944271909999159),.4472135954999579);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopHigh=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(o.width/2,o.height)]),t=new Phaser.Line(o.left,o.top,o.left+o.width/2,o.bottom),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.8944271909999159),.4472135954999579);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftLow=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(0,o.height/2)]),t=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.top),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.4472135954999579,.8944271909999159);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftHigh=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height/2),new SAT.Vector(0,o.height)]),t=new Phaser.Line(o.left,o.bottom,o.right,o.top+o.height/2),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector(.4472135954999579,.8944271909999159);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightLow=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height/2)]),t=new Phaser.Line(o.left,o.top,o.right,o.top+o.height/2),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.4472135954999579),.8944271909999159);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightHigh=function(e,o){var l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height/2)]),t=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.top+o.height),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},s=new SAT.Vector((-.4472135954999579),.8944271909999159);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,t,r,s)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset=function(e){var o=parseInt(e);return o=isNaN(o)||"number"!=typeof o?0:o-1},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapArcadeSlopes=function(e){offset=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset(e);var o={};return o[offset+1]="FULL",o[offset+2]="HALF_TOP",o[offset+3]="HALF_BOTTOM",o[offset+4]="HALF_LEFT",o[offset+5]="HALF_RIGHT",o[offset+6]="HALF_BOTTOM_LEFT",o[offset+7]="HALF_BOTTOM_RIGHT",o[offset+8]="HALF_TOP_LEFT",o[offset+9]="HALF_TOP_RIGHT",o[offset+10]="QUARTER_TOP_LEFT_HIGH",o[offset+11]="QUARTER_TOP_LEFT_LOW",o[offset+12]="QUARTER_TOP_RIGHT_LOW",o[offset+13]="QUARTER_TOP_RIGHT_HIGH",o[offset+14]="QUARTER_BOTTOM_LEFT_HIGH",o[offset+15]="QUARTER_BOTTOM_LEFT_LOW",o[offset+16]="QUARTER_BOTTOM_RIGHT_LOW",o[offset+17]="QUARTER_BOTTOM_RIGHT_HIGH",o[offset+18]="QUARTER_LEFT_BOTTOM_HIGH",o[offset+19]="QUARTER_RIGHT_BOTTOM_HIGH",o[offset+20]="QUARTER_LEFT_TOP_HIGH",o[offset+21]="QUARTER_RIGHT_TOP_HIGH",o[offset+35]="QUARTER_LEFT_BOTTOM_LOW",o[offset+36]="QUARTER_RIGHT_BOTTOM_LOW",o[offset+37]="QUARTER_LEFT_TOP_LOW",o[offset+38]="QUARTER_RIGHT_TOP_LOW",o},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapNinjaPhysics=function(e){offset=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset(e);var o={};return o[offset+2]="FULL",o[offset+3]="HALF_BOTTOM_LEFT",o[offset+4]="HALF_BOTTOM_RIGHT",o[offset+6]="HALF_TOP_LEFT",o[offset+5]="HALF_TOP_RIGHT",o[offset+15]="QUARTER_BOTTOM_LEFT_LOW",o[offset+16]="QUARTER_BOTTOM_RIGHT_LOW",o[offset+17]="QUARTER_TOP_RIGHT_LOW",o[offset+18]="QUARTER_TOP_LEFT_LOW",o[offset+19]="QUARTER_BOTTOM_LEFT_HIGH",o[offset+20]="QUARTER_BOTTOM_RIGHT_HIGH",o[offset+21]="QUARTER_TOP_RIGHT_HIGH",o[offset+22]="QUARTER_TOP_LEFT_HIGH",o[offset+23]="QUARTER_LEFT_BOTTOM_HIGH",o[offset+24]="QUARTER_RIGHT_BOTTOM_HIGH",o[offset+25]="QUARTER_RIGHT_TOP_LOW",o[offset+26]="QUARTER_LEFT_TOP_LOW",o[offset+27]="QUARTER_LEFT_BOTTOM_LOW",o[offset+28]="QUARTER_RIGHT_BOTTOM_LOW",o[offset+29]="QUARTER_RIGHT_TOP_HIGH",o[offset+30]="QUARTER_LEFT_TOP_HIGH",o[offset+31]="HALF_BOTTOM",o[offset+32]="HALF_RIGHT",o[offset+33]="HALF_TOP",o[offset+34]="HALF_LEFT",o},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.ARCADESLOPES=1,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.NINJA=2,function(e,o){"use strict";"function"==typeof define&&define.amd?define(o):"object"==typeof exports?module.exports=o():e.SAT=o()}(this,function(){"use strict";function e(e,o){this.x=e||0,this.y=o||0}function o(o,l){this.pos=o||new e,this.r=l||0}function l(o,l){this.pos=o||new e,this.angle=0,this.offset=new e,this.setPoints(l||[])}function t(o,l,t){this.pos=o||new e,this.w=l||0,this.h=t||0}function r(){this.a=null,this.b=null,this.overlapN=new e,this.overlapV=new e,this.clear()}function s(e,o,l){for(var t=Number.MAX_VALUE,r=-Number.MAX_VALUE,s=e.length,i=