function createCanvas(e){var t=document.createElement("canvas");t.id=e,t.width=canvases.cvs.width,t.height=canvases.cvs.height,t.style="image-rendering:pixelated;image-rendering: crisp-edges;display:none",document.body.appendChild(t),canvases[`${e}cvs`]=document.getElementById(e),canvases[`${e}ctx`]=canvases[`${e}cvs`].getContext("2d")}function startLoops(){try{draw}catch(e){return console.warn(bug+" no draw function found"),null}try{update}catch(e){return console.warn(bug+" no update function found"),null}try{input}catch(e){seperateInputLoop=!1}try{onAssetsLoaded()}catch(e){}requestAnimationFrame(drawLoop),setInterval(updateLoop,1e3/updateFPS),seperateInputLoop&&setInterval(inputLoop,4)}function mousePosition(){if(0===drawMode){return{x:mousePos.x-camera.x,y:mousePos.y-camera.y}}if(1===drawMode){var e=canvases.cvs.width/2,t=canvases.cvs.height/2;return{x:(mousePos.x-e)/camera.zoom+e-camera.x,y:(mousePos.y-t)/camera.zoom+t-camera.y}}e=canvases.cvs.width/2,t=canvases.cvs.height/2;var a={x:(mousePos.x-e)/camera.zoom+e-camera.x,y:(mousePos.y-t)/camera.zoom+t-camera.y},n={x:-camera.x+cw/2,y:-camera.y+ch/2},s=pointTo(n,a)-camera.angle,o=dist(n,a);return{x:n.x+Math.cos(s)*o,y:n.y+Math.sin(s)*o}}function addStyle(){var e=document.createElement("style");e.id="gamejsstyle",document.head.appendChild(e);var t=document.createElement("meta");t.setAttribute("charset","utf-8"),document.head.appendChild(t)}function rand(e,t){return Math.floor(Math.random()*(t-e+1))+e}function radToDeg(e){return e/Math.PI*180}function degToRad(e){return e*Math.PI/180}function velocity(e){return{x:Math.sin(e),y:Math.cos(e)}}function pointTo(e,t){var a=t.x-e.x,n=t.y-e.y;return Math.atan2(n,a)}function loadImagesAndSounds(){var e="";function t(a,n){let s="";for(let o=0;ocw-32&&mousePos.y<32?(mousePress[0]&&e&&(clickSound.play(),paused=!0,optionsMenu=!optionsMenu),optionsHover=25):optionsHover=0,mousePos.xcw-64&&mousePos.y<32?(pauseHover=25,mousePress[0]&&(clickSound.play(),paused=!paused)):pauseHover=0}function addFont(){var e=document.createElement("style");document.head.appendChild(e),canvases.ctx.textBaseline="hanging",canvases.ctx.textAlign="left"}function img(e,t,a,n=0,s=1,o=1){var r=e.drawLimitSize;if(t+r>drawLimitLeft&&t-rdrawLimitTop&&a-ro){var c=r[e].split(" "),i="",u=0;r.splice(e,1);for(let t=0;t=t.x-t.w/2&&e.x-e.w/2<=t.x+t.w/2&&e.y+e.h/2>=t.y-t.h/2&&e.y-e.h/2<=t.y+t.h/2}function rectpoint(e,t){return e.x+e.w/2>=t.x&&e.x-e.w/2<=t.x&&e.y+e.h/2>=t.y&&e.y-e.h/2<=t.y}function circlerect(e,t){let a=t.w/2,n=t.h/2,s=e.x-Math.max(t.x-a,Math.min(e.x,t.x+a)),o=e.y-Math.max(t.y-n,Math.min(e.y,t.y+n));return s*s+o*os&&ic&&i>s&&ir&&uo&&u>r&&us&&Pc&&P>s&&Pr&&So&&S>r&&Sedge.right&&(e.v.x*=-1,e.x=edge.right-n),t-nedge.bottom&&(e.v.y*=-1,e.y=edge.bottom-s),a-sedge.right&&(e.v.x*=-1,e.x=edge.right-n),t-nedge.bottom&&(e.v.y*=-1,e.y=edge.bottom-n),a-n