let body=[],map=[],cons=[],consBB=[],composite=[];const level={defaultZoom:1400,onLevel:-1,levelsCleared:0,playableLevels:["labs","rooftops","skyscrapers","warehouse","highrise","office","aerie","satellite","sewers","testChamber","ruins"],communityLevels:["stronghold","basement","crossfire","vats","run","n-gon","house","perplex","coliseum","tunnel"],trainingLevels:["walk","crouch","jump","hold","throw","throwAt","deflect","heal","fire","nailGun","shotGun","superBall","matterWave","missile","stack","mine","grenades","harpoon"],levels:[],start(){if(0===level.levelsCleared?simulation.isTraining?level.walk():level.intro():(spawn.setSpawnList(),level[level.levels[level.onLevel]](),simulation.isCheating||build.isExperimentRun||simulation.isTraining||(localSettings.runCount+=level.levelsCleared,localSettings.levelsClearedLastGame=level.levelsCleared,localStorage.setItem("localSettings",JSON.stringify(localSettings)))),simulation.isTraining||level.levelAnnounce(),simulation.noCameraScroll(),simulation.setZoom(),level.addToWorld(),simulation.draw.setPaths(),b.respawnBots(),m.resetHistory(),tech.isForeverDrones)if(tech.isDroneRadioactive)for(let e=0;e<.25*tech.isForeverDrones;e++)b.droneRadioactive({x:m.pos.x+30*(Math.random()-.5),y:m.pos.y+30*(Math.random()-.5)},5),bullet[bullet.length-1].endCycle=1/0;else for(let e=0;e<tech.isForeverDrones;e++)b.drone({x:m.pos.x+30*(Math.random()-.5),y:m.pos.y+30*(Math.random()-.5)},5),bullet[bullet.length-1].endCycle=1/0;if(tech.isExtraMaxEnergy&&(tech.healMaxEnergyBonus+=.05*powerUps.totalPowerUps,m.setMaxEnergy()),tech.isGunCycle&&(b.inventoryGun++,b.inventoryGun>b.inventory.length-1&&(b.inventoryGun=0),simulation.switchGun()),tech.isSwitchReality&&powerUps.research.count>0&&(powerUps.research.changeRerolls(-1),simulation.makeTextLog(`simulation.amplitude <span class='color-symbol'>=</span> ${Math.random()}`),m.switchWorlds(),simulation.trails(),powerUps.spawn(player.position.x+50*Math.random(),player.position.y-50*Math.random(),"tech",!1)),tech.isHealLowHealth){const e=Math.ceil((m.maxHealth-m.health)/.26);for(let t=0;t<e;t++)powerUps.spawn(player.position.x+90*(Math.random()-.5),player.position.y+90*(Math.random()-.5),"heal",!1)}tech.isMACHO&&spawn.MACHO();for(let e=0;e<tech.wimpCount;e++){spawn.WIMP();for(let e=0,t=5;e<t;e++)powerUps.spawn(level.exit.x+100*(Math.random()-.5),level.exit.y-100+100*(Math.random()-.5),"research",!1)}for(let e=0;e<tech.wimpExperiment;e++)spawn.WIMP();if(tech.isFlipFlopLevelReset&&!tech.isFlipFlopOn&&(tech.isFlipFlopOn=!0,m.eyeFillColor=m.fieldMeterColor,simulation.makeTextLog("tech.isFlipFlopOn <span class='color-symbol'>=</span> true")),tech.isSpawnExitTech)for(let e=0;e<2;e++)powerUps.spawn(level.exit.x+10*(Math.random()-.5),level.exit.y-100+10*(Math.random()-.5),"tech",!1)},trainingText(e){simulation.lastLogTime=0,simulation.isTextLogOpen=!0,simulation.makeTextLog(`<span style="font-size: 120%;line-height: 120%;"><span style="color:#51f;">supervised.learning</span>(<span style="color:#777; font-size: 80%;">${(Date.now()/1e3).toFixed(0)} s</span>)<span class='color-symbol'>:</span><br>${e}</span>`,1/0),simulation.isTextLogOpen=!1},trainingBackgroundColor:"#e1e1e1",custom(){},customTopLayer(){},setDifficulty(){simulation.difficulty=0,b.dmgScale=1,simulation.accelScale=1,simulation.CDScale=1,simulation.dmgScale=.41*simulation.difficulty,simulation.healScale=1/(1+.055*simulation.difficulty)},difficultyIncrease(e=1){for(let t=0;t<e;t++)simulation.difficulty++,b.dmgScale*=.914,simulation.accelScale<6&&(simulation.accelScale*=1.025),simulation.CDScale>.15&&(simulation.CDScale*=.965);simulation.dmgScale=.41*simulation.difficulty,simulation.healScale=1/(1+.055*simulation.difficulty)},difficultyDecrease(e=1){for(let t=0;t<e;t++)simulation.difficulty--,b.dmgScale/=.914,simulation.accelScale>1&&(simulation.accelScale/=1.025),simulation.CDScale<1&&(simulation.CDScale/=.965);simulation.difficulty<1&&(simulation.difficulty=0),simulation.dmgScale=.41*simulation.difficulty,simulation.dmgScale<.1&&(simulation.dmgScale=.1),simulation.healScale=1/(1+.055*simulation.difficulty)},difficultyText:()=>1===simulation.difficultyMode?"easy":2===simulation.difficultyMode?"normal":4===simulation.difficultyMode?"hard":6===simulation.difficultyMode?"why":void 0,levelAnnounce(){const e=simulation.isCheating?"testing":level.difficultyText();0===level.levelsCleared?document.title="n-gon: ("+e+")":(document.title=`n-gon: ${level.levelsCleared} ${level.levels[level.onLevel]} (${e})`,simulation.makeTextLog(`<span class='color-var'>level</span>.onLevel <span class='color-symbol'>=</span> "<span class='color-text'>${level.levels[level.onLevel]}</span>"`))},disableExit:!1,nextLevel(){if(!level.disableExit){if(level.levelsCleared++,level.onLevel++,simulation.isTraining){if(level.onLevel>level.levels.length-1)return level.disableExit=!0,document.getElementById("health").style.display="none",document.getElementById("health-bg").style.display="none",document.getElementById("text-log").style.opacity=0,document.getElementById("fade-out").style.opacity=1,void setTimeout((function(){simulation.paused=!0,level.disableExit=!1,engine.world.bodies.forEach((e=>{Matter.Composite.remove(engine.world,e)})),Engine.clear(engine),simulation.splashReturn()}),6e3);level.setDifficulty()}else level.onLevel>level.levels.length-1&&(level.onLevel=0),level.difficultyIncrease(simulation.difficultyMode);for(let e=0;e<tech.tech.length;e++)tech.tech[e].isLost&&(tech.tech[e].isLost=!1);tech.isDeathAvoidedThisLevel=!1,simulation.updateTechHUD(),simulation.clearNow=!0}},populateLevels(){simulation.isTraining?level.levels=level.trainingLevels.slice(0):(simulation.isHorizontalFlipped=Math.random()<.5,level.levels=level.playableLevels.slice(0),simulation.isCommunityMaps?(level.levels=level.levels.concat(level.communityLevels),level.levels=shuffle(level.levels),level.levels.splice(0,9)):level.levels=shuffle(level.levels),(!build.isExperimentSelection||build.hasExperimentalMode&&!simulation.isCheating)&&(level.levels.unshift("intro"),level.levels.push("gauntlet"),level.levels.push("final")))},flipHorizontal(){const e=e=>{for(let t=0,a=e.length;t<a;t++)Matter.Body.setPosition(e[t],{x:-e[t].position.x,y:e[t].position.y})};e(map),e(body),e(mob),e(powerUp);for(let e=0,t=cons.length;e<t;e++)cons[e].pointA.x*=-1,cons[e].pointB.x*=-1;for(let e=0,t=consBB.length;e<t;e++)consBB[e].pointA.x*=-1,consBB[e].pointB.x*=-1;level.exit.x=-level.exit.x-100},playerExitCheck(){player.position.x>level.exit.x&&player.position.x<level.exit.x+100&&player.position.y>level.exit.y-150&&player.position.y<level.exit.y-40&&player.velocity.y<.1&&level.nextLevel()},setPosToSpawn(e,t){m.spawnPos.x=m.pos.x=e,m.spawnPos.y=m.pos.y=t,level.enter.x=m.spawnPos.x-50,level.enter.y=m.spawnPos.y+20,m.transX=m.transSmoothX=canvas.width2-m.pos.x,m.transY=m.transSmoothY=canvas.height2-m.pos.y,m.Vx=m.spawnVel.x,m.Vy=m.spawnVel.y,player.force.x=0,player.force.y=0,Matter.Body.setPosition(player,m.spawnPos),Matter.Body.setVelocity(player,m.spawnVel),m.fieldPosition={x:m.pos.x,y:m.pos.y},m.fieldAngle=m.angle},enter:{x:0,y:0,draw(){ctx.beginPath(),ctx.moveTo(level.enter.x,level.enter.y+30),ctx.lineTo(level.enter.x,level.enter.y-80),ctx.bezierCurveTo(level.enter.x,level.enter.y-170,level.enter.x+100,level.enter.y-170,level.enter.x+100,level.enter.y-80),ctx.lineTo(level.enter.x+100,level.enter.y+30),ctx.lineTo(level.enter.x,level.enter.y+30),ctx.fillStyle="#ccc",ctx.fill()}},exit:{x:0,y:0,draw(){ctx.beginPath(),ctx.moveTo(level.exit.x,level.exit.y+30),ctx.lineTo(level.exit.x,level.exit.y-80),ctx.bezierCurveTo(level.exit.x,level.exit.y-170,level.exit.x+100,level.exit.y-170,level.exit.x+100,level.exit.y-80),ctx.lineTo(level.exit.x+100,level.exit.y+30),ctx.lineTo(level.exit.x,level.exit.y+30),ctx.fillStyle="#0ff",ctx.fill()}},addToWorld(){for(let e=0;e<body.length;e++)body[e]===m.holdingTarget||body[e].isNoSetCollision||(body[e].collisionFilter.category=cat.body,body[e].collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.mob|cat.mobBullet),body[e].classType="body",Composite.add(engine.world,body[e]);for(let e=0;e<map.length;e++)map[e].collisionFilter.category=cat.map,map[e].collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet,Matter.Body.setStatic(map[e],!0),Composite.add(engine.world,map[e])},spinner(e,t,a,o,l=.001,n=0,s=.001,p=0){e+=a/2,t+=o/2;const c=body[body.length]=Bodies.rectangle(e,t,a,o,{collisionFilter:{category:cat.body,mask:cat.player|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet},isNotHoldable:!0,frictionAir:s,friction:1,frictionStatic:1,restitution:0});Matter.Body.setAngle(c,n),Matter.Body.setAngularVelocity(c,p),Matter.Body.setDensity(c,l);const i=Constraint.create({pointA:{x:c.position.x,y:c.position.y},bodyB:c,stiffness:1,damping:1});return Composite.add(engine.world,i),i},boost:(e,t,a=1e3)=>(who=map[map.length]=Matter.Bodies.fromVertices(e+50,t+35,Vertices.fromPath("120 40 -120 40 -50 -40 50 -40"),{collisionFilter:{category:cat.body,mask:cat.player|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet},boostBounds:{min:{x:e,y:t-20},max:{x:e+100,y:t}},yVelocity:-1.21*Math.sqrt(Math.abs(a)),query(){query=e=>{Matter.Query.region(e,this.boostBounds).length>0&&(list=Matter.Query.region(e,this.boostBounds),Matter.Body.setVelocity(list[0],{x:list[0].velocity.x+2.5*(Math.random()-.5),y:this.yVelocity}))},query(body),query(mob),query(bullet),query(powerUp),Matter.Query.region([player],this.boostBounds).length>0&&(m.buttonCD_jump=0,m.hardLandCD=0,player.velocity.y>26?Matter.Body.setVelocity(player,{x:player.velocity.x,y:-15}):Matter.Body.setVelocity(player,{x:player.velocity.x+2.5*(Math.random()-.5),y:this.yVelocity})),ctx.fillStyle="rgba(200,0,255,0.15)",ctx.fillRect(this.boostBounds.min.x,this.boostBounds.min.y-10,100,30),ctx.fillStyle="rgba(200,0,255,0.05)",ctx.fillRect(this.boostBounds.min.x,this.boostBounds.min.y-50,100,70)}}),who),elevator(e,t,a,o,l,n=.003,s={up:.01,down:.2}){e+=a/2;const p=(l+=o/2)-(t+=o/2);n+=simulation.g;const c=body[body.length]=Bodies.rectangle(e,t,a,o,{collisionFilter:{category:cat.body,mask:cat.player|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet},inertia:1/0,isNotHoldable:!0,friction:1,frictionStatic:1,restitution:0,frictionAir:.001,holdX:e,move(){m.isBodiesAsleep||(this.isUp?(this.force.y-=n*this.mass,this.position.y<l&&(this.isUp=!1,this.frictionAir=s.down,Matter.Body.setPosition(this,{x:this.holdX,y:l}),Matter.Body.setVelocity(this,{x:0,y:0}))):this.position.y+10*this.velocity.y>t&&(Matter.Body.setVelocity(this,{x:0,y:.7*this.velocity.y}),this.position.y+this.velocity.y>t&&(this.isUp=!0,this.frictionAir=s.up))),Matter.Body.setPosition(this,{x:this.holdX,y:this.position.y}),Matter.Body.setVelocity(this,{x:0,y:this.velocity.y})},off(){Matter.Body.setPosition(this,{x:this.holdX,y:this.position.y}),Matter.Body.setVelocity(this,{x:0,y:this.velocity.y})},constraint:this.null,addConstraint(){this.constraint=Constraint.create({pointA:{x:this.position.x,y:this.position.y},bodyB:this,stiffness:.01,damping:.3}),Composite.add(engine.world,this.constraint)},removeConstraint(){Composite.remove(engine.world,this.constraint,!0)},drawTrack(){ctx.fillStyle="#ccc",ctx.fillRect(this.holdX,t,5,p)}});return Matter.Body.setDensity(c,.01),c},platform(e,t,a,o,l=0,n=.001){e+=a/2,t+=o/2;const s=body[body.length]=Bodies.rectangle(e,t,a,o,{collisionFilter:{category:cat.body,mask:cat.player|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet},inertia:1/0,isNotHoldable:!0,friction:1,frictionStatic:1,restitution:0});Matter.Body.setDensity(s,n);const p=Constraint.create({pointA:{x:e,y:t},bodyB:s,stiffness:.1,damping:.3});return Composite.add(engine.world,p),p.plat={position:s.position,speed:l},p.pauseUntilCycle=0,p},rotor(e,t,a=0,o=800,l=40,n=5e-4){const s=Matter.Bodies.rectangle(e,t,l,o,{density:n,isNotHoldable:!0,isNonStick:!0}),p=Matter.Bodies.rectangle(e,t,l,o,{angle:Math.PI/2,density:n,isNotHoldable:!0,isNonStick:!0});rotor=Body.create({parts:[s,p],restitution:0,collisionFilter:{category:cat.body,mask:cat.body|cat.mob|cat.mobBullet|cat.mobShield|cat.powerUp|cat.player|cat.bullet}}),Matter.Body.setPosition(rotor,{x:e,y:t}),Composite.add(engine.world,[rotor]),body[body.length]=s,body[body.length]=p,setTimeout((function(){rotor.collisionFilter.category=cat.body,rotor.collisionFilter.mask=cat.body|cat.player|cat.bullet|cat.mob|cat.mobBullet}),1e3);const c=Constraint.create({pointA:{x:e,y:t},bodyB:rotor});return Composite.add(engine.world,c),a&&(rotor.rotate=function(){m.isBodiesAsleep?Matter.Body.setAngularVelocity(rotor,0):Matter.Body.applyForce(rotor,{x:rotor.position.x+100,y:rotor.position.y+100},{x:a*rotor.mass,y:0})}),composite[composite.length]=rotor,rotor},toggle(e,t,a=!1,o=!1){spawn.mapVertex(e+65,t+2,"70 10 -70 10 -40 -10 40 -10"),map[map.length-1].restitution=0,map[map.length-1].friction=1,map[map.length-1].frictionStatic=1,spawn.bodyRect(e,t-5,120,15);let l=body[body.length-1];return l.isNoSetCollision=!0,l.collisionFilter.category=cat.body,l.collisionFilter.mask=cat.player|cat.body,l.isNotHoldable=!0,l.frictionAir=.01,l.restitution=0,Matter.Body.setDensity(l,.003),a?Matter.Body.setAngle(l,-.25*Math.PI):Matter.Body.setAngle(l,-.75*Math.PI),cons[cons.length]=Constraint.create({pointA:{x:e+65,y:t-5},bodyB:l,stiffness:1,length:0}),Composite.add(engine.world,[cons[cons.length-1]]),{flip:l,isOn:a,query(){const e={right:-.75*Math.PI,left:-.25*Math.PI};if(l.angle<e.right?(Matter.Body.setAngle(l,e.right),Matter.Body.setAngularVelocity(l,0),o||(this.isOn=!1)):l.angle>e.left&&(Matter.Body.setAngle(l,e.left),Matter.Body.setAngularVelocity(l,0),this.isOn=!0),this.isOn){ctx.beginPath(),ctx.moveTo(l.vertices[0].x,l.vertices[0].y);for(let e=1;e<l.vertices.length;e++)ctx.lineTo(l.vertices[e].x,l.vertices[e].y);ctx.lineTo(l.vertices[0].x,l.vertices[0].y),ctx.fillStyle="#3df",ctx.fill(),ctx.lineWidth=1,ctx.strokeStyle=color.blockS,ctx.stroke()}}}},button:(e,t,a=126)=>(spawn.mapVertex(e+65,t+2,"100 10 -100 10 -70 -10 70 -10"),map[map.length-1].restitution=0,map[map.length-1].friction=1,map[map.length-1].frictionStatic=1,{isUp:!1,min:{x:e+2,y:t-11},max:{x:e+a,y:t-10},width:a,height:20,query(){if(0===Matter.Query.region(body,this).length&&0===Matter.Query.region([player],this).length)this.isUp=!0;else{if(!0===this.isUp){const e=Matter.Query.region(body,this);e.length>0&&(e[0].bounds.max.x-e[0].bounds.min.x<150&&e[0].bounds.max.y-e[0].bounds.min.y<150&&Matter.Body.setPosition(e[0],{x:this.min.x+a/2,y:e[0].position.y}),Matter.Body.setVelocity(e[0],{x:0,y:0}))}this.isUp=!1}},draw(){ctx.fillStyle="hsl(0, 100%, 70%)",this.isUp?ctx.fillRect(this.min.x,this.min.y-10,this.width,20):ctx.fillRect(this.min.x,this.min.y-3,this.width,25)}}),vanish(e,t,a,o,l=!1,n={x:0,y:150}){const s=[{x:e+=a/2,y:t+=o/2,index:0,isInternal:!1},{x:e+a,y:t,index:1,isInternal:!1},{x:e+a,y:t+o,index:4,isInternal:!1},{x:e,y:t+o,index:3,isInternal:!1}],p=body[body.length]=Bodies.fromVertices(e,t,s,{collisionFilter:{category:cat.map,mask:cat.player|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet},isNoSetCollision:!0,inertia:1/0,isNotHoldable:!0,isNonStick:!0,isTouched:!1,fadeTime:10+Math.ceil(.25*a),fadeCount:null,isThere:!0,returnTime:120,returnCount:0,shrinkVertices:n=>l?[{x:e,y:t*n,index:0,isInternal:!1},{x:e+a,y:t*n,index:1,isInternal:!1},{x:e+a,y:(t+o)*n,index:4,isInternal:!1},{x:e,y:(t+o)*n,index:3,isInternal:!1}]:[{x:e*n,y:t,index:0,isInternal:!1},{x:(e+a)*n,y:t,index:1,isInternal:!1},{x:(e+a)*n,y:t+o,index:4,isInternal:!1},{x:e*n,y:t+o,index:3,isInternal:!1}],query(){if(this.isThere)if(this.isTouched){if(m.isBodiesAsleep||(this.fadeCount--,Matter.Body.setVertices(this,this.shrinkVertices(Math.max(this.fadeCount/this.fadeTime,.03)))),this.fadeCount<1){Matter.Body.setPosition(this,n),this.isThere=!1,this.isTouched=!1,this.collisionFilter.mask=0,this.returnCount=this.returnTime;Matter.Body.setVertices(this,this.shrinkVertices(1)),Matter.Body.setVertices(this,s)}}else Matter.Query.collides(this,[player]).length&&(this.isTouched=!0,this.fadeCount=this.fadeTime);else if(!m.isBodiesAsleep&&(this.returnCount--,this.returnCount<1))if(Matter.Body.setPosition(this,{x:e,y:t}),Matter.Query.collides(this,[player]).length)Matter.Body.setPosition(this,n),this.returnCount=15;else{this.isThere=!0,this.collisionFilter.mask=cat.player|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet,this.fadeCount=this.fadeTime;const e=Matter.Query.collides(this,body);for(let t=0;t<e.length;t++)if(e[t].bodyB!==this){Matter.Composite.remove(engine.world,e[t].bodyB),e[t].bodyB.isRemoveMeNow=!0;for(let e=1;e<body.length;e++)if(body[e].isRemoveMeNow){body.splice(e,1);break}}}ctx.beginPath();const a=this.vertices;ctx.moveTo(a[0].x,a[0].y);for(let e=1;e<a.length;++e)ctx.lineTo(a[e].x,a[e].y);ctx.lineTo(a[0].x,a[0].y),ctx.fillStyle="#586370",ctx.fill()}});return Matter.Body.setStatic(p,!0),simulation.isHorizontalFlipped&&(e*=-1),p},door(e,t,a,o,l,n=1){e+=a/2,t+=o/2;const s=body[body.length]=Bodies.rectangle(e,t,a,o,{collisionFilter:{category:cat.map,mask:cat.player|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet},isNoSetCollision:!0,inertia:1/0,isNotHoldable:!0,friction:1,frictionStatic:1,restitution:0,isClosing:!1,openClose(){if(!m.isBodiesAsleep)if(this.isClosing){if(this.position.y<t&&0===Matter.Query.collides(this,[player]).length&&Matter.Query.collides(this,body).length<2&&0===Matter.Query.collides(this,mob).length){const e={x:this.position.x,y:this.position.y+n};Matter.Body.setPosition(this,e)}}else if(this.position.y>t-l){const e={x:this.position.x,y:this.position.y-n};Matter.Body.setPosition(this,e)}},draw(){ctx.fillStyle="#555",ctx.beginPath();const e=this.vertices;ctx.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;++t)ctx.lineTo(e[t].x,e[t].y);ctx.lineTo(e[0].x,e[0].y),ctx.fill()}});return Matter.Body.setStatic(s,!0),s},portal(e,t,a,o){const l=150,n=200,s=Matter.Vector.rotate({x:1,y:0},t),p=Matter.Vector.rotate({x:1,y:0},o);draw=function(){ctx.beginPath();let e=this.vertices;ctx.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;++t)ctx.lineTo(e[t].x,e[t].y);ctx.fillStyle=this.color,ctx.fill()},query=function(e=!1){if(0===Matter.Query.collides(this,[player]).length)player.isInPortal===this&&(player.isInPortal=null);else if(player.isInPortal!==this){let e;m.buttonCD_jump===m.cycle&&(player.force.y=0),m.buttonCD_jump=0,player.isInPortal=this.portalPair,this.portalPair.angle%(Math.PI/2)?(m.immuneCycle<m.cycle+tech.collisionImmuneCycles&&(m.immuneCycle=m.cycle+tech.collisionImmuneCycles),Matter.Body.setPosition(player,this.portalPair.portal.position)):(m.immuneCycle<m.cycle+tech.collisionImmuneCycles&&(m.immuneCycle=m.cycle+tech.collisionImmuneCycles),Matter.Body.setPosition(player,this.portalPair.position)),e=0!==this.portalPair.angle&&this.portalPair.angle!==Math.PI?Math.max(10,Math.min(50,.8*player.velocity.y))+11:Math.max(6,Math.min(50,Vector.magnitude(player.velocity)));let t=Vector.mult(this.portalPair.unit,e);Matter.Body.setVelocity(player,t);for(let e=0;e<bullet.length;e++)bullet[e].botType&&(Matter.Body.setPosition(bullet[e],Vector.add(this.portalPair.portal.position,{x:250*(Math.random()-.5),y:250*(Math.random()-.5)})),Matter.Body.setVelocity(bullet[e],{x:0,y:0}))}for(let t=0,a=body.length;t<a;t++)if(body[t]!==m.holdingTarget)if(0===Matter.Query.collides(this,[body[t]]).length)body[t].isInPortal===this&&(body[t].isInPortal=null);else if(body[t].isInPortal!==this){if(e){Matter.Composite.remove(engine.world,body[t]),body.splice(t,1);break}let a;body[t].isInPortal=this.portalPair,this.portalPair.angle%(Math.PI/2)?Matter.Body.setPosition(body[t],this.portalPair.portal.position):Matter.Body.setPosition(body[t],this.portalPair.position),a=0!==this.portalPair.angle&&this.portalPair.angle!==Math.PI?Math.max(10,Math.min(50,.8*body[t].velocity.y))+11:Math.max(6,Math.min(50,Vector.magnitude(body[t].velocity)));let o=Vector.mult(this.portalPair.unit,a);Matter.Body.setVelocity(body[t],o)}};const c=composite[composite.length]=Bodies.rectangle(e.x,e.y,50,l,{isSensor:!0,angle:t,color:"hsla(197, 100%, 50%,0.7)",draw:draw}),i=composite[composite.length]=Bodies.rectangle(a.x,a.y,50,l,{isSensor:!0,angle:o,color:"hsla(29, 100%, 50%, 0.7)",draw:draw}),r=composite[composite.length]=Bodies.rectangle(e.x-.5*s.x*n,e.y-.5*s.y*n,n,160,{collisionFilter:{category:cat.map,mask:cat.bullet|cat.powerUp|cat.mob|cat.mobBullet},unit:s,angle:t,color:color.map,draw:draw,query:query,lastPortalCycle:0});Matter.Body.setStatic(r,!0),Composite.add(engine.world,r);const w=composite[composite.length]=Bodies.rectangle(a.x-.5*p.x*n,a.y-.5*p.y*n,n,160,{collisionFilter:{category:cat.map,mask:cat.bullet|cat.powerUp|cat.mob|cat.mobBullet},unit:p,angle:o,color:color.map,draw:draw,query:query,lastPortalCycle:0});return Matter.Body.setStatic(w,!0),Composite.add(engine.world,w),r.portal=c,w.portal=i,r.portalPair=w,w.portalPair=r,[c,i,r,w]},drip:(e,t,a,o=100,l="hsla(160, 100%, 35%, 0.5)")=>({x:e,y:t,period:o,dropCycle:0,speed:0,draw(){m.isBodiesAsleep||(this.dropCycle<simulation.cycle?(this.dropCycle=simulation.cycle+this.period+Math.floor(40*Math.random()),this.y=t,this.speed=1):(this.speed+=.35,this.y+=this.speed)),this.y<a&&(ctx.fillStyle=l,ctx.beginPath(),ctx.arc(this.x,this.y,8,0,2*Math.PI),ctx.fill())}}),isHazardRise:!1,hazard:(e,t,a,o,l=.003)=>({min:{x:e,y:t},max:{x:e+a,y:t+o},width:a,height:o,maxHeight:o,isOn:!0,opticalQuery(){this.isOn&&(ctx.fillStyle=`hsla(0, 100%, 50%,${.6+.4*Math.random()})`,ctx.fillRect(this.min.x,this.min.y,this.width,this.height),this.height>0&&Matter.Query.region([player],this).length&&!m.isCloak&&m.immuneCycle<m.cycle&&(m.immuneCycle=m.cycle+tech.collisionImmuneCycles,m.damage(l),simulation.drawList.push({x:player.position.x,y:player.position.y,radius:1500*l,color:simulation.mobDmgColor,time:20})))},query(){if(this.isOn){ctx.fillStyle="hsla(160, 100%, 35%,0.75)";const e=5*Math.sin(.015*simulation.cycle);if(ctx.fillRect(this.min.x,this.min.y+e,this.width,this.height-e),this.height>0&&Matter.Query.region([player],this).length){if(m.immuneCycle<m.cycle){const e=.002*(tech.isRadioactiveResistance?.25:1)+m.fieldRegen;m.energy>e?(m.energy-=e,m.damage(l*(tech.isRadioactiveResistance?.25:1)*.03)):m.damage(l*(tech.isRadioactiveResistance?.25:1))}player.velocity.y>5&&(player.force.y-=.95*player.mass*simulation.g);const e=player.velocity.y>0?Math.max(.8,1-.002*player.velocity.y*player.velocity.y):Math.max(.98,1-.001*Math.abs(player.velocity.y));Matter.Body.setVelocity(player,{x:Math.max(.95,1-.036*Math.abs(player.velocity.x))*player.velocity.x,y:e*player.velocity.y})}powerUpCollide=Matter.Query.region(powerUp,this);for(let e=0,t=powerUpCollide.length;e<t;e++){const t=2*powerUpCollide[e].size,a=1-.2*Math.max(0,Math.min(t,this.min.y-powerUpCollide[e].position.y+powerUpCollide[e].size))/t;powerUpCollide[e].force.y-=1.1*a*powerUpCollide[e].mass*simulation.g,Matter.Body.setVelocity(powerUpCollide[e],{x:powerUpCollide[e].velocity.x,y:.95*powerUpCollide[e].velocity.y})}}},level(e){if(!m.isBodiesAsleep){const t=1;e?this.height<this.maxHeight&&(this.height+=t,this.min.y-=t,this.max.y=this.min.y+this.height):this.height>0&&(this.height-=t,this.min.y+=t,this.max.y=this.min.y+this.height)}}}),chain(e,t,a=0,o=!0,l=15,n=20,s=1,p=1){const c=2*n,i=Math.cos(a),r=Math.sin(a);for(let a=0;a<l;a++)body[body.length]=Bodies.polygon(e+c*i*a,t+c*r*a,12,n,{inertia:1/0,isNotHoldable:!0});for(let e=1;e<l;e++)consBB[consBB.length]=Constraint.create({bodyA:body[body.length-e],bodyB:body[body.length-e-1],stiffness:s,damping:p}),Composite.add(engine.world,consBB[consBB.length-1]);cons[cons.length]=Constraint.create({pointA:{x:e,y:t},bodyB:body[body.length-l],stiffness:1,damping:p}),Composite.add(engine.world,cons[cons.length-1]),o&&(cons[cons.length]=Constraint.create({pointA:{x:e+c*i*(l-1),y:t+c*r*(l-1)},bodyB:body[body.length-1],stiffness:1,damping:p}),Composite.add(engine.world,cons[cons.length-1]))},labs(){let e,t;level.isProcedural=!0,level.defaultZoom=1700,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#d9d9de",doCustom=[],doCustomTopLayer=[],offset={x:0,y:0};enterOptions=[(e=offset.x,t=offset.y)=>{level.setPosToSpawn(e+1750,t-800),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),spawn.mapRect(e+1450,t-1350,50,450),spawn.bodyRect(e+1460,t-900,30,150),spawn.mapRect(e+1600,t-350,500,100);const a=level.toggle(e+1650,t-350,!0);let o;Math.random()>.5?(spawn.mapRect(e+550,t-750,1500,50),o=level.hazard(e+850,t-920,600,10,.4),spawn.mapRect(e+860,t-925,10,20),spawn.mapRect(e+660,t-975,200,120)):(spawn.mapRect(e+1350,t-750,700,50),o=level.hazard(e+1040,t-660,1e3,10,.4),spawn.mapRect(e+1050,t-665,10,20),spawn.mapRect(e+650,t-705,400,100));const l=level.hazard(e,t-330,450,10,.4);spawn.mapRect(e+440,t-335,10,20),spawn.mapRect(e+450,t-375,400,100);const n=Math.floor(400*Math.random()),s=level.hazard(e+n,t-1300,10,1300,.4);spawn.mapRect(e+n-5,t-1310,20,20);const p=1650+Math.floor(300*Math.random()),c=level.hazard(e+p,t-240,10,250,.4);spawn.mapRect(e+p-5,t-250,20,20),spawn.randomMob(e+150,t+-1100,0),spawn.randomMob(e+175,t+-775,0),spawn.randomMob(e+150,t+-350,0),spawn.randomMob(e+150,t+-75,0),spawn.randomMob(e+650,t+-125,0),spawn.randomMob(e+1200,t+-75,0),doCustomTopLayer.push((()=>{a.query(),o.isOn=a.isOn,l.isOn=a.isOn,s.isOn=a.isOn,c.isOn=a.isOn,o.opticalQuery(),l.opticalQuery(),s.opticalQuery(),c.opticalQuery()}))}],exitOptions=[(e=offset.x,t=offset.y)=>{level.exit.x=e+1725,level.exit.y=t-980,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),spawn.mapRect(e+1500,t-950,500,25),spawn.mapRect(e+1550,t-1300,25,175),spawn.mapVertex(e+1300,t-125,"-400 0 -250 -400 250 -400 400 0"),spawn.bodyRect(e+1075,t-475,125,125,.25),spawn.bodyRect(e+500,t-100,125,100,.25),spawn.bodyRect(e+200,t-150,100,150,.25),spawn.bodyRect(e+1075,t-1075,100,125,.25);const a=.0015,o=Math.PI/2,l=.03;balance1=level.spinner(e+200,t-500,30,400,a,o+0*(Math.random()-.5),l,0+0*(Math.random()-.5)),balance2=level.spinner(e+200,t-950,30,400,a,o+0*(Math.random()-.5),l,0+0*(Math.random()-.5)),balance3=level.spinner(e+650,t-750,30,400,a,o+0*(Math.random()-.5),l,0+0*(Math.random()-.5)),balance4=level.spinner(e+1250,t-1e3,30,400,a,o+0*(Math.random()-.5),l,0+0*(Math.random()-.5));let n=!1;doCustom.push((()=>{!n&&m.pos.x>e-100&&m.pos.x<e+2700&&m.pos.y>t-1300&&m.pos.y<t&&(n=!0,spawn.randomMob(e+1175,t-725,0),spawn.randomMob(e+1450,t-725,0),spawn.randomMob(e+425,t-100,0),spawn.randomMob(e+1700,t-300,0),spawn.randomMob(e+1300,t-375,0)),ctx.fillStyle="#d4f4f4",ctx.fillRect(e+1550,t-1300,450,350)})),doCustomTopLayer.push((()=>{ctx.fillStyle="#233",ctx.beginPath(),ctx.arc(balance1.pointA.x,balance1.pointA.y,9,0,2*Math.PI),ctx.moveTo(balance2.pointA.x,balance2.pointA.y),ctx.arc(balance2.pointA.x,balance2.pointA.y,9,0,2*Math.PI),ctx.moveTo(balance3.pointA.x,balance3.pointA.y),ctx.arc(balance3.pointA.x,balance3.pointA.y,9,0,2*Math.PI),ctx.moveTo(balance4.pointA.x,balance4.pointA.y),ctx.arc(balance4.pointA.x,balance4.pointA.y,9,0,2*Math.PI),ctx.fill()}))},(e=offset.x,t=offset.y)=>{if(level.exit.x=e+1750,level.exit.y=t-980,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),spawn.mapRect(e+1550,t-950,500,25),spawn.mapRect(e+1600,t-1300,25,175),spawn.bodyRect(e+1275,t-475,125,125,.25),spawn.bodyRect(e+500,t-100,125,100,.25),spawn.bodyRect(e+800,t-150,100,150,.25),spawn.bodyRect(e+875,t+-50,50,50),spawn.bodyRect(e+1025,t+-50,50,50),Math.random()>.5){const o=.0012,l=Math.PI/2,n=.2,s=.015,p=35;balance1=level.spinner(e+1300,t-425,p,410,o,l+n*(Math.random()-.5),s),balance3=level.spinner(e+750,t-650,p,410,o,l+n*(Math.random()-.5),s),balance2=level.spinner(e+300,t-425,p,410,o,l+n*(Math.random()-.5),s),balance4=level.spinner(e+1250,t-950,50,550,o,l,.1);const c=body[body.length-1];doCustom.push((()=>{!a&&m.pos.x>e-100&&m.pos.x<e+2700&&m.pos.y>t-1300&&m.pos.y<t&&(a=!0,spawn.randomMob(e+1175,t-725,0),spawn.randomMob(e+1450,t-725,0),spawn.randomMob(e+425,t-100,0),spawn.randomMob(e+1200,t-125,0),spawn.randomMob(e+1300,t-375,0)),ctx.fillStyle="#d4f4f4",ctx.fillRect(e+1600,t-1300,400,350),c.torque+=5e-6*c.inertia}))}else{const o=.001,l=Math.PI/2,n=Math.PI,s=.015,p=200,c=200,i=.05;balance1=level.spinner(e+175,t-300,c,p,o,l+n*(Math.random()-.5),s,i*(Math.random()-.5)),balance2=level.spinner(e+500,t-525,c,p,o,l+n*(Math.random()-.5),s,i*(Math.random()-.5)),balance3=level.spinner(e+850,t-700,c,p,o,l+n*(Math.random()-.5),s,i*(Math.random()-.5)),balance4=level.spinner(e+1250,t-850,c,p,o,l+n*(Math.random()-.5),s,i*(Math.random()-.5)),doCustom.push((()=>{!a&&m.pos.x>e-100&&m.pos.x<e+2700&&m.pos.y>t-1300&&m.pos.y<t&&(a=!0,spawn.randomMob(e+1175,t-725,0),spawn.randomMob(e+1450,t-725,0),spawn.randomMob(e+425,t-100,0),spawn.randomMob(e+1200,t-125,0),spawn.randomMob(e+1300,t-375,0)),ctx.fillStyle="#d4f4f4",ctx.fillRect(e+1600,t-1300,400,350)}))}let a=!1;doCustomTopLayer.push((()=>{ctx.fillStyle="#233",ctx.beginPath(),ctx.arc(balance1.pointA.x,balance1.pointA.y,9,0,2*Math.PI),ctx.moveTo(balance2.pointA.x,balance2.pointA.y),ctx.arc(balance2.pointA.x,balance2.pointA.y,9,0,2*Math.PI),ctx.moveTo(balance3.pointA.x,balance3.pointA.y),ctx.arc(balance3.pointA.x,balance3.pointA.y,9,0,2*Math.PI),ctx.moveTo(balance4.pointA.x,balance4.pointA.y),ctx.arc(balance4.pointA.x,balance4.pointA.y,9,0,2*Math.PI),ctx.fill()}))}],emptyOptions=[(a=offset.x,o=offset.y)=>{if(!e&&t){powerUps.spawnStartingPowerUps(a+2e3-1650,o+-400),spawn.mapRect(a+2e3-1575-25,o+-625,25,375),spawn.mapRect(a+2e3-1575-25,o+-1325,25,525),spawn.mapRect(a+2e3-1525-250,o+-350,250,450),spawn.mapRect(a+2e3-245-300,o+-200,300,100),spawn.mapRect(a+2e3-530-25,o+-190,25,80);const e=level.button(a+2e3-290-140,o-200);e.isReadyToFire=!0,doCustom.push((()=>{ctx.fillStyle="rgba(0,0,0,0.05)",ctx.fillRect(a+2e3-255-280,o+-100,280,100),e.query(),e.draw(),!e.isReadyToFire&&e.isUp?e.isReadyToFire=!0:e.isReadyToFire&&!e.isUp&&(e.isReadyToFire=!1,b.pulse(90,Math.PI,{x:a+2e3-560,y:o-150}))})),spawn.randomMob(a+2e3-1600,o+-425,0),spawn.randomMob(a+2e3-1725,o+-1250,0),spawn.randomMob(a+2e3-1250,o+-1200,0),spawn.randomMob(a+2e3-300,o+-1200,0),spawn.randomMob(a+2e3-800,o+-125,0);let t=spawn.pickList[Math.floor(Math.random()*spawn.pickList.length)];spawn[t](a+2e3-1275,o+-150,90+40*Math.random())}else{powerUps.spawnStartingPowerUps(a+1650,o+-400),spawn.mapRect(a+1575,o+-625,25,375),spawn.mapRect(a+1575,o+-1325,25,525),spawn.mapRect(a+1525,o+-350,250,450),spawn.mapRect(a+245,o+-200,300,100),spawn.mapRect(a+530,o+-190,25,80);const e=level.button(a+290,o-200);e.isReadyToFire=!0,doCustom.push((()=>{ctx.fillStyle="rgba(0,0,0,0.05)",ctx.fillRect(a+255,o+-100,280,100),e.query(),e.draw(),!e.isReadyToFire&&e.isUp?e.isReadyToFire=!0:e.isReadyToFire&&!e.isUp&&(e.isReadyToFire=!1,b.pulse(90,0,{x:a+560,y:o-150}))})),spawn.randomMob(a+1600,o+-425,0),spawn.randomMob(a+1725,o+-1250,0),spawn.randomMob(a+1250,o+-1200,0),spawn.randomMob(a+300,o+-1200,0),spawn.randomMob(a+800,o+-125,0);let t=spawn.pickList[Math.floor(Math.random()*spawn.pickList.length)];spawn[t](a+1275,o+-150,90+40*Math.random())}},(a=offset.x,o=offset.y)=>{if(!e&&t){powerUps.spawnStartingPowerUps(a+1650,o+-400),spawn.mapRect(a+2e3-1575-25,o+-625,25,375),spawn.mapRect(a+2e3-1575-25,o+-1325,25,525),spawn.mapRect(a+2e3-1525-250,o+-350,250,450),spawn.mapRect(a+2e3-245-300,o+-200,300,100),spawn.mapRect(a+2e3-530-25,o+-190,25,80);const e=level.button(a+2e3-290-140,o-200);e.isReadyToFire=!0,doCustom.push((()=>{ctx.fillStyle="rgba(0,0,0,0.05)",ctx.fillRect(a+2e3-255-280,o+-100,280,100),e.query(),e.draw(),!e.isReadyToFire&&e.isUp?e.isReadyToFire=!0:e.isReadyToFire&&!e.isUp&&(e.isReadyToFire=!1,fireBlock=function(e,t){const a=body.length;spawn.bodyRect(e,t,35+50*Math.random(),35+50*Math.random());const o=body[body.length-1];Matter.Body.setVelocity(body[a],{x:-120,y:-5}),body[a].collisionFilter.category=cat.body,body[a].collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.mob|cat.mobBullet,body[a].classType="body",Composite.add(engine.world,body[a]),setTimeout((()=>{for(let e=0;e<body.length;e++)body[e]===o&&(Matter.Composite.remove(engine.world,body[e]),body.splice(e,1))}),1e3)},fireBlock(a+2e3-90-560+30*Math.random(),o-140),fireBlock(a+2e3-90-560+30*Math.random(),o-160),fireBlock(a+2e3-90-560+30*Math.random(),o-180),fireBlock(a+2e3-90-560+30*Math.random(),o-200),fireBlock(a+2e3-90-560+30*Math.random(),o-220),fireBlock(a+2e3-90-560+30*Math.random(),o-240))})),spawn.randomMob(a+2e3-1600,o+-425,0),spawn.randomMob(a+2e3-1725,o+-1250,0),spawn.randomMob(a+2e3-1250,o+-1200,0),spawn.randomMob(a+2e3-300,o+-1200,0),spawn.randomMob(a+2e3-800,o+-125,0);let t=spawn.pickList[Math.floor(Math.random()*spawn.pickList.length)];spawn[t](a+2e3-1275,o+-150,90+40*Math.random())}else{powerUps.spawnStartingPowerUps(a+1650,o+-400),spawn.mapRect(a+1575,o+-625,25,375),spawn.mapRect(a+1575,o+-1325,25,525),spawn.mapRect(a+1525,o+-350,250,450),spawn.mapRect(a+245,o+-200,300,100),spawn.mapRect(a+530,o+-190,25,80);const e=level.button(a+290,o-200);e.isReadyToFire=!0,doCustom.push((()=>{ctx.fillStyle="rgba(0,0,0,0.05)",ctx.fillRect(a+255,o+-100,280,100),e.query(),e.draw(),!e.isReadyToFire&&e.isUp?e.isReadyToFire=!0:e.isReadyToFire&&!e.isUp&&(e.isReadyToFire=!1,fireBlock=function(e,t){const a=body.length;spawn.bodyRect(e,t,35+50*Math.random(),35+50*Math.random());const o=body[body.length-1];Matter.Body.setVelocity(body[a],{x:120,y:-5}),body[a].collisionFilter.category=cat.body,body[a].collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.mob|cat.mobBullet,body[a].classType="body",Composite.add(engine.world,body[a]),setTimeout((()=>{for(let e=0;e<body.length;e++)body[e]===o&&(Matter.Composite.remove(engine.world,body[e]),body.splice(e,1))}),1e3)},fireBlock(a+560+30*Math.random(),o-140),fireBlock(a+560+30*Math.random(),o-160),fireBlock(a+560+30*Math.random(),o-180),fireBlock(a+560+30*Math.random(),o-200),fireBlock(a+560+30*Math.random(),o-220),fireBlock(a+560+30*Math.random(),o-240))})),spawn.randomMob(a+1600,o+-425,0),spawn.randomMob(a+1725,o+-1250,0),spawn.randomMob(a+1250,o+-1200,0),spawn.randomMob(a+300,o+-1200,0),spawn.randomMob(a+800,o+-125,0);let t=spawn.pickList[Math.floor(Math.random()*spawn.pickList.length)];spawn[t](a+1275,o+-150,90+40*Math.random())}},(a=offset.x,o=offset.y)=>{if(!e&&t){powerUps.spawnStartingPowerUps(a+2e3-1650,o+-400),spawn.mapRect(a+2e3-1575-25,o+-625,25,375),spawn.mapRect(a+2e3-1575-25,o+-1325,25,525),spawn.mapRect(a+2e3-1525-250,o+-350,250,450),spawn.mapRect(a+2e3-175-370,o+-200,370,100),spawn.mapRect(a+2e3-530-25,o+-190,25,80),spawn.mapRect(a+2e3-545-10,o+-770,10,325),spawn.mapRect(a+2e3-620-10,o+-770,10,325),spawn.mapRect(a+2e3+50-150,o+-425,150,50),spawn.mapRect(a+2e3-175-370,o+-650,370,50),spawn.mapRect(a+2e3-540-95,o+-460,95,15);const e=map[map.length-1];for(let e=0;e<6;e++)spawn.bodyRect(a+2e3-60-555+Math.floor(10*Math.random()),o+-520-50*e,50,50);spawn.bodyRect(a+2e3-250-40,o+-700,40,50),spawn.bodyRect(a+2e3-350-30,o+-700,30,35),spawn.bodyRect(a+2e3-425-40,o+-700,40,70);const t=level.button(a+2e3-280-140,o-200);t.isReadyToFire=!0,doCustom.push((()=>{if(ctx.fillStyle="rgba(0,0,0,0.05)",ctx.fillRect(a+2e3-200-325,o+-625,325,650),t.query(),t.draw(),!t.isReadyToFire&&t.isUp)t.isReadyToFire=!0,e.collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.mob|cat.mobBullet;else if(t.isReadyToFire&&!t.isUp)t.isReadyToFire=!1,e.collisionFilter.mask=0;else if(!t.isUp){const e={min:{x:a+2e3-580,y:o-125},max:{x:a+2e3-530,y:o-110}},t=Matter.Query.region(body,e);for(let e=0,a=t.length;e<a;e++)Matter.Body.setVelocity(t[e],{x:-120,y:-5});Matter.Query.region([player],e).length&&Matter.Body.setVelocity(player,{x:-100,y:-5}),ctx.fillStyle=`rgba(255,0,255,${.2+.7*Math.random()})`,ctx.fillRect(e.min.x,o-185,38,70)}})),spawn.randomMob(a+2e3-1600,o+-425,0),spawn.randomMob(a+2e3-1725,o+-1250,0),spawn.randomMob(a+2e3-1250,o+-1200,0),spawn.randomMob(a+2e3-300,o+-1200,0),spawn.randomMob(a+2e3-800,o+-125,0);let l=spawn.pickList[Math.floor(Math.random()*spawn.pickList.length)];spawn[l](a+2e3-1275,o+-150,90+40*Math.random())}else{powerUps.spawnStartingPowerUps(a+1650,o+-400),spawn.mapRect(a+1575,o+-625,25,375),spawn.mapRect(a+1575,o+-1325,25,525),spawn.mapRect(a+1525,o+-350,250,450),spawn.mapRect(a+175,o+-200,370,100),spawn.mapRect(a+530,o+-190,25,80),spawn.mapRect(a+545,o+-770,10,325),spawn.mapRect(a+620,o+-770,10,325),spawn.mapRect(a-50,o+-425,150,50),spawn.mapRect(a+175,o+-650,370,50),spawn.mapRect(a+540,o+-460,95,15);const e=map[map.length-1];for(let e=0;e<6;e++)spawn.bodyRect(a+555+Math.floor(10*Math.random()),o+-520-50*e,50,50);spawn.bodyRect(a+250,o+-700,40,50),spawn.bodyRect(a+350,o+-700,30,35),spawn.bodyRect(a+425,o+-700,40,70);const t=level.button(a+280,o-200);t.isReadyToFire=!0,doCustom.push((()=>{if(ctx.fillStyle="rgba(0,0,0,0.05)",ctx.fillRect(a+200,o+-625,325,650),t.query(),t.draw(),!t.isReadyToFire&&t.isUp)t.isReadyToFire=!0,e.collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.mob|cat.mobBullet;else if(t.isReadyToFire&&!t.isUp)t.isReadyToFire=!1,e.collisionFilter.mask=0;else if(!t.isUp){const e={min:{x:a+530,y:o-125},max:{x:a+580,y:o-110}},t=Matter.Query.region(body,e);for(let e=0,a=t.length;e<a;e++)Matter.Body.setVelocity(t[e],{x:120,y:-5});Matter.Query.region([player],e).length&&Matter.Body.setVelocity(player,{x:100,y:-5}),ctx.fillStyle=`rgba(255,0,255,${.2+.7*Math.random()})`,ctx.fillRect(e.min.x,o-185,38,70)}})),spawn.randomMob(a+1600,o+-425,0),spawn.randomMob(a+1725,o+-1250,0),spawn.randomMob(a+1250,o+-1200,0),spawn.randomMob(a+300,o+-1200,0),spawn.randomMob(a+800,o+-125,0);let l=spawn.pickList[Math.floor(Math.random()*spawn.pickList.length)];spawn[l](a+1275,o+-150,90+40*Math.random())}}],lootOptions=[(e=offset.x,t=offset.y)=>{spawn.mapRect(e+1925,t+-325,125,150),spawn.mapRect(e+1925,t+-865,125,150),spawn.mapRect(e+-50,t+-325,125,150),spawn.mapRect(e+-50,t+-865,125,150),spawn.mapRect(e+1700,t+-500,200,25),spawn.mapRect(e+75,t+-500,200,25);let a=-650;Math.random()>.5?(a=-1290,spawn.mapRect(e+550,t+-10-640,900,25),spawn.mapRect(e+450,t+-20-640,1100,25),spawn.mapRect(e+450,t+-675-640,1100,25),powerUps.directSpawn(e+998,t-333-640,"tech",!1),spawn.mapVertex(e+1e3,t+-0,"575 0 -575 0 -450 -100 450 -100")):(spawn.mapRect(e+400,t+-10,1200,50),spawn.mapRect(e+450,t+-20,1100,50),spawn.mapRect(e+450,t+-675,1100,25),spawn.mapRect(e+550,t+-685,900,25),powerUps.directSpawn(e+998,t-333,"tech",!1));const o=powerUp[powerUp.length-1];o.holdPosition={x:o.position.x,y:o.position.y};let l=!1;doCustom.push((()=>{if(ctx.fillStyle="#e4e4e9",ctx.fillRect(e+450,t+a,1100,650),0!==o.velocity.y){if(ctx.strokeStyle="#f0f",ctx.lineWidth=2,Vector.magnitudeSquared(Vector.sub(m.pos,o.position))<9e4){m.immuneCycle<m.cycle&&(m.damage(.01),m.energy>.1&&(m.energy-=.02));const e=Vector.normalise(Vector.sub(m.pos,o.position));let t=o.position.x+40*e.x,a=o.position.y+40*e.y;ctx.beginPath(),ctx.moveTo(t,a);const l=40;for(let o=0;o<6;o++)t+=l*(e.x+1.5*(Math.random()-.5)),a+=l*(e.y+1.5*(Math.random()-.5)),ctx.lineTo(t,a)}else{const e=2*Math.random()*Math.PI,t=Math.cos(e),a=Math.sin(e);let l=o.position.x+40*t,n=o.position.y+40*a;ctx.beginPath(),ctx.moveTo(l,n);const s=40;for(let e=0;e<6;e++)l+=s*(t+1.5*(Math.random()-.5)),n+=s*(a+1.5*(Math.random()-.5)),ctx.lineTo(l,n)}ctx.lineWidth=2*Math.random(),ctx.stroke(),ctx.beginPath(),ctx.arc(o.position.x,o.position.y,300,0,2*Math.PI),ctx.stroke(),Matter.Body.setPosition(o,{x:o.holdPosition.x+4*Math.random(),y:o.holdPosition.y+4*Math.random()}),Matter.Body.setVelocity(o,{x:0,y:0})}else l||(l=!0,-650===a?(spawn.randomMob(e+250,t+-650,0),spawn.randomMob(e+1825,t+-600,0),spawn.randomGroup(e+275,t+-1050,0),spawn.randomGroup(e+675,t+-975,0),spawn.randomGroup(e+1225,t+-975,1/0)):(spawn.randomMob(e+250,t+-650,0),spawn.randomMob(e+1800,t+-625,0),spawn.randomGroup(e+300,t+-300,0),spawn.randomGroup(e+650,t+-275,0),spawn.randomGroup(e+1125,t+-300,1/0)))}))}],upDownOptions=[(e=offset.x,t=offset.y)=>{const a=level.toggle(e+950,t+0,!1,!0);a.isAddedElements=!1,spawn.mapVertex(e+5,t+-1318,"0 0 0 -250 125 -250"),spawn.mapVertex(e+1995,t+-1318,"0 0 0 -250 -125 -250"),doCustomTopLayer.push((()=>{if(a.query(),a.isOn&&!a.isAddedElements){a.isAddedElements=!0,addMapToLevelInProgress=e=>{e.collisionFilter.category=cat.map,e.collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet,Matter.Body.setStatic(e,!0),Composite.add(engine.world,e)};let o=150,l=`${o} 0 ${o*Math.cos(5.236)} ${o*Math.sin(5.236)} ${o*Math.cos(4.189)} ${o*Math.sin(4.189)} ${-o} 0 ${o*Math.cos(2.0944)} ${o*Math.sin(2.0944)} ${o*Math.cos(1.0472)} ${o*Math.sin(1.0472)} `;if(Math.random()<.5){spawn.mapVertex(e+775,t+-260,l),spawn.mapVertex(e+1225,t+-260,l),spawn.mapVertex(e+550,t+-650,l),spawn.mapVertex(e+1e3,t+-650,l),spawn.mapVertex(e+1450,t+-650,l),spawn.mapVertex(e+325,t+-1040,l),spawn.mapVertex(e+775,t+-1040,l),spawn.mapVertex(e+1225,t+-1040,l),spawn.mapVertex(e+1675,t+-1040,l),spawn.mapVertex(e+550,t+-1430,l),spawn.mapVertex(e+1e3,t+-1430,l),spawn.mapVertex(e+1450,t+-1430,l);const a=12;for(let e=0;e<a;e++)addMapToLevelInProgress(map[map.length-1-e]);spawn.randomMob(e+225,t+-1775,0),spawn.randomMob(e+700,t+-1750,0),spawn.randomMob(e+1175,t+-1725,0),spawn.randomMob(e+1700,t+-1700,0),spawn.randomMob(e+1750,t+-250,0),spawn.randomMob(e+125,t+-250,0)}else{spawn.mapVertex(e+775,t+-260,l),spawn.mapVertex(e+1225,t+-260,l),spawn.mapVertex(e+550,t+-650,l),spawn.mapVertex(e+1e3,t+-650,l),spawn.mapVertex(e+1450,t+-650,l),spawn.mapVertex(e+775,t+-1040,l),spawn.mapVertex(e+1225,t+-1040,l),spawn.mapVertex(e+550,t+-1430,l),spawn.mapVertex(e+1e3,t+-1430,l),spawn.mapVertex(e+1450,t+-1430,l),spawn.mapVertex(e+775,t+-1820,l),spawn.mapVertex(e+1225,t+-1820,l);const a=12;for(let e=0;e<a;e++)addMapToLevelInProgress(map[map.length-1-e]);spawn.randomMob(e+225,t+-1025,0),spawn.randomMob(e+200,t+-675,0),spawn.randomMob(e+225,t+-200,0),spawn.randomMob(e+1750,t+-1075,0),spawn.randomMob(e+1700,t+-650,0),spawn.randomMob(e+1675,t+-175,0)}simulation.draw.setPaths(),spawn.randomGroup(e+300,t+-2200),spawn.randomGroup(e+1625,t+-2200),spawn.randomLevelBoss(e+700,t+-2300),spawn.secondaryBossChance(e+1250,t+-2300)}}))},(e=offset.x,t=offset.y)=>{const a=level.toggle(e+950,t+0,!1,!0);a.isAddedElements=!1,spawn.mapVertex(e+5,t+-1868,"0 0 0 -250 125 -250"),spawn.mapVertex(e+5,t+-1318,"0 0 0 -250 125 -250"),spawn.mapVertex(e+5,t+-768,"0 0 0 -250 125 -250"),spawn.mapVertex(e+2e3,t+-1868,"0 0 0 -250 -125 -250"),spawn.mapVertex(e+2e3,t+-1318,"0 0 0 -250 -125 -250"),spawn.mapVertex(e+2e3,t+-768,"0 0 0 -250 -125 -250"),doCustomTopLayer.push((()=>{if(a.query(),a.isOn&&!a.isAddedElements){a.isAddedElements=!0,addMapToLevelInProgress=e=>{e.collisionFilter.category=cat.map,e.collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet,Matter.Body.setStatic(e,!0),Composite.add(engine.world,e)};let o=300,l=`${o} 0 ${o*Math.cos(5.236)} ${o*Math.sin(5.236)} ${o*Math.cos(4.189)} ${o*Math.sin(4.189)} ${-o} 0 ${o*Math.cos(2.0944)} ${o*Math.sin(2.0944)} ${o*Math.cos(1.0472)} ${o*Math.sin(1.0472)} `;spawn.mapVertex(e+1640,t+-365,l),o=150;const n=`${o} 0 ${o*Math.cos(5.236)} ${o*Math.sin(5.236)} ${o*Math.cos(4.189)} ${o*Math.sin(4.189)} ${-o} 0 ${o*Math.cos(2.0944)} ${o*Math.sin(2.0944)} ${o*Math.cos(1.0472)} ${o*Math.sin(1.0472)} `;spawn.mapVertex(e+1750,t+-1100,n),spawn.mapVertex(e+1750,t+-1650,n),spawn.mapVertex(e+1750,t+-2200,n),o=350;let s=`${o} 0 ${o*Math.cos(5.236)} ${o*Math.sin(5.236)} ${o*Math.cos(4.189)} ${o*Math.sin(4.189)} ${-o} 0 `;spawn.mapVertex(e+425,t+-90,s),spawn.mapVertex(e+850,t+-500,n),spawn.mapVertex(e+550,t+-850,n),spawn.mapVertex(e+250,t+-1200,n),spawn.mapVertex(e+250,t+-1700,n),spawn.mapVertex(e+725,t+-1950,n),spawn.mapVertex(e+1200,t+-2200,n);const p=11;for(let e=0;e<p;e++)addMapToLevelInProgress(map[map.length-1-e]);spawn.randomMob(e+1075,t+-1500,0),spawn.randomMob(e+325,t+-550,0),spawn.randomMob(e+800,t+-925,0),spawn.randomMob(e+1400,t+-1250,0),spawn.randomMob(e+1350,t+-1725,0),spawn.randomMob(e+575,t+-1375,0),spawn.randomMob(e+225,t+-2275,0),spawn.randomMob(e+875,t+-2450,0),spawn.randomMob(e+1550,t+-2525,0),spawn.randomLevelBoss(e+1075,t+-1500),spawn.secondaryBossChance(e+1200,t+-1e3),simulation.draw.setPaths()}}))}],enter=enterOptions[Math.floor(Math.random()*enterOptions.length)],exit=exitOptions[Math.floor(Math.random()*exitOptions.length)],empty=emptyOptions[Math.floor(Math.random()*emptyOptions.length)],loot=lootOptions[Math.floor(Math.random()*lootOptions.length)],upDown=upDownOptions[Math.floor(Math.random()*upDownOptions.length)];let a=["exit","loot","enter","empty"];for(a=shuffle(a);"enter"===a[0]&&"exit"===a[2]||"enter"===a[2]&&"exit"===a[0]||"enter"===a[1]&&"exit"===a[3]||"enter"===a[3]&&"exit"===a[1];)a=shuffle(a);for(let e=0;e<a.length;e++)"enter"===a[e]&&(a[e]=enter),"exit"===a[e]&&(a[e]=exit),"empty"===a[e]&&(a[e]=empty),"loot"===a[e]&&(a[e]=loot);outline=(a=!0)=>{if(spawn.mapRect(offset.x-100,offset.y-1400,2100,100),a&&spawn.mapRect(offset.x-100,offset.y,2200,100),e||spawn.mapRect(offset.x-100,offset.y-1400,100,1500),t){spawn.mapRect(offset.x+2e3,offset.y-1400,100,1225),spawn.mapRect(offset.x+2e3,offset.y-10,100,20);const e=15+Math.floor(100*Math.random()*Math.random());spawn.bodyRect(offset.x+2050-e/2,offset.y-175,e,165)}else spawn.mapRect(offset.x+2e3,offset.y-1400,100,1500)},outlineUpDown=()=>{if(spawn.mapRect(offset.x-100,offset.y+0,2100,100),spawn.mapRect(offset.x-100,offset.y-2800,2100,100),e||spawn.mapRect(offset.x-100,offset.y-2800,100,2900),t){spawn.mapRect(offset.x+2e3,offset.y-2800,100,1225),spawn.mapRect(offset.x+2e3,offset.y-1410,100,20);const e=15+Math.floor(100*Math.random()*Math.random());spawn.bodyRect(offset.x+2050-e/2,offset.y-1575,e,165),spawn.mapRect(offset.x+2e3,offset.y-1400,100,1225),spawn.mapRect(offset.x+2e3,offset.y-10,100,20);const t=15+Math.floor(100*Math.random()*Math.random());spawn.bodyRect(offset.x+2050-t/2,offset.y-175,t,165)}else spawn.mapRect(offset.x+2e3,offset.y-2800,100,2900)};let o=[()=>{offset.y=0,outlineUpDown(),upDown()},()=>{offset.y=0,outline(),a[0](),offset.y=-1400,outline(!1),a[1]()},()=>{offset.y=0,outline(),a[2](),offset.y=-1400,outline(!1),a[3]()}];o=shuffle(o);for(let a=0;a<3;a++)0===a?(e=!1,t=!0):1===a?(e=!0,t=!0):(e=!0,t=!1),offset.x=2100*a,o[a]();level.custom=()=>{for(let e=0,t=doCustom.length;e<t;e++)doCustom[e]();level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{for(let e=0,t=doCustomTopLayer.length;e<t;e++)doCustomTopLayer[e]()},powerUps.addResearchToLevel()},null(){level.levels.pop(),localSettings.loreCount<lore.conversation.length&&!simulation.isCheating&&(lore.testSpeechAPI(),lore.chapter=localSettings.loreCount,lore.sentence=0,lore.conversation[lore.chapter][lore.sentence](),localSettings.loreCount++,localStorage.setItem("localSettings",JSON.stringify(localSettings))),level.isHazardRise=!1;const e=level.hazard(-1800,-800,3600,1600,.004,"hsla(160, 100%, 35%,0.75)");e.height-=950,e.min.y+=950,e.max.y=e.min.y+e.height;const t=0,a=-500,o=50;level.custom=()=>{ctx.beginPath(),ctx.moveTo(t,-800),ctx.lineTo(t,a),ctx.lineWidth=40,ctx.strokeStyle=lore.talkingColor,ctx.globalAlpha=.03,ctx.stroke(),ctx.globalAlpha=1,ctx.fillStyle="rgba(0,0,0,0.2)",ctx.fillRect(-25,0,50,1e3),ctx.beginPath(),ctx.arc(t,a,o,0,2*Math.PI),ctx.fillStyle="#bcc",ctx.fill(),ctx.lineWidth=2,ctx.strokeStyle="#abb",ctx.stroke(),ctx.beginPath(),ctx.arc(t,a,o/8,0,2*Math.PI),ctx.fillStyle=lore.talkingColor,ctx.fill()};let l={x:0,y:0},n=-Math.PI/2;level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-1950,-950,3900,1900),ctx.beginPath();const s=Math.PI/20;simulation.isCheating&&(n+=.3*Math.random()*Math.random()),l.x=.995*l.x+.005*(m.pos.x-t)*.05,l.y=2.5*Math.sin(.015*simulation.cycle);for(let e=-19.5;e<20;e++){const p={x:t+o*Math.cos(e*s+n),y:a+o*Math.sin(e*s+n)};ctx.moveTo(p.x,p.y),ctx.bezierCurveTo(l.x*Math.abs(e)+p.x,p.y+25*Math.abs(e)+60+l.y*Math.sqrt(Math.abs(e)),l.x*Math.abs(e)+p.x+85*e,p.y+25*Math.abs(e)+60+l.y*Math.sqrt(Math.abs(e)),85*e,-800)}ctx.lineWidth=.5,ctx.strokeStyle="#899",ctx.stroke(),e.query(),level.isHazardRise&&e.level(!0)},level.setPosToSpawn(0,-50),spawn.mapRect(level.enter.x,level.enter.y+25,100,10),level.exit.x=0,level.exit.y=4e4,level.defaultZoom=1e3,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#ddd",spawn.mapRect(-3e3,800,5e3,1200),spawn.mapRect(-2e3,-2e3,5e3,1200),spawn.mapRect(-3e3,-2e3,1200,3400),spawn.mapRect(1800,-1400,1200,3400),spawn.mapRect(-500,0,1e3,50),spawn.mapRect(-500,-25,25,50),spawn.mapRect(475,-25,25,50)},testing(){const e=level.button(1e3,0);spawn.bodyRect(1e3,-50,50,50),level.custom=()=>{ctx.fillStyle="rgba(0,255,255,0.1)",ctx.fillRect(6400,-550,300,350),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{e.query(),e.draw(),t.query(),a.query(),o.query(),l.query(),n.query()};const t=level.vanish(1400,-200,200,50),a=level.vanish(1825,-150,150,150),o=level.vanish(1975,-150,150,150),l=level.vanish(1825,-300,150,150),n=level.vanish(1975,-300,150,150);level.setPosToSpawn(0,-450),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=6500,level.exit.y=-230,spawn.setSpawnList(),spawn.setSpawnList(),level.defaultZoom=1500,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor=color.background,spawn.mapRect(-950,0,8200,800),spawn.mapRect(-950,-1200,800,1400),spawn.mapRect(-950,-1800,8200,800),spawn.mapRect(-250,-400,1e3,600),spawn.mapRect(-250,-1200,1e3,550),spawn.mapRect(2500,-1200,200,750),spawn.mapRect(2500,-200,200,300),spawn.mapRect(4500,-1200,200,650),function(e,t,a=58){spawn.mapRect(e,t-290,40,60),spawn.mapRect(e,t,40,50);for(let o=0;o<4;++o)spawn.bodyRect(e+5,t-260+o*a,30,a)}(4585,-310),spawn.mapRect(4500,-300,200,400),spawn.mapRect(6400,-1200,400,750),spawn.mapRect(6400,-200,400,300),spawn.mapRect(6700,-1800,800,2600),spawn.mapRect(level.exit.x,level.exit.y+20,100,100),spawn.mapRect(4650,-300,1150,50),spawn.mapRect(5750,-300,50,200),spawn.mapRect(5575,-100,50,125),spawn.mapRect(5300,-275,50,175),spawn.mapRect(5050,-100,50,150),spawn.mapRect(4850,-275,50,175),level.difficultyIncrease(1),m.addHealth(1/0)},template(){level.custom=()=>{level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{},level.setPosToSpawn(0,-50),level.exit.x=1500,level.exit.y=-1875,spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.defaultZoom=1800,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#d8dadf",spawn.mapRect(-100,0,1e3,100),powerUps.addResearchToLevel()},final(){level.custom=()=>{level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.1)",ctx.fillRect(5400,-550,300,350)},level.setPosToSpawn(0,-250),spawn.mapRect(5500,-310,100,20),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=55e4,level.exit.y=-330,level.defaultZoom=2500,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#ddd",powerUps.spawn(1675,-50,"ammo"),powerUps.spawn(3350,-75,"ammo"),powerUps.spawn(3925,-50,"ammo"),powerUps.spawn(4250,-75,"ammo"),powerUps.spawn(4550,-75,"ammo"),powerUps.spawn(5025,-50,"ammo"),powerUps.spawn(4725,-50,"ammo"),powerUps.spawn(4975,-350,"ammo"),powerUps.spawn(5125,-350,"ammo"),powerUps.spawn(5075,-425,"ammo"),powerUps.spawn(5050,-400,"ammo"),powerUps.spawn(5075,-425,"ammo"),spawn.mapRect(-1950,0,8200,1800),spawn.mapRect(-1950,-1500,1800,1900),spawn.mapRect(-1950,-3300,8200,1800),spawn.mapRect(-250,-200,1e3,300),spawn.mapRect(-250,-1700,1e3,1250),spawn.blockDoor(710,-210),spawn.finalBoss(3e3,-750),spawn.mapRect(5400,-1700,400,1150),spawn.mapRect(5400,-300,400,400),spawn.mapRect(5700,-3300,1800,5100),spawn.mapRect(level.exit.x,level.exit.y+20,100,100),spawn.mapRect(5425,-650,375,450),simulation.isHorizontalFlipped&&(level.flipHorizontal(),level.setPosToSpawn(0,-250),level.custom=()=>{level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.1)",ctx.fillRect(-5700,-550,300,350)})},gauntlet(){level.custom=()=>{level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.1)",ctx.fillRect(6400,-550,300,350),ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-175,-975,900,575)},level.setPosToSpawn(0,-475),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=6500,level.exit.y=-230,level.defaultZoom=1500,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#ddd",spawn.mapRect(-950,0,8200,800),spawn.mapRect(-950,-1200,800,1400),spawn.mapRect(-950,-1800,8200,800),spawn.mapRect(175,-700,575,950),spawn.mapRect(-250,-425,600,650),spawn.mapRect(-250,-1200,1e3,250),powerUps.spawnStartingPowerUps(600,-800),spawn.blockDoor(710,-710),spawn[spawn.pickList[0]](1500,-200,150+30*Math.random()),spawn.mapRect(2500,-1200,200,750),spawn.blockDoor(2585,-210),spawn.mapRect(2500,-200,200,300),spawn.nodeGroup(3500,-200,spawn.allowedGroupList[Math.floor(Math.random()*spawn.allowedGroupList.length)]),spawn.mapRect(4500,-1200,200,750),spawn.blockDoor(4585,-210),spawn.mapRect(4500,-200,200,300),spawn.lineGroup(5e3,-200,spawn.allowedGroupList[Math.floor(Math.random()*spawn.allowedGroupList.length)]),spawn.mapRect(6400,-1200,400,750),spawn.mapRect(6400,-200,400,300),spawn.mapRect(6700,-1800,800,2600),spawn.mapRect(level.exit.x,level.exit.y+20,100,100);for(let e=0;e<3;++e)simulation.difficulty*Math.random()>15*e&&spawn.randomGroup(2e3+500*(Math.random()-.5),200*(Math.random()-.5)-800,1/0),simulation.difficulty*Math.random()>10*e&&spawn.randomGroup(3500+500*(Math.random()-.5),200*(Math.random()-.5)-800,1/0),simulation.difficulty*Math.random()>7*e&&spawn.randomGroup(5e3+500*(Math.random()-.5),200*(Math.random()-.5)-800,1/0);powerUps.addResearchToLevel(),spawn.secondaryBossChance(4125,-350),simulation.isHorizontalFlipped&&(level.flipHorizontal(),level.setPosToSpawn(0,-475),level.custom=()=>{level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.1)",ctx.fillRect(-6700,-550,300,350),ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-725,-975,900,575)})},intro(){if(0===level.levelsCleared){if(requestAnimationFrame((function e(){simulation.cycle>10?(powerUps.spawn(2095+15*(Math.random()-.5),-2070,"research",!1),powerUps.spawn(2095+15*(Math.random()-.5),-2095,"heal",!1),powerUps.spawn(2095+15*(Math.random()-.5),-2145,"heal",!1),powerUps.spawnStartingPowerUps(2095+15*(Math.random()-.5),-2195)):requestAnimationFrame(e)})),localSettings.levelsClearedLastGame<3)simulation.isCheating||m.isShipMode||build.isExperimentRun||(spawn.wireFoot(),spawn.wireFootLeft(),spawn.wireKnee(),spawn.wireKneeLeft(),spawn.wireHead());else if(!build.isExperimentRun&&(simulation.trails(),!simulation.isCheating&&localSettings.levelsClearedLastGame>1)){for(let e=0;e<localSettings.levelsClearedLastGame/3;e++)powerUps.spawn(2095+2*Math.random(),-1270-50*e,"tech",!1);simulation.makeTextLog("for (let i <span class='color-symbol'>=</span> 0; i <span class='color-symbol'><</span> localSettings.levelsClearedLastGame <span class='color-symbol'>/</span> 3; i<span class='color-symbol'>++</span>)"),simulation.makeTextLog('{ powerUps.spawn(m.pos.x, m.pos.y, "tech") <em>//simulation superposition</em>}'),localSettings.levelsClearedLastGame=0,localStorage.setItem("localSettings",JSON.stringify(localSettings))}spawn.mapRect(2025,0,150,50)}else for(let e=0;e<60;e++)setTimeout((()=>{spawn.sneaker(2100,-1500-50*e)}),2e3+500*e);const e=new Path2D;e.moveTo(-150,-275),e.lineTo(80,-275),e.lineTo(80,-1e3),e.moveTo(-150,-265),e.lineTo(90,-265),e.lineTo(90,-1e3),e.moveTo(-150,-255),e.lineTo(100,-255),e.lineTo(100,-1e3),e.moveTo(-150,-245),e.lineTo(1145,-245),e.lineTo(1145,0),e.moveTo(-150,-235),e.lineTo(1135,-235),e.lineTo(1135,0),e.moveTo(-150,-225),e.lineTo(1125,-225),e.lineTo(1125,0),e.moveTo(-150,-215),e.lineTo(460,-215),e.lineTo(460,0),e.moveTo(-150,-205),e.lineTo(450,-205),e.lineTo(450,0),e.moveTo(-150,-195),e.lineTo(440,-195),e.lineTo(440,0),e.moveTo(1155,0),e.lineTo(1155,-450),e.lineTo(1e3,-450),e.lineTo(1e3,-1e3),e.moveTo(1165,0),e.lineTo(1165,-460),e.lineTo(1010,-460),e.lineTo(1010,-1e3),e.moveTo(1175,0),e.lineTo(1175,-470),e.lineTo(1020,-470),e.lineTo(1020,-1e3),e.moveTo(1185,0),e.lineTo(1185,-480),e.lineTo(1030,-480),e.lineTo(1030,-1e3),e.moveTo(1195,0),e.lineTo(1195,-490),e.lineTo(1040,-490),e.lineTo(1040,-1e3),e.moveTo(1625,-1e3),e.lineTo(1625,0),e.moveTo(1635,-1e3),e.lineTo(1635,0),e.moveTo(1645,-1e3),e.lineTo(1645,0),e.moveTo(1655,-1e3),e.lineTo(1655,0),e.moveTo(1665,-1e3),e.lineTo(1665,0),e.moveTo(1675,-465),e.lineTo(2325,-465),e.lineTo(2325,0),e.moveTo(1675,-455),e.lineTo(2315,-455),e.lineTo(2315,0),e.moveTo(1675,-445),e.lineTo(2305,-445),e.lineTo(2305,0),e.moveTo(1675,-435),e.lineTo(2295,-435),e.lineTo(2295,0),e.moveTo(2335,0),e.lineTo(2335,-710),e.lineTo(2600,-710),e.moveTo(2345,0),e.lineTo(2345,-700),e.lineTo(2600,-700),e.moveTo(2355,0),e.lineTo(2355,-690),e.lineTo(2600,-690),level.custom=()=>{if(!(simulation.cycle%30))for(let e=0,t=powerUp.length;e<t;e++)powerUp[e].position.y<-1e3&&(powerUp[e].force.x+=.01*(Math.random()-.5)*powerUp[e].mass);const t=(localSettings.runCount>>>0).toString(2),a=-40;let o=-130;ctx.strokeStyle="#bff",ctx.lineWidth=1.5,ctx.beginPath();for(let e=0;e<t.length;e++)"0"===t[e]?(ctx.moveTo(o,a),ctx.lineTo(o,-20),ctx.lineTo(o+8,-20),ctx.lineTo(o+8,a),ctx.lineTo(o,a),o+=18):(ctx.moveTo(o,a),ctx.lineTo(o,-20),o+=10);ctx.stroke(),ctx.beginPath(),ctx.strokeStyle="#ccc",ctx.lineWidth=5,ctx.stroke(e),ctx.beginPath(),ctx.rect(1600,-500,90,100),ctx.rect(-55,-285,12,100),ctx.rect(1100,-497,8,54),ctx.rect(2285,-200,80,10),ctx.rect(1110,-70,100,10),ctx.fillStyle="#ccc",ctx.fill(),ctx.fillStyle="#f2f2f2",ctx.fillRect(2600,-600,400,300),level.exit.draw(),level.playerExitCheck()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(2600,-600,400,300),ctx.fillStyle="rgba(68, 68, 68,0.95)",ctx.fillRect(2030,-2800,150,1800),ctx.fillStyle="rgba(68, 68, 68,0.95)",ctx.fillRect(2030,0,150,1800)},level.setPosToSpawn(460,-100),level.exit.x=2800,level.exit.y=-335,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1e3,level.defaultZoom=1600,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor="#e1e1e1",spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(3e3,-2800,2600,4600),spawn.mapRect(-250,0,2300,1800),spawn.mapRect(2150,0,1200,1800),spawn.mapRect(2025,-3,25,15),spawn.mapRect(2150,-3,25,15),spawn.mapRect(-250,-2800,2300,1800),map[map.length-1].friction=0,map[map.length-1].frictionStatic=0,spawn.mapRect(2150,-2800,1200,1800),map[map.length-1].friction=0,map[map.length-1].frictionStatic=0,spawn.mapRect(2025,-1010,25,13),spawn.mapRect(2150,-1010,25,13),spawn.mapRect(2600,-300,500,500),spawn.mapRect(2600,-1200,500,600),spawn.mapRect(-95,-1100,80,110),spawn.mapRect(410,-10,90,20),spawn.bodyRect(2425,-120,70,50),spawn.bodyRect(2400,-100,100,60),spawn.bodyRect(2500,-150,100,150)},ruins(){const e=[];level.exit.x=-850,level.exit.y=-1485,spawn.mapRect(level.exit.x,level.exit.y+25,100,25),level.setPosToSpawn(-900,225),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.defaultZoom=1500,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#dcdcde",spawn.debris(-150,-775,1425,3),spawn.debris(1525,-25,950,3),spawn.debris(-650,-2100,575,2),spawn.mapRect(-200,-750,1500,100),spawn.mapRect(-575,0,3275,500),spawn.mapRect(-1275,275,875,225),spawn.mapRect(-1050,0,325,50),spawn.mapRect(-775,0,50,140),e.push(level.vanish(-725,13,150,25)),spawn.mapRect(-200,-750,100,648),spawn.mapRect(1200,-750,100,648),e.push(level.vanish(-350,-225,150,225)),e.push(level.vanish(-350,-450,150,223)),spawn.mapRect(2475,-1800,250,2300),e.push(level.vanish(1300,-225,150,225)),e.push(level.vanish(1300,-450,150,223)),powerUps.spawnStartingPowerUps(550,-100),spawn.mapRect(125,-12,850,50),spawn.mapRect(175,-25,750,50),spawn.bodyRect(215,-1175,100,100,.3),spawn.mapRect(-1300,-1800,250,2300),Math.random()<.5?(spawn.mapRect(500,-1350,525,425),spawn.mapRect(25,-1050,300,198)):(spawn.mapRect(500,-1350,525,497),spawn.mapRect(25,-1050,300,150)),e.push(level.vanish(550,-1575,50,225)),e.push(level.vanish(925,-1575,50,225)),spawn.bodyRect(225,-850,50,100,.4),spawn.mapRect(600,-1800,325,225),spawn.mapRect(1900,-1500,325,25),spawn.bodyRect(1e3,-1825,250,20,.2),Math.random()<.5?(e.push(level.vanish(1400,-1e3,200,25)),e.push(level.vanish(1625,-1250,200,25))):(e.push(level.vanish(1400,-1075,175,175)),e.push(level.vanish(1575,-1250,175,175))),e.push(level.vanish(1100,-1800,225,25)),e.push(level.vanish(1500,-1800,225,25)),e.push(level.vanish(-50,-1800,400,25)),spawn.mapRect(-1050,-1450,700,25),spawn.mapRect(-1050,-1800,525,25),spawn.mapRect(-550,-1800,25,200),spawn.randomMob(-1175,-1975,-.4),spawn.randomMob(275,-1500,-.3),spawn.randomMob(700,-1875,-.2),spawn.randomMob(2e3,-800,-.2),spawn.randomMob(2600,-1850,0),spawn.randomMob(1425,-525,.1),spawn.randomMob(2025,-1600,.3),spawn.randomMob(1625,-1875,.3),spawn.randomMob(-150,-1975,.4),spawn.randomSmallMob(900,-825),spawn.randomSmallMob(1050,-50),simulation.difficulty>1&&(spawn.randomGroup(750,-2150,-.8),spawn.randomLevelBoss(2050,-2025),spawn.secondaryBossChance(100,-1500)),powerUps.addResearchToLevel(),simulation.isHorizontalFlipped?(level.flipHorizontal(),level.setPosToSpawn(900,225),level.custom=()=>{level.playerExitCheck(),ctx.fillStyle="#d0d3d9",ctx.fillRect(-2500,-1800,3575,2100),ctx.fillStyle="#c0c3c9",ctx.fillRect(-2075,-1475,25,1500),ctx.fillStyle="#cff",ctx.fillRect(550,-1800,525,350),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,10,30,0.1)",ctx.fillRect(-1300,-650,1500,650),ctx.fillRect(725,50,325,225),ctx.fillRect(-325,-950,300,225),ctx.fillRect(-1025,-1e3,525,275),ctx.fillRect(-925,-1600,325,275);for(let t=0,a=e.length;t<a;t++)e[t].query()}):(level.custom=()=>{level.playerExitCheck(),ctx.fillStyle="#d0d3d9",ctx.fillRect(-1075,-1800,3575,2100),ctx.fillStyle="#c0c3c9",ctx.fillRect(2050,-1475,25,1500),ctx.fillStyle="#cff",ctx.fillRect(-1050,-1800,525,350),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,10,30,0.1)",ctx.fillRect(-200,-675,1500,700),ctx.fillRect(500,-950,525,225),ctx.fillRect(600,-1600,325,275),ctx.fillRect(-1050,50,325,225),ctx.fillRect(25,-950,300,225);for(let t=0,a=e.length;t<a;t++)e[t].query()})},testChamber(){level.setPosToSpawn(0,-50),level.exit.y=level.enter.y-550,spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=level.enter.x,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),level.defaultZoom=2200,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#d5d5d5",spawn.mapRect(0,-1955,175,30);const e=map.length-1;spawn.mapRect(1225,-1955,175,30);const t=map.length-1;let a,o,l;const n=level.hazard(simulation.isHorizontalFlipped?-1050:350,-2025,700,10,.4);spawn.mapRect(340,-2032.5,20,25);const s=level.hazard(simulation.isHorizontalFlipped?-1925:1775,-2550,150,10,.4);spawn.mapRect(1920,-2557.5,20,25);const p=level.button(2100,-2600),c=level.button(600,-550),i=level.door(312,-750,25,190,185);level.custom=()=>{if(!(m.cycle%60)){let a=Matter.Query.collides(map[e],body);if(a.length){Matter.Composite.remove(engine.world,a[0].bodyB);for(let e=0,t=body.length;e<t;e++)if(body[e].id===a[0].bodyB.id){body.splice(e,1);break}}if(a=Matter.Query.collides(map[t],body),a.length){Matter.Composite.remove(engine.world,a[0].bodyB);for(let e=0,t=body.length;e<t;e++)if(body[e].id===a[0].bodyB.id){body.splice(e,1);break}}}c.query(),c.draw(),c.isUp?i.isClosing=!0:i.isClosing=!1,i.openClose(),a[2].query(),a[3].query(),o[2].query(),o[3].query(),l[2].query(),l[3].query(),p.isUp?(n.isOn=!1,s.isOn=!1):(n.isOn=!0,s.isOn=!0),p.query(),p.draw(),ctx.fillStyle="#d4f4f4",ctx.fillRect(-300,-1e3,650,500),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{i.draw(),n.opticalQuery(),s.opticalQuery(),a[0].draw(),a[1].draw(),a[2].draw(),a[3].draw(),o[0].draw(),o[1].draw(),o[2].draw(),o[3].draw(),l[0].draw(),l[1].draw(),l[2].draw(),l[3].draw()},powerUps.spawnStartingPowerUps(1875,-3075);const r=shuffle([{x:-150,y:-1775},{x:2400,y:-2650},{x:-175,y:-1375},{x:1325,y:-150}]);powerUps.chooseRandomPowerUp(r[0].x,r[0].y),powerUps.chooseRandomPowerUp(r[1].x,r[1].y),spawn.mapRect(2500,-3700,1200,3800),spawn.mapRect(-1400,-3800,1100,3900),spawn.mapRect(-1400,-4800,5100,1200),spawn.mapRect(-1400,0,5100,1200),spawn.mapRect(300,-375,50,225),spawn.bodyRect(312,-150,25,140),spawn.mapRect(300,-10,50,50),spawn.mapVertex(1555,0,"625 0 75 0 200 -100 500 -100"),spawn.mapRect(-400,-1050,750,50),spawn.mapRect(300,-1050,50,300),spawn.mapRect(300,-560,50,50),spawn.bodyRect(750,-725,125,125),spawn.mapRect(1150,-1050,250,575),spawn.mapRect(1725,-550,50,200),spawn.mapRect(1925,-550,500,200),spawn.mapRect(1750,-390,200,40),spawn.mapRect(-400,-550,1800,200),spawn.mapRect(-200,-1700,150,25),spawn.mapRect(-200,-1325,350,25),spawn.mapRect(2425,-450,100,100),spawn.mapRect(2290,-12,375,100),spawn.mapRect(2350,-24,375,100),spawn.mapRect(2410,-36,375,100),spawn.mapRect(2290,-3012,375,50),spawn.mapRect(2350,-3024,375,50),spawn.mapRect(2410,-3036,375,50),spawn.mapRect(1400,-3e3,1300,50),spawn.mapRect(1750,-3050,250,75),spawn.mapRect(1400,-3625,50,200),spawn.mapRect(350,-3625,50,225),spawn.mapRect(350,-3260,50,60),spawn.mapRect(200,-3250,1240,50),spawn.mapRect(1400,-3260,50,310),spawn.bodyRect(1412,-3425,25,165),spawn.mapRect(-150,-2925,150,25),spawn.mapRect(-300,-2600,300,675),spawn.mapRect(1400,-2600,375,675),spawn.mapRect(1925,-2600,775,675),spawn.bodyRect(2130,-2660,50,50),spawn.mapRect(150,-2100,200,175),spawn.mapRect(1050,-2100,200,175),spawn.randomMob(1075,-3500,-.3),spawn.randomMob(2175,-700,-.2),spawn.randomMob(-75,-850,-.1),spawn.randomMob(550,-3400,0),spawn.randomMob(0,-1175,.5),spawn.randomMob(-75,-1150,.5),spawn.randomMob(1075,-625,.5),spawn.randomMob(800,-3400,-.3),spawn.randomMob(1225,-3375,-.2),spawn.randomMob(1200,-1125,-.1),spawn.randomMob(2050,-950,.5),simulation.difficulty>40&&(spawn.randomMob(2300,-2775,-.5),spawn.randomMob(600,-925,-.5),spawn.randomMob(1550,-2750,-.5),spawn.randomMob(1350,-1150,-.5),spawn.randomMob(-75,-1475,0),spawn.randomGroup(600,-2600,0)),simulation.difficulty>1&&(Math.random()<.5?spawn.randomLevelBoss(700,-1550):spawn.randomLevelBoss(675,-2775)),powerUps.addResearchToLevel(),spawn.secondaryBossChance(1925,-1250),simulation.isHorizontalFlipped?(level.flipHorizontal(),p.min.x=-p.min.x-126,p.max.x=126-p.max.x,c.min.x=-c.min.x-126,c.max.x=126-c.max.x,a=level.portal({x:-2475,y:-140},2*Math.PI,{x:-2475,y:-3140},2*Math.PI),o=level.portal({x:-75,y:-2150},-Math.PI/2,{x:-1325,y:-2150},-Math.PI/2),l=level.portal({x:-1850,y:-585},-Math.PI/2,{x:-2425,y:-600},-1*Math.PI/3)):(a=level.portal({x:2475,y:-140},Math.PI,{x:2475,y:-3140},Math.PI),o=level.portal({x:75,y:-2150},-Math.PI/2,{x:1325,y:-2150},-Math.PI/2),l=level.portal({x:1850,y:-585},-Math.PI/2,{x:2425,y:-600},-2*Math.PI/3))},sewers(){const e=level.button(6600,2675),t=level.hazard(simulation.isHorizontalFlipped?-9100:4550,2750,4550,150);let a,o,l,n,s;const p=level.drip(6100,1900,2900,100),c=level.drip(7300,1900,2900,150),i=level.drip(8750,1900,2900,70);level.custom=()=>{p.draw(),c.draw(),i.draw(),e.query(),e.draw(),s.rotate(),ctx.fillStyle="hsl(175, 15%, 76%)",ctx.fillRect(9300,2200,600,400),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="#233",ctx.beginPath(),ctx.arc(a.pointA.x,a.pointA.y,9,0,2*Math.PI),ctx.moveTo(o.pointA.x,o.pointA.y),ctx.arc(o.pointA.x,o.pointA.y,9,0,2*Math.PI),ctx.moveTo(l.pointA.x,l.pointA.y),ctx.arc(l.pointA.x,l.pointA.y,9,0,2*Math.PI),ctx.moveTo(n.pointA.x,n.pointA.y),ctx.arc(n.pointA.x,n.pointA.y,9,0,2*Math.PI),ctx.moveTo(balance5.pointA.x,balance5.pointA.y),ctx.arc(balance5.pointA.x,balance5.pointA.y,9,0,2*Math.PI),ctx.fill(),t.query(),t.level(e.isUp)},level.setPosToSpawn(0,-50),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=9700,level.exit.y=2560,level.defaultZoom=1800,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="hsl(138, 3%, 74%)",powerUps.spawnStartingPowerUps(3475,1775),spawn.debris(4575,2550,1600,9),spawn.debris(7e3,2550,2e3,7),spawn.mapRect(-500,-600,200,800),spawn.mapRect(-400,-600,3550,200),spawn.mapRect(-400,0,3e3,200),spawn.bodyRect(1450,-300,150,50);const r=shuffle([600,1250,2e3]);spawn.mapRect(r[0],-200,400,100),spawn.mapRect(r[1],-250,300,300),spawn.mapRect(r[2],-150,300,200),spawn.bodyRect(3100,410,75,100),spawn.bodyRect(2450,-25,250,25),spawn.mapRect(3050,-600,200,800),spawn.mapRect(3100,0,1200,200),spawn.mapRect(4200,0,200,1900),spawn.mapVertex(3500,1e3,"-500 -500 -400 -600 400 -600 500 -500 500 500 400 600 -400 600 -500 500"),spawn.mapVertex(3600,1940,"-400 -40 -350 -90 350 -90 400 -40 400 40 350 90 -350 90 -400 40"),spawn.mapRect(3925,2288,310,50),spawn.mapRect(3980,2276,200,50),spawn.mapRect(2625,2288,650,50),spawn.mapRect(2700,2276,500,50),spawn.mapRect(2400,0,200,1925),spawn.mapRect(600,2300,3750,200),spawn.bodyRect(3800,275,125,125),spawn.mapRect(4200,1700,5e3,200),spawn.mapRect(4150,2300,200,400),spawn.mapRect(600,1700,2e3,200),spawn.mapRect(500,1700,200,800),spawn.mapRect(675,1875,325,150,.5),spawn.mapRect(4450,2900,4900,200),spawn.mapRect(4150,2600,400,500),spawn.mapRect(6250,2675,700,325),spawn.mapRect(8e3,2600,600,400),spawn.bodyRect(5875,2725,200,200),spawn.bodyRect(6800,2490,50,50),spawn.bodyRect(6800,2540,50,50),spawn.bodyRect(6800,2590,50,50),spawn.bodyRect(8225,2225,100,100),spawn.mapRect(6250,1875,700,150),spawn.mapRect(8e3,1875,600,150),spawn.mapRect(9100,1700,900,500),spawn.mapRect(9100,2600,900,500),spawn.mapRect(9900,1700,200,1400),spawn.mapRect(9300,2590,650,25),spawn.mapRect(9700,2580,100,50),spawn.randomGroup(1300,2100,.1),spawn.randomMob(8300,2100,.1),spawn.randomSmallMob(2575,-75,.1),spawn.randomMob(8125,2450,.1),spawn.randomSmallMob(3200,250,.1),spawn.randomMob(2425,2150,.1),spawn.randomSmallMob(3500,250,.2),spawn.randomMob(3800,2175,.2),spawn.randomSmallMob(2500,-275,.2),spawn.randomMob(4450,2500,.2),spawn.randomMob(6350,2525,.2),spawn.randomGroup(9200,2400,.3),spawn.randomSmallMob(1900,-250,.3),spawn.randomMob(1500,2100,.4),spawn.randomSmallMob(1700,-150,.4),spawn.randomMob(8800,2725,.5),spawn.randomMob(7300,2200,.5),spawn.randomMob(2075,2025,.5),spawn.randomMob(3475,2175,.5),spawn.randomMob(8900,2825,.5),spawn.randomMob(9600,2425,.9),spawn.randomMob(3600,1725,.9),spawn.randomMob(4100,1225,.9),spawn.randomMob(2825,400,.9),simulation.difficulty>1&&spawn.randomLevelBoss(6e3,2300,["spiderBoss","launcherBoss","laserTargetingBoss","streamBoss","historyBoss","orbitalBoss","grenadierBoss"]),powerUps.addResearchToLevel(),spawn.secondaryBossChance(7725,2275),simulation.isHorizontalFlipped?(level.flipHorizontal(),s=level.rotor(-5100,2475,.001),a=level.spinner(-325,-395,25,390,.001),o=level.spinner(-2995,500,390,25,.001),l=level.spinner(-3192,1900,584,25,.001),n=level.spinner(-9325,2205,25,380,.001),balance5=level.spinner(-2995,1100,390,25,.001),e.min.x=-e.min.x-126,e.max.x=126-e.max.x,p.x*=-1,c.x*=-1,i.x*=-1,level.custom=()=>{p.draw(),c.draw(),i.draw(),e.query(),e.draw(),s.rotate(),ctx.fillStyle="hsl(175, 15%, 76%)",ctx.fillRect(-9900,2200,600,400),level.playerExitCheck(),level.exit.draw(),level.enter.draw()}):(s=level.rotor(5100,2475,-.001),a=level.spinner(300,-395,25,390,.001),o=level.spinner(2605,500,390,25,.001),l=level.spinner(2608,1900,584,25,.001),n=level.spinner(9300,2205,25,380,.001),balance5=level.spinner(2605,1100,390,25,.001))},satellite(){const e=level.boost(5825,235,1400),t=level.elevator(4210,-1265,380,50,-3450);level.custom=()=>{e.query(),ctx.fillStyle="#d4f4f4",ctx.fillRect(-250,-750,420,450),ctx.fillStyle="#d0d4d6",ctx.fillRect(-300,-1900,500,1100),ctx.fillRect(900,-2450,450,2050),ctx.fillRect(2e3,-2800,450,2500),ctx.fillRect(3125,-3100,450,3300),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,20,40,0.25)",ctx.fillRect(-250,-400,1800,775),ctx.fillRect(1800,-275,850,775),ctx.fillRect(5200,125,450,200),ctx.fillStyle="rgba(0,20,40,0.1)",ctx.fillRect(4e3,-1200,1050,1500),ctx.fillRect(4100,-3450,600,2250),t.move()},level.setPosToSpawn(-100,210),spawn.mapRect(-150,240,100,30),level.exit.x=-100,level.exit.y=-425,spawn.mapRect(level.exit.x,level.exit.y+15,100,50),level.defaultZoom=1700,simulation.zoomTransition(level.defaultZoom),powerUps.spawnStartingPowerUps(4900,-500),spawn.debris(1e3,20,1800,3),spawn.debris(4830,-1330,850,3),spawn.debris(3035,-3900,1500,3),document.body.style.backgroundColor="#dbdcde",spawn.mapRect(-350,-800,100,1100),spawn.mapRect(150,-510,50,365),spawn.bodyRect(170,-140,20,163,1,spawn.propsFriction),spawn.mapVertex(175,200,"625 0 300 0 425 -300 500 -300"),spawn.mapRect(-350,250,6350,300),spawn.bodyRect(2100,50,80,80),spawn.bodyRect(2e3,50,60,60),spawn.mapVertex(2225,250,"575 0 -575 0 -450 -100 450 -100"),spawn.mapRect(-350,-850,550,100),spawn.mapRect(150,-800,50,110),spawn.bodyRect(170,-690,14,180,1,spawn.propsFriction),spawn.mapRect(-300,-400,500,150),spawn.mapRect(-500,-1900,400,50),spawn.mapRect(0,-1900,400,50),spawn.mapRect(-150,-1350,200,25),spawn.bodyRect(140,-2100,150,200),spawn.mapVertex(1125,-450,"325 0 250 80 -250 80 -325 0 -250 -80 250 -80"),spawn.mapRect(150,-500,1410,100),spawn.mapRect(625,-2450,1e3,50),spawn.bodyRect(1300,-3600,150,150),spawn.mapVertex(2225,-250,"325 0 250 80 -250 80 -325 0 -250 -80 250 -80"),spawn.mapRect(1725,-2800,1e3,50),spawn.mapRect(1790,-300,870,100),spawn.bodyRect(2400,-2950,150,150),spawn.mapVertex(3350,175,"425 0 -425 0 -275 -300 275 -300"),spawn.bodyRect(3350,-150,200,120),spawn.mapRect(2850,-3150,1e3,50),spawn.bodyRect(3675,-3470,525,20),spawn.bodyRect(3600,-3450,200,300),spawn.mapRect(5200,-725,100,870),spawn.mapRect(5300,-1075,350,1220),spawn.mapRect(3900,-300,450,50),spawn.mapRect(4675,-375,450,50),spawn.mapRect(4e3,-1300,200,100),spawn.mapRect(4600,-1300,450,100),spawn.mapRect(4100,-2250,100,650),spawn.mapRect(4100,-3450,100,850),spawn.mapRect(4600,-3450,100,1850),spawn.randomSmallMob(4400,-3500),spawn.randomSmallMob(4800,-800),spawn.randomMob(800,-2600),spawn.randomMob(700,-600,.3),spawn.randomMob(3100,-3600,.3),spawn.randomMob(3300,-1e3,.3),spawn.randomMob(4200,-250,.3),spawn.randomMob(4900,-1500,.3),spawn.randomMob(3800,175,.4),spawn.randomMob(5750,125,.4),spawn.randomMob(5900,-1500,.4),spawn.randomMob(4700,-800,.4),spawn.randomMob(1400,200,.3),spawn.randomMob(2850,175,.4),spawn.randomMob(2e3,-2800,.4),spawn.randomMob(2400,-400,.4),spawn.randomMob(4475,-3550,.3),spawn.randomGroup(5e3,-2150,1),spawn.randomGroup(3700,-4100,.3),spawn.randomGroup(2700,-1600,.1),spawn.randomGroup(1600,-100,0),spawn.randomGroup(5e3,-3900,-.3),simulation.difficulty>1&&(Math.random()<.25?spawn.randomLevelBoss(2800,-1400):Math.random()<.25?spawn.laserBoss(2900+300*Math.random(),150*Math.random()-2950):Math.random()<.33?spawn.laserBoss(1800+250*Math.random(),150*Math.random()-2600):Math.random()<.5?spawn.laserBoss(3500+250*Math.random(),1e3*Math.random()-2600):spawn.laserBoss(600+200*Math.random(),250*Math.random()-2150)),powerUps.addResearchToLevel(),spawn.secondaryBossChance(3950,-850),simulation.isHorizontalFlipped&&(level.flipHorizontal(),e.boostBounds.min.x=-e.boostBounds.min.x-100,e.boostBounds.max.x=100-e.boostBounds.max.x,level.setPosToSpawn(100,210),t.holdX=-t.holdX,level.custom=()=>{e.query(),ctx.fillStyle="#d4f4f4",ctx.fillRect(-170,-750,420,450),ctx.fillStyle="#d0d4d6",ctx.fillRect(-200,-1900,500,1100),ctx.fillRect(-1350,-2450,450,2050),ctx.fillRect(-2450,-2800,450,2500),ctx.fillRect(-3575,-3100,450,3300),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{t.move(),ctx.fillStyle="rgba(0,20,40,0.25)",ctx.fillRect(-1550,-400,1800,775),ctx.fillRect(-2650,-275,850,775),ctx.fillRect(-5650,125,450,200),ctx.fillStyle="rgba(0,20,40,0.1)",ctx.fillRect(-5050,-1200,1050,1500),ctx.fillRect(-4700,-3450,600,2250)})},rooftops(){const e=level.elevator(1450,-990,235,45,-2e3),t=level.boost(4950,0,1100);level.custom=()=>{t.query(),e.move(),e.drawTrack(),ctx.fillStyle="#d4f4f4",a?ctx.fillRect(-650,-2300,440,300):ctx.fillRect(3460,-700,1090,800),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(710,-2225,580,225),ctx.fillRect(3510,-1550,330,300),ctx.fillRect(1735,-900,1515,1900),ctx.fillRect(1735,-1550,1405,550),ctx.fillRect(1860,-1950,630,350),ctx.fillRect(-700,-1950,2100,2950),ctx.fillRect(3400,100,2150,900),ctx.fillRect(4550,-725,900,725),ctx.fillRect(3460,-1250,1080,550),a?ctx.fillRect(3460,-700,1090,800):ctx.fillRect(-650,-2300,440,300)},level.defaultZoom=1700,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#dcdcde";let a=!1;Math.random()<.75?(level.setPosToSpawn(-450,-2060),level.exit.x=3600,level.exit.y=-300,spawn.mapRect(3600,-285,100,50),spawn.bodyRect(4850,-750,300,25,.6),spawn.randomSmallMob(4100,-100),spawn.randomSmallMob(4600,-100),spawn.randomMob(3765,-450,.3)):(a=!0,level.setPosToSpawn(3650,-325),level.exit.x=-550,level.exit.y=-2030,spawn.mapRect(-550,-2015,100,50)),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),spawn.debris(1650,-1800,3800,16),powerUps.spawnStartingPowerUps(2450,-1675),spawn.mapRect(3400,0,2150,100),spawn.mapRect(-700,-2e3,2125,50),spawn.bodyRect(1300,-2125,50,125,.8),spawn.bodyRect(1307,-2225,50,100,.8),spawn.mapRect(-700,-2350,50,400),spawn.mapRect(-700,-2010,500,50),spawn.mapRect(-700,-2350,500,50),spawn.mapRect(-250,-2350,50,200),spawn.bodyRect(-240,-2150,30,36),spawn.bodyRect(-240,-2115,30,36),spawn.bodyRect(-240,-2080,30,35),spawn.bodyRect(-240,-2045,30,35),spawn.mapRect(1850,-2e3,650,50),spawn.bodyRect(200,-2150,80,220,.8),spawn.mapRect(700,-2275,600,50),spawn.mapRect(1e3,-1350,410,50),spawn.bodyRect(1050,-2350,30,30,.8),spawn.mapRect(-725,-1e3,2150,100),spawn.bodyRect(350,-1100,200,100,.8),spawn.bodyRect(370,-1200,100,100,.8),spawn.bodyRect(360,-1300,100,100,.8),spawn.bodyRect(950,-1050,300,50,.8),spawn.bodyRect(-575,-1150,125,150,.8),spawn.mapRect(1710,-1e3,1565,100),spawn.mapRect(3400,-1e3,75,25),spawn.bodyRect(2600,-1950,100,250,.8),spawn.bodyRect(2700,-1125,125,125,.8),spawn.bodyRect(2710,-1250,125,125,.8),spawn.bodyRect(2705,-1350,75,100,.8),spawn.mapRect(3500,-1600,350,50),spawn.mapRect(1725,-1600,1435,50),spawn.bodyRect(3100,-1015,375,15),spawn.bodyRect(3500,-850,75,125,.8),spawn.mapRect(3450,-1e3,50,580),spawn.bodyRect(3460,-420,30,144),spawn.mapRect(5450,-775,100,875),spawn.bodyRect(3925,-1400,100,150,.8),spawn.mapRect(3450,-1250,1090,50),spawn.mapRect(4500,-1250,50,415),spawn.mapRect(3450,-725,1500,50),spawn.mapRect(5100,-725,400,50),spawn.mapRect(4500,-735,50,635),spawn.bodyRect(4500,-100,50,100),spawn.mapRect(4500,-885,100,50),spawn.spawnStairs(3800,0,3,150,206),spawn.mapRect(3400,-275,450,275),spawn.randomSmallMob(2200,-1775),spawn.randomSmallMob(4e3,-825),spawn.randomSmallMob(-350,-3400),spawn.randomMob(4250,-1350,.8),spawn.randomMob(2550,-1350,.8),spawn.randomMob(1875,-1075,.3),spawn.randomMob(1120,-1200,.3),spawn.randomMob(3e3,-1150,.2),spawn.randomMob(3200,-1150,.3),spawn.randomMob(3300,-1750,.3),spawn.randomMob(3650,-1350,.3),spawn.randomMob(3600,-1800,.1),spawn.randomMob(5200,-100,.3),spawn.randomMob(5275,-900,.2),spawn.randomMob(0,-1075,.3),spawn.randomGroup(600,-1575,0),spawn.randomGroup(2225,-1325,.4),spawn.randomGroup(4900,-1200,0),simulation.difficulty>1&&spawn.randomLevelBoss(3200,-1900),powerUps.addResearchToLevel(),spawn.secondaryBossChance(2175,-2425),simulation.isHorizontalFlipped&&(level.flipHorizontal(),t.boostBounds.min.x=-t.boostBounds.min.x-100,t.boostBounds.max.x=100-t.boostBounds.max.x,e.holdX=-e.holdX,a?level.setPosToSpawn(-3650,-325):level.setPosToSpawn(450,-2060),level.custom=()=>{t.query(),e.move(),e.drawTrack(),ctx.fillStyle="#d4f4f4",a?ctx.fillRect(210,-2300,440,300):ctx.fillRect(-4550,-700,1090,800),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-1290,-2225,580,225),ctx.fillRect(-3840,-1550,330,300),ctx.fillRect(-3250,-900,1515,1900),ctx.fillRect(-3140,-1550,1405,550),ctx.fillRect(-2490,-1950,630,350),ctx.fillRect(-1400,-1950,2100,2950),ctx.fillRect(-5550,100,2150,900),ctx.fillRect(-5450,-725,900,725),ctx.fillRect(-4540,-1250,1080,550),a?ctx.fillRect(-4550,-700,1090,800):ctx.fillRect(210,-2300,440,300)})},aerie(){const e=level.boost(-425,100,1400),t=level.boost(5350,275,2850);level.custom=()=>{e.query(),t.query(),a?(ctx.fillStyle="#d4f4f4",ctx.fillRect(-275,-1275,425,300)):(ctx.fillStyle="#d4f4f4",ctx.fillRect(3750,-3650,550,400)),ctx.fillStyle="#c7c7ca",ctx.fillRect(4200,-2200,100,2600),ctx.fillRect(-100,-1e3,1450,1400),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{a?(ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(3750,-3650,550,400)):(ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-275,-1275,425,300)),ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(3700,-3150,1100,950),ctx.fillRect(2e3,-1110,450,1550),ctx.fillStyle="rgba(0,0,0,0.04)",ctx.beginPath(),ctx.moveTo(-100,-900),ctx.lineTo(300,-900),ctx.lineTo(150,100),ctx.lineTo(-100,100),ctx.moveTo(600,-900),ctx.lineTo(1350,-900),ctx.lineTo(1350,100),ctx.lineTo(750,100),ctx.fill()},level.defaultZoom=2100,simulation.zoomTransition(level.defaultZoom);const a=Math.random()<.25&&simulation.difficulty>8;a?(level.setPosToSpawn(4e3,-3300),level.exit.x=-100,level.exit.y=-1025):(level.setPosToSpawn(-50,-1050),level.exit.x=3950,level.exit.y=-3275),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),spawn.mapRect(level.exit.x,level.exit.y+15,100,20),powerUps.spawnStartingPowerUps(1075,-550),document.body.style.backgroundColor="#dcdcde",spawn.mapRect(-300,-1e3,600,100),spawn.mapRect(-300,-1300,450,50),spawn.mapRect(-300,-1300,50,350),a||spawn.bodyRect(100,-1250,200,240),spawn.mapRect(-100,-975,100,975),spawn.mapRect(-500,100,1950,400),spawn.mapRect(600,-1e3,750,100),spawn.mapRect(900,-500,550,100),spawn.mapRect(1250,-975,100,375),spawn.bodyRect(1250,-600,100,100,.7),spawn.mapRect(1250,-450,100,450),spawn.bodyRect(1250,-1225,100,200,.7),spawn.bodyRect(1200,-1025,350,35),a?spawn.bodyRect(2e3,-800,700,35):spawn.bodyRect(1750,-800,700,35),spawn.mapVertex(2225,-2100,"0 0 450 0 300 -2500 150 -2500"),spawn.mapRect(2e3,-700,450,300),spawn.bodyRect(2360,-450,100,300,.6),spawn.mapRect(2e3,-75,450,275),spawn.bodyRect(2450,150,150,150,.4),spawn.mapRect(1550,300,4600,200),spawn.mapRect(6050,-1060,450,1560),spawn.mapVertex(6275,-2100,"0 0 450 0 300 -2500 150 -2500"),spawn.mapRect(3700,-3200,100,800),spawn.mapRect(4700,-2910,100,510),spawn.mapRect(3700,-2600,300,50),spawn.mapRect(4100,-2900,900,50),spawn.mapRect(3450,-2300,750,100),spawn.mapRect(4300,-2300,750,100),spawn.mapRect(4150,-1600,200,25),spawn.mapRect(4150,-700,200,25),spawn.mapRect(3700,-3700,600,50),spawn.mapRect(3700,-3700,50,500),spawn.mapRect(4250,-3700,50,300),spawn.mapRect(3700,-3250,1100,100),spawn.randomGroup(350,-500,1),spawn.randomSmallMob(-225,25),spawn.randomSmallMob(2100,-900),spawn.randomSmallMob(4e3,-250),spawn.randomSmallMob(4450,-3e3),spawn.randomSmallMob(5600,100),spawn.randomMob(4275,-2600,.8),spawn.randomMob(1050,-700,.8),spawn.randomMob(6050,-850,.7),spawn.randomMob(2150,-300,.6),spawn.randomMob(3900,-2700,.8),spawn.randomMob(3600,-500,.8),spawn.randomMob(3400,-200,.8),spawn.randomMob(425,0,.7),spawn.randomMob(4100,-50,.7),spawn.randomMob(4100,-50,.5),spawn.randomMob(1700,-50,.3),spawn.randomMob(2350,-900,.3),spawn.randomMob(4700,-150,.2),spawn.randomGroup(4e3,-350,.6),spawn.randomGroup(2750,-550,.1),spawn.randomMob(2175,-925,.5),spawn.randomMob(2750,100,.5),spawn.randomMob(4250,-1725,.5),spawn.randomMob(3575,-2425,.5),spawn.randomMob(3975,-3900,.5),spawn.randomMob(1725,125,.5),simulation.difficulty>1&&(Math.random()<.33?(spawn.randomLevelBoss(4250,-250),spawn.debris(-250,50,1650,2),spawn.debris(2475,0,750,2),spawn.debris(3450,0,2e3,16),spawn.debris(3500,-2350,1500,2)):(powerUps.chooseRandomPowerUp(4e3,200),powerUps.chooseRandomPowerUp(4e3,200),spawn.bodyRect(3e3,50,150,250,.9),spawn.bodyRect(4500,-500,300,250,.7),spawn.bodyRect(3500,-100,100,150,.7),spawn.bodyRect(4200,-500,110,30,.7),spawn.bodyRect(3800,-500,150,130,.7),spawn.bodyRect(4e3,50,200,150,.9),spawn.bodyRect(4500,50,300,200,.9),spawn.bodyRect(4200,-350,200,50,.9),spawn.bodyRect(4700,-350,50,200,.9),spawn.bodyRect(4900,-100,300,300,.7),spawn.suckerBoss(4500,-400))),powerUps.addResearchToLevel(),spawn.secondaryBossChance(5350,-325),simulation.isHorizontalFlipped&&(level.flipHorizontal(),e.boostBounds.min.x=-e.boostBounds.min.x-100,e.boostBounds.max.x=100-e.boostBounds.max.x,t.boostBounds.min.x=-t.boostBounds.min.x-100,t.boostBounds.max.x=100-t.boostBounds.max.x,a?level.setPosToSpawn(-4e3,-3300):level.setPosToSpawn(50,-1050),level.custom=()=>{e.query(),t.query(),a?(ctx.fillStyle="#d4f4f4",ctx.fillRect(-150,-1275,425,300)):(ctx.fillStyle="#d4f4f4",ctx.fillRect(-4300,-3650,550,400)),ctx.fillStyle="#c7c7ca",ctx.fillRect(-4300,-2200,100,2600),ctx.fillRect(-1350,-1e3,1450,1400),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{a?(ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-4300,-3650,550,400)):(ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-150,-1275,425,300)),ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-4800,-3150,1100,950),ctx.fillRect(-2450,-1110,450,1550),ctx.fillStyle="rgba(0,0,0,0.04)",ctx.beginPath(),ctx.moveTo(100,-900),ctx.lineTo(-300,-900),ctx.lineTo(-150,100),ctx.lineTo(100,100),ctx.moveTo(-600,-900),ctx.lineTo(-1350,-900),ctx.lineTo(-1350,100),ctx.lineTo(-750,100),ctx.fill()})},skyscrapers(){const e=level.boost(475,0,1300),t=level.boost(4450,0,1300);level.custom=()=>{e.query(),t.query(),ctx.fillStyle="#d4f4f4",ctx.fillRect(1350,-2100,400,250),ctx.fillStyle="#d4d4d7",ctx.fillRect(3350,-1300,50,1325),ctx.fillRect(1300,-1800,750,1800),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(2500,-1100,450,250),ctx.fillRect(2400,-550,600,150),ctx.fillRect(2550,-1650,250,200),ctx.fillStyle="rgba(0,0,0,0.2)",ctx.fillRect(700,-110,400,110),ctx.fillRect(3800,-110,400,110),ctx.fillStyle="rgba(0,0,0,0.15)",ctx.fillRect(-250,-300,450,300)},level.setPosToSpawn(-50,-60),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=1500,level.exit.y=-1875,level.defaultZoom=2e3,simulation.zoomTransition(level.defaultZoom),powerUps.spawnStartingPowerUps(1475,-1175),spawn.debris(750,-2200,3700,16),document.body.style.backgroundColor="#dcdcde",spawn.mapRect(-300,0,5100,300),spawn.mapRect(-300,-350,50,400),spawn.mapRect(-300,-10,500,50),spawn.mapRect(-300,-350,500,50),spawn.mapRect(150,-350,50,200),spawn.bodyRect(170,-130,14,140,1,spawn.propsFriction),spawn.mapRect(700,-1100,400,990),spawn.mapRect(1600,-400,1500,500),spawn.mapRect(1345,-1100,250,25),spawn.mapRect(1755,-1100,250,25),spawn.mapRect(1300,-1850,800,50),spawn.mapRect(1300,-2150,50,350),spawn.mapRect(1300,-2150,450,50),spawn.mapRect(1500,-1860,100,50),spawn.mapRect(2400,-850,600,300),spawn.mapRect(2500,-1450,450,350),spawn.mapRect(2500,-1675,50,300),spawn.mapRect(2500,-1700,300,50),spawn.mapRect(3275,-750,200,25),spawn.mapRect(3275,-1300,200,25),spawn.mapRect(3800,-1100,400,990),spawn.bodyRect(3200,-1375,300,25,.9),spawn.bodyRect(1825,-1875,400,25,.9),spawn.bodyRect(1800,-600,110,150,.8),spawn.bodyRect(2557,-450,35,55,.7),spawn.bodyRect(2957,-450,30,15,.7),spawn.bodyRect(2900,-450,60,45,.7),spawn.bodyRect(915,-1200,60,100,.95),spawn.bodyRect(925,-1300,50,100,.95),Math.random()<.9&&(spawn.bodyRect(2300,-1720,400,20),spawn.bodyRect(2590,-1780,80,80)),spawn.bodyRect(2925,-1100,25,250,.8),spawn.bodyRect(3325,-1550,50,200,.3),Math.random()<.8&&(spawn.bodyRect(1400,-75,200,75),spawn.bodyRect(1525,-125,50,50)),spawn.bodyRect(1025,-1110,400,25,.9),spawn.bodyRect(1425,-1110,115,25,.9),spawn.bodyRect(1540,-1110,300,25,.9),spawn.randomMob(-100,-1300,.5),spawn.randomSmallMob(1850,-600),spawn.randomSmallMob(3200,-100),spawn.randomSmallMob(4450,-100),spawn.randomSmallMob(2700,-475),spawn.randomMob(2650,-975,.8),spawn.randomMob(2650,-1550,.8),spawn.randomMob(4150,-200,.15),spawn.randomMob(1700,-1300,.2),spawn.randomMob(1850,-1950,.25),spawn.randomMob(2610,-1880,.25),spawn.randomMob(3350,-950,.25),spawn.randomMob(1690,-2250,.25),spawn.randomMob(2200,-600,.2),spawn.randomMob(850,-1300,.25),spawn.randomMob(-100,-1700,-.2),spawn.randomGroup(3700,-1500,.4),spawn.randomGroup(1700,-900,.4),simulation.difficulty>1&&spawn.randomLevelBoss(2600,-2300),powerUps.addResearchToLevel(),spawn.secondaryBossChance(3075,-2050),simulation.isHorizontalFlipped&&(level.flipHorizontal(),e.boostBounds.min.x=-e.boostBounds.min.x-100,e.boostBounds.max.x=100-e.boostBounds.max.x,t.boostBounds.min.x=-t.boostBounds.min.x-100,t.boostBounds.max.x=100-t.boostBounds.max.x,level.setPosToSpawn(50,-60),level.custom=()=>{e.query(),t.query(),ctx.fillStyle="#d4f4f4",ctx.fillRect(-1750,-2100,400,250),ctx.fillStyle="#d4d4d7",ctx.fillRect(-3400,-1300,50,1325),ctx.fillRect(-2050,-1800,750,1800),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-2950,-1100,450,250),ctx.fillRect(-3e3,-550,600,150),ctx.fillRect(-2800,-1650,250,200),ctx.fillStyle="rgba(0,0,0,0.2)",ctx.fillRect(-1100,-110,400,110),ctx.fillRect(-4200,-110,400,110),ctx.fillStyle="rgba(0,0,0,0.15)",ctx.fillRect(-200,-300,450,300)})},highrise(){const e=level.elevator(-790,-190,180,25,-1150);e.addConstraint();const t=level.toggle(-500,-200),a=level.elevator(-3630,-1e3,180,25,-1740);a.addConstraint();const o=level.toggle(-3100,-1330);level.custom=()=>{ctx.fillStyle="#cff",ctx.fillRect(-4425,-3050,425,275),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{t.query(),t.isOn?e.isOn||(e.isOn=!0,e.isUp=!1,e.removeConstraint(),e.frictionAir=.2):e.isOn&&(e.isOn=!1,e.frictionAir=.2,e.addConstraint()),e.isOn?(e.move(),ctx.fillStyle="#444",ctx.fillRect(-700,-1140,1,975)):(ctx.fillStyle="#aaa",ctx.fillRect(-700,-1140,1,975)),o.query(),o.isOn?a.isOn||(a.isOn=!0,a.isUp=!1,a.removeConstraint(),a.frictionAir=.2):a.isOn&&(a.isOn=!1,a.frictionAir=.2,a.addConstraint()),a.isOn?(a.move(),ctx.fillStyle="#444",ctx.fillRect(-3540,-1720,1,740)):(ctx.fillStyle="#aaa",ctx.fillRect(-3540,-1720,1,740)),ctx.fillStyle="rgba(64,64,64,0.97)",ctx.fillRect(-4450,-750,800,200),ctx.fillStyle="rgba(0,0,0,0.12)",ctx.fillRect(-2500,-1975,150,300),ctx.fillRect(-1830,-1150,2030,1150),ctx.fillRect(-3410,-2150,495,1550),ctx.fillRect(-2585,-1675,420,1125),ctx.fillRect(-1650,-1575,750,450)},level.setPosToSpawn(-300,-700),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=-4275,level.exit.y=-2805,level.defaultZoom=1500,simulation.zoomTransition(level.defaultZoom),powerUps.spawnStartingPowerUps(-2550,-700),document.body.style.backgroundColor="#dcdcde",spawn.debris(-2325,-1825,2400),spawn.debris(-2625,-600,600,5),spawn.debris(-2e3,-60,1200,5),powerUps.spawn(-4300,-700,"heal"),powerUps.spawn(-4200,-700,"ammo"),powerUps.spawn(-4e3,-700,"ammo"),spawn.mapRect(-4450,-1e3,100,500),spawn.bodyRect(-3300,-750,150,150),spawn.bodyRect(-1e3,-675,25,25),spawn.mapRect(-2225,0,2475,150),spawn.mapRect(175,-1e3,75,1100),spawn.mapRect(-600,-1075,50,475),spawn.mapRect(-600,-650,625,50),spawn.mapRect(-1300,-650,500,50),spawn.bodyRect(-75,-300,50,50),spawn.mapRect(-600,-200,500,250),spawn.bodyRect(-250,-300,100,100),spawn.bodyRect(-425,-1375,400,225),spawn.mapRect(-925,-1575,50,475),spawn.bodyRect(-1475,-1275,250,125),spawn.mapRect(-1675,-1575,650,50),spawn.mapRect(-600,-1150,850,175),spawn.mapRect(-1850,-1150,1050,175),spawn.bodyRect(-1907,-1600,550,25),simulation.difficulty<4?(spawn.bodyRect(-1600,-125,125,125),spawn.bodyRect(-1560,-200,75,75)):(spawn.bodyRect(-1200,-125,125,125),spawn.bodyRect(-1160,-200,75,75)),spawn.mapRect(-4450,-600,2300,750),spawn.mapRect(-2225,-450,175,550),spawn.mapRect(-3425,-1325,525,75),spawn.mapRect(-3425,-2200,525,50),spawn.mapRect(-2600,-1700,450,50),spawn.bodyRect(-2275,-2700,50,60),spawn.mapRect(-2515,-2e3,180,50),spawn.bodyRect(-3410,-1425,50,50),spawn.bodyRect(-3390,-1525,40,60),spawn.mapRect(-4450,-1750,800,1050),spawn.mapRect(-4e3,-2390,200,800),spawn.mapRect(-4450,-2775,475,1125),spawn.bodyRect(-3715,-2050,50,50),spawn.bodyRect(-2970,-2250,50,50),spawn.bodyRect(-3080,-2250,40,40),spawn.bodyRect(-3420,-650,50,50),spawn.mapRect(-4450,-3075,25,300),spawn.mapRect(-4450,-3075,450,25),spawn.mapRect(-4025,-3075,25,100),spawn.mapRect(-4275,-2785,100,25),spawn.bodyRect(-3900,-2400,50,50),spawn.randomMob(-2500,-2700,1),spawn.randomMob(-3200,-750,1),spawn.randomMob(-1875,-775,.2),spawn.randomMob(-950,-1675,.2),spawn.randomMob(-1525,-1750,.2),spawn.randomMob(-1375,-1400,.2),spawn.randomMob(-1625,-1275,.2),spawn.randomMob(-1900,-1250,.2),spawn.randomMob(-2250,-1850,.2),spawn.randomMob(-2475,-2200,.2),spawn.randomMob(-3e3,-1475,.2),spawn.randomMob(-3850,-2500,.2),spawn.randomMob(-3650,-2125,.2),spawn.randomMob(-4010,-3200,.2),spawn.randomMob(-3500,-1825,.2),spawn.randomMob(-975,-100,0),spawn.randomMob(-1050,-725,.2),spawn.randomMob(-1525,-100,0),spawn.randomMob(-525,-1700,-.1),spawn.randomMob(-125,-1500,-.1),spawn.randomMob(-325,-1900,-.1),spawn.randomMob(-550,-100,-.1),spawn.randomGroup(-3250,-2700,.2),spawn.randomGroup(-2450,-1100,0),simulation.difficulty>1&&spawn.randomLevelBoss(-2400,-2650),powerUps.addResearchToLevel(),spawn.secondaryBossChance(-1825,-1975),simulation.isHorizontalFlipped&&(level.flipHorizontal(),level.setPosToSpawn(300,-700),e.holdX=-e.holdX,e.removeConstraint(),e.addConstraint(),a.holdX=-a.holdX,a.removeConstraint(),a.addConstraint(),level.custom=()=>{ctx.fillStyle="#cff",ctx.fillRect(4e3,-3050,425,275),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{t.query(),t.isOn?e.isOn||(e.isOn=!0,e.isUp=!1,e.removeConstraint(),e.frictionAir=.2):e.isOn&&(e.isOn=!1,e.frictionAir=.2,e.addConstraint()),e.isOn?(e.move(),ctx.fillStyle="#444",ctx.fillRect(699,-1140,1,975)):(ctx.fillStyle="#aaa",ctx.fillRect(699,-1140,1,975)),o.query(),o.isOn?a.isOn||(a.isOn=!0,a.isUp=!1,a.removeConstraint(),a.frictionAir=.2):a.isOn&&(a.isOn=!1,a.frictionAir=.2,a.addConstraint()),a.isOn?(a.move(),ctx.fillStyle="#444",ctx.fillRect(3539,-1720,1,740)):(ctx.fillStyle="#aaa",ctx.fillRect(3539,-1720,1,740)),ctx.fillStyle="rgba(64,64,64,0.97)",ctx.fillRect(3650,-750,800,200),ctx.fillStyle="rgba(0,0,0,0.12)",ctx.fillRect(2350,-1975,150,300),ctx.fillRect(-200,-1150,2030,1150),ctx.fillRect(2915,-2150,495,1550),ctx.fillRect(2165,-1675,420,1125),ctx.fillRect(900,-1575,750,450)})},warehouse(){level.custom=()=>{ctx.fillStyle="#444",ctx.fillRect(-920,-505,40,10),ctx.fillRect(-920,95,40,10),ctx.fillRect(180,95,40,10),ctx.fillRect(-20,695,40,10),ctx.fillRect(-2320,945,40,10),ctx.fillStyle="#cff",ctx.fillRect(300,-250,350,250),level.playerExitCheck(),level.exit.draw(),level.enter.draw()};const e=new Path2D;e.moveTo(-1800,-500),e.lineTo(-910,-500),e.lineTo(-1300,0),e.lineTo(-500,0),e.lineTo(-890,-500),e.lineTo(-175,-500),e.lineTo(-175,-250),e.lineTo(175,-250),e.lineTo(175,0),e.lineTo(-910,100),e.lineTo(-1300,600),e.lineTo(-500,600),e.lineTo(-890,100),e.lineTo(190,100),e.lineTo(-200,600),e.lineTo(600,600),e.lineTo(210,100),e.lineTo(1100,100),e.lineTo(1100,1400),e.lineTo(600,1400),e.lineTo(10,700),e.lineTo(-10,700),e.lineTo(-600,1400),e.lineTo(-1950,1400),e.lineTo(-2290,950),e.lineTo(-2310,950),e.lineTo(-2650,1400),e.lineTo(-3025,1400),e.lineTo(-3025,150),e.lineTo(-2590,150),e.lineTo(-2600,-150),e.lineTo(-1800,-150),e.lineTo(-1800,-500),level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.15)",ctx.fill(e)},level.setPosToSpawn(25,-55),level.exit.x=425,level.exit.y=-30,level.defaultZoom=1300,simulation.zoomTransition(level.defaultZoom),spawn.debris(-2250,1330,3e3,6),spawn.debris(-3e3,-800,3280,6),spawn.debris(-1400,410,2300,5),powerUps.spawnStartingPowerUps(25,500),document.body.style.backgroundColor="#dcdcde",spawn.mapRect(-1500,0,2750,100),spawn.mapRect(175,-270,125,300),spawn.mapRect(-1900,-600,1775,100),spawn.mapRect(-1900,-550,100,1250),spawn.mapRect(-175,-550,50,400),spawn.mapRect(-175,-10,350,50),spawn.mapRect(-25,-20,100,50),spawn.mapRect(300,-10,350,50),spawn.mapRect(-150,-300,800,50),spawn.mapRect(600,-275,50,75),spawn.mapRect(425,-20,100,25),spawn.mapRect(1100,0,150,1500),spawn.mapRect(-3150,1400,4400,100),spawn.mapRect(-2375,875,1775,75),spawn.mapRect(-1450,865,75,435),spawn.mapRect(-1450,662,75,100),spawn.bodyRect(-1418,773,11,102,1,spawn.propsFriction),spawn.mapRect(-3150,50,125,1450),spawn.mapRect(-2350,600,3150,100),spawn.mapRect(-2125,400,250,275),spawn.mapRect(-3150,50,775,100),spawn.mapRect(-2600,-250,775,100);let t,a,o,l=!1;Math.random()<.5?(l=!0,t=level.elevator(-1780,500,260,40,7,3e-4),a=level.elevator(820,1300,260,40,607,3e-4),o=level.elevator(-2850,1250,160,40,600,.007),simulation.isHorizontalFlipped?spawn.mapVertex(-2900,225,"0 0 0 -500 -500 -500"):spawn.mapVertex(-2900,225,"0 0 0 -500 500 -500"),spawn.mapRect(-3050,1175,175,300),spawn.bodyRect(-2375,1300,100,100),spawn.bodyRect(-2325,1250,50,50),spawn.bodyRect(-2275,1350,125,50),level.custom=()=>{t.move(),t.drawTrack(),a.move(),a.drawTrack(),o.move(),o.drawTrack(),ctx.fillStyle="#444",ctx.fillRect(-920,-505,40,10),ctx.fillRect(-920,95,40,10),ctx.fillRect(180,95,40,10),ctx.fillRect(-20,695,40,10),ctx.fillRect(-2320,945,40,10),ctx.fillStyle="#cff",ctx.fillRect(300,-250,350,250),level.playerExitCheck(),level.exit.draw(),level.enter.draw()}):(spawn.mapRect(-2950,1250,175,250),spawn.mapRect(-3050,1100,150,400),spawn.bodyRect(-1450,-125,125,125,1,spawn.propsSlide),spawn.bodyRect(-1800,0,300,100,1,spawn.propsHoist),cons[cons.length]=Constraint.create({pointA:{x:-1650,y:-500},bodyB:body[body.length-1],stiffness:1815e-7,length:1}),Composite.add(engine.world,cons[cons.length-1]),spawn.bodyRect(600,525,125,125,1,spawn.propsSlide),spawn.bodyRect(800,600,300,100,1,spawn.propsHoist),cons[cons.length]=Constraint.create({pointA:{x:950,y:100},bodyB:body[body.length-1],stiffness:1815e-7,length:1}),Composite.add(engine.world,cons[cons.length-1]),spawn.bodyRect(-2700,1150,100,160,1,spawn.propsSlide),spawn.bodyRect(-2550,1200,150,150,1,spawn.propsSlide),spawn.bodyRect(-2763,1300,350,100,1,spawn.propsHoist),cons[cons.length]=Constraint.create({pointA:{x:-2575,y:150},bodyB:body[body.length-1],stiffness:4e-4,length:566}),Composite.add(engine.world,cons[cons.length-1])),spawn.bodyRect(-165,-150,30,35,1),spawn.bodyRect(-165,-115,30,35,1),spawn.bodyRect(-165,-80,30,35,1),spawn.bodyRect(-165,-45,30,35,1),spawn.bodyRect(-750,400,150,150,.5),spawn.bodyRect(-400,1175,100,250,1),spawn.bodyRect(-2525,-50,145,100,.5),spawn.bodyRect(-2325,-300,150,100,.5),spawn.bodyRect(-1275,-750,200,150,.5),spawn.bodyRect(-525,-700,125,100,.5),spawn.randomSmallMob(-1125,550),spawn.randomSmallMob(-2950,-50),spawn.randomMob(-2025,175,.3),spawn.randomMob(-2325,450,.3),spawn.randomMob(-2925,675,.2),spawn.randomMob(-2700,300,.1),spawn.randomMob(-2500,300,.1),spawn.randomMob(-2075,-425,.1),spawn.randomMob(-1550,-725,.1),spawn.randomMob(375,1100,0),spawn.randomMob(-1575,1100,0),spawn.randomSmallMob(825,300),spawn.randomMob(-800,-1750,0),spawn.randomMob(400,-750,-.1),spawn.randomMob(650,1300,-.1),spawn.randomMob(-2450,1050,-.1),spawn.randomMob(500,400,-.1),spawn.randomMob(-75,-1700,-.1),spawn.randomMob(900,-800,-.2),spawn.randomGroup(-75,1050,-.1),spawn.randomGroup(-900,1e3,.2),spawn.randomGroup(-1300,-1100,-.3),spawn.randomSmallMob(-2325,800),spawn.randomSmallMob(-900,825),simulation.difficulty>1&&(Math.random()<.7?spawn.randomLevelBoss(-800,-1300):spawn.snakeBoss(2500*Math.random()-1e3,-1300)),powerUps.addResearchToLevel(),spawn.secondaryBossChance(300,-800),simulation.isHorizontalFlipped&&(level.flipHorizontal(),level.setPosToSpawn(-25,-55),l?(t.holdX=-t.holdX,a.holdX=-a.holdX,o.holdX=-o.holdX,level.custom=()=>{t.move(),t.drawTrack(),a.move(),a.drawTrack(),o.move(),o.drawTrack(),ctx.fillStyle="#444",ctx.fillRect(880,-505,40,10),ctx.fillRect(880,95,40,10),ctx.fillRect(-220,95,40,10),ctx.fillRect(-20,695,40,10),ctx.fillRect(2280,945,40,10),ctx.fillStyle="#cff",ctx.fillRect(-650,-250,350,250),level.playerExitCheck(),level.exit.draw(),level.enter.draw()}):level.custom=()=>{ctx.fillStyle="#444",ctx.fillRect(880,-505,40,10),ctx.fillRect(880,95,40,10),ctx.fillRect(-220,95,40,10),ctx.fillRect(-20,695,40,10),ctx.fillRect(2280,945,40,10),ctx.fillStyle="#cff",ctx.fillRect(-650,-250,350,250),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.15)",ctx.beginPath(),ctx.moveTo(1800,-500),ctx.lineTo(910,-500),ctx.lineTo(1300,0),ctx.lineTo(500,0),ctx.lineTo(890,-500),ctx.lineTo(175,-500),ctx.lineTo(175,-250),ctx.lineTo(-175,-250),ctx.lineTo(-175,0),ctx.lineTo(910,100),ctx.lineTo(1300,600),ctx.lineTo(500,600),ctx.lineTo(890,100),ctx.lineTo(-190,100),ctx.lineTo(200,600),ctx.lineTo(-600,600),ctx.lineTo(-210,100),ctx.lineTo(-1100,100),ctx.lineTo(-1100,1400),ctx.lineTo(-600,1400),ctx.lineTo(-10,700),ctx.lineTo(10,700),ctx.lineTo(600,1400),ctx.lineTo(1950,1400),ctx.lineTo(2290,950),ctx.lineTo(2310,950),ctx.lineTo(2650,1400),ctx.lineTo(3025,1400),ctx.lineTo(3025,150),ctx.lineTo(2590,150),ctx.lineTo(2600,-150),ctx.lineTo(1800,-150),ctx.lineTo(1800,-500),ctx.fill()})},office(){let e,t,a=!1;Math.random()<.75?(e=level.button(525,0),t=level.door(1362,-200,25,200,195),level.setPosToSpawn(1375,-1550),level.exit.x=3088,level.exit.y=-630):(a=!0,e=level.button(3800,0),t=level.door(3012,-200,25,200,195),level.setPosToSpawn(3137,-650),level.exit.x=1375,level.exit.y=-1530),level.custom=()=>{e.query(),e.draw(),e.isUp?t.isClosing=!0:t.isClosing=!1,t.openClose(),ctx.fillStyle="#ccc",ctx.fillRect(2495,-500,10,525),ctx.fillStyle="#dff",a?ctx.fillRect(725,-1950,825,450):ctx.fillRect(3050,-950,625,500),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(3650,-1300,1300,1300),ctx.fillRect(3e3,-1e3,650,1e3),ctx.fillRect(750,-1950,800,450),ctx.fillRect(750,-1450,650,1450),ctx.fillRect(-550,-1700,1300,1700),t.draw()},level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom),spawn.mapRect(level.exit.x,level.exit.y+20,100,50),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),document.body.style.backgroundColor="#e0e5e0",spawn.debris(-300,-200,1e3,6),spawn.debris(3500,-200,800,5),spawn.debris(-300,-650,1200,5),powerUps.spawnStartingPowerUps(-525,-700),spawn.mapRect(-600,0,2e3,325),spawn.mapRect(1400,25,1600,300),spawn.mapRect(3e3,0,2e3,325),spawn.mapRect(-600,-1700,50,1900),spawn.bodyRect(-295,-1540,40,40),spawn.bodyRect(-298,-1580,40,40),spawn.bodyRect(1500,-1540,30,30),spawn.mapRect(1550,-2e3,50,550),spawn.mapRect(1350,-1495,50,1295),spawn.mapRect(-600,-1750,1300,50),spawn.mapRect(700,-2e3,50,300),spawn.mapRect(700,-2e3,900,50),map[map.length]=Bodies.polygon(725,-1700,0,15),spawn.bodyRect(720,-1675,15,170,1,spawn.propsDoor),body[body.length-1].isNotHoldable=!0,consBB[consBB.length]=Constraint.create({bodyA:body[body.length-1],pointA:{x:0,y:-90},bodyB:map[map.length-1],stiffness:1}),Composite.add(engine.world,consBB[consBB.length-1]),spawn.mapRect(-300,-1500,1900,50),spawn.mapRect(800,-1480,50,375),spawn.bodyRect(800,-1106,50,106),spawn.mapRect(-600,-1e3,1100,50),spawn.mapRect(600,-1e3,500,50),spawn.spawnStairs(-600,-1e3,4,250,350),spawn.mapRect(375,-600,350,150),spawn.mapRect(-300,-500,1690,50),spawn.spawnStairs(1340,-500,4,250,350,!0),spawn.spawnStairs(-600,0,4,250,350),spawn.bodyRect(700,-200,100,100),spawn.bodyRect(700,-300,100,100),spawn.bodyRect(700,-400,100,100),spawn.mapRect(1390,13,30,20),spawn.mapRect(2980,13,30,20),spawn.bodyRect(4250,-700,50,100),spawn.mapRect(3e3,-1e3,50,800),spawn.mapRect(4950,-1300,50,1100),spawn.mapRect(4150,-600,350,150),spawn.mapRect(3650,-1300,50,700),spawn.mapRect(3650,-1300,1350,50),spawn.bodyRect(3665,-600,20,100),spawn.mapRect(3025,-600,250,125),spawn.mapRect(3175,-550,175,75),spawn.mapRect(3e3,-1e3,700,50),spawn.mapRect(3010,-500,1690,50),spawn.spawnStairs(4950,0,4,250,350,!0),spawn.randomSmallMob(4575,-560,1),spawn.randomSmallMob(1315,-880,1),spawn.randomSmallMob(800,-600),spawn.randomMob(4100,-225,.8),spawn.randomMob(-250,-700,.8),spawn.randomMob(4500,-225,.15),spawn.randomMob(3250,-225,.15),spawn.randomMob(-100,-225,.1),spawn.randomMob(1150,-225,.15),spawn.randomMob(2e3,-225,.15),spawn.randomMob(450,-225,.15),spawn.randomMob(100,-1200,1),spawn.randomMob(950,-1150,-.1),spawn.randomGroup(1800,-800,-.2),spawn.randomGroup(4150,-1e3,.6),simulation.difficulty>1&&(Math.random()<.5?(spawn.tetherBoss(2850,-80,{x:2500,y:-500}),simulation.difficulty>6&&spawn.nodeGroup(2850,-80,"spawns",8,20,105)):spawn.randomLevelBoss(2200,-450)),powerUps.addResearchToLevel(),spawn.secondaryBossChance(1875,-675),simulation.isHorizontalFlipped&&(level.flipHorizontal(),level.setPosToSpawn(50,-60),a?level.setPosToSpawn(-3137,-650):level.setPosToSpawn(-1375,-1550),e.min.x=-e.min.x-126,e.max.x=126-e.max.x,level.custom=()=>{e.query(),e.draw(),e.isUp?t.isClosing=!0:t.isClosing=!1,t.openClose(),ctx.fillStyle="#ccc",ctx.fillRect(-2505,-500,10,525),ctx.fillStyle="#dff",a?ctx.fillRect(-1550,-1950,825,450):ctx.fillRect(-3675,-950,625,500),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(-4950,-1300,1300,1300),ctx.fillRect(-3650,-1e3,650,1e3),ctx.fillRect(-1550,-1950,800,450),ctx.fillRect(-1400,-1450,650,1450),ctx.fillRect(-750,-1700,1300,1700),t.draw()})},stronghold(){const e=level.boost(1470,-250,1080),t=level.boost(-370,0,800),a=level.boost(4865,0,1800);level.custom=()=>{e.query(),t.query(),a.query(),ctx.fillStyle="#edf9f9",ctx.fillRect(-500,-1220,550,-480),ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(0,-700,1050,700),ctx.fillRect(-550,-1170,550,1170),ctx.fillRect(1150,-1700,250,1700),ctx.fillRect(1100,-1700,50,450),ctx.fillRect(1050,-1200,100,1200),ctx.fillRect(1400,-250,200,-1500),ctx.fillRect(1600,-550,600,-1150),ctx.fillRect(2530,-550,430,-1450),ctx.fillRect(3270,-1700,80,600),ctx.fillRect(3350,-1350,700,230),ctx.fillRect(4050,-1700,600,1290),ctx.fillRect(3650,-110,1e3,170),ctx.fillRect(4865,-55,100,55),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{},level.setPosToSpawn(1900,-40),level.exit.x=-350,level.exit.y=-1250,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom),spawn.mapRect(level.exit.x,level.exit.y+25,100,20),spawn.debris(3800,-1480,300,12),spawn.debris(3600,-1130,200,2),document.body.style.backgroundColor="#dbdcde",spawn.mapRect(1600,-500,50,500),spawn.mapRect(1600,-550,1500,50),spawn.mapRect(2300,-500,50,300),spawn.mapRect(-550,0,4300,200),spawn.mapRect(3700,55,1300,145),spawn.mapRect(5e3,0,50,200),spawn.mapRect(3100,-1070,50,570),spawn.mapRect(3100,-1120,950,50),spawn.mapRect(4050,-1750,600,50),spawn.mapRect(4600,-1700,50,100),spawn.mapRect(3650,-160,400,50),spawn.mapRect(4050,-410,600,300),spawn.mapRect(4600,-1120,50,710),spawn.mapRect(4550,-1170,100,50),spawn.mapVertex(3700,35,"0 0 450 0 300 -60 150 -60"),spawn.mapVertex(4850,35,"0 0 370 0 370 -65 150 -65"),spawn.bodyRect(3950,-280,170,120),spawn.bodyRect(4050,-500,275,100,1,spawn.propsSlide),spawn.bodyRect(4235,-500,275,100,1,spawn.propsSlide),spawn.bodyRect(4025,-450,550,100,1,spawn.propsHoist),cons[cons.length]=Constraint.create({pointA:{x:4325,y:-1700},bodyB:body[body.length-1],stiffness:2e-4,length:200}),Composite.add(engine.world,cons[cons.length-1]),spawn.bodyRect(2799,-870,310,290),spawn.mapRect(4e3,-1750,50,400),spawn.mapRect(3400,-1400,600,50),spawn.mapRect(3350,-1750,50,400),spawn.bodyRect(3400,-1470,110,70),spawn.mapRect(3270,-1750,80,50),spawn.mapRect(2530,-2e3,430,50),spawn.mapRect(1600,-1750,600,50),spawn.mapRect(1100,-1750,300,50),spawn.bodyRect(1830,-1980,190,230),spawn.bodyRect(1380,-1770,250,20),spawn.mapRect(1e3,-1250,400,50),spawn.mapRect(1100,-1550,50,190),spawn.bodyRect(1100,-1380,48,109),spawn.mapRect(-100,-750,1100,50),spawn.mapRect(1e3,-1200,50,500),spawn.mapRect(50,-1550,1050,50),spawn.bodyRect(1,-900,48,150),spawn.mapRect(0,-1170,50,270),spawn.bodyRect(920,-900,120,120),spawn.mapRect(0,-1700,50,320),spawn.mapRect(-550,-1220,600,50),spawn.mapRect(-500,-1750,550,50),spawn.mapRect(-550,-1750,50,530),spawn.bodyRect(-503,-1250,30,30),spawn.mapRect(500,-700,100,590),spawn.mapRect(1350,-250,250,250),map[map.length]=Bodies.polygon(2325,-205,0,15),spawn.bodyRect(2325,-180,15,170,1,spawn.propsDoor),body[body.length-1].isNotHoldable=!0,consBB[consBB.length]=Constraint.create({bodyA:body[body.length-1],pointA:{x:0,y:-90},bodyB:map[map.length-1],stiffness:1}),Composite.add(engine.world,consBB[consBB.length-1]),spawn.bodyRect(650,50,70,50),spawn.bodyRect(300,0,100,60),spawn.bodyRect(400,0,100,150),spawn.bodyRect(2545,-50,70,50),spawn.bodyRect(2550,0,100,30),spawn.randomSmallMob(200,-1300,.5),spawn.randomSmallMob(300,-1300,.9),spawn.randomSmallMob(470,-650,1),spawn.randomSmallMob(1e3,-400,1),spawn.randomSmallMob(2550,-560,1),spawn.randomSmallMob(3350,-900,1),spawn.randomSmallMob(3600,-1210,1),spawn.randomSmallMob(700,-1950,.2),spawn.randomSmallMob(5050,-550),spawn.randomMob(-250,-250,.8),spawn.randomMob(-300,-600,.6),spawn.randomMob(350,-900,.5),spawn.randomMob(770,-950,.8),spawn.randomMob(900,-160,1),spawn.randomMob(2360,-820,.8),spawn.randomMob(2700,-2020,.8),spawn.randomMob(3050,-1650,.8),spawn.randomMob(3350,-600,.8),spawn.randomMob(4400,-50,1),spawn.randomGroup(1500,-1900,.5),spawn.randomGroup(2350,-850,1),spawn.randomGroup(100,-450,.9),simulation.difficulty>1&&spawn.randomLevelBoss(1850,-1400),spawn.secondaryBossChance(1850,-1400),powerUps.addResearchToLevel()},basement(){let e,t,a,o,l,n=Math.random();n=!(n<.7);const s=level.platform(4545,-200,110,30,-20),p=level.hazard(1675,-1050,800,150),c=level.portal({x:-620,y:-257},Math.PI/2,{x:500,y:2025},-Math.PI/2);spawn.mapRect(350,2025,300,300),!1===n?(e=level.button(2700,-1150),level.setPosToSpawn(2600,-2050),level.exit.x=level.enter.x+4510,level.exit.y=level.enter.y+600,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),spawn.mapRect(level.enter.x,level.enter.y+20,100,20)):(e=level.button(1450,-1150),o=level.button(3530,-1150),a=level.button(8033,-3625),t=level.door(7700,-3905,25,184,184),l=level.door(3200,-1225,299,80,525),level.setPosToSpawn(7110,-1450),level.exit.x=level.enter.x-4510,level.exit.y=level.enter.y-600,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),spawn.mapRect(7675,-3935,75,25),spawn.mapRect(7675,-3715,75,25),spawn.bodyRect(8075,-3675,50,25));const i=level.boost(8290,-2100,1800);level.custom=()=>{i.query(),level.playerExitCheck(),c[2].query(),c[3].query(),e.query(),e.draw(),!0===n&&(a.draw(),a.query(),o.draw(),o.query(),a.isUp?t.isClosing=!1:t.isClosing=!0,t.openClose(),o.isUp?l.isClosing=!0:l.isClosing=!1,t.openClose(),l.openClose()),p.level(e.isUp),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(61,62,62,0.95)",ctx.fillRect(-750,-900,750,450),!0===n&&(t.draw(),l.draw()),c[0].draw(),c[1].draw(),c[2].draw(),c[3].draw(),p.query(),s.pauseUntilCycle<simulation.cycle&&!m.isBodiesAsleep&&(s.plat.position.y>-200?(s.plat.speed=-20,s.pauseUntilCycle=simulation.cycle+90):s.plat.position.y<-3e3&&(s.plat.speed=30,s.pauseUntilCycle=simulation.cycle+90),s.plat.position={x:s.plat.position.x,y:s.plat.position.y+s.plat.speed},s.pointA=s.plat.position)},level.defaultZoom=1300,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#c7c7c7",spawn.mapRect(-400,-2e3,400,1430),spawn.mapRect(3700,-3e3,700,2650),spawn.mapRect(-400,-2e3,3700,250),spawn.mapRect(2475,-1150,1225,250),spawn.mapRect(500,-1150,1175,250),spawn.mapRect(350,-180,4600,1255),spawn.mapRect(-400,-458,750,3337),spawn.mapRect(-2850,-3375,5300,1375),spawn.mapRect(-2850,-4200,8e3,825),spawn.mapRect(3700,-3375,550,375),spawn.mapRect(-2850,-5200,10200,1e3),spawn.mapRect(5600,-1250,3550,2e3),spawn.mapRect(9150,-5200,1725,5800),spawn.mapRect(2300,-3375,950,1e3),spawn.mapRect(3550,-3375,150,1625),spawn.mapVertex(2020,-791," 250 250 -860 250 -2200 0 250 0"),spawn.mapVertex(690,-295,"1700 0 -200 0 -200 -284 500 -284"),spawn.mapRect(2950,-900,750,250),!1===n?(spawn.mapRect(3250,-1800,50,150),spawn.mapRect(3400,-1800,50,150),spawn.mapRect(3150,-1300,50,200),spawn.mapRect(3500,-1300,50,200),spawn.mapRect(3050,-3375,500,1260),spawn.mapRect(3400,-2265,150,515),spawn.bodyRect(3625,-1225,75,75)):(spawn.mapRect(3050,-3375,500,1e3),spawn.mapRect(3400,-2400,150,650),spawn.bodyRect(3425,-1515,75,75),spawn.mapRect(3200,-1275,300,175)),!1===n?(spawn.bodyRect(0,-1e3,500,120,1,spawn.propsHoist),cons[cons.length]=Constraint.create({pointA:{x:250,y:-1750},bodyB:body[body.length-1],stiffness:14e-5,length:120}),Composite.add(engine.world,cons[cons.length-1]),spawn.bodyRect(0,-1250,240,190)):(spawn.bodyRect(0,-650,225,175),spawn.mapRect(425,-950,175,50),spawn.mapRect(-25,-1150,100,50)),spawn.mapVertex(4200,-1810,"0 0 450 0 600 -2500 0 -2500"),spawn.mapVertex(5e3,-1809,"0 0 450 0 450 -2500 -150 -2500"),spawn.mapRect(4800,-3e3,800,5875),spawn.mapRect(4800,-3150,50,200),spawn.mapRect(5100,-3530,50,380),spawn.mapRect(5100,-3200,150,50),spawn.mapVertex(5450,-3650,"220 0 200 30 -200 30 -220 0 -200 -30 200 -30"),spawn.mapVertex(6225,-3350,"275 0 250 50 -250 50 -275 0 -250 -50 250 -50"),spawn.mapRect(5600,-3e3,1600,725),spawn.mapRect(7300,-3325,50,50),spawn.mapRect(7350,-4075,850,50),spawn.mapRect(7400,-4050,800,50),spawn.mapRect(7450,-4025,750,50),spawn.mapRect(7500,-4e3,700,50),spawn.mapRect(7550,-3975,650,50),spawn.mapRect(7350,-3600,850,50),spawn.mapRect(7400,-3625,800,50),spawn.mapRect(7450,-3650,575,50),spawn.mapRect(7500,-3675,525,50),spawn.mapRect(7550,-3700,475,50),spawn.mapRect(7350,-5200,1800,1125),spawn.mapRect(8475,-4075,675,2825),spawn.mapRect(7300,-2100,1175,850),spawn.mapRect(7350,-3550,850,1275),spawn.mapRect(6600,-2100,200,75),spawn.mapRect(6750,-2100,750,250),spawn.mapRect(6950,-1850,550,200),spawn.mapRect(6750,-1400,750,150),spawn.mapRect(6550,-1625,250,375),spawn.mapRect(6350,-1800,250,550),spawn.mapRect(5600,-2275,800,1025),!1===n?(spawn.bodyRect(1350,-1175,225,25),spawn.bodyRect(1450,-1200,25,25)):(spawn.bodyRect(700,-1175,225,25),spawn.bodyRect(800,-1200,25,25)),spawn.bodyRect(1100,-1375,225,225),spawn.bodyRect(1775,-925,75,25),spawn.bodyRect(2225,-950,75,50),spawn.bodyRect(2e3,-1e3,50,100),spawn.bodyRect(3100,-1175,50,25),spawn.bodyRect(2200,-375,50,50),spawn.bodyRect(2200,-425,50,50),spawn.bodyRect(2200,-475,50,50),spawn.bodyRect(2200,-525,50,50),spawn.bodyRect(1050,-400,50,25),spawn.mapRect(2200,-650,50,125),spawn.mapRect(2200,-325,50,150),spawn.mapRect(2875,-225,250,50),spawn.mapRect(2050,-1225,75,100),!1===n?simulation.difficulty>1&&(Math.random()<.2?(spawn.tetherBoss(7e3,-3300,{x:7300,y:-3300}),simulation.difficulty>4&&spawn.nodeGroup(7e3,-3300,"spawns",8,20,105)):spawn.randomLevelBoss(6100,-3600,["shooterBoss","launcherBoss","laserTargetingBoss","spiderBoss","laserBoss","pulsarBoss"])):simulation.difficulty>1&&(Math.random()<.2?(spawn.tetherBoss(2300,-1300,{x:2300,y:-1750}),simulation.difficulty>4&&spawn.nodeGroup(2350,-1300,"spawns",8,20,105)):spawn.randomLevelBoss(2300,-1400,["shooterBoss","launcherBoss","laserTargetingBoss","spiderBoss","laserBoss","snakeBoss","pulsarBoss"])),spawn.randomSmallMob(100,-1e3,1),spawn.randomSmallMob(1340,-675,1),spawn.randomSmallMob(7e3,-3750,1),spawn.randomSmallMob(6050,-3200,1),spawn.randomMob(1970+10*Math.random(),20*Math.random()-1150,1),spawn.randomMob(3500,-525,.8),spawn.randomMob(6700,-3700,.8),spawn.randomMob(2600,-1300,.7),spawn.randomMob(600,-1250,.7),spawn.randomMob(2450,-250,.6),spawn.randomMob(6200,-3200,.6),spawn.randomMob(900,-700,.5),spawn.randomMob(1960,-400,.5),spawn.randomMob(5430,-3520,.5),spawn.randomMob(400,-700,.5),spawn.randomMob(6500,-4e3,.4),spawn.randomMob(3333,-400,.4),spawn.randomMob(3050,-1220,.4),spawn.randomMob(800,1200,.3),spawn.randomMob(7200,-4e3,.3),spawn.randomMob(250,-1550,.3),spawn.randomGroup(900,-1450,.3),spawn.randomGroup(2980,-400,.3),spawn.randomGroup(5750,-3860,.4),spawn.randomGroup(1130,1300,.1),powerUps.addResearchToLevel(),powerUps.spawn(1900,-940,"heal"),powerUps.spawn(3e3,-230,"heal"),powerUps.spawn(5450,-3675,"ammo"),spawn.mapRect(-850,-2e3,600,1150),spawn.mapRect(-2850,-2e3,2150,4880),spawn.mapRect(-850,-458,500,3340),spawn.mapRect(-400,2025,3450,850),spawn.mapRect(625,1300,225,50),spawn.mapRect(850,1775,470,50),spawn.mapRect(1e3,1625,100,150),spawn.mapRect(1400,1275,100,100),spawn.mapRect(1700,1675,75,450),spawn.mapRect(2100,1375,450,50),spawn.mapRect(2900,900,175,325),spawn.mapRect(2900,1675,150,350),spawn.mapRect(2900,1225,75,100),spawn.mapRect(2900,1575,75,100),spawn.mapRect(2800,1575,100,25),spawn.mapRect(3050,1675,400,1200),spawn.mapRect(3075,1075,375,150),spawn.mapRect(3300,1075,1500,1800),spawn.tetherBoss(2330,1850,{x:2330,y:1425}),spawn.secondaryBossChance(2330,1850),simulation.difficulty>1&&spawn.nodeGroup(2330,1850,"spawns",8,20,105),powerUps.chooseRandomPowerUp(3100,1630)},detours(){level.setPosToSpawn(0,0),level.exit.y=150,spawn.mapRect(level.enter.x,45,100,20),level.exit.x=10625,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#d5d5d5";const e=level.spinner(5500,-412.5,25,660),t=level.rotor(7e3,580,-.001),a=level.door(8590,-520,20,800,750);let o;function l(e,t,a,o){spawn.mapRect(e,t,a,o),len=map.length-1,map[len].collisionFilter.category=cat.map,map[len].collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet,Matter.Body.setStatic(map[len],!0),Composite.add(engine.world,map[len]),simulation.draw.setPaths()}function n(e,t,a,o){spawn.bodyRect(e,t,a,o),len=body.length-1,body[len].collisionFilter.category=cat.body,body[len].collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.mob|cat.mobBullet,Composite.add(engine.world,body[len]),body[len].classType="body"}function s(){l(3800,-270,75,75),l(3900,-895,500,75),l(3900,-1195,75,375),l(3525,-1195,450,75),l(3525,-1995,50,1575),l(3325,-1995,50,1575),l(3525,-1670,1675,75),l(5100,-1670,100,1250),l(1800,-1195,1575,75),l(1800,-1520,375,400),l(1800,-2370,100,1250),l(2375,-1845,375,250),l(2700,-1745,650,75),l(1800,-2370,1775,100),l(3525,-2370,50,775),l(4650,-1220,550,75),n(3225,-1845,100,100),n(3575,1255,125,25),n(2450,2255,25,25),n(3975,-945,175,50),n(4825,-1295,50,75),n(4850,-720,250,200),n(4050,-970,25,25),n(3075,-1245,50,50),o=level.portal({x:3650,y:-1470},Math.PI/2,{x:3250,y:-1473},Math.PI/2),spawn.randomSmallMob(2500,-2070+Math.random(),1),spawn.randomSmallMob(5e3,-1370,1),spawn.randomMob(5e3,-645,.9),spawn.randomMob(4050,-970,.9),spawn.randomSmallMob(2800,-1620,.7),spawn.randomMob(2400,-1370,.5),spawn.randomMob(3725,-1320,.3),spawn.randomGroup(2115,-2020,.1),powerUps.spawn(5e3,-1275,"heal"),level.custom=()=>{o[2].query(),o[3].query(),t.rotate(),a.openClose(),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{a.draw(),o[0].draw(),o[1].draw(),o[2].draw(),o[3].draw(),ctx.fillStyle="#233",ctx.beginPath(),ctx.arc(e.pointA.x,e.pointA.y,9,0,2*Math.PI),ctx.fill()}}if(level.custom=()=>{level.playerExitCheck(),t.rotate(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{a.draw(),ctx.fillStyle="#233",ctx.beginPath(),ctx.arc(e.pointA.x,e.pointA.y,9,0,2*Math.PI),ctx.fill()},spawn.mapRect(-200,-295,75,425),spawn.mapRect(-200,55,700,75),spawn.mapRect(-200,-295,700,75),spawn.bodyRect(470,-220,25,275),spawn.mapRect(450,-520,50,300),spawn.mapRect(450,55,50,300),spawn.mapRect(1700,-520,50,325),spawn.mapRect(1700,55,50,300),spawn.mapRect(4375,55,50,300),spawn.mapRect(4575,55,50,300),spawn.bodyRect(4625,155,75,100),spawn.bodyRect(4725,230,50,25),Math.random()>.5?powerUps.chooseRandomPowerUp(4500,200):powerUps.chooseRandomPowerUp(8350,-630),spawn.bodyRect(7475,1055,50,75),spawn.bodyRect(7775,1105,25,25),spawn.bodyRect(6925,1105,125,25),spawn.bodyRect(6375,380,50,50),spawn.bodyRect(6425,-220,125,150),spawn.bodyRect(6475,-245,125,25),spawn.bodyRect(7675,-245,100,50),spawn.bodyRect(7075,-520,50,100),spawn.bodyRect(8400,-595,100,75),spawn.bodyRect(1700,5,50,50),spawn.bodyRect(1700,-45,50,50),spawn.bodyRect(1700,-95,50,50),spawn.bodyRect(1700,-145,50,50),spawn.bodyRect(1700,-195,50,50),spawn.mapRect(450,-520,1600,100),spawn.mapRect(450,255,1600,100),spawn.mapRect(2250,-45,1450,75),spawn.mapRect(3900,-520,2e3,100),spawn.mapRect(3900,255,2e3,100),spawn.bodyRect(5900,830,325,300),spawn.mapRect(5775,-1295,2900,100),spawn.mapRect(5775,1130,2900,100),spawn.mapRect(5925,-70,650,50),spawn.mapRect(7575,-520,1100,100),spawn.mapRect(6800,-420,450,50),spawn.mapRect(7750,-1295,75,575),spawn.mapRect(6100,430,375,50),spawn.mapRect(7450,-195,1225,75),spawn.mapRect(5775,-1295,125,875),spawn.mapRect(5775,255,125,975),spawn.mapRect(8550,-1295,125,875),spawn.mapRect(8550,180,125,1050),spawn.mapRect(8875,-520,1425,325),spawn.mapRect(8550,-520,1750,100),spawn.mapRect(8550,180,2625,100),spawn.mapRect(10175,-745,125,325),spawn.mapRect(10175,-745,1e3,125),spawn.mapRect(11050,-745,125,1025),spawn.mapRect(8875,80,1425,200),spawn.randomSmallMob(900,-70,1),spawn.randomMob(4300,95,1),spawn.randomSmallMob(6250,630,1),spawn.randomMob(6255,-835,.9),spawn.randomMob(8200,-900,.7),spawn.randomMob(5700,-270,.7),spawn.randomMob(8275,-320,.7),spawn.randomMob(2700,-270,.7),spawn.randomMob(7575,950,.5),spawn.randomMob(7e3,-695,.4),spawn.randomMob(1850,-345,.3),spawn.randomMob(3600,-270,.3),spawn.randomMob(1500,-270,.2),spawn.randomMob(1250,55,.2),spawn.randomMob(8800,-45,.2),spawn.randomGroup(8025,-845,.2),simulation.difficulty>2){let e;spawn.randomLevelBoss(8e3,630,["shooterBoss","launcherBoss","laserTargetingBoss","spiderBoss","laserBoss","bomberBoss","orbitalBoss","pulsarBoss"]),spawn.secondaryBossChance(8e3,630);for(let t=0,a=mob.length;t<a;t++)mob[t].isBoss&&(e=mob[t]);e?e.onDeath=function(){s(),a.isClosing=!1}:(s(),a.isClosing=!1)}else{let e;spawn.randomLevelBoss(8e3,630,["shooterBoss"]);for(let t=0,a=mob.length;t<a;t++)mob[t].isBoss&&(e=mob[t]);e?e.onDeath=function(){s(),a.isClosing=!1}:(s(),a.isClosing=!1)}},house(){const e=level.rotor(4315,-315,-2e-4,120,20,200),t=level.hazard(4350,-1e3,300,110),a=level.door(1152,-1150,25,250,250),o=level.door(1152,-1625,25,150,160),l=level.button(1250,-850),n=level.door(1401,-2150,20,26,28),s=level.door(1401,-2125,20,26,53),p=level.door(1401,-2100,20,26,78),c=level.door(1401,-2075,20,26,103),i=level.door(1401,-2050,20,26,128),r=level.door(1401,-2025,20,26,153);let m,w=!1;level.setPosToSpawn(0,-50),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=3100,level.exit.y=-2480,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),level.defaultZoom=1800,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="rgb(170 170 170)",level.custom=()=>{ctx.fillStyle="rgb(221, 221, 221)",ctx.fillRect(1175,-1425,4e3,1200),ctx.fillStyle="rgb(170 170 170)",ctx.fillRect(1650,-1300,175,150),ctx.fillStyle="rgb(77, 76, 76)",ctx.fillRect(624,-1150,28,1075),ctx.fillStyle="#ababab",ctx.fillRect(3420,-380,285,40),ctx.fillStyle="#474747",ctx.fillRect(3555,-367.5,15,15),ctx.fillRect(3418,-344,288,8),ctx.fillRect(3555,-327.5,15,15),ctx.fillRect(3418,-304,288,8),ctx.fillRect(3555,-285,15,15),ctx.fillStyle="#ababab",ctx.fillRect(3420,-340,285,40),ctx.fillRect(3420,-300,285,45),ctx.fillStyle="rgba(141, 141, 141,1)",ctx.fillRect(3800,-1275,250,425),ctx.fillStyle="#000",ctx.fillRect(3800,-1275,250,3),ctx.fillRect(4048,-1275,3,425),ctx.fillRect(3800,-1275,3,425),ctx.fillRect(3830,-1050,35,10),ctx.fillStyle="rgba(225, 242, 245,0.6)",ctx.fillRect(4050,-1425,1125,600),ctx.fillStyle="#444",ctx.fillRect(1736,-1300,3,150),ctx.fillRect(1650,-1224,175,3),ctx.fillStyle="#5806ac",ctx.fillRect(3375,-625,375,175),ctx.fillStyle="rgba(166, 166, 166,0.8)",ctx.fillRect(4050,-1425,1,600),ctx.fillRect(4090,-1425,1,600),ctx.fillRect(4130,-1425,1,600),ctx.fillRect(4170,-1425,1,600),ctx.fillRect(4210,-1425,1,600),ctx.fillRect(4250,-1425,1,600),ctx.fillRect(4290,-1425,1,600),ctx.fillRect(4330,-1425,1,600),ctx.fillRect(4370,-1425,1,600),ctx.fillRect(4410,-1425,1,600),ctx.fillRect(4450,-1425,1,600),ctx.fillRect(4490,-1425,1,600),ctx.fillRect(4530,-1425,1,600),ctx.fillRect(4570,-1425,1,600),ctx.fillRect(4610,-1425,1,600),ctx.fillRect(4650,-1425,1,600),ctx.fillRect(4690,-1425,1,600),ctx.fillRect(4730,-1425,1,600),ctx.fillRect(4770,-1425,1,600),ctx.fillRect(4810,-1425,1,600),ctx.fillRect(4850,-1425,1,600),ctx.fillRect(4890,-1425,1,600),ctx.fillRect(4930,-1425,1,600),ctx.fillRect(4970,-1425,1,600),ctx.fillRect(5010,-1425,1,600),ctx.fillRect(5050,-1425,1,600),ctx.fillRect(5090,-1425,1,600),ctx.fillRect(5130,-1425,1,600),ctx.fillRect(4050,-1425,1125,2),ctx.fillRect(4050,-1385,1125,2),ctx.fillRect(4050,-1345,1125,2),ctx.fillRect(4050,-1305,1125,2),ctx.fillRect(4050,-1265,1125,2),ctx.fillRect(4050,-1225,1125,2),ctx.fillRect(4050,-1185,1125,2),ctx.fillRect(4050,-1145,1125,2),ctx.fillRect(4050,-1105,1125,2),ctx.fillRect(4050,-1065,1125,2),ctx.fillRect(4050,-1025,1125,2),ctx.fillRect(4050,-985,1125,2),ctx.fillRect(4050,-945,1125,2),ctx.fillRect(4050,-905,1125,2),ctx.fillRect(4050,-865,1125,2),l.query(),l.draw(),l.isUp?0==w&&(a.isClosing=!0,o.isClosing=!0,n.isClosing=!0,s.isClosing=!0,p.isClosing=!0,c.isClosing=!0,i.isClosing=!0,r.isClosing=!0):(a.isClosing=!1,o.isClosing=!1,n.isClosing=!1,s.isClosing=!1,p.isClosing=!1,c.isClosing=!1,i.isClosing=!1,r.isClosing=!1,0==w&&(w=!0)),a.openClose(),o.openClose(),n.openClose(),s.openClose(),p.openClose(),c.openClose(),i.openClose(),r.openClose(),e.rotate(),m=ctx.createRadialGradient(512.5,-1025,5,512.5,-1025,100),m.addColorStop(0,"rgb(255, 199, 43)"),m.addColorStop(1,"rgb(170 170 170)"),ctx.fillStyle=m,ctx.fillRect(450,-1025,125,100),m=ctx.createRadialGradient(762.5,-1025,5,762.5,-1025,100),m.addColorStop(0,"rgb(255, 199, 43, 1)"),m.addColorStop(1,"rgb(170 170 170)"),ctx.fillStyle=m,ctx.fillRect(700,-1025,125,100),ctx.lineWidth=7,ctx.strokeStyle="#444444",ctx.strokeRect(1650,-1300,175,150),chair.force.y+=chair.mass*simulation.g,chair2.force.y+=chair2.mass*simulation.g,P.force.y+=P.mass*simulation.g,level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{ctx.fillStyle="rgba(64,64,64,0.97)",ctx.fillRect(2800,-400,275,175),t.query(),a.draw(),o.draw(),n.draw(),s.draw(),p.draw(),c.draw(),i.draw(),r.draw()};const d=Matter.Bodies.rectangle(4525,-255,25,200,{density:5e-4,isNotHoldable:!0}),y=Matter.Bodies.rectangle(4562,-235,100,25,{density:5e-4,isNotHoldable:!0}),x=Matter.Bodies.rectangle(4600,-202,25,91.5,{density:5e-4,isNotHoldable:!0}),R=Matter.Bodies.rectangle(5100,-255,25,200,{density:5e-4,isNotHoldable:!0}),b=Matter.Bodies.rectangle(5063,-235,100,25,{density:5e-4,isNotHoldable:!0}),h=Matter.Bodies.rectangle(5025,-202,25,91.5,{density:5e-4,isNotHoldable:!0});chair=Body.create({parts:[d,y,x]}),chair2=Body.create({parts:[R,b,h]}),Composite.add(engine.world,[chair]),Composite.add(engine.world,[chair2]),composite[composite.length]=chair,composite[composite.length]=chair2,body[body.length]=d,body[body.length]=y,body[body.length]=x,body[body.length]=R,body[body.length]=b,body[body.length]=h,setTimeout((function(){chair.collisionFilter.category=cat.body,chair.collisionFilter.mask=cat.body|cat.player|cat.bullet|cat.mob|cat.mobBullet|cat.map}),1e3),setTimeout((function(){chair2.collisionFilter.category=cat.body,chair2.collisionFilter.mask=cat.body|cat.player|cat.bullet|cat.mob|cat.mobBullet|cat.map}),1e3);var f=Matter.Bodies.rectangle(300,-260,34,40,{isNotHoldable:!0}),u=Matter.Bodies.rectangle(300,-200,55,80,{isNotHoldable:!0}),v=Matter.Bodies.rectangle(339,-215,20,40,{isNotHoldable:!0}),g=Matter.Bodies.rectangle(339,-175,20,60,{isNotHoldable:!0}),M=Matter.Bodies.rectangle(261,-215,20,40,{isNotHoldable:!0}),T=Matter.Bodies.rectangle(261,-175,20,60,{isNotHoldable:!0}),S=Matter.Bodies.rectangle(280,-143,20,40,{isNotHoldable:!0}),C=Matter.Bodies.rectangle(280,-103,20,60,{isNotHoldable:!0}),B=Matter.Bodies.rectangle(320,-143,20,40,{isNotHoldable:!0}),k=Matter.Bodies.rectangle(320,-103,20,60,{isNotHoldable:!0}),P=Body.create({parts:[u,f,T,M,g,v,C,k,S,B]});Composite.add(engine.world,[P]),composite[composite.length]=P,body[body.length]=u,body[body.length]=f,body[body.length]=x,body[body.length]=C,body[body.length]=S,body[body.length]=M,body[body.length]=T,body[body.length]=k,body[body.length]=B,body[body.length]=g,body[body.length]=v,setTimeout((function(){P.collisionFilter.category=cat.body,P.collisionFilter.mask=cat.body|cat.player|cat.bullet|cat.mob|cat.mobBullet|cat.map}),1e3),spawn.mapRect(-200,0,5400,100),spawn.mapRect(1150,-255,4050,355),spawn.mapRect(800,-255,400,90),spawn.mapRect(650,-170,550,90),spawn.mapRect(500,-85,700,90),spawn.mapRect(1150,-850,50,175),spawn.bodyRect(1162.5,-675,25,420),spawn.mapRect(1150,-850,1500,50),spawn.mapRect(3025,-850,2175,50),spawn.mapRect(5150,-850,50,650),spawn.mapRect(4225,-400,25,150),spawn.mapRect(4225,-400,175,25),spawn.mapRect(4375,-400,25,150),spawn.bodyRect(4350,-350,20,40),spawn.bodyRect(4325,-325,20,20),spawn.bodyRect(4325,-275,20,20),spawn.mapRect(3025,-850,50,225),spawn.mapRect(2925,-775,150,150),spawn.mapRect(2800,-700,275,75),spawn.mapRect(2575,-400,175,175),spawn.mapRect(2475,-325,175,100),spawn.mapRect(2675,-475,400,100),spawn.mapRect(2675,-475,150,250),spawn.mapRect(4025,-850,50,175),spawn.mapRect(4025,-375,50,125),map[map.length]=Bodies.polygon(4050,-675,0,15),spawn.bodyRect(4040,-650,20,260,1,spawn.propsDoor),body[body.length-1].isNotHoldable=!0,consBB[consBB.length]=Constraint.create({bodyA:body[body.length-1],pointA:{x:0,y:-130},bodyB:map[map.length-1],stiffness:1}),Composite.add(engine.world,consBB[consBB.length-1]),spawn.mapRect(4025,-850,50,175),spawn.mapRect(4650,-375,325,25),spawn.mapRect(4700,-350,25,100),spawn.mapRect(4900,-350,25,100),spawn.bodyRect(4875,-400,75,25),spawn.bodyRect(4700,-400,75,25),spawn.mapRect(3400,-400,20,150),spawn.mapRect(3705,-400,20,150),spawn.mapRect(3400,-400,325,20),spawn.mapRect(3500,-415,125,17),spawn.mapRect(3550,-450,25,50),spawn.bodyRect(3075,-375,125,125),spawn.bodyRect(3075,-400,50,25),spawn.bodyRect(3725,-325,100,75),spawn.bodyRect(3375,-275,25,25),spawn.mapRect(1150,-1450,4050,50),spawn.mapRect(5150,-1450,50,650),spawn.mapRect(1150,-1450,50,300),spawn.mapRect(1150,-900,50,100),spawn.mapVertex(1066,-730,"-200 60 0 -60 100 -60 100 60"),spawn.mapRect(2350,-1450,50,175),spawn.mapRect(1475,-1025,25,225),spawn.mapRect(1850,-925,25,125),spawn.mapRect(1475,-925,400,50),spawn.bodyRect(1500,-950,375,25),spawn.bodyRect(1500,-1e3,75,50),spawn.bodyRect(1950,-1e3,30,150),spawn.bodyRect(2250,-1e3,30,150),spawn.bodyRect(1920,-1025,390,25),spawn.mapRect(4025,-1450,50,175),map[map.length]=Bodies.polygon(5050,-925,0,35.4),spawn.mapRect(5015,-960,125,40),spawn.mapRect(5050,-925,90,35.4),spawn.mapVertex(5086.5,-875,"100 60 -30 60 20 0 100 0"),spawn.mapRect(5125,-1070,15,120),spawn.bodyRect(5016,-965,108,15),spawn.mapVertex(4316,-965,"30 100 0 100 -80 -50 30 -50"),spawn.mapVertex(4675,-961.5,"30 100 0 100 0 -50 80 -50"),spawn.mapVertex(4400,-860,"0 -20 -20 20 20 20 0 -20"),spawn.mapVertex(4600,-860,"0 -20 -20 20 20 20 0 -20"),spawn.mapRect(4325,-900,350,25),spawn.mapRect(4300,-1175,25,175),spawn.mapRect(4300,-1175,125,25),spawn.mapRect(4400,-1175,25,50),spawn.mapVertex(4412.5,-1105,"-20 -20 -30 40 30 40 20 -20"),spawn.mapRect(1150,-1475,50,50),spawn.mapRect(1150,-1800,50,175),spawn.mapRect(5150,-1800,50,400),spawn.mapVertex(1300,-1900,"-150 200 -200 200 50 0 100 0"),spawn.mapVertex(1800,-2300,"-150 200 -200 200 175 -100 225 -100"),spawn.mapRect(1390,-2180,250,30),spawn.mapVertex(5050,-1900,"150 200 200 200 -50 0 -100 0"),spawn.mapVertex(4550,-2300,"150 200 200 200 -175 -100 -225 -100"),spawn.mapRect(4710,-2175,250,25),spawn.mapRect(5150,-1450,200,50),spawn.mapRect(3775,-1800,99,50),spawn.mapRect(2425,-2150,50,425),spawn.mapRect(2150,-1775,325,50),spawn.mapRect(3825,-2150,50,750),spawn.mapRect(3826,-2150,149,50),spawn.mapRect(4125,-2150,149,50),spawn.mapRect(4225,-2150,50,450),spawn.mapRect(4225,-1750,250,50),level.chain(2495,-2130,0,!0,10),spawn.bodyRect(2950,-375,120,120),spawn.bodyRect(2350,-1850,75,75),spawn.bodyRect(4275,-1900,75,100),spawn.bodyRect(4825,-1650,325,200),spawn.bodyRect(5025,-1725,25,25),spawn.bodyRect(4900,-1700,200,75),spawn.mapVertex(2950,-2096,"-75 -50 75 -50 75 0 0 100 -75 0"),spawn.mapRect(1963,-2450,2425,35),spawn.mapRect(2925,-2900,125,480),spawn.mapRect(2900,-2900,175,75),spawn.mapRect(2900,-2975,25,100),spawn.mapRect(3050,-2975,25,100),spawn.mapRect(2875,-3e3,225,25),spawn.mapRect(1e3,-1450,200,25),spawn.mapRect(500,-1150,275,25),spawn.mapRect(750,-1150,25,75),spawn.mapRect(500,-1150,25,75),spawn.mapRect(450,-1075,125,50),spawn.mapRect(700,-1075,125,50),spawn.mapRect(2985,-4600,.1,1700),spawn.bodyRect(1740,-475,80,220),spawn.bodyRect(1840,-290,38,23),spawn.bodyRect(1200+1475*Math.random(),-350,15+110*Math.random(),15+110*Math.random()),spawn.bodyRect(1200+1475*Math.random(),-350,15+110*Math.random(),15+110*Math.random()),spawn.bodyRect(3070+600*Math.random(),-1100,20+50*Math.random(),150+100*Math.random()),spawn.bodyRect(3050+1e3*Math.random(),-920,30+100*Math.random(),15+65*Math.random()),spawn.bodyRect(1600+250*Math.random(),-1540,80,220),spawn.debris(3070,-900,1e3,3),spawn.debris(1200,-350,1475,4),spawn.debris(1250,-1550,3565,9),powerUps.chooseRandomPowerUp(2860,-270),spawn.randomSmallMob(1385,-600,1),spawn.randomSmallMob(5e3,-680,1),spawn.randomSmallMob(4750,-925,1),spawn.randomSmallMob(2300,-1830,1),spawn.randomMob(3170,-720,.8),spawn.randomMob(3700,-975,.8),spawn.randomMob(2625,-1150,.7),spawn.randomMob(4175,-750,.7),spawn.randomMob(2100,-370,.7),spawn.randomMob(2e3,-1230,.7),spawn.randomMob(4175,-1075,.6),spawn.randomMob(3965,-1650,.6),spawn.randomMob(4650,-1750,.6),spawn.randomMob(830,-1170,.5),spawn.randomGroup(3730,-1100,.5),spawn.randomMob(2650,-2250,.3),spawn.randomMob(1615,-2270,.3),spawn.randomMob(1380,-1280,.25),spawn.randomMob(2280,-650,.2),spawn.randomGroup(2450,-2650,.2),spawn.randomMob(3800,-580,.2),spawn.randomMob(4630,-425,.1),spawn.randomGroup(630,-1300,-.1),spawn.randomGroup(3450,-2880,-.2),simulation.difficulty>3&&(spawn.secondaryBossChance(3380,-1775),Math.random()<.16?(spawn.tetherBoss(3380,-1775,{x:3775,y:-1775}),simulation.difficulty>4&&spawn.nodeGroup(3380,-1775,"spawns",8,20,105)):spawn.randomLevelBoss(3100,-1850,["shooterBoss","spiderBoss","launcherBoss","laserTargetingBoss","snakeBoss","laserBoss"]))},perplex(){document.body.style.backgroundColor="#dcdcde",level.setPosToSpawn(-600,400),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=550,level.exit.y=-2730,spawn.mapRect(level.exit.x,level.exit.y+20,100,20);const e=level.portal({x:-1e3,y:50},-Math.PI/2,{x:1e3,y:50},-Math.PI/2),t=level.portal({x:1400,y:-2200},-Math.PI/2,{x:1700,y:-1700},-Math.PI/2),a=level.rotor(-200,-1950,-.001);level.custom=()=>{e[2].query(!0),e[3].query(!0),t[2].query(!0),t[3].query(!0),a.rotate(),ctx.fillStyle="#d4f4f4",ctx.fillRect(375,-3e3,450,300),level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{e[0].draw(),e[1].draw(),e[2].draw(),e[3].draw(),t[0].draw(),t[1].draw(),t[2].draw(),t[3].draw(),ctx.fillStyle="rgba(0,0,0,0.03)",ctx.fillRect(-875,-250,1500,700),ctx.fillRect(-925,-505,930,255),ctx.fillStyle="rgba(0,0,0,0.1)",ctx.fillRect(725,-1400,200,200),ctx.fillRect(925,-2150,150,2175),ctx.fillRect(925,-3400,150,850),ctx.fillStyle="rgba(0,0,0,0.03)",ctx.fillRect(1800,-2600,400,400),ctx.fillRect(2200,-2600,400,1250)},level.defaultZoom=1700,simulation.zoomTransition(level.defaultZoom),spawn.mapRect(-925,450,1850,250),spawn.mapRect(-925,-300,55,755),spawn.mapRect(-875,50,1100,50),spawn.mapRect(620,-300,305,755),spawn.bodyRect(200,350,230,100),spawn.bodyRect(300,250,150,100),spawn.mapRect(-875,-300,580,50),spawn.mapRect(0,-300,625,50),spawn.mapRect(0,-650,150,350),spawn.mapRect(-925,-650,975,150),spawn.mapRect(-1280,100,205,150),spawn.mapRect(-1280,245,360,455),spawn.mapRect(-1600,-200,200,50),spawn.mapRect(920,245,160,455),spawn.mapRect(1075,-300,500,1e3),spawn.bodyRect(100,-1e3,50,350),spawn.bodyRect(100,-1015,250,15),spawn.mapRect(-925,-1600,100,1e3),spawn.mapRect(725,-2150,200,750),spawn.mapRect(725,-1200,200,200),spawn.mapRect(300,-1e3,625,50),spawn.mapRect(1075,-2005,550,1055),spawn.mapRect(875,-1e3,50,300),spawn.mapRect(860,-1030,50,300),spawn.mapRect(850,-1100,50,300),spawn.mapRect(830,-980,50,50),spawn.mapRect(1075,-1e3,50,300),spawn.mapRect(1090,-1030,50,300),spawn.mapRect(1100,-1100,50,300),spawn.mapRect(1120,-980,50,50),spawn.mapRect(1850,-650,400,50),spawn.mapRect(-1775,-1e3,700,300),spawn.mapRect(-1900,-2300,175,1600),spawn.mapRect(-1375,-1300,300,50),spawn.mapRect(-1600,-1650,300,50),spawn.mapRect(-1775,-2300,700,300),spawn.mapRect(-830,-1600,300,50),spawn.mapRect(250,-2150,675,50),spawn.mapRect(-925,-2300,100,300),spawn.mapRect(-600,-2700,1525,150),spawn.mapRect(1075,-2150,250,150),spawn.mapRect(1475,-2700,150,700),spawn.mapRect(1775,-1650,250,150),spawn.mapRect(1575,-1505,450,555),spawn.mapRect(1800,-2250,400,50),spawn.bodyRect(2200,-2250,15,300),spawn.mapRect(2200,-1950,400,50),spawn.mapRect(2600,-1650,400,50),spawn.mapRect(2200,-1350,400,50),spawn.bodyRect(2200,-1900,15,550),spawn.bodyRect(2585,-1650,15,300),spawn.mapRect(1800,-4200,800,1600),spawn.mapRect(800,-4200,1800,-500),spawn.mapRect(1075,-3400,225,850),spawn.mapRect(800,-3400,125,850),spawn.mapRect(-700,-2700,100,450),spawn.mapRect(-1450,-2700,900,50),spawn.mapRect(-925,-2300,325,50),spawn.mapRect(-1900,-3e3,450,50),spawn.bodyRect(-1150,-2950,200,250),spawn.mapRect(-1900,-2450,250,450),spawn.mapRect(350,-3e3,50,100),spawn.mapRect(350,-3e3,450,-1700),spawn.bodyRect(350,-2900,50,50.5),spawn.bodyRect(350,-2850,50,50.5),spawn.bodyRect(350,-2800,50,50.5),spawn.bodyRect(350,-2750,50,50.5),spawn.debris(-400,450,400,5),spawn.debris(-1650,-2300,250,4),spawn.debris(-750,-650,750,3),spawn.randomMob(-650,-100,.7),spawn.randomMob(100,-150,.3),spawn.randomMob(-100,-400,0),spawn.randomMob(1450,-450,0),spawn.randomMob(1700,-800,1),spawn.randomGroup(-550,-900,-.3),spawn.randomMob(-1550,-1800,.7),spawn.randomMob(450,-2350,.3),spawn.randomGroup(2400,-2300,-.3),spawn.randomMob(2400,-1450,0),spawn.randomMob(2800,-1800,.5),spawn.randomMob(-1700,-3200,.7),spawn.randomMob(-550,-2800,.3),simulation.difficulty>3&&(Math.random()<.5?spawn.randomLevelBoss(450,-1350,["shooterBoss","launcherBoss","laserTargetingBoss","streamBoss","shieldingBoss","pulsarBoss","laserBoss"]):spawn.randomLevelBoss(-300,-3200,["shooterBoss","launcherBoss","laserTargetingBoss","streamBoss","shieldingBoss","pulsarBoss","laserBoss"])),powerUps.addResearchToLevel(),spawn.secondaryBossChance(7725,2275)},coliseum(){level.custom=()=>{level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{},level.defaultZoom=1800,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#dcdcde",level.setPosToSpawn(200,50),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=8950,level.exit.y=170,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),spawn.mapRect(-100,-400,100,600),spawn.mapRect(-100,100,700,100),spawn.mapRect(500,100,100,1700),spawn.mapRect(500,1700,4e3,100),spawn.mapRect(4100,600,400,100),spawn.mapRect(4400,600,100,1600),spawn.mapRect(4400,2100,4300,100),spawn.mapRect(8600,200,100,2e3),spawn.mapRect(8600,200,700,100),spawn.mapRect(9200,-300,100,600),spawn.mapRect(8600,-300,700,100),spawn.mapRect(8600,-700,100,500),spawn.mapRect(4400,-700,4300,100),spawn.mapRect(4400,-700,100,900),spawn.mapRect(-100,-400,4600,100),spawn.mapRect(1100,400,300,100),spawn.mapRect(500,500,300,100),spawn.mapRect(1050,800,300,100),spawn.mapRect(1770,1050,300,100),spawn.mapRect(1800,500,300,100),spawn.mapRect(2550,900,300,100),spawn.mapRect(2800,1400,300,100),spawn.mapRect(1250,1350,300,100),spawn.mapRect(4750,850,300,100),spawn.mapRect(3200,1050,300,100),spawn.mapRect(4700,100,300,100),spawn.mapRect(5350,0,300,100),spawn.mapRect(3800,900,300,100),spawn.mapRect(5100,500,300,100),spawn.mapRect(5900,-300,300,100),spawn.mapRect(6500,-700,300,1300),spawn.mapRect(7900,0,300,100),spawn.mapRect(8050,800,300,100),spawn.mapRect(7800,1900,300,100),spawn.mapRect(8300,450,300,100),spawn.mapRect(8400,1200,300,100),spawn.mapRect(7570,1100,300,100),spawn.mapRect(6700,1850,300,100),spawn.mapRect(8e3,1500,300,100),spawn.mapRect(7120,-100,300,100),spawn.mapRect(7e3,1500,300,100),spawn.mapRect(6500,1e3,300,1200),spawn.mapRect(5800,1100,300,100),spawn.mapRect(5900,1700,300,100),spawn.mapRect(5300,1400,300,100),spawn.mapRect(5200,1100,300,100),spawn.mapRect(6700,1100,300,100),spawn.mapRect(4800,1650,300,100),spawn.randomMob(1e3,700,.7),spawn.randomGroup(1100,700,.5),spawn.randomMob(1900,400,.7),spawn.randomGroup(2e3,400,.4),spawn.randomGroup(1800,1100,.4),spawn.randomGroup(2700,700,.5),spawn.randomMob(2900,1200,.7),spawn.randomSmallMob(3200,300,.9),spawn.randomSmallMob(3700,800,.9),spawn.randomMob(1100,700,.6),spawn.randomGroup(1200,700,.5),spawn.randomMob(2e3,400,.8),spawn.randomGroup(2100,400,.5),spawn.randomGroup(1900,1100,.5),spawn.randomGroup(2800,700,.5),spawn.randomMob(3e3,1200,.7),spawn.randomSmallMob(3200,300,.9),spawn.randomSmallMob(3700,800,.9),spawn.randomMob(800,1500,.9),spawn.randomMob(1500,1500,.7),spawn.randomMob(2200,1500,.6),spawn.randomMob(2500,1500,.7),spawn.randomMob(2800,1500,.7),spawn.randomMob(3300,1500,.6),spawn.randomGroup(4700,2e3,.9),spawn.randomMob(5e3,2e3,.5),spawn.randomSmallMob(5700,1500,.9),spawn.randomMob(8500,2e3,.6),spawn.randomGroup(8e3,1300,.9),spawn.randomMob(8300,-300,.4),spawn.randomSmallMob(7600,-200,.9),spawn.randomMob(5200,-300,.5),spawn.randomSmallMob(4700,-200,.5),spawn.randomGroup(4700,2e3,.8),spawn.randomMob(5e3,2e3,.5),spawn.randomSmallMob(5700,1500,.9),spawn.randomGroup(8500,2e3,.3),spawn.randomSmallMob(8e3,1300,.4),spawn.randomMob(8300,-300,.3),spawn.randomGroup(7600,-200,.5),spawn.randomMob(5200,-300,.3),spawn.randomGroup(4700,-200,.4),spawn.randomGroup(8650,-200,.9),spawn.randomMob(8650,-200,.9),simulation.difficulty>3&&(spawn.randomLevelBoss(6e3,700,["pulsarBoss","laserTargetingBoss","powerUpBoss","bomberBoss","historyBoss","orbitalBoss"]),simulation.difficulty>10&&spawn.shieldingBoss(7200,500),simulation.difficulty>20&&spawn.randomLevelBoss(2e3,300,["historyBoss","shooterBoss"])),spawn.bodyRect(550,-300,50,400),spawn.bodyRect(4400,200,100,400),spawn.bodyRect(6600,600,50,400),spawn.debris(400,800,400,2),spawn.debris(3800,1600,1200,6),spawn.debris(7500,2e3,800,4),spawn.debris(5500,2e3,800,4),powerUps.spawnStartingPowerUps(1250,1500),powerUps.spawnStartingPowerUps(1500,1500),powerUps.spawn(8650,-200,"ammo"),powerUps.spawn(8650,-200,"ammo"),powerUps.spawn(8650,-200,"ammo"),powerUps.spawn(8650,-200,"ammo"),powerUps.spawn(200,50,"heal"),powerUps.spawn(200,50,"ammo"),powerUps.spawn(200,50,"ammo"),powerUps.spawn(200,50,"ammo"),powerUps.addResearchToLevel(),spawn.secondaryBossChance(6600,600)},crossfire(){const e=level.hazard(0,850,3800,120),t=level.hazard(4600,430,2e3,120),a=level.hazard(6500,200,1e3,170);level.custom=()=>{level.playerExitCheck(),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{e.query(),t.query(),a.query()},level.setPosToSpawn(-500,550),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=10300,level.exit.y=-830,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),level.defaultZoom=3e3,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#dcdcde",spawn.mapRect(-800,-600,800,200),spawn.mapRect(-200,-600,200,800),spawn.mapRect(-800,-600,200,800),spawn.mapRect(-1e3,0,1e3,200),spawn.mapRect(-1e3,0,200,800),spawn.mapRect(-1e3,600,1400,200),spawn.mapRect(0,600,200,400),spawn.mapRect(0,950,4e3,100),spawn.mapRect(800,800,600,200),spawn.mapRect(1700,700,500,300),spawn.mapRect(2500,600,400,400),spawn.mapRect(3200,600,1200,200),spawn.mapRect(3800,600,200,800),spawn.mapRect(3800,1200,800,200),spawn.mapRect(4400,400,300,1e3),spawn.mapRect(4400,500,2e3,100),spawn.mapRect(6500,300,1e3,100),spawn.mapRect(5e3,200,700,400),spawn.mapRect(6e3,0,650,600),spawn.mapRect(6900,-300,700,100),spawn.mapRect(7400,-600,200,1100),spawn.mapRect(7400,300,2600,200),spawn.mapRect(9800,-800,200,1300),spawn.mapRect(9800,-800,1e3,200),spawn.mapRect(10600,-1400,200,800),spawn.mapRect(9800,-1400,200,400),spawn.mapRect(7400,-1400,3400,200),spawn.mapRect(7400,-1600,200,800),spawn.mapRect(5400,-1600,2200,200),spawn.mapRect(6e3,-1600,200,800),spawn.mapRect(5400,-1600,200,800),spawn.mapRect(4800,-1e3,1400,200),spawn.mapRect(4800,-1e3,200,600),spawn.mapRect(3800,-600,1200,200),spawn.mapRect(3200,-800,800,200),spawn.mapRect(3200,-800,200,800),spawn.mapRect(3800,-800,200,800),spawn.mapRect(-200,-200,4200,200),spawn.mapRect(7700,100,300,40),spawn.mapRect(8600,0,300,40),spawn.mapRect(9200,100,300,40),spawn.mapRect(9400,-200,300,40),spawn.mapRect(8e3,-200,300,40),spawn.mapRect(8500,-400,300,40),spawn.mapRect(9e3,-600,300,40),spawn.mapRect(9400,-800,300,40),spawn.mapRect(8600,-1e3,300,40),spawn.mapRect(7900,-800,300,40),spawn.randomMob(200,400,.7),spawn.randomMob(2e3,400,.7),spawn.randomMob(5e3,0,.7),spawn.randomMob(5600,0,.7),spawn.randomMob(6200,-200,.7),spawn.randomMob(7200,-800,.7),spawn.randomSmallMob(800,400,.9),spawn.randomSmallMob(1800,400,.9),spawn.randomSmallMob(5200,0,.9),spawn.randomSmallMob(6400,-200,.9),spawn.randomGroup(3800,400,.5),spawn.randomGroup(4200,400,.5),spawn.randomGroup(7e3,-800,.5),spawn.randomGroup(9800,300,.5),spawn.randomGroup(9800,-1100,.5),simulation.difficulty>3&&spawn.randomLevelBoss(8600,-600,["powerUpBoss","bomberBoss","snakeBoss","spiderBoss","historyBoss"]),spawn.secondaryBossChance(7900,-400),simulation.difficulty>10&&(spawn.pulsarBoss(3600,-400),powerUps.chooseRandomPowerUp(4006,400),powerUps.chooseRandomPowerUp(4407,400),powerUps.spawnStartingPowerUps(4400,400),simulation.difficulty>30&&(powerUps.chooseRandomPowerUp(4002,400),powerUps.chooseRandomPowerUp(4004,400),spawn.pulsarBoss(4200,1e3),simulation.difficulty>60&&(powerUps.chooseRandomPowerUp(4409,400),spawn.pulsarBoss(5800,-1200),simulation.difficulty>80&&(spawn.pulsarBoss(-400,-200),simulation.difficulty>100&&(spawn.pulsarBoss(3600,-400),simulation.difficulty>120&&spawn.pulsarBoss(-400,-200)))))),powerUps.spawnStartingPowerUps(4e3,400),powerUps.addResearchToLevel(),spawn.bodyRect(7450,-800,25,200),spawn.bodyRect(9850,-1e3,25,200),spawn.mapRect(-200,350,200,450),spawn.mapRect(3800,-75,200,525),spawn.mapRect(3875,590,50,150),spawn.mapRect(3875,350,50,140);spawn.debris(1050,700,400,3),spawn.debris(1900,600,400,3),spawn.debris(2700,500,400,3),spawn.debris(4150,500,400,3),spawn.debris(5300,0,400,3),spawn.debris(6300,-100,400,3),spawn.debris(7200,-500,400,3),spawn.debris(8e3,-600,400,3),spawn.debris(8700,-700,400,3),spawn.debris(9300,-900,400,3)},vats(){simulation.zoomScale=1500,level.setPosToSpawn(4400,-1060),spawn.mapRect(level.enter.x,level.enter.y+30,100,20),level.exit.x=3900,level.exit.y=1060,spawn.mapRect(level.exit.x,level.exit.y+30,100,20),document.body.style.backgroundColor="#dcdcde";var e=simulation.cycle+Math.floor(60*Math.random()+30);const t=level.door(475,900,50,200,201),a=level.door(3375,900,50,200,201),o=level.button(3500,-410),l=level.button(-1600,1090),n=level.button(-1600,-1160),s=level.button(5874,-2410);let p=!1,c=!1,r=!1;const w=level.hazard(3700,-940,100,480),d=level.hazard(3700,-461,100,1141),y=level.hazard(700,1200,2500,1300,.004,"hsla(160, 100%, 35%,0.75)"),x=level.hazard(800,-460,2900,90,.004,"hsla(160, 100%, 35%,0.75)"),R=level.rotor(0,-725,.001),b=level.portal({x:-135,y:800},Math.PI/2,{x:570,y:-395},-Math.PI/2),h=level.portal({x:-1800,y:1900},Math.PI,{x:200,y:1105},-Math.PI/2),f=level.drip(1875,-660,-400,70),u=level.drip(3525,-940,-400,150),v=level.drip(1975,100,1200,100);t.isClosing=!0,a.isClosing=!0,spawn.mapRect(4500,-2400,1700,2050),spawn.mapRect(3800,-1e3,700,650),spawn.mapRect(4e3,-1310,50,60),spawn.mapRect(4450,-1310,50,60),spawn.mapRect(4e3,-1320,500,20),level.chain(4025,-1225,.5*Math.PI,!1,5,25),spawn.mapRect(3650,-460,50,90),spawn.mapRect(3525,-1e3,325,20),spawn.mapRect(3650,-1e3,50,440),spawn.mapRect(3300,-1e3,50,450),spawn.mapRect(3325,-725,150,25),spawn.mapRect(3500,-980,175,35),spawn.mapRect(3325,-980,50,35),spawn.mapRect(-1800,-1250,50,120),spawn.mapRect(6150,-2500,50,120),spawn.bodyRect(3350,-1e3,175,20,1,spawn.propsIsNotHoldable),Matter.Body.setMass(body[body.length-1],.7),spawn.mapRect(750,-475,50,75);for(let e=1;e<5;e++)spawn.mapRect(800+100*e+500*(e-1),-120*e-460+20*(e-1),500,20);spawn.mapRect(400,-400,2950,500),spawn.mapRect(-1800,-1150,1800,1950),spawn.mapRect(-1800,1100,780,1800),spawn.mapRect(-300,1100,1e3,1800),spawn.blockDoor(-1800,1070),level.chain(-1e3,1120,0,!0,18,20),spawn.mapRect(700,2500,2500,900),spawn.mapRect(400,100,200,599),spawn.mapRect(400,650,75,250),spawn.mapRect(525,650,75,250),spawn.mapRect(3300,650,75,250),spawn.mapRect(3425,650,75,250),spawn.mapRect(3200,1100,1800,2200),spawn.mapRect(3300,-400,200,1099),spawn.mapRect(3450,-400,250,1100),spawn.mapRect(3650,680,200,20),spawn.mapRect(3800,-400,1400,1100),spawn.mapRect(4100,700,100,300),spawn.mapRect(4900,-400,1300,2500),spawn.bodyRect(4100,1e3,100,100),spawn.bodyRect(-2100,2050,290,30);let g=body[body.length-1];cons[cons.length]=Constraint.create({pointA:{x:-1820,y:2065},bodyB:g,pointB:{x:-135,y:0},stiffness:1,length:1}),cons[cons.length]=Constraint.create({pointA:{x:-1800,y:1400},bodyB:g,pointB:{x:135,y:0},stiffness:.005,length:700}),Composite.add(engine.world,[cons[cons.length-2],cons[cons.length-1]]),spawn.bodyRect(5225,-2525,300,75),spawn.bodyRect(4700,-2525,100,75,.5),spawn.bodyRect(4900,-2600,50,50,.4),spawn.bodyRect(5050,-2475,500,100,.4),spawn.bodyRect(2950,-950,175,75,.5),spawn.bodyRect(3050,-1e3,75,50,.3),spawn.bodyRect(2300,-850,75,50,.7),spawn.bodyRect(2150,-575,100,175,.6),spawn.bodyRect(2500,-550,400,150,.2),spawn.bodyRect(1525,-500,225,100,.2),spawn.bodyRect(1625,-575,100,75),spawn.bodyRect(1e3,-475,100,100,.8),spawn.bodyRect(1225,-450,125,50,.9),spawn.bodyRect(525,-500,175,125,.75),spawn.bodyRect(575,-600,100,75,.5),spawn.bodyRect(-925,-1225,275,75,.4),spawn.bodyRect(-1125,-1300,200,150,.7),spawn.bodyRect(-475,-1250,200,100,.8),spawn.bodyRect(-425,-1300,100,50,.75),spawn.bodyRect(-1225,-1200,100,25,.45),spawn.bodyRect(-1025,-1350,75,50,.5),spawn.bodyRect(-450,1025,75,50,.5),spawn.bodyRect(-775,1050,50,50,.6),spawn.bodyRect(-650,975,75,75,.2),spawn.bodyRect(-475,1025,100,50,.7),spawn.bodyRect(-450,1025,75,50,.6),spawn.bodyRect(-800,1050,100,50,.5),spawn.bodyRect(-600,950,75,75,.3),spawn.bodyRect(-500,1e3,75,25,.2),spawn.bodyRect(-900,1025,150,50),spawn.bodyRect(-1350,1e3,100,100,.4),spawn.bodyRect(-1225,1075,100,25),spawn.debris(900,-1e3,2e3,16),spawn.randomSmallMob(2900,-1e3),spawn.randomSmallMob(1750,-700),spawn.randomMob(4250,-1400),spawn.randomMob(4800,-2400,.3),spawn.randomMob(1e3,600,.3),spawn.randomMob(1650,950,.2),spawn.randomMob(1300,-1250,0),spawn.randomMob(-600,-1250,.1),spawn.randomMob(1e3,-600,.4),spawn.randomMob(1800,-700,.4),spawn.randomMob(2200,950,.2),spawn.randomMob(-1900,1400,.3),spawn.randomMob(-750,-1e3,.3),spawn.randomMob(3250,1e3,.1),spawn.randomMob(2e3,-2800,.4),spawn.randomMob(2200,-500,0),spawn.randomMob(1800,-450,.3),spawn.randomGroup(2300,-450,1),spawn.randomGroup(3e3,-450,.3),spawn.randomGroup(6e3,-2700,0),spawn.randomGroup(-1200,-1300,-.3),powerUps.addResearchToLevel(),simulation.difficulty>3?spawn.randomLevelBoss(1900,400,["shieldingBoss","shooterBoss","launcherBoss","streamBoss"]):a.isClosing=!1,spawn.secondaryBossChance(800,-800),powerUps.spawn(4450,1050,"heal"),Math.random()>.2+simulation.difficulty/60?(powerUps.spawn(4500,1050,"ammo"),powerUps.spawn(4550,1050,"ammo")):(powerUps.spawn(4500,1050,"tech"),spawn.randomMob(4550,1050,1/0)),powerUps.spawnStartingPowerUps(3750,-940);const M=500;for(let e=1;e<5;e++){spawn.bodyRect(700+100*e+M*(e-1),1110,M,20,1,spawn.propsIsNotHoldable);let t=body[body.length-1];cons[cons.length]=Constraint.create({pointA:{x:t.position.x-250+50,y:t.position.y-1025},bodyB:t,pointB:{x:-200,y:0},stiffness:.002,length:1e3}),cons[cons.length]=Constraint.create({pointA:{x:t.position.x+250-50,y:t.position.y-1025},bodyB:t,pointB:{x:200,y:0},stiffness:.002,length:1e3}),Composite.add(engine.world,[cons[cons.length-1],cons[cons.length-2]])}const T=level.boost(4400,-1385,1200);level.custom=()=>{if(T.query(),level.playerExitCheck(),l.query(),n.query(),s.query(),l.isUp||(p||(Matter.Composite.remove(engine.world,cons[1]),cons.splice(1,2)),p=!0),n.isUp||(c=!0),s.isUp||(r=!0),t.isClosing=!(p&&c&&r),t.openClose(),a.openClose(),m.pos.y>1600&&700<m.pos.x&&m.pos.x<3200){Matter.Body.setVelocity(player,{x:0,y:0}),Matter.Body.setPosition(player,{x:200,y:1e3});for(let e=0;e<bullet.length;e++)bullet[e].botType&&(Matter.Body.setPosition(bullet[e],Vector.add(player.position,{x:250*(Math.random()-.5),y:250*(Math.random()-.5)})),Matter.Body.setVelocity(bullet[e],{x:0,y:0}));m.damage(.1*simulation.difficultyMode),m.energy-=.1*simulation.difficultyMode}if(simulation.cycle>=e&&body.length<100){var d=body.length;body[d]=Matter.Bodies.polygon(Math.floor(1700*Math.random())+1050,100,Math.floor(11*Math.random())+10,Math.floor(20*Math.random())+15),body[d].collisionFilter.category=cat.body,body[d].collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.mob|cat.mobBullet,Composite.add(engine.world,body[d]),e=simulation.cycle+Math.floor(60*Math.random()+30)}if(a.isClosing)for(a.isClosing=!1,i=0;i<mob.length;i++)mob[i].isBoss&&525<mob[i].position.x<3200&&-2500<mob[i].position.y<100&&(a.isClosing=!0);for(let e=0,t=body.length;e<t;e++)if(body[e].position.x>700&&body[e].position.x<3200&&body[e].position.y>1200&&!body[e].isNotHoldable){Matter.Body.scale(body[e],.99,.99),body[e].velocity.y>3&&(body[e].force.y-=.96*body[e].mass*simulation.g);const t=body[e].velocity.y>0?Math.max(.3,1-.0015*body[e].velocity.y*body[e].velocity.y):Math.max(.98,1-.001*Math.abs(body[e].velocity.y));if(Matter.Body.setVelocity(body[e],{x:Math.max(.6,1-.07*Math.abs(body[e].velocity.x))*body[e].velocity.x,y:t*body[e].velocity.y}),body[e].mass<.05){Matter.Composite.remove(engine.world,body[e]),body.splice(e,1);break}}for(let e=0,t=mob.length;e<t;++e)mob[e].position.x>700&&mob[e].position.x<3200&&mob[e].alive&&!mob[e].isShielded&&mob[e].position.y>1200&&mobs.statusDoT(mob[e],.005,30);ctx.beginPath(),ctx.fillStyle="#666",ctx.arc(l.min.x-50,l.min.y-70,20,0,2*Math.PI),ctx.fillRect(l.min.x-55,l.max.y+25,10,-95),ctx.fill(),ctx.beginPath(),ctx.arc(n.min.x-50,n.min.y-70,20,0,2*Math.PI),ctx.fillRect(n.min.x-55,n.max.y+25,10,-95),ctx.fill(),ctx.beginPath(),ctx.arc(s.min.x-50,s.min.y-70,20,0,2*Math.PI),ctx.fillRect(s.min.x-55,s.max.y+25,10,-95),ctx.fill(),ctx.beginPath(),ctx.arc(l.min.x-50,l.min.y-70,10,0,2*Math.PI),ctx.fillStyle=p?"rgba(0, 255, 0, 0.9)":"rgba(255, 0, 0, 0.9)",ctx.fill(),ctx.beginPath(),ctx.arc(n.min.x-50,n.min.y-70,10,0,2*Math.PI),ctx.fillStyle=c?"rgba(0, 255, 0, 0.9)":"rgba(255, 0, 0, 0.9)",ctx.fill(),ctx.beginPath(),ctx.arc(s.min.x-50,s.min.y-70,10,0,2*Math.PI),ctx.fillStyle=r?"rgba(0, 255, 0, 0.9)":"rgba(255, 0, 0, 0.9)",ctx.fill(),y.query(),ctx.shadowColor="hsla(160, 100%, 50%, 1)",ctx.shadowBlur=100,ctx.shadowBlur=0,ctx.shadowColor="rgba(0, 0, 0, 0)",o.query(),b[2].query(),h[2].query(),w.level(o.isUp),x.level(!r),R.rotate(),ctx.fillStyle="#d4f4f4",ctx.fillRect(3500,675,600,450),level.exit.draw(),level.enter.draw()},level.customTopLayer=()=>{x.query(),w.query(),d.query(),f.draw(),u.draw(),v.draw(),ctx.fillStyle=`rgba(68, 68, 68, ${Math.max(.3,Math.min((4200-m.pos.x)/100,.99))})`,ctx.fillRect(4100,650,850,500),ctx.fillStyle="rgba(0,20,40,0.1)",ctx.fillRect(4025,-1300,475,300),ctx.fillRect(3325,-1e3,375,600),ctx.fillRect(425,100,3050,2400),ctx.fillRect(-1775,800,1750,2100),ctx.fillStyle="rgba(0,20,40,0.2)",ctx.fillRect(2725,-860,450,460),ctx.fillRect(2125,-760,450,360),ctx.fillRect(1525,-660,450,260),ctx.fillRect(925,-560,450,160),ctx.fillRect(3700,-980,100,1200),ctx.fillStyle="#444",ctx.fillRect(465,690,70,209),ctx.fillRect(3365,690,70,209),ctx.beginPath(),ctx.arc(500,870,20,0,2*Math.PI),ctx.arc(500,820,20,0,2*Math.PI),ctx.arc(500,770,20,0,2*Math.PI),ctx.fillStyle="rgba(0, 0, 0, 0.3",ctx.fill(),ctx.beginPath(),ctx.arc(500,870,10,0,2*Math.PI),ctx.fillStyle=p?"rgba(0, 255, 0, 0.9)":"rgba(255, 0, 0, 0.9)",ctx.fill(),ctx.beginPath(),ctx.arc(500,820,10,0,2*Math.PI),ctx.fillStyle=c?"rgba(0, 255, 0, 0.9)":"rgba(255, 0, 0, 0.9)",ctx.fill(),ctx.beginPath(),ctx.arc(500,770,10,0,2*Math.PI),ctx.fillStyle=r?"rgba(0, 255, 0, 0.9)":"rgba(255, 0, 0, 0.9)",ctx.fill(),o.draw(),l.draw(),n.draw(),s.draw(),b[0].draw(),b[2].draw(),h[0].draw(),h[2].draw()}},"n-gon"(){document.body.style.backgroundColor="#dcdcde";let e=[],t=-200,a=-2350,o=0,l=15,n={x:12,y:24},s={x:-30.96,y:58.34},p={x:0,y:91},c="#ccc",i="#bbb",r="#999",m="#aaa";const w=level.boost(2550,1500,1700),d=level.boost(-3400,-2050,2100);level.custom=()=>{w.query(),d.query(),level.playerExitCheck(),level.exit.draw(),level.enter.draw();for(let t=0;t<e.length;t++)e[t].force.y+=e[t].mass*simulation.g;ctx.fillStyle="#444",ctx.fillRect(2350,995,40,10),ctx.save(),ctx.translate(t,a),R(-3,m),R(0,r),ctx.rotate(o),ctx.beginPath(),ctx.arc(0,0,30*l,0,2*Math.PI);let n=ctx.createLinearGradient(-30*l,0,30*l,0);n.addColorStop(0,i),n.addColorStop(1,c),ctx.fillStyle=n,ctx.fill(),ctx.arc(15*l,0,4*l,0,2*Math.PI),ctx.strokeStyle=r,ctx.lineWidth=2*l,ctx.stroke(),ctx.restore()},level.customTopLayer=()=>{ctx.fillStyle="rgba(60,60,60,0.9)",ctx.fillRect(-3451,-4e3,202,1500),ctx.fillRect(2499,-170,202,1170),ctx.fillStyle="rgba(0,0,0,0.2)",ctx.beginPath(),ctx.moveTo(2360,1e3),ctx.lineTo(2120,900),ctx.lineTo(1500,900),ctx.lineTo(1500,1500),ctx.lineTo(3e3,1500),ctx.lineTo(3e3,1e3),ctx.lineTo(2380,1e3),ctx.lineTo(2870,1500),ctx.lineTo(1870,1500),ctx.lineTo(2360,1e3),ctx.fill(),ctx.fillStyle="rgba(0,0,0,0.3)",ctx.fillRect(1600,-1e3,1400,830),ctx.fillRect(1600,-170,520,170),ctx.fillRect(-1300,-200,2200,200),ctx.fillRect(-800,-400,1200,200),ctx.fillRect(-500,-700,600,300),ctx.fillRect(-4e3,-2500,2e3,2500)},level.setPosToSpawn(1810,1450),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=2700,level.exit.y=-4030,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),level.defaultZoom=3500,simulation.zoomTransition(level.defaultZoom),spawn.debris(2750,1500,200,4),spawn.debris(1770,-350,120,4),spawn.debris(-3200,0,1e3,6),spawn.mapRect(-4100,1500,7200,100),spawn.mapRect(3e3,-4e3,100,5600),spawn.mapRect(-4100,-4e3,100,5600),spawn.mapRect(1600,-4e3,1500,3e3),spawn.mapRect(-4100,0,5600,1550),spawn.mapRect(1500,0,700,900),spawn.mapRect(2120,-170,380,1170),spawn.mapRect(2700,-170,400,1170),spawn.mapRect(-3500,-300,300,400),spawn.mapRect(-3900,-600,300,100),spawn.mapRect(-3500,-900,300,100),spawn.mapRect(-3100,-1150,1e3,150),spawn.mapRect(-2200,-2600,200,1600),spawn.mapRect(-2700,-1450,300,100),spawn.mapRect(-3100,-1750,300,100),spawn.mapRect(-3500,-2050,300,100),spawn.mapRect(-4100,-4e3,650,1500),spawn.mapRect(-3250,-4e3,1250,1500),spawn.mapRect(-700,-900,1e3,200),spawn.mapRect(-700,-900,200,500),spawn.mapRect(-1e3,-600,500,200),spawn.mapRect(-1e3,-600,200,400),spawn.mapRect(-1300,-300,500,100),spawn.mapRect(100,-900,200,500),spawn.mapRect(100,-600,500,200),spawn.mapRect(400,-600,200,400),spawn.mapRect(400,-300,500,100),b(-1900,-4e3,1,1e3,1,!1,{density:.001,friction:1e-4,frictionAir:.001,frictionStatic:0,restitution:0,isNotHoldable:!0}),b(1900,-4600,.2,300,5e-4,!1,{density:5e-5,friction:1e-4,frictionAir:.003,frictionStatic:0,restitution:1,isNotHoldable:!0}),spawn.bodyRect(1920,-400,200,400),spawn.bodyRect(1720,-250,200,250),spawn.bodyRect(1770,-300,150,50),spawn.bodyRect(2120,-280,100,100),spawn.bodyRect(1990,-500,100,100),spawn.bodyRect(850,-50,50,50),spawn.bodyRect(850,-100,50,50),spawn.bodyRect(850,-150,50,50),spawn.bodyRect(850,-200,50,50),spawn.bodyRect(-1300,-50,50,50),spawn.bodyRect(-1300,-100,50,50),spawn.bodyRect(-1300,-150,50,50),spawn.bodyRect(-1300,-200,50,50),spawn.randomMob(700+100*Math.random(),100*Math.random()-500,1),spawn.randomMob(400+100*Math.random(),100*Math.random()-800,.4),spawn.randomMob(100+100*Math.random(),100*Math.random()-1100,-.2),spawn.randomGroup(-200,-1400,-.4),spawn.randomMob(100*Math.random()-600,100*Math.random()-1100,-.2),spawn.randomMob(100*Math.random()-900,100*Math.random()-800,.4),spawn.randomMob(100*Math.random()-1200,100*Math.random()-500,1),spawn.randomSmallMob(400+300*Math.random(),100*Math.random()-150,.2),spawn.randomSmallMob(300*Math.random()-1100,100*Math.random()-150,.2),spawn.randomMob(300*Math.random()-2600,300*Math.random()-700,.6),spawn.randomSmallMob(300*Math.random()-3e3,300*Math.random()-400,.2),spawn.randomSmallMob(300*Math.random()-3e3,300*Math.random()-400,0),spawn.randomMob(100*Math.random()-3900,100*Math.random()-200,.6),spawn.randomMob(100*Math.random()-3400,-400,.4),spawn.randomSmallMob(100*Math.random()-3800,-700,-.4),spawn.randomMob(100*Math.random()-3400,-1e3,.6),spawn.randomMob(100*Math.random()-3e3,-1850,0),spawn.randomGroup(-2700,-2e3,.4),spawn.randomSmallMob(-3800,-5800,-.2),spawn.randomSmallMob(-2400,-5200,.2),spawn.randomGroup(2e3,-5700,.6),powerUps.addResearchToLevel();let y=["shooterBoss","launcherBoss","laserTargetingBoss","streamBoss","pulsarBoss","spawnerBossCulture","laserBoss","growBossCulture"],x=Math.random();function R(e,t){ctx.save(),ctx.translate(e,e);let a=t;ctx.beginPath(),ctx.moveTo((n.x+e)*l,(n.y+e)*l),ctx.lineTo((s.x+2*e)*l,(s.y+e)*l),ctx.lineTo((p.x+e)*l,(p.y+e)*l),ctx.strokeStyle=a,ctx.lineWidth=7*l,ctx.stroke(),ctx.beginPath(),ctx.moveTo((p.x+e)*l,(p.y+e)*l),ctx.lineTo((p.x-15+e)*l,(p.y+5+e)*l),ctx.moveTo((p.x+e)*l,(p.y+e)*l),ctx.lineTo((p.x+15+e)*l,(p.y+5+e)*l),ctx.lineWidth=4*l,ctx.stroke(),ctx.beginPath(),ctx.arc((n.x+e)*l,(n.y+e)*l,11*l,0,2*Math.PI),ctx.moveTo((s.x+7+2*e)*l,(s.y+e)*l),ctx.arc((s.x+2*e)*l,(s.y+e)*l,7*l,0,2*Math.PI),ctx.moveTo((p.x+6+e)*l,(p.y+e)*l),ctx.arc((p.x+e)*l,(p.y+e)*l,6*l,0,2*Math.PI),ctx.fillStyle=c,ctx.fill(),ctx.lineWidth=2*l,ctx.stroke(),ctx.restore()}function b(t,a,o,l,n,s,p){function c(t,a,o,l,n,s,p,c,i,r){const m=Matter.Bodies.fromVertices(t,a,Vertices.fromPath(o),r),w=Matter.Bodies.fromVertices(l,n,Vertices.fromPath(s),r),d=Matter.Bodies.fromVertices(p,c,Vertices.fromPath(i),r),y=Body.create({parts:[m,w,d]});Composite.add(engine.world,[y]),e[e.length]=y,composite[composite.length]=y,body[body.length]=m,body[body.length]=w,body[body.length]=d,setTimeout((function(){y.collisionFilter.category=cat.body,y.collisionFilter.mask=cat.body|cat.player|cat.bullet|cat.mob|cat.mobBullet|cat.map}),1e3)}function i(e,t,a,o,l,n,s=!1){s&&(map[map.length]=Bodies.polygon(e,t,0,15)),cons[cons.length]=Constraint.create({pointA:{x:e,y:t},bodyB:n,pointB:{x:a,y:o},stiffness:l}),Composite.add(engine.world,cons[cons.length-1])}c(t+100*o,a+310*o,"0 0 "+200*o+" 0 "+200*o+" "+620*o+" 0 "+620*o,t+300*o,a+160*o,200*o+" "+40*o+" "+400*o+" "+40*o+" "+400*o+" "+280*o+" "+200*o+" "+280*o,t+499*o,a+333.3*o,400*o+" "+40*o+" "+540*o+" "+40*o+" "+600*o+" "+100*o+" "+600*o+" "+620*o+" "+400*o+" "+620*o+" "+400*o+" "+280*o,p),i(t+300*o,a-l,0,-10*o,n,composite[composite.length-1],s),spawn.bodyRect(t+800*o,a+250*o,200*o,100*o,1,p),body[body.length-1].frictionAir=.05,i(t+900*o,a-l,0,-30*o,n,body[body.length-1],s),c(t+1400*o,a+300*o,"0 0 "+250*o+" 0 "+425*o+" "+175*o+" "+425*o+" "+450*o+" "+275*o+" "+600*o+" 0 "+600*o+" "+-175*o+" "+425*o+" "+-175*o+" "+175*o,t+1636*o,a+633*o,425*o+" "+450*o+" "+425*o+" "+750*o+" "+375*o+" "+800*o+" "+275*o+" "+675*o+" "+275*o+" "+600*o,t+1398*o,a+737*o,375*o+" "+800*o+" "+-75*o+" "+800*o+" "+-75*o+" "+675*o+" "+275*o+" "+675*o,p),i(t+1500*o,a-l,0,-15*o,n,composite[composite.length-1],s),spawn.bodyVertex(t+2300*o,a+300*o,"0 0 "+250*o+" 0 "+425*o+" "+175*o+" "+425*o+" "+425*o+" "+250*o+" "+600*o+" 0 "+600*o+" "+-175*o+" "+425*o+" "+-175*o+" "+175*o,p),i(t+2300*o,a-l,0,-10*o,n,body[body.length-1],s),c(t+2900*o,a+310*o,"0 0 "+200*o+" 0 "+200*o+" "+620*o+" 0 "+620*o,t+3100*o,a+160*o,200*o+" "+40*o+" "+400*o+" "+40*o+" "+400*o+" "+280*o+" "+200*o+" "+280*o,t+3300*o,a+333.3*o,400*o+" "+40*o+" "+540*o+" "+40*o+" "+600*o+" "+100*o+" "+600*o+" "+620*o+" "+400*o+" "+620*o+" "+400*o+" "+280*o,p),i(t+3100*o,a-l,0,-10*o,n,composite[composite.length-1],s)}simulation.difficulty>3&&(x<.6?spawn.randomLevelBoss(250*Math.random()-1500,200*Math.random()-1100,y):x<.85?spawn.laserBoss(300*Math.random()-350,200*Math.random()-600):spawn.randomLevelBoss(850+250*Math.random(),200*Math.random()-1100,y)),spawn.secondaryBossChance(850+250*Math.random(),200*Math.random()-1100)},tunnel(){level.custom=()=>{if(level.playerExitCheck(),ctx.beginPath(),ctx.moveTo(level.enter.x,level.enter.y+30),ctx.lineTo(level.enter.x,level.enter.y-80),ctx.bezierCurveTo(level.enter.x,level.enter.y-170,level.enter.x+100,level.enter.y-170,level.enter.x+100,level.enter.y-80),ctx.lineTo(level.enter.x+100,level.enter.y+30),ctx.lineTo(level.enter.x,level.enter.y+30),ctx.fillStyle="#013",ctx.fill(),ctx.beginPath(),ctx.moveTo(level.exit.x,level.exit.y+30),ctx.lineTo(level.exit.x,level.exit.y-80),ctx.bezierCurveTo(level.exit.x,level.exit.y-170,level.exit.x+100,level.exit.y-170,level.exit.x+100,level.exit.y-80),ctx.lineTo(level.exit.x+100,level.exit.y+30),ctx.lineTo(level.exit.x,level.exit.y+30),ctx.fillStyle="#9ff",ctx.fill(),ctx.fillStyle="#322",ctx.fillRect(3750,-1650,3500,350),m.pos.x>1500&&m.pos.x<2500&&m.pos.y>-4e3&&m.pos.y<-3500&&mob.reduce(((e,t)=>e||Math.sqrt((t.position.x-3600)*(t.position.x-3600)+(t.position.y+3600)*(t.position.y+3600))<2e4&&t.isDropPowerUp),!1)&&!c&&Matter.Body.setPosition(player,{x:2800,y:m.pos.y}),w.query(),y=y||!w.isUp,d.level(!y),Matter.Query.region([player],d).length&&(m.energy-=.001),e.query(),e.draw(),!e.isUp&&!a){for(var i=0;i<5;i++)powerUps.spawn(3614,-3700,"ammo");a=!0}if(t.query(),t.draw(),!t.isUp&&!o){for(i=0;i<4;i++)powerUps.spawn(1614,-3700,"research");o=!0}e.isUp?(l--,n&&(l+=3),l=Math.min(60,Math.max(l,0))):(l+=2,n=1,l=Math.max(0,Math.min(l,60))),n>0&&(n++,n>150&&(n=0)),c||!t.isUp?(s+=2,p=1,s=Math.max(0,Math.min(s,60))):(s--,p&&(s+=3),s=Math.min(60,Math.max(s,0))),p>0&&(p++,p>150&&(p=0)),ctx.beginPath(),ctx.arc(m.pos.x,m.pos.y,200,0,2*Math.PI),ctx.fillStyle="#ff25",ctx.fill(),ctx.beginPath(),ctx.arc(m.pos.x,m.pos.y,400,0,2*Math.PI),ctx.fillStyle="#ff22",ctx.fill(),ctx.beginPath(),ctx.arc(m.pos.x,m.pos.y,700,0,2*Math.PI),ctx.fillStyle="#ff21",ctx.fill(),x.move(),x.drawTrack()},level.customTopLayer=()=>{d.query(),r.level(c),r.query(),w.draw();let e=R.reduce(((e,t)=>e||Math.sqrt((m.pos.x-t[0])*(m.pos.x-t[0])+(m.pos.y+90-t[1])*(m.pos.y+90-t[1]))<50),!1);e?(h++,h=Math.min(h,100)):(h--,h=Math.max(h,-8)),h>-8&&(ctx.fillStyle="#fa0b",ctx.fillRect(m.pos.x-50,m.pos.y-100,Math.min(12.5*h+100,100),15)),h>0&&(ctx.fillStyle="#f00c",ctx.fillRect(m.pos.x-50,m.pos.y-100,h,15),m.damage(.001*(1.5*e+1)),S(m.pos.x,m.pos.y+90,"#d40",Math.PI/2+1),S(m.pos.x,m.pos.y+90,"#d40",Math.PI/2+1),S(m.pos.x,m.pos.y+90,"#d40",Math.PI/2+1),S(m.pos.x,m.pos.y+90,"#d40",Math.PI/2-1),S(m.pos.x,m.pos.y+90,"#d40",Math.PI/2-1),S(m.pos.x,m.pos.y+90,"#d40",Math.PI/2-1),S(m.pos.x,m.pos.y+90,"#f70",Math.PI/2),S(m.pos.x,m.pos.y+90,"#f70",Math.PI/2),S(m.pos.x,m.pos.y+90,"#f70",Math.PI/2));for(let e=0;e<5;e++){S(1130+10*e,-1700);for(let e=0;e<7;e++)S(2550+200*e,-2800);for(let e=0;e<10;e++)S(2800+500*e,-1650);for(let e=0;e<9;e++)S(1595+95*e,-3860);S(4850,-1300),S(6350,-1300)}ctx.fillStyle="#541";for(let e=0;e<9;e++)ctx.fillRect(1592+95*e,-3860,6,70);m.pos.x>1500&&m.pos.x<3750&&m.pos.y>-5e3&&m.pos.y<-3300?(f-=5,f=Math.max(f,85)):(f+=5,f=Math.min(f,250));let t=mob.reduce(((e,t)=>e||Math.sqrt((t.position.x-3600)*(t.position.x-3600)+(t.position.y+3600)*(t.position.y+3600))<2e4&&t.isDropPowerUp),!1)&&!c;if(i.isClosing=t,i.openClose(),ctx.fillStyle="#444444"+f.toString(16),ctx.fillRect(1480,-5e3,2270,1710),t&&(ctx.fillStyle="#444",ctx.fillRect(1480,-5e3,1070,1710)),l>0&&(C([3614,-3530],[2900,-3900],[3400,-3600],l,60),l>=42&&(ctx.font="27px monospace",ctx.textAlign="start",ctx.fillStyle="#00ffff"+Math.floor(12.75*(l-40)).toString(16),ctx.fillText("Waste Discharge Interruption:",2910,-3870),ctx.fillText("Owner 'Scarlet' not found",2910,-3830),ctx.fillText("Detected user: 'm'",2910,-3790),ctx.fillStyle=(t?"#ff6644":"#ffff44")+Math.floor(12.75*(l-40)).toString(16),ctx.fillText(t?"AREA HAS MOBS.":"Area clear.",2910,-3710),ctx.fillText(t?"'openDoor' failed.":"'openDoor' complete.",2910,-3670),ctx.strokeStyle="#00ff00"+Math.floor(6*(l-40)).toString(16),ctx.beginPath(),ctx.arc(3300,-3730,60,0,2*Math.PI),ctx.stroke(),ctx.arc(3330,-3730,8,0,2*Math.PI),ctx.lineWidth=4,ctx.stroke(),ctx.textAlign="center",ctx.fillStyle="#00ffff"+Math.floor(12.75*(l-40)).toString(16),ctx.font="30px monospace",ctx.fillText("n-gon inc",3300,-3630),ctx.font="25px Arial")),s>0&&(C([1614,-3530],[2050,-3900],[1550,-3600],s,60),s>=42&&(ctx.font="27px monospace",ctx.textAlign="start",ctx.fillStyle="#00ffff"+Math.floor(12.75*(s-40)).toString(16),ctx.fillText("SECURITY BREACH DETECTED",1560,-3870),ctx.fillText("Entity name: m",1560,-3830),ctx.fillStyle=(tech.totalCount<25?tech.totalCount<10?"#ffff44":"#22ff22":"#ff6644")+Math.floor(12.75*(s-40)).toString(16),ctx.fillText("Threat level: "+(tech.totalCount<25?tech.totalCount<10?"Low":"Medium":"HIGH"),1560,-3790),tech.totalCount>=15&&ctx.fillText("PROCEDURE ACTIVATED",1560,-3750),ctx.strokeStyle="#00ff00"+Math.floor(6*(s-40)).toString(16),ctx.beginPath(),ctx.arc(1950,-3730,60,0,2*Math.PI),ctx.stroke(),ctx.arc(1980,-3730,8,0,2*Math.PI),ctx.lineWidth=4,ctx.stroke(),ctx.textAlign="center",ctx.fillStyle="#00ffff"+Math.floor(12.75*(s-40)).toString(16),ctx.font="30px monospace",ctx.fillText("n-gon inc",1950,-3630),ctx.font="25px Arial",s>=60&&!c&&tech.totalCount>=10))){for(let e=0;e<5;e++)spawn.exploder(1614,-3900),tech.totalCount>=25&&spawn.randomMob(1614,-3900,1/0);c=!0}},level.setPosToSpawn(0,-50),level.exit.x=8500,level.exit.y=680,level.defaultZoom=1800,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#123",spawn.mapRect(-100,0,1050,100),spawn.mapRect(900,-300,50,300),spawn.mapRect(700,-300,50,200),spawn.mapRect(-100,-350,850,50),spawn.mapRect(900,-350,850,50),spawn.mapRect(-100,-1550,50,1200),spawn.mapRect(1700,-1550,50,1200),spawn.mapRect(-100,-1550,850,50),spawn.mapRect(900,-1550,850,50),spawn.bodyRect(700,-400,50,50),spawn.bodyRect(900,-400,50,50),spawn.mapRect(500,-650,650,25),spawn.mapRect(200,-1e3,200,25),spawn.mapRect(1250,-1e3,200,25),spawn.mapRect(600,-1300,450,25),spawn.mapRect(700,-1650,50,100),spawn.mapRect(900,-1650,50,100),spawn.mapRect(950,-1650,3050,50),spawn.mapRect(1100,-1700,100,50),spawn.mapRect(0,-5e3,1500,3e3),spawn.mapRect(1500,-2050,300,50),spawn.mapRect(2e3,-3100,300,1100),spawn.mapRect(1500,-5e3,2250,1e3),spawn.mapRect(1500,-3500,1050,225),spawn.mapRect(4e3,-5e3,500,3e3),spawn.mapRect(3748,-5e3,252,1550),spawn.mapRect(1700,-2400,300,50),spawn.mapRect(1500,-2750,300,50),spawn.mapRect(2300,-3e3,1700,50),spawn.mapRect(2300,-2800,1700,800),spawn.mapRect(2450,-3300,1300,100),spawn.mapRect(2700,-3500,1050,50),spawn.mapRect(2549,-5e3,1201,1e3);const e=level.button(3550,-3500),t=level.button(1550,-3500);let a=!1,o=!1,l=0,n=0,s=0,p=0,c=!1;const i=level.door(2450,-4e3,100,500,490),r=level.hazard(1500,-4e3,1e3,510,.01),w=level.button(3800,-3e3),d=level.hazard(2300,-3090,1700,110,.005);let y=!1;b.inventory.length<5&&powerUps.spawn(3800,-3200,"gun"),powerUps.spawn(3900,-3100,"heal",!0,null,30),powerUps.spawn(3900,-3100,"heal",!0,null,30),spawn.mapRect(2e3,-1850,50,200),spawn.mapRect(2200,-2e3,50,200),spawn.mapRect(2400,-1850,50,200),spawn.mapRect(4200,-1650,1300,50),spawn.mapRect(5700,-1650,1300,50),spawn.mapRect(7200,-1650,750,50),spawn.mapRect(3700,-1600,50,350),spawn.mapRect(7250,-1600,50,350),spawn.mapRect(3750,-1300,3500,50),spawn.mapRect(4500,-2150,3550,50),spawn.mapRect(7900,-1600,50,1e3),spawn.mapRect(8050,-3e3,50,2400),spawn.mapRect(7e3,-600,950,50),spawn.mapRect(8050,-600,950,50),spawn.mapRect(7e3,-600,50,1e3),spawn.mapRect(8950,-600,50,1e3),spawn.mapRect(7e3,400,950,50),spawn.mapRect(8050,400,950,50),spawn.mapRect(7900,400,50,300),spawn.mapRect(7900,700,1e3,50);const x=level.elevator(7962.5,500,75,50,-1800),R=[];R.push([1150,-1700],[1150,-1770]);for(let e=0;e<10;e++)R.push([2800+500*e,-1650],[2800+500*e,-1720]);R.push([4850,-1300],[6350,-1300],[4850,-1370],[6350,-1370]);let h=-8,f=250,u=[[500,-750],[1150,-750],[825,-1100],[300,-1100],[1350,-1100]];for(;u.length>5-Math.sqrt(2.5*simulation.difficulty)&&u.length;){let e=Math.floor(Math.random()*u.length);spawn[["hopper","sneaker","striker"][Math.floor(3*Math.random())]](u[e][0],u[e][1],60+10*Math.random()),u.splice(e,1)}let v=spawn.pickList.includes("laser");v&&spawn.pickList.splice(spawn.pickList.indexOf("laser"),1);let g=[[50,-1400],[1600,-450],[50,-450],[1600,-1400]];for(let e=0;e<10;e++)g.push([2800+500*e,-1800]);for(;g.length&&mob.length<16*Math.log10(simulation.difficulty+1)-1;){let e=Math.floor(Math.random()*g.length);spawn.randomMob(...g[e]),g.splice(e,1)}let M=["spawn.randomGroup(8250, 575);","spawn.randomGroup(3200, -3700);\n if (simulation.difficulty > 15) \n spawn.randomGroup(3500, -3700, 0.3);","spawn.randomGroup(7800, -1800, 0.5);"];for(;M.length>0;){let e=Math.floor(Math.random()*M.length);Function(M[e])(),M.splice(e,1)}v&&spawn.pickList.push("laser"),spawn.shieldingBoss(3900,-3200,70);let T=Math.floor(2*Math.random());function S(e,t,a="#f81",o=Math.PI/2){ctx.beginPath(),ctx.moveTo(e,t),ctx.strokeStyle=a,ctx.lineWidth=3;for(let a=0;a<3;a++){let a=2*(Math.random()-.5)+o;randLen=30+10*Math.random(),e+=Math.cos(a)*randLen,t-=Math.sin(a)*randLen,ctx.lineTo(e,t)}ctx.stroke()}function C(e,t,a,o,l){ctx.strokeStyle="#003",ctx.fillStyle="#0055aa"+("0"+(60*o/l).toString(16)).slice(-2);let n=(l-o)/l,s=t.map(((t,a)=>(e[a]-t)*n)),p=a.map(((t,a)=>(e[a]-t)*n));ctx.beginPath(),ctx.moveTo(t[0]+s[0],t[1]+s[1]),ctx.lineTo(...e),ctx.lineTo(a[0]+p[0],t[1]+s[1]),ctx.fill(),ctx.stroke(),ctx.beginPath(),ctx.moveTo(t[0]+s[0],t[1]+s[1]),ctx.lineTo(...e),ctx.lineTo(t[0]+s[0],a[1]+p[1]),ctx.fill(),ctx.stroke(),ctx.beginPath(),ctx.moveTo(t[0]+s[0],a[1]+p[1]),ctx.lineTo(...e),ctx.lineTo(a[0]+p[0],a[1]+p[1]),ctx.fill(),ctx.stroke(),ctx.beginPath(),ctx.moveTo(a[0]+p[0],a[1]+p[1]),ctx.lineTo(...e),ctx.lineTo(a[0]+p[0],t[1]+s[1]),ctx.fill(),ctx.stroke(),o>=2*l/3&&(ctx.fillStyle="#0055aa"+("0"+Math.floor(6.25*(o-2*l/3)*60/l).toString(16)).slice(-2),ctx.strokeStyle="#000033"+("0"+Math.floor(12.75*(o-2*l/3)*60/l).toString(16)).slice(-2),ctx.fillRect(t[0],t[1],a[0]-t[0],a[1]-t[1]),ctx.shadowColor="#00aaaa"+("0"+Math.floor(12.75*(o-2*l/3)*60/l).toString(16)).slice(-2),ctx.shadowBlur=10,ctx.strokeRect(t[0],t[1],a[0]-t[0],a[1]-t[1]),ctx.shadowBlur=0,ctx.shadowColor="#0000")}simulation.difficulty>5?spawn[["shooterBoss","launcherBoss"][T]](7500,-150):spawn[["shooter","launcher"][T]](7500,-150,150),spawn[["shooter","launcher"][T]](8500,-150,150)},run(){addPartToMap=e=>{map[e].collisionFilter.category=cat.map,map[e].collisionFilter.mask=cat.player|cat.map|cat.body|cat.bullet|cat.powerUp|cat.mob|cat.mobBullet,Matter.Body.setStatic(map[e],!0),Composite.add(engine.world,map[e])},anotherBoss=(e,t)=>{tech.isDuplicateBoss&&Math.random()<2*tech.duplicationChance()?(tech.isScaleMobsWithDuplication=!0,spawn.randomLevelBoss(e,t,["historyBoss"]),tech.isScaleMobsWithDuplication=!1):tech.isResearchBoss&&(powerUps.research.count>3?(powerUps.research.changeRerolls(-4),simulation.makeTextLog(`<span class='color-var'>m</span>.<span class='color-r'>research</span> <span class='color-symbol'>-=</span> 4<br>${powerUps.research.count}`)):tech.addJunkTechToPool(.49),spawn.randomLevelBoss(e,t,["historyBoss"]))};const e=level.boost(8200,-200,500);var t=!1,a=0,o=!1;let l=["hopper","slasher","striker","stabber","springer","pulsar","sneaker","spinner","grower","focuser","spawner"];level.custom=()=>{for(i in level.playerExitCheck(),level.exit.draw(),level.enter.draw(),e.query(),m.pos.x>8e3&&!1===t&&(spawn.mapRect(7800,-900,200,900),addPartToMap(map.length-1),simulation.draw.setPaths(),simulation.makeTextLog('<strong>UNKNOWN</strong>: "Well done. Now climb."',600),simulation.makeTextLog('<strong>UNKNOWN</strong>: "I left a gift at the top."',600),t=!0),m.pos.x>9e3&&!1===o&&(simulation.makeTextLog('<strong>UNKNOWN</strong>: "Good luck. I hope you get out of here."',600),o=!0),mob)mob[i].damageReduction=0,Matter.Body.setVelocity(mob[i],{x:.97*mob[i].velocity.x,y:.97*mob[i].velocity.y})},level.customTopLayer=()=>{if(ctx.fillStyle="#888",0===a?(ctx.fillRect(8e3,-900,300,100),ctx.fillRect(8500,-1800,300,100),ctx.fillRect(8300,-2700,300,100),ctx.fillRect(8e3,-3600,300,100),ctx.fillRect(8200,-4500,300,100)):1===a?(ctx.fillRect(8300,-1200,300,100),ctx.fillRect(8500,-2100,300,100),ctx.fillRect(8100,-3e3,300,100),ctx.fillRect(8e3,-3900,300,100),ctx.fillRect(8200,-4800,300,100)):2===a&&(ctx.fillRect(8500,-600,300,100),ctx.fillRect(8100,-1500,300,100),ctx.fillRect(8e3,-2400,300,100),ctx.fillRect(8500,-3300,300,100),ctx.fillRect(8500,-4200,300,100)),simulation.cycle%120==0){for(var e=0;e<map.length;e++)map[e].isRemove&&(Matter.Composite.remove(engine.world,map[e]),map.splice(e,1));0===a?(spawn.mapRect(8e3,-900,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8500,-1800,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8300,-2700,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8e3,-3600,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8200,-4500,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,a=1):1===a?(spawn.mapRect(8300,-1200,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8500,-2100,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8100,-3e3,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8e3,-3900,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8200,-4800,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,a=2):2===a&&(spawn.mapRect(8500,-600,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8100,-1500,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8e3,-2400,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8500,-3300,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,spawn.mapRect(8500,-4200,300,100),addPartToMap(map.length-1),map[map.length-1].isRemove=!0,a=0),simulation.draw.setPaths()}},level.defaultZoom=1300,simulation.zoomTransition(level.defaultZoom),document.body.style.backgroundColor="#dcdcde",level.setPosToSpawn(-100,-1450),spawn.mapRect(level.enter.x,level.enter.y+20,100,20),level.exit.x=9300,level.exit.y=-5130,spawn.mapRect(level.exit.x,level.exit.y+20,100,20),spawn.mapRect(-1400,-2200,1700,200),spawn.mapRect(100,-2200,200,1e3),spawn.mapRect(-600,-1400,8600,200),spawn.mapRect(-1400,-2200,200,1e3),spawn.mapRect(-2800,-1400,1600,200),spawn.mapRect(-2800,-1400,200,1400),spawn.mapRect(-2800,-200,11800,200),spawn.mapRect(-900,-600,600,600),spawn.mapRect(200,-800,500,100),spawn.mapRect(1300,-1400,200,900),spawn.mapRect(1300,-600,500,100),spawn.mapRect(2300,-800,200,200),spawn.mapRect(2900,-400,100,400),spawn.mapRect(3200,-600,100,600),spawn.mapRect(3500,-800,100,800),spawn.mapRect(4400,-900,500,100),spawn.mapRect(4400,-600,500,100),spawn.mapRect(4800,-900,100,400),spawn.mapRect(5300,-550,600,550),spawn.mapRect(5600,-900,300,800),spawn.mapRect(6300,-300,1100,300),spawn.mapRect(6600,-400,500,200),spawn.mapRect(6600,-800,500,100),spawn.mapRect(7e3,-1400,100,700),spawn.mapRect(7800,-5900,200,5100),spawn.mapRect(7800,-5900,1900,200),spawn.mapRect(9500,-5900,200,1e3),spawn.mapRect(8800,-5100,900,200),spawn.mapRect(8800,-5100,200,5100),spawn.mapRect(400,-1600,100,10),spawn.mapRect(400,-1600,10,100),spawn.mapRect(490,-1600,10,40),spawn.mapRect(400,-1570,100,10),spawn.mapRect(400,-1540,100,10),spawn.mapRect(490,-1540,10,40),spawn.mapRect(600,-1600,10,100),spawn.mapRect(600,-1510,100,10),spawn.mapRect(690,-1600,10,100),spawn.mapRect(800,-1600,100,10),spawn.mapRect(800,-1600,10,100),spawn.mapRect(890,-1600,10,100),spawn.mapRect(0,0,1,1),spawn.mapRect(1,0,1,1),spawn.mapRect(0,1,1,1),spawn.mapRect(1,1,1,1),spawn.mapRect(-1,0,1,1),spawn.mapRect(0,-1,1,1),spawn.mapRect(-1,-1,1,1),spawn.mapRect(1,-1,1,1),spawn.mapRect(-1,1,1,1),setTimeout((()=>{simulation.makeTextLog('<strong>UNKNOWN</strong>: "You cannot kill them."',600)}),2e3),setTimeout((()=>{simulation.makeTextLog('<strong>UNKNOWN</strong>: "But I have slowed them down for you."',600)}),6e3),spawn[l[Math.floor(Math.random()*l.length)]](200,-400),spawn[l[Math.floor(Math.random()*l.length)]](1800,-1e3),spawn[l[Math.floor(Math.random()*l.length)]](3200,-1e3),spawn[l[Math.floor(Math.random()*l.length)]](6200,-400),simulation.difficulty>10&&(spawn[l[Math.floor(Math.random()*l.length)]](1e3,-400),spawn[l[Math.floor(Math.random()*l.length)]](2400,-400),spawn[l[Math.floor(Math.random()*l.length)]](4e3,-400),spawn[l[Math.floor(Math.random()*l.length)]](6600,-1e3),setTimeout((()=>{simulation.makeTextLog('<strong>UNKNOWN</strong>: "Run."',600)}),1e4)),simulation.difficulty>20&&(spawn[l[Math.floor(Math.random()*l.length)]](1e3,-1e3),spawn[l[Math.floor(Math.random()*l.length)]](3100,-300),spawn[l[Math.floor(Math.random()*l.length)]](4200,-1e3),spawn[l[Math.floor(Math.random()*l.length)]](7400,-800),setTimeout((()=>{simulation.makeTextLog('<strong>UNKNOWN</strong>: "RUN!"',600)}),11e3)),simulation.difficulty>30&&(spawn[l[Math.floor(Math.random()*l.length)]](200,-1e3),spawn[l[Math.floor(Math.random()*l.length)]](3400,-300),spawn[l[Math.floor(Math.random()*l.length)]](5200,-800),spawn[l[Math.floor(Math.random()*l.length)]](7500,-300),setTimeout((()=>{simulation.makeTextLog('<strong>UNKNOWN</strong>: "GET OUT OF HERE."',600)}),12e3)),simulation.difficulty>5&&(spawn.randomLevelBoss(-2200,-700,["historyBoss","powerUpBossBaby","blockBoss","revolutionBoss"]),setTimeout((()=>{simulation.makeTextLog('<strong>UNKNOWN</strong>: "They are coming for you."',600)}),14e3)),anotherBoss(-1800,-700),spawn.bodyRect(1300,-500,200,100),spawn.bodyRect(1400,-500,200,100),spawn.bodyRect(1500,-500,200,100),spawn.bodyRect(5700,-1200,100,100),spawn.bodyRect(5700,-1100,100,100),spawn.bodyRect(5700,-1e3,100,100),spawn.bodyRect(6800,-700,100,100),spawn.bodyRect(6800,-600,100,100),spawn.bodyRect(6800,-500,100,100),spawn.debris(4400,-300,500,16),spawn.debris(3300,-600,200,6),spawn.debris(3e3,-500,20,6),spawn.debris(2300,-300,200,6),spawn.debris(200,-300,500,16),simulation.difficulty>10&&powerUps.spawn(1600,-700,"tech"),powerUps.spawnRandomPowerUp(1700,-700),simulation.difficulty>20&&powerUps.spawn(4600,-700,"tech"),powerUps.spawnRandomPowerUp(4700,-700),simulation.difficulty>30&&powerUps.spawn(6800,-1e3,"tech"),powerUps.spawnRandomPowerUp(6900,-1e3),powerUps.spawn(9200,-5400,"tech"),simulation.difficulty>10&&powerUps.spawn(9200,-5500,"tech"),simulation.difficulty>20&&powerUps.spawn(9200,-5600,"tech"),simulation.difficulty>30&&powerUps.spawn(9200,-5700,"tech"),powerUps.addResearchToLevel()},walk(){m.addHealth(1/0),document.getElementById("health").style.display="none",document.getElementById("health-bg").style.display="none",level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,simulation.lastLogTime=0;let e=0;level.trainingText(`move <strong>↔</strong> with <strong class="key-input-train">${input.key.left.replace("Key","").replace("Digit","")}</strong> and <strong class="key-input-train">${input.key.right.replace("Key","").replace("Digit","")}</strong>`),level.custom=()=>{0===e&&input.right&&(e++,level.trainingText(`<s>move <strong>↔</strong> with <strong class="key-input-train">${input.key.left.replace("Key","").replace("Digit","")}</strong> and <strong class="key-input-train">${input.key.right.replace("Key","").replace("Digit","")}</strong></s>\n <br>exit through the blue door`)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400)},spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,0,3500,1800),spawn.mapRect(1575,0,500,100),spawn.mapRect(-250,-2800,3500,2200),spawn.mapRect(700,-8,50,25),spawn.mapRect(725,-16,75,25),spawn.mapRect(1375,-16,50,50),spawn.mapRect(1400,-8,50,25),spawn.mapRect(750,-24,650,100),spawn.mapRect(1600,-1200,500,850),spawn.mapRect(1600,-400,50,225)},crouch(){m.addHealth(1/0),level.setPosToSpawn(75,-100),spawn.mapRect(25,-60,100,20),spawn.mapRect(0,-50,150,25),spawn.mapRect(-25,-40,200,25),spawn.mapRect(-50,-30,250,25),spawn.mapRect(-75,-20,300,25),spawn.mapRect(-100,-10,350,25),spawn.mapRect(-150,-50,175,75),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor;let e=0;level.trainingText(`press <strong class="key-input-train">${input.key.down.replace("Key","").replace("Digit","")}</strong> to crouch`),level.custom=()=>{0===e&&input.down&&(e++,level.trainingText(`<s>press <strong class="key-input-train">${input.key.down.replace("Key","").replace("Digit","")}</strong> to crouch</s>`)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1625,-350,375,350),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1625,-350,375,350),ctx.fillStyle="rgba(0,0,0,0.2)",ctx.fillRect(500,-100,1125,175)},spawn.mapRect(500,-650,1125,550),spawn.mapRect(-200,-650,875,300),spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(1575,0,500,100),spawn.mapRect(-250,-2800,3500,2200),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1525,25,75,50),spawn.mapRect(1500,38,50,25),spawn.mapRect(1550,12,50,25),spawn.mapRect(1600,-1200,500,850)},jump(){m.addHealth(1/0),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor;let e=0;level.trainingText(`hold down <strong class="key-input-train">${input.key.up.replace("Key","").replace("Digit","")}</strong> longer to jump higher`),level.custom=()=>{0===e&&m.pos.x>300&&(e++,level.trainingText(`<s>hold down <strong class="key-input-train">${input.key.up.replace("Key","").replace("Digit","")}</strong> longer to jump higher</s>`)),m.health=1,ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.2)",ctx.fillRect(1e3,0,450,1800),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400)},spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(275,-350,200,375),spawn.mapRect(-250,0,1250,1800),spawn.mapRect(1450,0,1075,1800),spawn.mapRect(-250,-2800,1250,2200),spawn.mapRect(1450,-2800,1075,2200),spawn.mapVertex(375,0,"150 0 -150 0 -100 -50 100 -50"),spawn.mapRect(1600,-1200,500,850),spawn.mapRect(1600,-400,50,225),spawn.mapRect(1e3,-650,25,25),spawn.mapRect(1e3,-675,50,25),spawn.mapRect(1e3,-700,75,25),spawn.mapRect(1e3,-725,100,25),spawn.mapRect(1425,-650,25,25),spawn.mapRect(1400,-675,50,25),spawn.mapRect(1375,-700,75,25),spawn.mapRect(1350,-725,100,25),spawn.mapRect(1325,-750,150,25),spawn.mapRect(1300,-775,150,25),spawn.mapRect(1e3,-750,125,25),spawn.mapRect(1275,-2800,200,2025),spawn.mapRect(975,-2800,200,2025),spawn.mapRect(1e3,-775,150,25)},hold(){m.addHealth(1/0),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,spawn.bodyRect(1025,-75,50,50);const e=level.button(500,0),t=level.door(1612.5,-175,25,190,185,3);let a=0;level.trainingText(`activate your <strong class='color-f'>field</strong> with <strong class="key-input-train">${input.key.field.replace("Key","").replace("Digit","")}</strong> or <strong>right mouse</strong>`),level.custom=()=>{0===a&&input.field?(a++,level.trainingText(`<s>activate your <strong class='color-f'>field</strong> with <strong class="key-input-train">${input.key.field.replace("Key","").replace("Digit","")}</strong> or <strong>right mouse</strong></s><br>release your <strong class='color-f'>field</strong> on a <strong class='color-block'>block</strong> to pick it up`)):1===a&&m.isHolding?(a++,level.trainingText(`<s>activate your <strong class='color-f'>field</strong> with <strong class="key-input-train">${input.key.field.replace("Key","").replace("Digit","")}</strong> or <strong>right mouse</strong><br>release your <strong class='color-f'>field</strong> on a <strong class='color-block'>block</strong> to pick it up</s><br>drop the <strong class='color-block'>block</strong> on the red button to open the door`)):2===a&&!e.isUp&&Vector.magnitudeSquared(Vector.sub(body[0].position,e.min))<1e4&&(a++,level.trainingText(`<s>activate your <strong class='color-f'>field</strong> with <strong class="key-input-train">${input.key.field.replace("Key","").replace("Digit","")}</strong> or <strong>right mouse</strong><br>release your <strong class='color-f'>field</strong> on a <strong class='color-block'>block</strong> to pick it up<br>drop the <strong class='color-block'>block</strong> on the red button to open the door</s>`)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{e.query(),e.draw(),e.isUp?t.isClosing=!0:t.isClosing=!1,t.openClose(),t.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400)},spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(1575,0,500,100),spawn.mapRect(-250,-2800,3500,2200),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1525,25,75,50),spawn.mapRect(1500,38,50,25),spawn.mapRect(1550,12,50,25),spawn.mapRect(1600,-1200,500,850),spawn.mapRect(1600,-400,50,225)},throw(){m.addHealth(1/0),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,spawn.bodyRect(1025,-75,50,50);const e=level.button(1635,-400),t=level.door(1612.5,-175,25,190,185,3);let a=0;level.trainingText("pick up the <strong class='color-block'>block</strong> with your <strong class='color-f'>field</strong>"),level.custom=()=>{0===a&&m.isHolding?(a++,level.trainingText("<s>pick up the <strong class='color-block'>block</strong> with your <strong class='color-f'>field</strong></s>\n <br>hold your <strong class='color-f'>field</strong> down to charge up then release to throw a <strong class='color-block'>block</strong>")):1===a&&m.throwCharge>2?(a++,level.trainingText("<s>pick up the <strong class='color-block'>block</strong> with your <strong class='color-f'>field</strong>\n <br>hold your <strong class='color-f'>field</strong> down to charge up then release to throw a <strong class='color-block'>block</strong></s>\n <br>throw the <strong class='color-block'>block</strong> onto the button")):2===a&&!e.isUp&&Vector.magnitudeSquared(Vector.sub(body[0].position,e.min))<1e4&&(a++,level.trainingText("<s>pick up the <strong class='color-block'>block</strong> with your <strong class='color-f'>field</strong>\n <br>hold your <strong class='color-f'>field</strong> down to charge up then release to throw a <strong class='color-block'>block</strong>\n <br>throw the <strong class='color-block'>block</strong> onto the button</s>")),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{e.query(),e.draw(),e.isUp?t.isClosing=!0:t.isClosing=!1,t.openClose(),t.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400)},spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(1575,0,500,100),spawn.mapRect(-250,-2800,3500,2200),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1525,25,75,50),spawn.mapRect(1500,38,50,25),spawn.mapRect(1550,12,50,25),spawn.mapRect(1790,-600,250,225),spawn.mapRect(1625,-400,400,50),spawn.mapRect(1600,-400,50,225)},throwAt(){m.addHealth(1/0),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor;const e=level.door(1612.5,-175,25,190,185,3);let t=0;level.trainingText("throw the <strong class='color-block'>block</strong> at the <strong>mobs</strong> to open the door"),level.custom=()=>{0!==t||mob.length||(t++,level.trainingText("<s>throw the <strong class='color-block'>block</strong> at the <strong>mobs</strong> to open the door</s>")),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{mob.length>0?e.isClosing=!0:e.isClosing=!1,e.openClose(),e.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400)},spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(1575,0,500,100),spawn.mapRect(-250,-2800,3500,2200),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1525,25,75,50),spawn.mapRect(1500,38,50,25),spawn.mapRect(1550,12,50,25),spawn.mapRect(1600,-400,50,225),spawn.mapRect(1600,-600,425,250),spawn.bodyRect(1025,-75,50,50),spawn.starter(425,-350,35),spawn.starter(800,-350,44)},fire(){level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=15,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor;const e=level.door(1612.5,-125,25,190,185,3),t=level.button(400,0);let a=0;level.trainingText("use your <strong class='color-f'>field</strong> to pick up the gun power up"),level.custom=()=>{0===a&&simulation.isChoosing?(a++,level.trainingText("<s>use your <strong class='color-f'>field</strong> to pick up the gun power up</s>\n <br>choose a <strong class='color-g'>gun</strong>")):1!==a||simulation.isChoosing?2===a&&0===mob.length?(a++,level.trainingText("<s>use your <strong class='color-f'>field</strong> to pick up the gun power up\n <br>choose a <strong class='color-g'>gun</strong>\n <br>use the <strong>left mouse</strong> button to shoot the <strong>mobs</strong></s>\n <br>drop a <strong class='color-block'>block</strong> on the red button to open the door")):3!==a||e.isClosing||(a++,level.trainingText("<s>use your <strong class='color-f'>field</strong> to pick up the gun power up\n <br>choose a <strong class='color-g'>gun</strong>\n <br>use the <strong>left mouse</strong> button to shoot the <strong>mobs</strong>\n <br>put a <strong class='color-block'>block</strong> on the red button to open the door</s>")):(a++,level.trainingText("<s>use your <strong class='color-f'>field</strong> to pick up the gun power up\n <br>choose a <strong class='color-g'>gun</strong></s>\n <br>use the <strong>left mouse</strong> button to shoot the <strong>mobs</strong>")),!powerUp.length&&b.inventory.length&&0===b.guns[b.activeGun].ammo&&powerUps.directSpawn(1300,-2e3,"ammo",!1),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-350,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{t.query(),t.draw(),t.isUp?e.isClosing=!0:e.isClosing=!1,e.openClose(),e.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-350,400,400),ctx.fillStyle="rgba(0,0,0,0.4)",ctx.fillRect(1250,-2800,100,2200)},spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(-150,-2800,1400,2200),spawn.mapRect(1350,-2800,675,2200),spawn.mapRect(725,-588,50,25),spawn.mapRect(725,-600,75,25),spawn.mapRect(750,-612,75,25),spawn.mapRect(-275,-650,1025,87),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1600,-600,425,300),spawn.mapRect(1600,-400,50,275),powerUps.directSpawn(1300,-1500,"gun",!1),spawn.starter(900,-300,35),spawn.starter(1400,-400,44)},deflect(){m.addHealth(1/0),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor;let e=0;level.trainingText("use your <strong class='color-f'>field</strong> to <strong>deflect</strong> the <strong style=\"color:rgb(215,0,145);\">mobs</strong>"),level.custom=()=>{if(0===e&&m.pos.x>1350&&(e++,level.trainingText("<s>use your <strong class='color-f'>field</strong> to <strong>deflect</strong> the <strong style=\"color:rgb(215,0,145);\">mobs</strong></s>")),m.immuneCycle>m.cycle&&(m.energy=m.maxEnergy,Matter.Body.setPosition(player,{x:60,y:-50})),!(simulation.cycle%5)){spawn.sniperBullet(660+580*Math.random(),-2e3,10,4);const e=mob[mob.length-1];Matter.Body.setVelocity(e,{x:0,y:8}),e.timeLeft=300}ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,0,0,0.05)",ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400),ctx.fillStyle="rgba(255,0,255,0.013)",ctx.fillRect(650,-2800,600,2800)},spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,0,3e3,1800),spawn.mapRect(-250,-2800,900,2200),spawn.mapRect(1250,-2800,1275,2200),spawn.mapVertex(950,0,"400 0 -400 0 -300 -50 300 -50"),spawn.mapRect(1600,-1200,500,850),spawn.mapRect(1600,-400,50,225);for(let e=0;e<32;e++){spawn.sniperBullet(660+580*Math.random(),40*e-2e3,10,4);const t=mob[mob.length-1];Matter.Body.setVelocity(t,{x:0,y:8}),t.timeLeft=300}},heal(){m.addHealth(1/0),m.health=0,m.addHealth(.25),document.getElementById("health").style.display="inline",document.getElementById("health-bg").style.display="inline",level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor;let e=0;level.trainingText('your <strong>health</strong> is displayed in the top left corner\n <br>use your <strong class=\'color-f\'>field</strong> to pick up <div class="heal-circle" style = "border: none;"></div> until your <strong>health</strong> is full'),level.custom=()=>{0===e&&1===m.health&&(e++,level.trainingText('<s>use your <strong class=\'color-f\'>field</strong> to pick up <div class="heal-circle" style = "border: none;"></div> until your <strong>health</strong> is full</s>')),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{1!==m.health?t.isClosing=!0:t.isClosing=!1,t.openClose(),t.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400)},spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,0,3500,1800),spawn.mapRect(1575,0,500,100),spawn.mapRect(-250,-2800,3500,2200),spawn.mapRect(700,-8,50,25),spawn.mapRect(725,-16,75,25),spawn.mapRect(1375,-16,50,50),spawn.mapRect(1400,-8,50,25),spawn.mapRect(750,-24,650,100),powerUps.directSpawn(875,-40,"heal",!1,null,15),powerUps.directSpawn(1075,-50,"heal",!1,null,25),powerUps.directSpawn(1275,-65,"heal",!1,null,35);const t=level.door(1612.5,-175,25,190,185,3);spawn.mapRect(1600,-1200,500,850),spawn.mapRect(1600,-400,50,225)},nailGun(){level.difficultyIncrease(1),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,b.removeAllGuns(),b.giveGuns("nail gun"),b.guns[b.activeGun].ammo=0,simulation.updateGunHUD();const e=level.door(1612.5,-175,25,190,185,3);let t=0;level.trainingText("use your <strong class='color-f'>field</strong> to pick up <div class=\"ammo-circle\" style = \"border: none;\"></div> for your <strong class='color-g'>nail gun</strong>"),level.custom=()=>{0===t&&b.inventory.length&&b.guns[b.activeGun].ammo>0?(t++,level.trainingText("<s>use your <strong class='color-f'>field</strong> to pick up <div class=\"ammo-circle\" style = \"border: none;\"></div> for your <strong class='color-g'>nail gun</strong></s>\n <br>use the <strong>left mouse</strong> button to shoot the <strong>mobs</strong>")):1===t&&0===mob.length&&(t++,level.trainingText("<s>use your <strong class='color-f'>field</strong> to pick up <div class=\"ammo-circle\" style = \"border: none;\"></div> for your <strong class='color-g'>nail gun</strong>\n <br>use the <strong>left mouse</strong> button to shoot the <strong>mobs</strong></s>"));let e=!1;for(let t=0;t<powerUp.length;t++)"ammo"===powerUp[t].name&&(e=!0);!e&&b.inventory.length&&0===b.guns[b.activeGun].ammo&&(powerUps.directSpawn(1300,-2e3,"ammo",!1),powerUps.directSpawn(1301,-2200,"ammo",!1)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{mob.length>0?e.isClosing=!0:e.isClosing=!1,e.openClose(),e.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400),ctx.fillStyle="rgba(0,0,0,0.4)",ctx.fillRect(1250,-2800,100,2200)},m.health<1&&(powerUps.directSpawn(1298,-3500,"heal",!1,23),powerUps.directSpawn(1305,-3e3,"heal",!1,35));for(let e=0;e<2;e++)spawn.spinner(1300+e,-3e3-200*e,25+5*e),Matter.Body.setVelocity(mob[mob.length-1],{x:0,y:62});spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(1575,0,500,100),spawn.mapRect(-150,-2800,1400,2200),spawn.mapRect(1350,-2800,675,2200),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1525,25,75,50),spawn.mapRect(1500,38,50,25),spawn.mapRect(1550,12,50,25),spawn.mapRect(1600,-400,50,225),spawn.mapRect(1600,-600,425,250)},shotGun(){level.difficultyIncrease(1),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,b.removeAllGuns(),b.giveGuns("shotgun");const e=level.door(1612.5,-175,25,190,185,3);let t=0;level.trainingText("use your <strong class='color-g'>shotgun</strong> to clear the room of mobs"),level.custom=()=>{0===t&&0===mob.length&&(t++,level.trainingText("<s>use your <strong class='color-g'>shotgun</strong> to clear the room of mobs</s>"));let e=!1;for(let t=0;t<powerUp.length;t++)"ammo"===powerUp[t].name&&(e=!0);!e&&b.inventory.length&&0===b.guns[b.activeGun].ammo&&(powerUps.directSpawn(1300,-2e3,"ammo",!1),powerUps.directSpawn(1301,-2200,"ammo",!1)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{mob.length>0?e.isClosing=!0:e.isClosing=!1,e.openClose(),e.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400),ctx.fillStyle="rgba(0,0,0,0.4)",ctx.fillRect(1250,-2800,100,2200)},m.health<1&&(powerUps.directSpawn(1298,-3500,"heal",!1,23),powerUps.directSpawn(1305,-3e3,"heal",!1,35));for(let e=0;e<3;e++)spawn.hopper(1300+e,-3e3-2e3*e,25+5*e);spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(1575,0,500,100),spawn.mapRect(-150,-2800,1400,2200),spawn.mapRect(1350,-2800,675,2200),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1525,25,75,50),spawn.mapRect(1500,38,50,25),spawn.mapRect(1550,12,50,25),spawn.mapRect(1600,-400,50,225),spawn.mapRect(1600,-600,425,250)},superBall(){level.difficultyIncrease(1),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,b.removeAllGuns(),b.giveGuns("super balls");const e=level.door(1612.5,-175,25,190,185,3);let t=0;level.trainingText("use <strong class='color-g'>super balls</strong> to clear the room of mobs"),level.custom=()=>{0===t&&0===mob.length&&(t++,level.trainingText("<s>use <strong class='color-g'>super balls</strong> to clear the room of mobs</s>"));let e=!1;for(let t=0;t<powerUp.length;t++)"ammo"===powerUp[t].name&&(e=!0);!e&&b.inventory.length&&0===b.guns[b.activeGun].ammo&&(powerUps.directSpawn(1300,-2e3,"ammo",!1),powerUps.directSpawn(1301,-2200,"ammo",!1)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{mob.length>0?e.isClosing=!0:e.isClosing=!1,e.openClose(),e.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400),ctx.fillStyle="rgba(0,0,0,0.2)",ctx.fillRect(-150,-2800,1500,2450)},m.health<1&&(powerUps.directSpawn(1298,-3500,"heal",!1,23),powerUps.directSpawn(1305,-3e3,"heal",!1,35));for(let e=0;e<6;e++)spawn.spawner(230*e,-800);spawn.mapVertex(510,-430,"725 0 725 80 -650 80 -650 -80 650 -80"),spawn.mapRect(-225,-2800,1450,2e3),spawn.mapRect(1350,-2800,675,2450),spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(1575,0,500,100),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1525,25,75,50),spawn.mapRect(1500,38,50,25),spawn.mapRect(1550,12,50,25),spawn.mapRect(1600,-400,50,225)},matterWave(){level.difficultyIncrease(1),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,b.removeAllGuns(),b.giveGuns("matter wave");const e=level.door(1612.5,-175,25,190,185,3);let t=0;level.trainingText("use <strong class='color-g'>matter wave</strong> to clear the room of mobs"),level.custom=()=>{0===t&&0===mob.length&&(t++,level.trainingText("<s>use <strong class='color-g'>matter wave</strong> to clear the room of mobs</s>"));let e=!1;for(let t=0;t<powerUp.length;t++)"ammo"===powerUp[t].name&&(e=!0);!e&&b.inventory.length&&0===b.guns[b.activeGun].ammo&&(powerUps.directSpawn(1300,-2e3,"ammo",!1),powerUps.directSpawn(1301,-2200,"ammo",!1)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{mob.length>0?e.isClosing=!0:e.isClosing=!1,e.openClose(),e.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400),ctx.fillStyle="rgba(0,0,0,0.2)",ctx.fillRect(-150,-2800,1500,2450)},m.health<1&&(powerUps.directSpawn(1298,-3500,"heal",!1,23),powerUps.directSpawn(1305,-3e3,"heal",!1,35));for(let e=0;e<6;e++)spawn.springer(200*e,-800);spawn.springer(1825,-330,20),spawn.mapRect(1175,-850,50,500),spawn.mapRect(-225,-400,1450,50),spawn.mapRect(-225,-2800,1450,2e3),spawn.mapRect(1350,-2800,675,2450),spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(1575,0,500,100),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1525,25,75,50),spawn.mapRect(1500,38,50,25),spawn.mapRect(1550,12,50,25),spawn.mapRect(1600,-400,50,225)},missile(){level.difficultyIncrease(1),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,30),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,b.removeAllGuns(),b.giveGuns("missiles");const e=level.button(2500,50),t=level.door(1612.5,-175,25,190,185,3);let a=0;level.trainingText("use <strong class='color-g'>missiles</strong> to drop a <strong class='color-block'>block</strong> on the button"),level.custom=()=>{0===a&&0===mob.length&&(a++,level.trainingText("<s>use <strong class='color-g'>missiles</strong> to drop a <strong class='color-block'>block</strong> on the button</s>"));let e=!1;for(let t=0;t<powerUp.length;t++)"ammo"===powerUp[t].name&&(e=!0);!e&&b.inventory.length&&0===b.guns[b.activeGun].ammo&&(powerUps.directSpawn(1300,-2e3,"ammo",!1),powerUps.directSpawn(1301,-2200,"ammo",!1)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{e.query(),e.draw(),e.isUp?t.isClosing=!0:t.isClosing=!1,t.openClose(),t.draw(),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400),ctx.fillStyle="rgba(0,0,0,0.4)",ctx.fillRect(1250,-2800,100,2200),ctx.fillRect(1550,25,475,25)},m.health<1&&(powerUps.directSpawn(1298,-3500,"heal",!1,23),powerUps.directSpawn(1305,-3e3,"heal",!1,35));for(let e=0;e<10;e++)spawn.springer(2100+100*e,-250);spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(3050,-2800,1550,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(-150,-2800,1400,2200),spawn.mapRect(1350,-2800,675,2200),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1550,0,475,35),spawn.mapRect(1600,-400,50,225),spawn.mapRect(1600,-600,425,250),spawn.mapRect(1975,-600,50,625),spawn.mapRect(2025,-2800,1075,2450)},stack(){level.difficultyIncrease(1),level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-685,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,b.removeAllGuns();let e=0;level.trainingText("use your <strong class='color-f'>field</strong> to stack the <strong class='color-block'>blocks</strong>"),level.custom=()=>{0===e&&m.pos.x>1635&&(e++,level.trainingText("<s>use your <strong class='color-f'>field</strong> to stack the <strong class='color-block'>blocks</strong></s>")),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-1050,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-1050,400,400),ctx.fillStyle="rgba(0,0,0,0.4)",ctx.fillRect(250,-2800,200,1800)},m.health<1&&(powerUps.directSpawn(298,-3500,"heal",!1,23),powerUps.directSpawn(305,-3e3,"heal",!1,35));for(let e=0;e<15;e++)spawn.bodyRect(280,-2e3-500*e,30+80*Math.random(),30+80*Math.random());spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,0,3500,1800),spawn.mapRect(1600,-650,450,775),spawn.mapRect(-150,-2800,400,1800),spawn.mapRect(450,-2800,1675,1800),spawn.mapVertex(1300,0,"400 0 -500 0 -300 -125 400 -125")},mine(){level.difficultyIncrease(1),level.setPosToSpawn(300,-50),spawn.mapRect(250,-10,100,20),level.exit.x=1775,level.exit.y=-685,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,b.removeAllGuns(),b.giveGuns("mine");let e=0;level.trainingText("press the red <strong>button</strong> to spawn a <strong>mob</strong>");const t=level.button(-100,-200);t.isUp=!0,spawn.mapRect(-150,-200,240,425),level.custom=()=>{0!==e||t.isUp?1===e&&body.length>2?(e++,level.trainingText("<s>press the red <strong>button</strong> to spawn a <strong>mob</strong><br>turn the <strong>mobs</strong> into <strong class='color-block'>blocks</strong></s><br>use your <strong class='color-f'>field</strong> to stack the <strong class='color-block'>blocks</strong>")):2===e&&m.pos.x>1635&&(e++,level.trainingText("<s>press the red <strong>button</strong> to spawn a <strong>mob</strong><br>turn the <strong>mobs</strong> into <strong class='color-block'>blocks</strong><br>use your <strong class='color-f'>field</strong> to stack the <strong class='color-block'>blocks</strong></s>")):(e++,level.trainingText("<s>press the red <strong>button</strong> to spawn a <strong>mob</strong></s><br>turn the <strong>mobs</strong> into <strong class='color-block'>blocks</strong>"));let a=!1;for(let e=0;e<powerUp.length;e++)"ammo"===powerUp[e].name&&(a=!0);!a&&b.inventory.length&&0===b.guns[b.activeGun].ammo&&(powerUps.directSpawn(1300,-2e3,"ammo",!1),powerUps.directSpawn(1301,-2200,"ammo",!1)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-1050,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{t.query(),t.draw(),t.isUp?t.isReady=!0:t.isReady&&(t.isReady=!1,spawn.exploder(335,-1700),Matter.Body.setVelocity(mob[mob.length-1],{x:0,y:20}),ctx.fillStyle="rgba(255,0,0,0.9)",ctx.fillRect(550,-2800,200,1800)),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-1050,400,400),ctx.fillStyle="rgba(0,0,0,0.4)",ctx.fillRect(550,-2800,200,1800)},m.health<1&&(powerUps.directSpawn(298,-3500,"heal",!1,23),powerUps.directSpawn(305,-3e3,"heal",!1,35)),spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,0,3500,1800),spawn.mapRect(1600,-650,450,775),spawn.mapRect(-150,-2800,700,1800),spawn.mapRect(750,-2800,1675,1800),spawn.mapVertex(1300,0,"400 0 -600 0 -300 -125 400 -125")},grenades(){level.difficultyIncrease(1),level.setPosToSpawn(0,-50),spawn.mapRect(-50,-10,100,20),level.exit.x=1900,level.exit.y=-2835,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,b.removeAllGuns(),b.giveGuns("grenades");const e=level.elevator(550,-100,180,25,-840,.003,{up:.05,down:.2});e.addConstraint();const t=level.toggle(275,0),a=level.elevator(1400,-950,180,25,-2400,.0025);a.addConstraint();const o=level.button(1e3,-850);let l=0;level.trainingText("flip the <strong>switch</strong> to turn on the <strong>elevator</strong>"),level.custom=()=>{0===l&&e.isOn?(l++,level.trainingText("<s>flip the <strong>switch</strong> to turn on the <strong>elevator</strong></s>\n <br>put a <strong class='color-block'>block</strong> on the <strong>button</strong> to active the <strong>elevator</strong>")):1===l&&a.isOn?(l++,level.trainingText("<s>flip the <strong>switch</strong> to turn on the <strong>elevator</strong><br>put a <strong class='color-block'>block</strong> on the <strong>button</strong> to active the <strong>elevator</strong></s>\n <br>hold <strong>jump</strong> before the <strong>elevator's</strong> <strong>apex</strong> to reach the <strong>exit</strong>")):2===l&&m.pos.x>1635&&(l++,level.trainingText("<s>flip the <strong>switch</strong> to turn on the <strong>elevator</strong><br>put a <strong class='color-block'>block</strong> on the <strong>button</strong> to active the <strong>elevator</strong><br>hold <strong>jump</strong> before the <strong>elevator's</strong> <strong>apex</strong> to reach the <strong>exit</strong></s>")),ctx.fillStyle="#f2f2f2",ctx.fillRect(1725,-3100,375,300),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{t.query(),t.isOn?e.isOn||(e.isOn=!0,e.isUp=!1,e.removeConstraint(),e.frictionAir=.2):e.isOn&&(e.isOn=!1,e.frictionAir=.2,e.addConstraint()),e.isOn?(e.move(),ctx.fillStyle="#444"):ctx.fillStyle="#aaa",ctx.fillRect(640,-825,1,745),o.query(),o.draw(),o.isUp?a.isOn&&(a.isOn=!1,a.frictionAir=.2,a.addConstraint()):a.isOn||(a.isOn=!0,a.isUp=!1,a.removeConstraint(),a.frictionAir=.2),a.isOn?(a.move(),ctx.fillStyle="#444"):ctx.fillStyle="#aaa",ctx.fillRect(1490,-2300,1,1375),ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1725,-3100,375,300),ctx.fillStyle="rgba(0,0,0,0.05)",ctx.fillRect(-150,-250,300,250);let l=ctx.createLinearGradient(0,-150,0,-2300);l.addColorStop(0,"rgba(0,0,0,0.35)"),l.addColorStop(1,"rgba(0,0,0,0)"),ctx.fillStyle=l,ctx.fillRect(-200,-2300,1825,2300)},m.health<1&&(powerUps.directSpawn(298,-3500,"heal",!1,23),powerUps.directSpawn(305,-3e3,"heal",!1,35)),spawn.mapRect(-2750,-4800,2600,6600),spawn.mapRect(1600,-2800,3e3,4600),spawn.mapRect(-150,-4800,300,4550),spawn.mapRect(2125,-4775,2475,2050),spawn.mapRect(-250,0,3500,1800),spawn.mapRect(750,-850,950,950),spawn.mapRect(125,-275,25,100),spawn.mapRect(2100,-3150,50,350),spawn.mapRect(1725,-3150,50,175),spawn.mapRect(1725,-3150,425,50),spawn.nodeGroup(1200,-1500,"grenadier",7)},harpoon(){level.difficultyIncrease(1),level.setPosToSpawn(0,-50),spawn.mapRect(-50,-10,100,20),level.exit.x=1900,level.exit.y=-2835,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor,b.removeAllGuns(),b.giveGuns("harpoon");let e=0;level.trainingText("climb up to the exit"),level.custom=()=>{0===e&&m.pos.x>1635&&(e++,level.trainingText("<s>climb up to the exit</s>")),ctx.fillStyle="#f2f2f2",ctx.fillRect(1725,-3100,375,300),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1725,-3100,375,300),ctx.fillStyle="rgba(0,90,100,0.05)",ctx.fillRect(-150,-250,300,250);let e=ctx.createLinearGradient(0,-150,0,-2300);e.addColorStop(0,"rgba(0,90,100,0.35)"),e.addColorStop(1,"rgba(0,90,100,0)"),ctx.fillStyle=e,ctx.fillRect(-200,-2300,1825,2300),t.query(),a.query(),o.query(),l.query(),n.query(),s.query(),p.query(),c.query(),i.query(),r.query(),w.query(),d.query()};const t=level.vanish(175,-325,175,25),a=level.vanish(525,-625,175,25),o=level.vanish(1125,-1125,175,25),l=level.vanish(1500,-1450,100,25),n=level.vanish(1125,-1675,175,25),s=level.vanish(750,-1950,175,25),p=level.vanish(550,-1950,175,25),c=level.vanish(350,-1950,175,25),i=level.vanish(150,-1950,175,25),r=level.vanish(325,-2300,200,25),w=level.vanish(725,-2550,100,25),d=level.vanish(1125,-2700,150,25);m.health<1&&(powerUps.directSpawn(298,-3500,"heal",!1,23),powerUps.directSpawn(305,-3e3,"heal",!1,35)),spawn.mapRect(-2750,-4800,2600,6600),spawn.mapRect(1600,-2800,3e3,4600),spawn.mapRect(-150,-4800,300,4550),spawn.mapRect(2125,-4775,2475,2050),spawn.mapRect(-250,0,3500,1800),spawn.mapRect(750,-850,950,950),spawn.mapRect(125,-275,25,100),spawn.mapRect(2100,-3150,50,350),spawn.mapRect(1725,-3150,50,175),spawn.mapRect(1725,-3150,425,50),spawn.grower(250,-375),spawn.grower(1e3,-900),spawn.grower(1475,-925),spawn.grower(275,-2e3),spawn.grower(650,-2e3),spawn.grower(1475,-975),spawn.grower(1575,-1525),spawn.grower(1700,-2850)},trainingTemplate(){m.addHealth(1/0),document.getElementById("health").style.display="none",document.getElementById("health-bg").style.display="none",level.setPosToSpawn(60,-50),spawn.mapRect(10,-10,100,20),level.exit.x=1775,level.exit.y=-35,spawn.mapRect(level.exit.x,level.exit.y+25,100,100),simulation.zoomScale=1400,level.defaultZoom=1400,simulation.zoomTransition(level.defaultZoom,1),document.body.style.backgroundColor=level.trainingBackgroundColor;let e=0;level.trainingText(`press <strong class="key-input-train">${input.key.down.replace("Key","").replace("Digit","")}</strong> to crouch`),level.custom=()=>{0===e&&input.down&&(e++,level.trainingText(`<s>press <strong class="key-input-train">${input.key.down.replace("Key","").replace("Digit","")}</strong> to crouch</s>`)),ctx.fillStyle="#f2f2f2",ctx.fillRect(1600,-400,400,400),level.exit.draw(),level.enter.draw(),level.playerExitCheck()},level.customTopLayer=()=>{ctx.fillStyle="rgba(0,255,255,0.05)",ctx.fillRect(1600,-400,400,400)},spawn.mapRect(-2750,-2800,2600,4600),spawn.mapRect(2e3,-2800,2600,4600),spawn.mapRect(-250,50,3500,1750),spawn.mapRect(-200,0,950,100),spawn.mapRect(1575,0,500,100),spawn.mapRect(-250,-2800,3500,2200),spawn.mapRect(725,12,50,25),spawn.mapRect(725,25,75,25),spawn.mapRect(750,38,75,25),spawn.mapRect(1525,25,75,50),spawn.mapRect(1500,38,50,25),spawn.mapRect(1550,12,50,25),spawn.mapRect(1600,-1200,500,850),spawn.mapRect(1600,-400,50,225)}};