Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

craters

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

craters - npm Package Compare versions

Comparing version 0.1.0-rebase.1 to 0.1.0-rebase.2

10

dist/font-manager.d.ts

@@ -1,5 +0,4 @@

import Canvas2DRenderer from "./canvas-2d-renderer";
import Tile from "./tile";
declare class Font {
fontMap: any;
fontAtlas: any;
canvas2DRenderer: any;

@@ -11,8 +10,7 @@ constructor(fontMap: Map<number, {

height: number;
font: Tile;
}>);
}>, fontAtlas: any);
draw(text: string, destX: number, destY: number): void;
}
export default class FontManager {
canvas2DRenderer: Canvas2DRenderer;
canvas2DRenderer: any;
fontName: string;

@@ -23,5 +21,5 @@ fill: boolean;

strokeStyle: string;
constructor(canvas2DRenderer: Canvas2DRenderer, fontName: string, fillStyle?: string, strokeStyle?: string, fill?: boolean, stroke?: boolean);
constructor(canvas2DRenderer: any, fontName: string, fillStyle?: string, strokeStyle?: string, fill?: boolean, stroke?: boolean);
load(letters: string): Font;
}
export {};

2

dist/index.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.CRATERS=e():t.CRATERS=e()}(self,(function(){return(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AssetsManager:()=>r,Canvas2DRenderer:()=>o,FontManager:()=>y,Input:()=>E,RenderLoop:()=>w,SoundManager:()=>x,Sprite:()=>R,Tile:()=>v,TilemapManager:()=>b,WebGLRenderer:()=>p,default:()=>F});var n=function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))},i=function(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};const r=function(){function t(){}return t.prototype.loadText=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,fetch(t).then((function(t){return t.text()}))]}))}))},t.prototype.loadJson=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,fetch(t).then((function(t){return t.json()}))]}))}))},t.prototype.loadImage=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,n){var i=new Image;i.onload=function(){e(i)},i.onerror=n,i.src=t}))]}))}))},t.prototype.loadFont=function(t,e){return n(this,void 0,void 0,(function(){return i(this,(function(n){return[2,new FontFace(t,e).load()]}))}))},t.prototype.loadBinary=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,fetch(t).then((function(t){return t.blob()}))]}))}))},t}(),o=function(){function t(t,e,n,i){void 0===i&&(i=window.devicePixelRatio),this.width=t,this.height=e,this.canvasElement=document.createElement("canvas",n),this.context=this.canvasElement.getContext("2d"),this.devicePixelRatio=i,this.canvasElement.style.width=t+"px",this.canvasElement.style.height=e+"px",this.canvasElement.width=Math.round(t*i),this.canvasElement.height=Math.round(e*i),this.context.setTransform(i,0,0,i,0,0)}return t.prototype.createImage=function(t){return t},t.prototype.drawImage=function(t,e,n,i,r,o,a,s,h){this.context.drawImage(t,e,n,i,r,o,a,s,h)},t.prototype.clear=function(t,e,n,i,r){void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=this.width),void 0===r&&(r=this.height),t?(this.context.save(),this.context.fillStyle=t,this.context.fillRect(e,n,i,r),this.context.restore()):this.context.clearRect(e,n,i,r)},t.prototype.resize=function(t,e,n){void 0===t&&(t=this.width),void 0===e&&(e=this.height),void 0===n&&(n=this.devicePixelRatio),this.width=t,this.height=e,this.devicePixelRatio=n,this.canvasElement.style.width=t+"px",this.canvasElement.style.height=e+"px",this.canvasElement.width=Math.round(t*n),this.canvasElement.height=Math.round(e*n),this.context.setTransform(n,0,0,n,0,0)},t}();var a="undefined"!=typeof Float32Array?Float32Array:Array;function s(){var t=new a(16);return a!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function h(t,e,n){var i,r,o,a,s,h,u,c,d,f,l,p,v=n[0],m=n[1],y=n[2];return e===t?(t[12]=e[0]*v+e[4]*m+e[8]*y+e[12],t[13]=e[1]*v+e[5]*m+e[9]*y+e[13],t[14]=e[2]*v+e[6]*m+e[10]*y+e[14],t[15]=e[3]*v+e[7]*m+e[11]*y+e[15]):(i=e[0],r=e[1],o=e[2],a=e[3],s=e[4],h=e[5],u=e[6],c=e[7],d=e[8],f=e[9],l=e[10],p=e[11],t[0]=i,t[1]=r,t[2]=o,t[3]=a,t[4]=s,t[5]=h,t[6]=u,t[7]=c,t[8]=d,t[9]=f,t[10]=l,t[11]=p,t[12]=i*v+s*m+d*y+e[12],t[13]=r*v+h*m+f*y+e[13],t[14]=o*v+u*m+l*y+e[14],t[15]=a*v+c*m+p*y+e[15]),t}function u(t,e,n){var i=n[0],r=n[1],o=n[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}Math.random,Math.PI,Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var c=function(t,e,n,i,r,o,a){var s=1/(e-n),h=1/(i-r),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*s,t[13]=(r+i)*h,t[14]=(a+o)*u,t[15]=1,t};function d(t,e,n){var i=new a(3);return i[0]=t,i[1]=e,i[2]=n,i}f=new a(3),a!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0);var f,l=function(){function t(t,e,n,i){void 0===i&&(i=window.devicePixelRatio),this.width=t,this.height=e,this.canvasElement=document.createElement("canvas");var r=this.canvasElement.getContext("webgl");this.gl=r,this.devicePixelRatio=i,this.canvasElement.style.width=t+"px",this.canvasElement.style.height=e+"px",this.canvasElement.width=Math.round(t*i),this.canvasElement.height=Math.round(e*i),r.viewport(0,0,Math.round(t*i),Math.round(e*i));var o=r.createShader(r.VERTEX_SHADER);r.shaderSource(o,"\n\tattribute vec4 a_position;\n\tuniform mat4 u_matrix;\n\tuniform mat4 u_textureMatrix;\n\tvarying vec2 v_texcoord;\n\tvoid main() {\n\t\tgl_Position = u_matrix * a_position;\n\t\tv_texcoord = (u_textureMatrix * a_position).xy;\n\t}\n"),r.compileShader(o);var a=r.createShader(r.FRAGMENT_SHADER);r.shaderSource(a,"\n\tprecision mediump float;\n\tvarying vec2 v_texcoord;\n\tuniform sampler2D u_texture;\n\tvoid main() {\n\t\tgl_FragColor = texture2D(u_texture, v_texcoord);\n\t}\n"),r.compileShader(a);var s=r.createProgram();r.attachShader(s,o),r.attachShader(s,a),r.linkProgram(s),r.useProgram(s),this.positionLocation=r.getAttribLocation(s,"a_position"),this.matrixLocation=r.getUniformLocation(s,"u_matrix"),this.textureMatrixLocation=r.getUniformLocation(s,"u_textureMatrix"),this.textureLocation=r.getUniformLocation(s,"u_texture");var h=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,h),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,0,1,0,1,1,0,1]),r.STATIC_DRAW);var u=r.createBuffer();r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,u);var d=new Uint8Array([2,3,0,0,1,2]);r.bufferData(r.ELEMENT_ARRAY_BUFFER,d,r.STATIC_DRAW),this.n=d.length,r.bindBuffer(r.ARRAY_BUFFER,h),r.enableVertexAttribArray(this.positionLocation),r.vertexAttribPointer(this.positionLocation,2,r.FLOAT,!1,0,0),this.matrix=c(new Float32Array(16),0,t,e,0,-1,1)}return t.prototype.createImage=function(t){var e=this.gl,n=e.createTexture(),i=t.width,r=t.height;return e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255])),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),{width:i,height:r,texture:n}},t.prototype.drawImage=function(t,e,n,i,r,o,a,c,f){void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=t.width),void 0===r&&(r=t.height),void 0===o&&(o=0),void 0===a&&(a=0),void 0===c&&(c=t.width),void 0===f&&(f=t.height);var l=this.gl,p=this.matrix,v=this,m=v.matrixLocation,y=v.textureMatrixLocation,E=v.textureLocation;l.bindTexture(l.TEXTURE_2D,t.texture),p=h(s(),p,d(o,a,0)),p=u(s(),p,d(c,f,1)),l.uniformMatrix4fv(m,!1,p);var w=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(s(),d(1/t.width,1/t.height,1));w=h(s(),w,d(e,n,0)),w=u(s(),w,d(i,r,1)),l.uniformMatrix4fv(y,!1,w),l.uniform1i(E,0),l.drawElements(l.TRIANGLES,this.n,l.UNSIGNED_BYTE,0)},t.prototype.resize=function(t,e,n){void 0===t&&(t=this.width),void 0===e&&(e=this.height),void 0===n&&(n=this.devicePixelRatio),this.width=t,this.height=e;var i=this.gl;this.devicePixelRatio=n,this.canvasElement.style.width=t+"px",this.canvasElement.style.height=e+"px",this.canvasElement.width=Math.round(t*n),this.canvasElement.height=Math.round(e*n),i.viewport(0,0,Math.round(t*n),Math.round(e*n)),this.matrix=c(new Float32Array(16),0,t,e,0,-1,1)},t.prototype.clear=function(t,e,n,i,r){void 0===t&&(t=[.1,.1,.1,1]),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=this.width),void 0===r&&(r=this.height);var o=this.gl;o.disable(o.DEPTH_TEST),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),o.clearColor.apply(o,t),o.clear(o.COLOR_BUFFER_BIT)},t}();const p=l,v=function(){function t(t,e,n,i,r,a,s,h,u,c,d,f,l){void 0===s&&(s=[[0,0],[e.width,0],[e.width,e.height],[0,e.height]]),void 0===h&&(h=e.width),void 0===u&&(u=e.height),void 0===c&&(c="no-repeat"),void 0===d&&(d="rgba(25.5, 114.75, 114.75, 0)"),void 0===f&&(f="rgba(229.5, 25.5, 25.5, 0)"),void 0===l&&(l=2),this.canvas2DRenderer=t,this.sImage=e,this.sWidth=n,this.sHeight=i,this.dWidth=r,this.dHeight=a,this.positions=s,this.width=h,this.height=u,this.repeat=c,this.fillStyle=d,this.strokeStyle=f,this.lineWidth=l;var p=new o(e.width,e.height,null,1),v=p.context;v.moveTo(s[0][0],s[0][1]),s.forEach((function(t){v.lineTo(t[0],t[1])})),v.lineTo(s[0][0],s[0][1]),v.clip(),v.fillStyle=d,v.strokeStyle=f,v.lineWidth=l,v.fill(),v.stroke(),v.drawImage(e,0,0,e.width,e.height,0,0,e.width,e.height);var m=v.createPattern(p.canvasElement,c);p.resize(h,u,1),v.fillStyle=m,v.fillRect(0,0,h,u),this.sImage=this.canvas2DRenderer.createImage(p.canvasElement)}return t.prototype.draw=function(t,e,n,i){this.canvas2DRenderer.drawImage(this.sImage,t,e,this.sWidth,this.sHeight,n,i,this.dWidth,this.dHeight)},t}();var m=function(){function t(t){this.fontMap=t}return t.prototype.draw=function(t,e,n){var i=this,r=0;Array.from(t).forEach((function(t){var o=t.charCodeAt(0);if(i.fontMap.has(o)){var a=i.fontMap.get(o),s=a.width;a.font.draw(a.x,a.y,e+r,n),r+=s}}))},t}();const y=function(){function t(t,e,n,i,r,o){void 0===n&&(n="#fafafa"),void 0===i&&(i="#fafafa"),void 0===r&&(r=!0),void 0===o&&(o=!1),this.canvas2DRenderer=t,this.fontName=e,this.fill=r,this.stroke=o,this.fillStyle=n,this.strokeStyle=i}return t.prototype.load=function(t){var e=this,n=new o(0,0),i=n.context;i.font=this.fontName;var r=new Map,a=1.2*parseInt(i.font,10),s=Array.from(t).map((function(t){return{letter:t,measurement:i.measureText(t)}})),h=s.map((function(t){return t.measurement.width})).reduce((function(t,e){return t+e}));return n.resize(h,a,1),s.forEach((function(t){var o=t.letter,s=t.measurement;i.textBaseline="top",i.font=e.fontName,i.fillStyle=e.fillStyle;var u=h-=s.width;i.fillText(o,u,0),r.set(o.charCodeAt(0),{font:new v(e.canvas2DRenderer,n.canvasElement,s.width,a,s.width,a),width:s.width,height:a,x:u,y:0})})),new m(r)},t}(),E=function(){function t(){this.bindings=new Map,this.pressed=new Map,this.bindKeys()}return t.prototype.bind=function(t,e){this.bindings.set(t,e),this.pressed.set(e,0)},t.prototype.bindKeys=function(){document.addEventListener("keyup",this.keyup.bind(this),!1),document.addEventListener("keydown",this.keydown.bind(this),!1)},t.prototype.unbindKeys=function(){document.removeEventListener("keyup",this.keyup.bind(this),!1),document.removeEventListener("keydown",this.keydown.bind(this),!1)},t.prototype.keyup=function(t){var e=t.keyCode;if(this.bindings.has(e)){var n=this.bindings.get(e);this.pressed.has(n)&&this.pressed.set(n,0)}},t.prototype.keydown=function(t){var e=t.keyCode;if(this.bindings.has(e)){var n=this.bindings.get(e);this.pressed.has(n)&&this.pressed.set(n,2)}},t.prototype.isPressed=function(t){if(this.pressed.has(t)){var e=this.pressed.get(t);if(e)return 2===e&&this.pressed.set(t,1),e}return 0},t.KEY={BREAK:3,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,SPACEBAR:32,PAGE_UP:33,PAGE_DOWN:34,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40,HELP:47,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,NUMPAD_ZERO:96,NUMPAD_ONE:97,NUMPAD_TWO:98,NUMPAD_THREE:99,NUMPAD_FOUR:100,NUMPAD_FIVE:101,NUMPAD_SIX:102,NUMPAD_SEVEN:103,NUMPAD_EIGHT:104,NUMPAD_NINE:105,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,F16:127,F17:128,F18:129,F19:130,F20:131,F21:132,F22:133,F23:134,F24:135,F25:136,F26:137,F27:138,F28:139,F29:140,F30:141,F31:142,F32:143,DECREASE_VOLUME:174,INCREASE_VOLUME:175,NEXT:176,PREVIOUS:177,STOP:178,PLAY_PAUSE:179},t}(),w=function(){function t(t,e){void 0===e&&(e=60),this.index=0,this.delta=0,this.elapsed=0,this.frameRate=e,this.frameRatio=1e3/e,this.current=0,this.previous=window.performance.now(),this.render=t,this.start()}return t.prototype.start=function(){var t=this,e=function(){t.index=requestAnimationFrame(e),t.current=window.performance.now(),t.delta=t.current-t.previous,t.elapsed+=t.delta,t.current<t.previous+t.frameRatio||(t.previous=t.current,t.render(t))};e()},t.prototype.stop=function(){cancelAnimationFrame(this.index)},t}();var g=function(){function t(t,e){var n=t.createBufferSource();n.buffer=e;var i=t.createGain();n.connect(i),i.connect(t.destination),this.source=n,this.gainNode=i}return t.prototype.play=function(){this.source.start()},t.prototype.pause=function(){},t.prototype.resume=function(){},t.prototype.getVolume=function(){return this.gainNode.gain.value},t.prototype.setVolume=function(t){this.gainNode.gain.value=t},t.prototype.stop=function(){this.source.stop()},t}();const x=function(){function t(){this.audioContext=new AudioContext,this.unlockAudioContext()}return t.prototype.unlockAudioContext=function(){var t=this;if("suspended"===this.audioContext.state){var e=function(){document.removeEventListener("touchstart",e,!1),document.removeEventListener("mousedown",e,!1),document.removeEventListener("keydown",e,!1),t.audioContext.resume()};document.addEventListener("touchstart",e,!1),document.addEventListener("mousedown",e,!1),document.addEventListener("keydown",e,!1)}},t.prototype.load=function(t){var e=this,n=new Request(t);return fetch(n).then((function(t){return t.arrayBuffer()})).then((function(t){return new Promise((function(n){e.audioContext.decodeAudioData(t,(function(t){n(new g(e.audioContext,t))}))}))}))},t}(),R=function(){function t(t,e,n,i,r,o,a,s){this.frames=[],this.index=[],this.frames=[],this.index=[],this.renderer=t,this.image=e,this.sWidth=n,this.sHeight=i,this.frames=r,this.duration=o,this.dWidth=a,this.dHeight=s;var h=new v(t,e,n,i,a,s);this.grid=new Array(e.height/i).fill(0).map((function(){return new Array(e.width/n).fill(0).map((function(){return{tile:null,width:n,height:i,position:null,positions:null}}))})).map((function(t,e){return t.map((function(t,n){return t.position={x:n*t.width,y:e*t.height},t.positions=[{x:0,y:0},{x:t.width,y:0},{x:t.width,y:t.height},{x:0,y:t.height}],t.tile=h,t}))}))}return t.prototype.draw=function(t,e,n,i){this.index=i||this.frames[Math.floor(n.elapsed/1e3/this.duration)%this.frames.length];var r=this.grid[this.index[0]][this.index[1]],o=r.position,a=o.x,s=o.y;r.tile.draw(a,s,t,e)},t}();var A=function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))},_=function(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},T=function(){function t(t){this.tilemap=t}return t.prototype.draw=function(){var t=this;this.tilemap.layers.forEach((function(e){e.data.forEach((function(e){var n=e[0],i=e[1],r=e[2],o=e[3],a=e[4],s=t.tilemap.tilesets[a],h=s.sprite,u=s.tilewidth,c=s.tileheight;h.draw(r*u,o*c,null,[i,n])}))}))},t}();const b=function(){function t(t){this.canvas2DRenderer=t}return t.prototype.load=function(t){var e=this,n=new Request(t);return fetch(n).then((function(t){return t.json()})).then((function(t){return A(e,void 0,void 0,(function(){var e,n=this;return _(this,(function(i){switch(i.label){case 0:return e=t,[4,Promise.all(t.tilesets.map((function(t){return A(n,void 0,void 0,(function(){var e=this;return _(this,(function(n){return[2,new Promise((function(n,i){var r=new Image;r.onload=function(){t.sprite=new R(e.canvas2DRenderer,r,t.tilewidth,t.tileheight,[],0,t.tilewidth,t.tileheight),n(t)},r.onerror=i,r.src=t.image}))]}))}))})))];case 1:return e.tilesets=i.sent(),[2,new T(t)]}}))}))}))},t}(),F={AssetsManager:r,Canvas2DRenderer:o,WebGLRenderer:p,FontManager:y,Tile:v,Input:E,RenderLoop:w,SoundManager:x,Sprite:R,TilemapManager:b};return e})()}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.CRATERS=e():t.CRATERS=e()}(self,(function(){return(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AssetsManager:()=>r,Canvas2DRenderer:()=>o,FontManager:()=>y,Input:()=>E,RenderLoop:()=>w,SoundManager:()=>x,Sprite:()=>R,Tile:()=>v,TilemapManager:()=>b,WebGLRenderer:()=>p,default:()=>F});var n=function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))},i=function(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};const r=function(){function t(){}return t.prototype.loadText=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,fetch(t).then((function(t){return t.text()}))]}))}))},t.prototype.loadJson=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,fetch(t).then((function(t){return t.json()}))]}))}))},t.prototype.loadImage=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,n){var i=new Image;i.onload=function(){e(i)},i.onerror=n,i.src=t}))]}))}))},t.prototype.loadFont=function(t,e){return n(this,void 0,void 0,(function(){return i(this,(function(n){return[2,new FontFace(t,e).load()]}))}))},t.prototype.loadBinary=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,fetch(t).then((function(t){return t.blob()}))]}))}))},t}(),o=function(){function t(t,e,n,i){void 0===i&&(i=window.devicePixelRatio),this.width=t,this.height=e,this.canvasElement=document.createElement("canvas",n),this.context=this.canvasElement.getContext("2d"),this.devicePixelRatio=i,this.canvasElement.style.width=t+"px",this.canvasElement.style.height=e+"px",this.canvasElement.width=Math.round(t*i),this.canvasElement.height=Math.round(e*i),this.context.setTransform(i,0,0,i,0,0)}return t.prototype.createImage=function(t){return t},t.prototype.drawImage=function(t,e,n,i,r,o,a,s,h){this.context.drawImage(t,e,n,i,r,o,a,s,h)},t.prototype.clear=function(t,e,n,i,r){void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=this.width),void 0===r&&(r=this.height),t?(this.context.save(),this.context.fillStyle=t,this.context.fillRect(e,n,i,r),this.context.restore()):this.context.clearRect(e,n,i,r)},t.prototype.resize=function(t,e,n){void 0===t&&(t=this.width),void 0===e&&(e=this.height),void 0===n&&(n=this.devicePixelRatio),this.width=t,this.height=e,this.devicePixelRatio=n,this.canvasElement.style.width=t+"px",this.canvasElement.style.height=e+"px",this.canvasElement.width=Math.round(t*n),this.canvasElement.height=Math.round(e*n),this.context.setTransform(n,0,0,n,0,0)},t}();var a="undefined"!=typeof Float32Array?Float32Array:Array;function s(){var t=new a(16);return a!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function h(t,e,n){var i,r,o,a,s,h,u,c,d,f,l,p,v=n[0],m=n[1],y=n[2];return e===t?(t[12]=e[0]*v+e[4]*m+e[8]*y+e[12],t[13]=e[1]*v+e[5]*m+e[9]*y+e[13],t[14]=e[2]*v+e[6]*m+e[10]*y+e[14],t[15]=e[3]*v+e[7]*m+e[11]*y+e[15]):(i=e[0],r=e[1],o=e[2],a=e[3],s=e[4],h=e[5],u=e[6],c=e[7],d=e[8],f=e[9],l=e[10],p=e[11],t[0]=i,t[1]=r,t[2]=o,t[3]=a,t[4]=s,t[5]=h,t[6]=u,t[7]=c,t[8]=d,t[9]=f,t[10]=l,t[11]=p,t[12]=i*v+s*m+d*y+e[12],t[13]=r*v+h*m+f*y+e[13],t[14]=o*v+u*m+l*y+e[14],t[15]=a*v+c*m+p*y+e[15]),t}function u(t,e,n){var i=n[0],r=n[1],o=n[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}Math.random,Math.PI,Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var c=function(t,e,n,i,r,o,a){var s=1/(e-n),h=1/(i-r),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*s,t[13]=(r+i)*h,t[14]=(a+o)*u,t[15]=1,t};function d(t,e,n){var i=new a(3);return i[0]=t,i[1]=e,i[2]=n,i}f=new a(3),a!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0);var f,l=function(){function t(t,e,n,i){void 0===i&&(i=window.devicePixelRatio),this.width=t,this.height=e,this.canvasElement=document.createElement("canvas");var r=this.canvasElement.getContext("webgl");this.gl=r,this.devicePixelRatio=i,this.canvasElement.style.width=t+"px",this.canvasElement.style.height=e+"px",this.canvasElement.width=Math.round(t*i),this.canvasElement.height=Math.round(e*i),r.viewport(0,0,Math.round(t*i),Math.round(e*i));var o=r.createShader(r.VERTEX_SHADER);r.shaderSource(o,"\n\tattribute vec4 a_position;\n\tuniform mat4 u_matrix;\n\tuniform mat4 u_textureMatrix;\n\tvarying vec2 v_texcoord;\n\tvoid main() {\n\t\tgl_Position = u_matrix * a_position;\n\t\tv_texcoord = (u_textureMatrix * a_position).xy;\n\t}\n"),r.compileShader(o);var a=r.createShader(r.FRAGMENT_SHADER);r.shaderSource(a,"\n\tprecision mediump float;\n\tvarying vec2 v_texcoord;\n\tuniform sampler2D u_texture;\n\tvoid main() {\n\t\tgl_FragColor = texture2D(u_texture, v_texcoord);\n\t}\n"),r.compileShader(a);var s=r.createProgram();r.attachShader(s,o),r.attachShader(s,a),r.linkProgram(s),r.useProgram(s),this.positionLocation=r.getAttribLocation(s,"a_position"),this.matrixLocation=r.getUniformLocation(s,"u_matrix"),this.textureMatrixLocation=r.getUniformLocation(s,"u_textureMatrix"),this.textureLocation=r.getUniformLocation(s,"u_texture");var h=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,h),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,0,1,0,1,1,0,1]),r.STATIC_DRAW);var u=r.createBuffer();r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,u);var d=new Uint8Array([2,3,0,0,1,2]);r.bufferData(r.ELEMENT_ARRAY_BUFFER,d,r.STATIC_DRAW),this.n=d.length,r.bindBuffer(r.ARRAY_BUFFER,h),r.enableVertexAttribArray(this.positionLocation),r.vertexAttribPointer(this.positionLocation,2,r.FLOAT,!1,0,0),this.matrix=c(new Float32Array(16),0,t,e,0,-1,1)}return t.prototype.createImage=function(t){var e=this.gl,n=e.createTexture(),i=t.width,r=t.height;return e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255])),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),{width:i,height:r,texture:n}},t.prototype.drawImage=function(t,e,n,i,r,o,a,c,f){void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=t.width),void 0===r&&(r=t.height),void 0===o&&(o=0),void 0===a&&(a=0),void 0===c&&(c=t.width),void 0===f&&(f=t.height);var l=this.gl,p=this.matrix,v=this,m=v.matrixLocation,y=v.textureMatrixLocation,E=v.textureLocation;l.bindTexture(l.TEXTURE_2D,t.texture),p=h(s(),p,d(o,a,0)),p=u(s(),p,d(c,f,1)),l.uniformMatrix4fv(m,!1,p);var w=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(s(),d(1/t.width,1/t.height,1));w=h(s(),w,d(e,n,0)),w=u(s(),w,d(i,r,1)),l.uniformMatrix4fv(y,!1,w),l.uniform1i(E,0),l.drawElements(l.TRIANGLES,this.n,l.UNSIGNED_BYTE,0)},t.prototype.resize=function(t,e,n){void 0===t&&(t=this.width),void 0===e&&(e=this.height),void 0===n&&(n=this.devicePixelRatio),this.width=t,this.height=e;var i=this.gl;this.devicePixelRatio=n,this.canvasElement.style.width=t+"px",this.canvasElement.style.height=e+"px",this.canvasElement.width=Math.round(t*n),this.canvasElement.height=Math.round(e*n),i.viewport(0,0,Math.round(t*n),Math.round(e*n)),this.matrix=c(new Float32Array(16),0,t,e,0,-1,1)},t.prototype.clear=function(t,e,n,i,r){void 0===t&&(t=[.1,.1,.1,1]),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=this.width),void 0===r&&(r=this.height);var o=this.gl;o.disable(o.DEPTH_TEST),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),o.clearColor.apply(o,t),o.clear(o.COLOR_BUFFER_BIT)},t}();const p=l,v=function(){function t(t,e,n,i,r,a,s,h,u,c,d,f,l){void 0===s&&(s=[[0,0],[e.width,0],[e.width,e.height],[0,e.height]]),void 0===h&&(h=e.width),void 0===u&&(u=e.height),void 0===c&&(c="no-repeat"),void 0===d&&(d="rgba(25.5, 114.75, 114.75, 0)"),void 0===f&&(f="rgba(229.5, 25.5, 25.5, 0)"),void 0===l&&(l=2),this.canvas2DRenderer=t,this.sImage=e,this.sWidth=n,this.sHeight=i,this.dWidth=r,this.dHeight=a,this.positions=s,this.width=h,this.height=u,this.repeat=c,this.fillStyle=d,this.strokeStyle=f,this.lineWidth=l;var p=new o(e.width,e.height,null,1),v=p.context;v.moveTo(s[0][0],s[0][1]),s.forEach((function(t){v.lineTo(t[0],t[1])})),v.lineTo(s[0][0],s[0][1]),v.clip(),v.fillStyle=d,v.strokeStyle=f,v.lineWidth=l,v.fill(),v.stroke(),v.drawImage(e,0,0,e.width,e.height,0,0,e.width,e.height);var m=v.createPattern(p.canvasElement,c);p.resize(h,u,1),v.fillStyle=m,v.fillRect(0,0,h,u),this.sImage=this.canvas2DRenderer.createImage(p.canvasElement)}return t.prototype.draw=function(t,e,n,i,r,o,a,s){void 0===r&&(r=this.sWidth),void 0===o&&(o=this.sHeight),void 0===a&&(a=this.dWidth),void 0===s&&(s=this.dHeight),this.canvas2DRenderer.drawImage(this.sImage,t,e,r,o,n,i,a,s)},t}();var m=function(){function t(t,e){this.fontMap=t,this.fontAtlas=e}return t.prototype.draw=function(t,e,n){var i=this,r=0;Array.from(t).forEach((function(t){var o=t.charCodeAt(0);if(i.fontMap.has(o)){var a=i.fontMap.get(o),s=a.width,h=a.height;i.fontAtlas.draw(a.x,a.y,e+r,n,s,h,s,h),r+=s}}))},t}();const y=function(){function t(t,e,n,i,r,o){void 0===n&&(n="#fafafa"),void 0===i&&(i="#fafafa"),void 0===r&&(r=!0),void 0===o&&(o=!1),this.canvas2DRenderer=t,this.fontName=e,this.fill=r,this.stroke=o,this.fillStyle=n,this.strokeStyle=i}return t.prototype.load=function(t){var e=this,n=new o(0,0,void 0,1),i=n.context;i.font=this.fontName;var r=new Map,a=1.2*parseInt(i.font,10),s=Array.from(t).map((function(t){return{letter:t,measurement:i.measureText(t)}})),h=s.map((function(t){return t.measurement.width})).reduce((function(t,e){return t+e}));n.resize(h,a),s.forEach((function(t){var n=t.letter,o=t.measurement;i.textBaseline="top",i.font=e.fontName,i.fillStyle=e.fillStyle;var s=h-=o.width;i.fillText(n,s,0),r.set(n.charCodeAt(0),{width:o.width,height:a,x:s,y:0})}));var u=new v(this.canvas2DRenderer,n.canvasElement,n.width,n.height,n.width,n.height);return new m(r,u)},t}(),E=function(){function t(){this.bindings=new Map,this.pressed=new Map,this.bindKeys()}return t.prototype.bind=function(t,e){this.bindings.set(t,e),this.pressed.set(e,0)},t.prototype.bindKeys=function(){document.addEventListener("keyup",this.keyup.bind(this),!1),document.addEventListener("keydown",this.keydown.bind(this),!1)},t.prototype.unbindKeys=function(){document.removeEventListener("keyup",this.keyup.bind(this),!1),document.removeEventListener("keydown",this.keydown.bind(this),!1)},t.prototype.keyup=function(t){var e=t.keyCode;if(this.bindings.has(e)){var n=this.bindings.get(e);this.pressed.has(n)&&this.pressed.set(n,0)}},t.prototype.keydown=function(t){var e=t.keyCode;if(this.bindings.has(e)){var n=this.bindings.get(e);this.pressed.has(n)&&this.pressed.set(n,2)}},t.prototype.isPressed=function(t){if(this.pressed.has(t)){var e=this.pressed.get(t);if(e)return 2===e&&this.pressed.set(t,1),e}return 0},t.KEY={BREAK:3,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,SPACEBAR:32,PAGE_UP:33,PAGE_DOWN:34,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40,HELP:47,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,NUMPAD_ZERO:96,NUMPAD_ONE:97,NUMPAD_TWO:98,NUMPAD_THREE:99,NUMPAD_FOUR:100,NUMPAD_FIVE:101,NUMPAD_SIX:102,NUMPAD_SEVEN:103,NUMPAD_EIGHT:104,NUMPAD_NINE:105,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,F16:127,F17:128,F18:129,F19:130,F20:131,F21:132,F22:133,F23:134,F24:135,F25:136,F26:137,F27:138,F28:139,F29:140,F30:141,F31:142,F32:143,DECREASE_VOLUME:174,INCREASE_VOLUME:175,NEXT:176,PREVIOUS:177,STOP:178,PLAY_PAUSE:179},t}(),w=function(){function t(t,e){void 0===e&&(e=60),this.index=0,this.delta=0,this.elapsed=0,this.frameRate=e,this.frameRatio=1e3/e,this.current=0,this.previous=window.performance.now(),this.render=t,this.start()}return t.prototype.start=function(){var t=this,e=function(){t.index=requestAnimationFrame(e),t.current=window.performance.now(),t.delta=t.current-t.previous,t.elapsed+=t.delta,t.current<t.previous+t.frameRatio||(t.previous=t.current,t.render(t))};e()},t.prototype.stop=function(){cancelAnimationFrame(this.index)},t}();var g=function(){function t(t,e){var n=t.createBufferSource();n.buffer=e;var i=t.createGain();n.connect(i),i.connect(t.destination),this.source=n,this.gainNode=i}return t.prototype.play=function(){this.source.start()},t.prototype.pause=function(){},t.prototype.resume=function(){},t.prototype.getVolume=function(){return this.gainNode.gain.value},t.prototype.setVolume=function(t){this.gainNode.gain.value=t},t.prototype.stop=function(){this.source.stop()},t}();const x=function(){function t(){this.audioContext=new AudioContext,this.unlockAudioContext()}return t.prototype.unlockAudioContext=function(){var t=this;if("suspended"===this.audioContext.state){var e=function(){document.removeEventListener("touchstart",e,!1),document.removeEventListener("mousedown",e,!1),document.removeEventListener("keydown",e,!1),t.audioContext.resume()};document.addEventListener("touchstart",e,!1),document.addEventListener("mousedown",e,!1),document.addEventListener("keydown",e,!1)}},t.prototype.load=function(t){var e=this,n=new Request(t);return fetch(n).then((function(t){return t.arrayBuffer()})).then((function(t){return new Promise((function(n){e.audioContext.decodeAudioData(t,(function(t){n(new g(e.audioContext,t))}))}))}))},t}(),R=function(){function t(t,e,n,i,r,o,a,s){this.frames=[],this.index=[],this.frames=[],this.index=[],this.renderer=t,this.image=e,this.sWidth=n,this.sHeight=i,this.frames=r,this.duration=o,this.dWidth=a,this.dHeight=s;var h=new v(t,e,n,i,a,s);this.grid=new Array(e.height/i).fill(0).map((function(){return new Array(e.width/n).fill(0).map((function(){return{tile:null,width:n,height:i,position:null,positions:null}}))})).map((function(t,e){return t.map((function(t,n){return t.position={x:n*t.width,y:e*t.height},t.positions=[{x:0,y:0},{x:t.width,y:0},{x:t.width,y:t.height},{x:0,y:t.height}],t.tile=h,t}))}))}return t.prototype.draw=function(t,e,n,i){this.index=i||this.frames[Math.floor(n.elapsed/1e3/this.duration)%this.frames.length];var r=this.grid[this.index[0]][this.index[1]],o=r.position,a=o.x,s=o.y;r.tile.draw(a,s,t,e)},t}();var A=function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))},_=function(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},T=function(){function t(t){this.tilemap=t}return t.prototype.draw=function(){var t=this;this.tilemap.layers.forEach((function(e){e.data.forEach((function(e){var n=e[0],i=e[1],r=e[2],o=e[3],a=e[4],s=t.tilemap.tilesets[a],h=s.sprite,u=s.tilewidth,c=s.tileheight;h.draw(r*u,o*c,null,[i,n])}))}))},t}();const b=function(){function t(t){this.canvas2DRenderer=t}return t.prototype.load=function(t){var e=this,n=new Request(t);return fetch(n).then((function(t){return t.json()})).then((function(t){return A(e,void 0,void 0,(function(){var e,n=this;return _(this,(function(i){switch(i.label){case 0:return e=t,[4,Promise.all(t.tilesets.map((function(t){return A(n,void 0,void 0,(function(){var e=this;return _(this,(function(n){return[2,new Promise((function(n,i){var r=new Image;r.onload=function(){t.sprite=new R(e.canvas2DRenderer,r,t.tilewidth,t.tileheight,[],0,t.tilewidth,t.tileheight),n(t)},r.onerror=i,r.src=t.image}))]}))}))})))];case 1:return e.tilesets=i.sent(),[2,new T(t)]}}))}))}))},t}(),F={AssetsManager:r,Canvas2DRenderer:o,WebGLRenderer:p,FontManager:y,Tile:v,Input:E,RenderLoop:w,SoundManager:x,Sprite:R,TilemapManager:b};return e})()}));

@@ -16,3 +16,3 @@ export default class Tile {

constructor(canvas2DRenderer: any, sImage: any, sWidth: number, sHeight: number, dWidth: number, dHeight: number, positions?: number[][], width?: number, height?: number, repeat?: string, fillStyle?: string, strokeStyle?: string, lineWidth?: number);
draw(sx: number, sy: number, dx: number, dy: number): void;
draw(sx: number, sy: number, dx: number, dy: number, sw?: number, sh?: number, dw?: number, dh?: number): void;
}
{
"name": "craters",
"description": "Craters is a modular JavaScript framework reimplemented in TypeScript for HTML5 game development in a spartan-programmer's way",
"version": "0.1.0-rebase.1",
"version": "0.1.0-rebase.2",
"homepage": "https://github.com/swashvirus/craters",

@@ -6,0 +6,0 @@ "author": {

# Craters
[![CI commit action](https://github.com/swashvirus/craters/actions/workflows/commit.yml/badge.svg)](https://github.com/swashvirus/craters/actions/workflows/commit.yml)
[![Release publish action](https://github.com/swashvirus/craters/actions/workflows/release.yml/badge.svg)](https://github.com/swashvirus/craters/actions/workflows/release.yml)
![craters logo](https://swashvirus.github.io/craters/media/craters.gif)

@@ -9,3 +11,3 @@ > _Craters is a modular JavaScript framework reimplemented in TypeScript for rapid HTML5 game development_

## Examples
_(Coming soon)_
[Play sandbox demos](https://swashvirus.github.io/craters-sandbox/)

@@ -12,0 +14,0 @@ ## Contributing

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc