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.10 to 0.1.0-rebase.11

dist/ecs.d.ts

2

dist/canvas-2d-renderer.d.ts

@@ -9,5 +9,5 @@ export default class Canvas2DRenderer {

createImage(image: any): any;
drawImage(image: any, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number): void;
drawImage(image: any, sx?: number, sy?: number, sWidth?: number, sHeight?: number, dx?: number, dy?: number, dWidth?: number, dHeight?: number): void;
clear(v?: string, w?: number, x?: number, y?: number, z?: number): void;
resize(width?: number, height?: number, devicePixelRatio?: number): void;
}

@@ -0,11 +1,15 @@

import Canvas2DRenderer from "./canvas-2d-renderer";
import Tile from "./tile";
declare type FontMap = Map<number, {
x: number;
y: number;
width: number;
height: number;
}>;
declare type FontAtlas = Tile;
declare class Font {
fontMap: any;
fontAtlas: any;
canvas2DRenderer: any;
constructor(fontMap: Map<number, {
x: number;
y: number;
width: number;
height: number;
}>, fontAtlas: any);
fontMap: FontMap;
fontAtlas: FontAtlas;
canvas2DRenderer: Canvas2DRenderer;
constructor(fontMap: FontMap, fontAtlas: FontAtlas);
draw(text: string, destX: number, destY: number): void;

@@ -12,0 +16,0 @@ }

@@ -11,3 +11,4 @@ import AssetsManager from "./assets-manager";

import TilemapManager from "./tilemap-manager";
export { AssetsManager, Canvas2DRenderer, WebGLRenderer, FontManager, Tile, Input, RenderLoop, SoundManager, Sprite, TilemapManager };
import * as EntityComponentSystem from "./ecs";
export { AssetsManager, Canvas2DRenderer, WebGLRenderer, FontManager, Tile, Input, RenderLoop, SoundManager, Sprite, TilemapManager, EntityComponentSystem };
declare const _default: {

@@ -24,3 +25,4 @@ AssetsManager: typeof AssetsManager;

TilemapManager: typeof TilemapManager;
EntityComponentSystem: typeof EntityComponentSystem;
};
export default _default;

@@ -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,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).filter((function(t,e,n){return n.indexOf(t)==e})).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})()}));
!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,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},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:()=>s,EntityComponentSystem:()=>i,FontManager:()=>E,Input:()=>v,RenderLoop:()=>y,SoundManager:()=>w,Sprite:()=>x,Tile:()=>f,TilemapManager:()=>M,WebGLRenderer:()=>m,default:()=>N});var i={};t.r(i),t.d(i,{Component:()=>_,ComponentManager:()=>T,Entity:()=>F,EntityManager:()=>P,Query:()=>S,QueryManager:()=>L,System:()=>b,SystemManager:()=>D,World:()=>U});var n=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{h(n.next(t))}catch(t){s(t)}}function o(t){try{h(n.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}h((n=n.apply(t,e||[])).next())}))};class r{loadText(t){return n(this,void 0,void 0,(function*(){return fetch(t).then((function(t){return t.text()}))}))}loadJson(t){return n(this,void 0,void 0,(function*(){return fetch(t).then((function(t){return t.json()}))}))}loadImage(t){return n(this,void 0,void 0,(function*(){return new Promise((function(e,i){var n=new Image;n.onload=function(){e(n)},n.onerror=i,n.src=t}))}))}loadFont(t,e){return n(this,void 0,void 0,(function*(){return new FontFace(t,e).load()}))}loadBinary(t){return n(this,void 0,void 0,(function*(){return fetch(t).then((function(t){return t.blob()}))}))}}class s{constructor(t,e,i,n=window.devicePixelRatio){this.width=t,this.height=e,this.canvasElement=document.createElement("canvas",i),this.context=this.canvasElement.getContext("2d"),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)}createImage(t){return t}drawImage(t,e=0,i=0,n=t.width,r=t.height,s=0,a=0,o=t.width,h=t.height){this.context.drawImage(t,e,i,n,r,s,a,o,h)}clear(t,e=0,i=0,n=this.width,r=this.height){t?(this.context.save(),this.context.fillStyle=t,this.context.fillRect(e,i,n,r),this.context.restore()):this.context.clearRect(e,i,n,r)}resize(t=this.width,e=this.height,i=this.devicePixelRatio){this.width=t,this.height=e,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)}}var a="undefined"!=typeof Float32Array?Float32Array:Array;function o(){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,i){var n,r,s,a,o,h,c,u,d,l,m,f,g=i[0],E=i[1],v=i[2];return e===t?(t[12]=e[0]*g+e[4]*E+e[8]*v+e[12],t[13]=e[1]*g+e[5]*E+e[9]*v+e[13],t[14]=e[2]*g+e[6]*E+e[10]*v+e[14],t[15]=e[3]*g+e[7]*E+e[11]*v+e[15]):(n=e[0],r=e[1],s=e[2],a=e[3],o=e[4],h=e[5],c=e[6],u=e[7],d=e[8],l=e[9],m=e[10],f=e[11],t[0]=n,t[1]=r,t[2]=s,t[3]=a,t[4]=o,t[5]=h,t[6]=c,t[7]=u,t[8]=d,t[9]=l,t[10]=m,t[11]=f,t[12]=n*g+o*E+d*v+e[12],t[13]=r*g+h*E+l*v+e[13],t[14]=s*g+c*E+m*v+e[14],t[15]=a*g+u*E+f*v+e[15]),t}function c(t,e,i){var n=i[0],r=i[1],s=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,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 u,d=function(t,e,i,n,r,s,a){var o=1/(e-i),h=1/(n-r),c=1/(s-a);return t[0]=-2*o,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*c,t[11]=0,t[12]=(e+i)*o,t[13]=(r+n)*h,t[14]=(a+s)*c,t[15]=1,t};function l(t,e,i){var n=new a(3);return n[0]=t,n[1]=e,n[2]=i,n}u=new a(3),a!=Float32Array&&(u[0]=0,u[1]=0,u[2]=0);class m{constructor(t,e,i,n=window.devicePixelRatio){this.width=t,this.height=e,this.canvasElement=document.createElement("canvas");var r=this.canvasElement.getContext("webgl");this.gl=r,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),r.viewport(0,0,Math.round(t*n),Math.round(e*n));var s=r.createShader(r.VERTEX_SHADER);r.shaderSource(s,"\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(s);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 o=r.createProgram();r.attachShader(o,s),r.attachShader(o,a),r.linkProgram(o),r.useProgram(o),this.positionLocation=r.getAttribLocation(o,"a_position"),this.matrixLocation=r.getUniformLocation(o,"u_matrix"),this.textureMatrixLocation=r.getUniformLocation(o,"u_textureMatrix"),this.textureLocation=r.getUniformLocation(o,"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 c=r.createBuffer();r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,c);var u=new Uint8Array([2,3,0,0,1,2]);r.bufferData(r.ELEMENT_ARRAY_BUFFER,u,r.STATIC_DRAW),this.n=u.length,r.bindBuffer(r.ARRAY_BUFFER,h),r.enableVertexAttribArray(this.positionLocation),r.vertexAttribPointer(this.positionLocation,2,r.FLOAT,!1,0,0),this.matrix=d(new Float32Array(16),0,t,e,0,-1,1)}createImage(t){var e=this.gl,i=e.createTexture(),n=t.width,r=t.height;return e.bindTexture(e.TEXTURE_2D,i),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,i),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),{width:n,height:r,texture:i}}drawImage(t,e=0,i=0,n=t.width,r=t.height,s=0,a=0,u=t.width,d=t.height){var m=this.gl,f=this.matrix,{matrixLocation:g,textureMatrixLocation:E,textureLocation:v}=this;m.bindTexture(m.TEXTURE_2D,t.texture),f=h(o(),f,l(s,a,0)),f=c(o(),f,l(u,d,1)),m.uniformMatrix4fv(g,!1,f);var y=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}(o(),l(1/t.width,1/t.height,1));y=h(o(),y,l(e,i,0)),y=c(o(),y,l(n,r,1)),m.uniformMatrix4fv(E,!1,y),m.uniform1i(v,0),m.drawElements(m.TRIANGLES,this.n,m.UNSIGNED_BYTE,0)}resize(t=this.width,e=this.height,i=this.devicePixelRatio){this.width=t,this.height=e;var n=this.gl;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),n.viewport(0,0,Math.round(t*i),Math.round(e*i)),this.matrix=d(new Float32Array(16),0,t,e,0,-1,1)}clear(t=[.1,.1,.1,1],e=0,i=0,n=this.width,r=this.height){var s=this.gl;s.disable(s.DEPTH_TEST),s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),s.clearColor(...t),s.clear(s.COLOR_BUFFER_BIT)}}class f{constructor(t,e,i,n,r,a,o=[[0,0],[e.width,0],[e.width,e.height],[0,e.height]],h=e.width,c=e.height,u="no-repeat",d="rgba(25.5, 114.75, 114.75, 0)",l="rgba(229.5, 25.5, 25.5, 0)",m=2){this.canvas2DRenderer=t,this.sImage=e,this.sWidth=i,this.sHeight=n,this.dWidth=r,this.dHeight=a,this.positions=o,this.width=h,this.height=c,this.repeat=u,this.fillStyle=d,this.strokeStyle=l,this.lineWidth=m;{const t=new s(e.width,e.height,null,1),i=t.context;i.moveTo(o[0][0],o[0][1]),o.forEach((function(t){i.lineTo(t[0],t[1])})),i.lineTo(o[0][0],o[0][1]),i.clip(),i.fillStyle=d,i.strokeStyle=l,i.lineWidth=m,i.fill(),i.stroke(),i.drawImage(e,0,0,e.width,e.height,0,0,e.width,e.height);const n=i.createPattern(t.canvasElement,u);t.resize(h,c,1),i.fillStyle=n,i.fillRect(0,0,h,c),this.sImage=this.canvas2DRenderer.createImage(t.canvasElement)}}draw(t,e,i,n,r=this.sWidth,s=this.sHeight,a=this.dWidth,o=this.dHeight){this.canvas2DRenderer.drawImage(this.sImage,t,e,r,s,i,n,a,o)}}class g{constructor(t,e){this.fontMap=t,this.fontAtlas=e}draw(t,e,i){var n=0;Array.from(t).forEach((t=>{var r=t.charCodeAt(0);if(this.fontMap.has(r)){var s=this.fontMap.get(r),{width:a,height:o}=s;this.fontAtlas.draw(s.x,s.y,e+n,i,a,o,a,o),n+=a}}))}}class E{constructor(t,e,i="#fafafa",n="#fafafa",r=!0,s=!1){this.canvas2DRenderer=t,this.fontName=e,this.fill=r,this.stroke=s,this.fillStyle=i,this.strokeStyle=n}load(t){var e=new s(0,0,void 0,1),i=e.context;i.font=this.fontName;var n=new Map,r=1.2*parseInt(i.font,10),a=Array.from(t).filter((function(t,e,i){return i.indexOf(t)==e})).map((function(t){return{letter:t,measurement:i.measureText(t)}})),o=a.map((function(t){return t.measurement.width})).reduce((function(t,e){return t+e}));e.resize(o,r),a.forEach((t=>{var e=t.letter,s=t.measurement;i.textBaseline="top",i.font=this.fontName,i.fillStyle=this.fillStyle;var a=o-=s.width;i.fillText(e,a,0),n.set(e.charCodeAt(0),{width:s.width,height:r,x:a,y:0})}));var h=new f(this.canvas2DRenderer,e.canvasElement,e.width,e.height,e.width,e.height);return new g(n,h)}}class v{constructor(){this.bindings=new Map,this.pressed=new Map,this.bindKeys()}bind(t,e){this.bindings.set(t,e),this.pressed.set(e,0)}bindKeys(){document.addEventListener("keyup",this.keyup.bind(this),!1),document.addEventListener("keydown",this.keydown.bind(this),!1)}unbindKeys(){document.removeEventListener("keyup",this.keyup.bind(this),!1),document.removeEventListener("keydown",this.keydown.bind(this),!1)}keyup(t){var e=t.key;if(this.bindings.has(e)){var i=this.bindings.get(e);this.pressed.has(i)&&this.pressed.set(i,0)}}keydown(t){var e=t.key;if(this.bindings.has(e)){var i=this.bindings.get(e);this.pressed.has(i)&&this.pressed.set(i,2)}}isPressed(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}}v.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"};class y{constructor(t,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.execute=t,this.start()}start(){const t=()=>{this.index=requestAnimationFrame(t),this.current=window.performance.now(),this.delta=this.current-this.previous,this.elapsed+=this.delta,this.current<this.previous+this.frameRatio||(this.previous=this.current,this.execute(this))};t()}stop(){cancelAnimationFrame(this.index)}}class p{constructor(t,e){const i=t.createBufferSource();i.buffer=e;const n=t.createGain();i.connect(n),n.connect(t.destination),this.source=i,this.gainNode=n}play(){this.source.start()}pause(){}resume(){}getVolume(){return this.gainNode.gain.value}setVolume(t){this.gainNode.gain.value=t}stop(){this.source.stop()}}class w{constructor(){this.audioContext=new AudioContext,this.unlockAudioContext()}unlockAudioContext(){if("suspended"!==this.audioContext.state)return;const t=()=>{document.removeEventListener("touchstart",t,!1),document.removeEventListener("mousedown",t,!1),document.removeEventListener("keydown",t,!1),this.audioContext.resume()};document.addEventListener("touchstart",t,!1),document.addEventListener("mousedown",t,!1),document.addEventListener("keydown",t,!1)}load(t){const e=new Request(t);return fetch(e).then((function(t){return t.arrayBuffer()})).then((t=>new Promise((e=>{this.audioContext.decodeAudioData(t,(t=>{e(new p(this.audioContext,t))}))}))))}}class x{constructor(t,e,i,n,r,s,a,o){this.frames=[],this.index=[],this.frames=[],this.index=[],this.renderer=t,this.image=e,this.sWidth=i,this.sHeight=n,this.frames=r,this.duration=s,this.dWidth=a,this.dHeight=o;const h=new f(t,e,i,n,a,o);this.grid=new Array(e.height/n).fill(0).map((function(){return new Array(e.width/i).fill(0).map((function(){return{tile:null,width:i,height:n,position:null,positions:null}}))})).map((function(t,e){return t.map((function(t,i){return t.position={x:i*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}))}))}draw(t,e,i,n){this.index=n||this.frames[Math.floor(i.elapsed/1e3/this.duration)%this.frames.length];const r=this.grid[this.index[0]][this.index[1]],{x:s,y:a}=r.position;r.tile.draw(s,a,t,e)}}var A=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{h(n.next(t))}catch(t){s(t)}}function o(t){try{h(n.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}h((n=n.apply(t,e||[])).next())}))};class R{constructor(t){this.tilemap=t}draw(){this.tilemap.layers.forEach((t=>{t.data.forEach((t=>{var[e,i,n,r,s]=t,{sprite:a,tilewidth:o,tileheight:h}=this.tilemap.tilesets[s];a.draw(n*o,r*h,null,[i,e])}))}))}}class M{constructor(t){this.canvas2DRenderer=t}load(t){return A(this,void 0,void 0,(function*(){const e=new Request(t);return fetch(e).then((function(t){return t.json()})).then((t=>A(this,void 0,void 0,(function*(){return t.tilesets=yield Promise.all(t.tilesets.map((t=>A(this,void 0,void 0,(function*(){return new Promise(((e,i)=>{var n=new Image;n.onload=()=>{t.sprite=new x(this.canvas2DRenderer,n,t.tilewidth,t.tileheight,[],0,t.tilewidth,t.tileheight),e(t)},n.onerror=i,n.src=t.image}))}))))),new R(t)}))))}))}}class _{constructor(t){Array.from(Object.keys(this.constructor.schema)).forEach((e=>{t.hasOwnProperty(e)&&(this[e]=t[e])}))}}class T{constructor(){this.components=new Map}}class F{constructor(){this.componentManager=new T}}class P{constructor(){this.entities=new Set}}class S{constructor(){this.componentManager=new T,this.entityManager=new P}}class L{constructor(){this.queries=new Map}}class b{constructor(){this.queryManager=new L}execute(){}}b.queryManager=new L;class D{constructor(){this.systems=new Set}}class U{constructor(){this.systemManager=new D,this.entityManager=new P,this.componentManager=new T}registerEntity(t){this.systemManager.systems.forEach((e=>{Array.from(e.constructor.queryManager.queries.keys()).forEach((i=>{Array.from(e.queryManager.queries.get(i).componentManager.components.keys()).forEach((n=>{t.componentManager.components.has(n)&&!1===e.queryManager.queries.get(i).entityManager.entities.has(t)&&e.queryManager.queries.get(i).entityManager.entities.add(t)}))}))}))}unregisterEntity(t){this.systemManager.systems.forEach((e=>{Array.from(e.constructor.queryManager.queries.keys()).forEach((i=>{Array.from(e.queryManager.queries.get(i).componentManager.components.keys()).forEach((n=>{t.componentManager.components.has(n)&&!0===e.queryManager.queries.get(i).entityManager.entities.has(t)&&e.queryManager.queries.get(i).entityManager.entities.delete(t)}))}))}))}execute(){this.systemManager.systems.forEach((t=>{t.execute()}))}}const N={AssetsManager:r,Canvas2DRenderer:s,WebGLRenderer:m,FontManager:E,Tile:f,Input:v,RenderLoop:y,SoundManager:w,Sprite:x,TilemapManager:M,EntityComponentSystem:i};return e})()}));
export default class Input {
static KEY: {
[key: string]: number;
[key: string]: string;
};

@@ -8,3 +8,3 @@ private bindings;

constructor();
bind(key: number, action: string): void;
bind(key: string, action: string): void;
bindKeys(): void;

@@ -11,0 +11,0 @@ unbindKeys(): void;

@@ -9,6 +9,6 @@ export default class RenderLoop {

previous: number;
render: any;
constructor(render: any, frameRate?: number);
execute: any;
constructor(execute: any, frameRate?: number);
start(): void;
stop(): 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.10",
"version": "0.1.0-rebase.11",
"homepage": "https://github.com/swashvirus/craters",

@@ -36,9 +36,7 @@ "author": {

"devDependencies": {
"gl-matrix": "^3.4.3",
"@timohausmann/quadtree-js": "github:timohausmann/quadtree-js",
"@tsconfig/recommended": "^1.0.1",
"@types/chai": "^4.2.22",
"@types/mocha": "^9.0.0",
"@types/sat": "^0.0.31",
"chai": "^4.3.4",
"gl-matrix": "^3.4.3",
"grunt": "^1.4.1",

@@ -51,3 +49,2 @@ "grunt-webpack": "^4.0.3",

"mocha": "^9.1.3",
"sat": "github:jriecken/sat-js",
"ts-loader": "^9.2.6",

@@ -54,0 +51,0 @@ "typedoc": "^0.22.6"

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