-
-
Notifications
You must be signed in to change notification settings - Fork 97
/
kontra.min.mjs
1 lines (1 loc) · 19.6 KB
/
kontra.min.mjs
1
let canvasEl,context,callbacks={};function on(t,e){callbacks[t]=callbacks[t]||[],callbacks[t].push(e)}function off(t,e){let i;!callbacks[t]||(i=callbacks[t].indexOf(e))<0||callbacks[t].splice(i,1)}function emit(t,...e){callbacks[t]&&callbacks[t].map(t=>t(...e))}function getCanvas(){return canvasEl}function getContext(){return context}function init(t){if(!(canvasEl=document.getElementById(t)||t||document.querySelector("canvas")))throw Error("You must provide a canvas element for the game");return(context=canvasEl.getContext("2d")).imageSmoothingEnabled=!1,emit("init"),{canvas:canvasEl,context:context}}class Animation{constructor({spriteSheet:t,frames:e,frameRate:i,loop:s=!0}={}){this.spriteSheet=t,this.frames=e,this.frameRate=i,this.loop=s;let{width:n,height:a,margin:r=0}=t.frame;this.width=n,this.height=a,this.margin=r,this._f=0,this._a=0}clone(){return animationFactory(this)}reset(){this._f=0,this._a=0}update(t=1/60){if(this.loop||this._f!=this.frames.length-1)for(this._a+=t;this._a*this.frameRate>=1;)this._f=++this._f%this.frames.length,this._a-=1/this.frameRate}render({x:t,y:e,width:i=this.width,height:s=this.height,context:n=getContext()}={}){let a=this.frames[this._f]/this.spriteSheet._f|0,r=this.frames[this._f]%this.spriteSheet._f|0;n.drawImage(this.spriteSheet.image,r*this.width+(2*r+1)*this.margin,a*this.height+(2*a+1)*this.margin,this.width,this.height,t,e,i,s)}}function animationFactory(t){return new Animation(t)}animationFactory.prototype=Animation.prototype,animationFactory.class=Animation;let imageRegex=/(jpeg|jpg|gif|png)$/,audioRegex=/(wav|mp3|ogg|aac)$/,leadingSlash=/^\//,trailingSlash=/\/$/,dataMap=new WeakMap,imagePath="",audioPath="",dataPath="";function getUrl(t,e){return new URL(t,e).href}function joinPath(t,e){return[t.replace(trailingSlash,""),t?e.replace(leadingSlash,""):e].filter(t=>t).join("/")}function getExtension(t){return t.split(".").pop()}function getName(t){let e=t.replace("."+getExtension(t),"");return 2==e.split("/").length?e.replace(leadingSlash,""):e}function getCanPlay(t){return{wav:"",mp3:t.canPlayType("audio/mpeg;"),ogg:t.canPlayType('audio/ogg; codecs="vorbis"'),aac:t.canPlayType("audio/aac;")}}let imageAssets={},audioAssets={},dataAssets={};function addGlobal(){window.__k||(window.__k={dm:dataMap,u:getUrl,d:dataAssets,i:imageAssets})}function setImagePath(t){imagePath=t}function setAudioPath(t){audioPath=t}function setDataPath(t){dataPath=t}function loadImage(t){return addGlobal(),new Promise((e,i)=>{let s,n,a;if(s=joinPath(imagePath,t),imageAssets[s])return e(imageAssets[s]);(n=new Image).onload=function(){a=getUrl(s,window.location.href),imageAssets[getName(t)]=imageAssets[s]=imageAssets[a]=this,emit("assetLoaded",this,t),e(this)},n.onerror=function(){i("Unable to load image "+s)},n.src=s})}function loadAudio(t){return new Promise((e,i)=>{let s,n,a,r;return s=new Audio,n=getCanPlay(s),(t=[].concat(t).reduce((t,e)=>t||(n[getExtension(e)]?e:null),0))?(a=joinPath(audioPath,t),audioAssets[a]?e(audioAssets[a]):(s.addEventListener("canplay",function(){r=getUrl(a,window.location.href),audioAssets[getName(t)]=audioAssets[a]=audioAssets[r]=this,emit("assetLoaded",this,t),e(this)}),s.onerror=function(){i("Unable to load audio "+a)},s.src=a,void s.load())):i("cannot play any of the audio formats provided"+t)})}function loadData(t){let e,i;return addGlobal(),e=joinPath(dataPath,t),dataAssets[e]?Promise.resolve(dataAssets[e]):fetch(e).then(t=>{if(!t.ok)throw t;return t.clone().json().catch(()=>t.text())}).then(s=>(i=getUrl(e,window.location.href),"object"==typeof s&&dataMap.set(s,i),dataAssets[getName(t)]=dataAssets[e]=dataAssets[i]=s,emit("assetLoaded",s,t),s))}function load(...t){return addGlobal(),Promise.all(t.map(t=>{let e=getExtension([].concat(t)[0]);return e.match(imageRegex)?loadImage(t):e.match(audioRegex)?loadAudio(t):loadData(t)}))}const noop=()=>{};function clear(){let t=getCanvas();getContext().clearRect(0,0,t.width,t.height)}function GameLoop({fps:t=60,clearCanvas:e=!0,update:i,render:s}={}){if(!i||!s)throw Error("You must provide update() and render() functions");let n,a,r,o,h,c=0,d=1e3/t,l=1/t,u=e?clear:noop;function p(){if(a=requestAnimationFrame(p),r=performance.now(),o=r-n,n=r,!(o>1e3)){for(emit("tick"),c+=o;c>=d;)h.update(l),c-=d;u(),h.render()}}return h={update:i,render:s,isStopped:!0,start(){n=performance.now(),this.isStopped=!1,requestAnimationFrame(p)},stop(){this.isStopped=!0,cancelAnimationFrame(a)},_frame:p,set _last(t){n=t}}}let callbacks$1={},pressedKeys={},keyMap={13:"enter",27:"esc",32:"space",37:"left",38:"up",39:"right",40:"down"};function keydownEventHandler(t){let e=keyMap[t.which];pressedKeys[e]=!0,callbacks$1[e]&&callbacks$1[e](t)}function keyupEventHandler(t){pressedKeys[keyMap[t.which]]=!1}function blurEventHandler(){pressedKeys={}}function initKeys(){let t;for(t=0;t<26;t++)keyMap[65+t]=(10+t).toString(36);for(t=0;t<10;t++)keyMap[48+t]=""+t;window.addEventListener("keydown",keydownEventHandler),window.addEventListener("keyup",keyupEventHandler),window.addEventListener("blur",blurEventHandler)}function bindKeys(t,e){[].concat(t).map(t=>callbacks$1[t]=e)}function unbindKeys(t){[].concat(t).map(t=>callbacks$1[t]=0)}function keyPressed(t){return!!pressedKeys[t]}function getMethod(t){let e=t.substr(t.search(/[A-Z]/));return e[0].toLowerCase()+e.substr(1)}function removeInterceptor(t,e){let i=t.indexOf(e);-1!==i&&t.splice(i,1)}function registerPlugin(t,e){let i=t.prototype;i&&(i._inc||(i._inc={},i._bInc=function(t,e,...i){return this._inc[e].before.reduce((e,i)=>{let s=i(t,...e);return s||e},i)},i._aInc=function(t,e,i,...s){return this._inc[e].after.reduce((e,i)=>{let n=i(t,e,...s);return n||e},i)}),Object.getOwnPropertyNames(e).forEach(t=>{let s=getMethod(t);i[s]&&(i["_o"+s]||(i["_o"+s]=i[s],i[s]=function(...t){let e=this._bInc(this,s,...t),n=i["_o"+s].call(this,...e);return this._aInc(this,s,n,...t)}),i._inc[s]||(i._inc[s]={before:[],after:[]}),t.startsWith("before")?i._inc[s].before.push(e[t]):t.startsWith("after")&&i._inc[s].after.push(e[t]))}))}function unregisterPlugin(t,e){let i=t.prototype;i&&i._inc&&Object.getOwnPropertyNames(e).forEach(t=>{let s=getMethod(t);t.startsWith("before")?removeInterceptor(i._inc[s].before,e[t]):t.startsWith("after")&&removeInterceptor(i._inc[s].after,e[t])})}function extendObject(t,e){let i=t.prototype;i&&Object.getOwnPropertyNames(e).forEach(t=>{i[t]||(i[t]=e[t])})}let thisFrameRenderOrder=[],lastFrameRenderOrder=[],callbacks$2={},trackedObjects=[],pressedButtons={},buttonMap={0:"left",1:"middle",2:"right"},pointer={x:0,y:0,radius:5};function circleRectCollision(t){let e=t.x,i=t.y;t.anchor&&(e-=t.width*t.anchor.x,i-=t.height*t.anchor.y);let s=pointer.x-Math.max(e,Math.min(pointer.x,e+t.width)),n=pointer.y-Math.max(i,Math.min(pointer.y,i+t.height));return s*s+n*n<pointer.radius*pointer.radius}function getCurrentObject(){let t,e,i=lastFrameRenderOrder.length?lastFrameRenderOrder:thisFrameRenderOrder;for(let s=i.length-1;s>=0;s--)if(e=(t=i[s]).collidesWithPointer?t.collidesWithPointer(pointer):circleRectCollision(t))return t}function pointerDownHandler(t){let e=void 0!==t.button?buttonMap[t.button]:"left";pressedButtons[e]=!0,pointerHandler(t,"onDown")}function pointerUpHandler(t){let e=void 0!==t.button?buttonMap[t.button]:"left";pressedButtons[e]=!1,pointerHandler(t,"onUp")}function mouseMoveHandler(t){pointerHandler(t,"onOver")}function blurEventHandler$1(){pressedButtons={}}function pointerHandler(t,e){let i,s,n=getCanvas();if(!n)return;-1!==["touchstart","touchmove","touchend"].indexOf(t.type)?(i=(t.touches[0]||t.changedTouches[0]).clientX,s=(t.touches[0]||t.changedTouches[0]).clientY):(i=t.clientX,s=t.clientY);let a=n.height/n.offsetHeight,r=n.getBoundingClientRect(),o=(i-r.left)*a,h=(s-r.top)*a;pointer.x=o,pointer.y=h,t.preventDefault();let c=getCurrentObject();c&&c[e]&&c[e](t),callbacks$2[e]&&callbacks$2[e](t,c)}function initPointer(){let t=getCanvas();t.addEventListener("mousedown",pointerDownHandler),t.addEventListener("touchstart",pointerDownHandler),t.addEventListener("mouseup",pointerUpHandler),t.addEventListener("touchend",pointerUpHandler),t.addEventListener("blur",blurEventHandler$1),t.addEventListener("mousemove",mouseMoveHandler),t.addEventListener("touchmove",mouseMoveHandler),on("tick",()=>{lastFrameRenderOrder.length=0,thisFrameRenderOrder.map(t=>{lastFrameRenderOrder.push(t)}),thisFrameRenderOrder.length=0})}function track(t){[].concat(t).map(t=>{t._r||(t._r=t.render,t.render=function(){thisFrameRenderOrder.push(this),this._r()},trackedObjects.push(t))})}function untrack(t){[].concat(t).map(t=>{t.render=t._r,t._r=0;let e=trackedObjects.indexOf(t);-1!==e&&trackedObjects.splice(e,1)})}function pointerOver(t){return!!trackedObjects.includes(t)&&getCurrentObject()===t}function onPointerDown(t){callbacks$2.onDown=t}function onPointerUp(t){callbacks$2.onUp=t}function pointerPressed(t){return!!pressedButtons[t]}class Pool{constructor({create:t,maxSize:e=1024}={}){let i;if(!t||!(i=t())||!(i.update&&i.init&&i.isAlive))throw Error("Must provide create() function which returns an object with init(), update(), and isAlive() functions");this._c=t,this._i=0,this.objects=[t()],this.size=1,this.maxSize=e}get(t={}){if(this.objects.length==this._i){if(this.size===this.maxSize)return;for(let t=0;t<this.size&&this.objects.length<this.maxSize;t++)this.objects.unshift(this._c());this.size=this.objects.length}let e=this.objects.shift();return e.init(t),this.objects.push(e),this._i++,e}getAliveObjects(){return this.objects.slice(this.objects.length-this._i)}clear(){this._i=this.objects.length=0,this.size=1,this.objects.push(this._c())}update(t){let e,i=this.size-1,s=Math.max(this.objects.length-this._i,0);for(;i>=s;)(e=this.objects[i]).update(t),e.isAlive()?i--:(this.objects=this.objects.splice(i,1).concat(this.objects),this._i--,s++)}render(){let t=Math.max(this.objects.length-this._i,0);for(let e=this.size-1;e>=t;e--)this.objects[e].render()}}function poolFactory(t){return new Pool(t)}function getIndices(t,e){let i=[],s=e.x+e.width/2,n=e.y+e.height/2,a=t.y<n&&t.y+t.height>=e.y,r=t.y+t.height>=n&&t.y<e.y+e.height;return t.x<s&&t.x+t.width>=e.x&&(a&&i.push(0),r&&i.push(2)),t.x+t.width>=s&&t.x<e.x+e.width&&(a&&i.push(1),r&&i.push(3)),i}poolFactory.prototype=Pool.prototype,poolFactory.class=Pool;class Quadtree{constructor({maxDepth:t=3,maxObjects:e=25,bounds:i}={}){this.maxDepth=t,this.maxObjects=e;let s=getCanvas();this.bounds=i||{x:0,y:0,width:s.width,height:s.height},this._b=!1,this._d=0,this._o=[],this._s=[],this._p=null}clear(){this._s.map(function(t){t.clear()}),this._b=!1,this._o.length=0}get(t){let e,i,s=new Set;for(;this._s.length&&this._b;){for(e=getIndices(t,this.bounds),i=0;i<e.length;i++)this._s[e[i]].get(t).forEach(t=>s.add(t));return Array.from(s)}return this._o.filter(e=>e!==t)}add(){let t,e,i,s;for(e=0;e<arguments.length;e++)if(i=arguments[e],Array.isArray(i))this.add.apply(this,i);else if(this._b)this._a(i);else if(this._o.push(i),this._o.length>this.maxObjects&&this._d<this.maxDepth){for(this._sp(),t=0;s=this._o[t];t++)this._a(s);this._o.length=0}}_a(t,e,i){for(e=getIndices(t,this.bounds),i=0;i<e.length;i++)this._s[e[i]].add(t)}_sp(t,e,i){if(this._b=!0,!this._s.length)for(t=this.bounds.width/2|0,e=this.bounds.height/2|0,i=0;i<4;i++)this._s[i]=quadtreeFactory({bounds:{x:this.bounds.x+(i%2==1?t:0),y:this.bounds.y+(i>=2?e:0),width:t,height:e},maxDepth:this.maxDepth,maxObjects:this.maxObjects}),this._s[i]._d=this._d+1,this._s[i]._p=this}}function quadtreeFactory(t){return new Quadtree(t)}quadtreeFactory.prototype=Quadtree.prototype,quadtreeFactory.class=Quadtree;class Vector{constructor(t=0,e=0){this._x=t,this._y=e}add(t,e=1){return vectorFactory(this.x+(t.x||0)*e,this.y+(t.y||0)*e,this)}clamp(t,e,i,s){this._c=!0,this._a=t,this._b=e,this._d=i,this._e=s}get x(){return this._x}get y(){return this._y}set x(t){this._x=this._c?Math.min(Math.max(this._a,t),this._d):t}set y(t){this._y=this._c?Math.min(Math.max(this._b,t),this._e):t}}function vectorFactory(t,e,i={}){let s=new Vector(t,e);return i._c&&(s.clamp(i._a,i._b,i._d,i._e),s.x=t,s.y=e),s}vectorFactory.prototype=Vector.prototype,vectorFactory.class=Vector;class Sprite{constructor(t){this.init(t)}init(t={}){let{x:e,y:i,dx:s,dy:n,ddx:a,ddy:r,width:o,height:h,image:c}=t;this.position=vectorFactory(e,i),this.velocity=vectorFactory(s,n),this.acceleration=vectorFactory(a,r),this._fx=this._fy=1,this.width=this.height=this.rotation=0,this.ttl=1/0,this.anchor={x:0,y:0},this.context=getContext();for(let e in t)this[e]=t[e];c&&(this.width=void 0!==o?o:c.width,this.height=void 0!==h?h:c.height),this.sx=0,this.sy=0}get x(){return this.position.x}get y(){return this.position.y}get dx(){return this.velocity.x}get dy(){return this.velocity.y}get ddx(){return this.acceleration.x}get ddy(){return this.acceleration.y}get animations(){return this._a}get viewX(){return this.x-this.sx}get viewY(){return this.y-this.sy}get width(){return this._w}get height(){return this._h}set x(t){this.position.x=t}set y(t){this.position.y=t}set dx(t){this.velocity.x=t}set dy(t){this.velocity.y=t}set ddx(t){this.acceleration.x=t}set ddy(t){this.acceleration.y=t}set animations(t){let e,i;for(e in this._a={},t)this._a[e]=t[e].clone(),i=i||this._a[e];this.currentAnimation=i,this.width=this.width||i.width,this.height=this.height||i.height}set viewX(t){}set viewY(t){}set width(t){let e=t<0?-1:1;this._fx=e,this._w=t*e}set height(t){let e=t<0?-1:1;this._fy=e,this._h=t*e}isAlive(){return this.ttl>0}collidesWith(t){if(this.rotation||t.rotation)return null;let e=this.x-this.width*this.anchor.x,i=this.y-this.height*this.anchor.y,s=t.x,n=t.y;return t.anchor&&(s-=t.width*t.anchor.x,n-=t.height*t.anchor.y),e<s+t.width&&e+this.width>s&&i<n+t.height&&i+this.height>n}update(t){this.advance(t)}render(){this.draw()}playAnimation(t){this.currentAnimation=this.animations[t],this.currentAnimation.loop||this.currentAnimation.reset()}advance(t){this.velocity=this.velocity.add(this.acceleration,t),this.position=this.position.add(this.velocity,t),this.ttl--,this.currentAnimation&&this.currentAnimation.update(t)}draw(){let t=-this.width*this.anchor.x,e=-this.height*this.anchor.y;if(this.context.save(),this.context.translate(this.viewX,this.viewY),this.rotation&&this.context.rotate(this.rotation),-1==this._fx||-1==this._fy){let i=this.width/2+t,s=this.height/2+e;this.context.translate(i,s),this.context.scale(this._fx,this._fy),this.context.translate(-i,-s)}this.image?this.context.drawImage(this.image,0,0,this.image.width,this.image.height,t,e,this.width,this.height):this.currentAnimation?this.currentAnimation.render({x:t,y:e,width:this.width,height:this.height,context:this.context}):(this.context.fillStyle=this.color,this.context.fillRect(t,e,this.width,this.height)),this.context.restore()}}function spriteFactory(t){return new Sprite(t)}function parseFrames(t){if(+t===t)return t;let e=[],i=t.split(".."),s=+i[0],n=+i[1],a=s;if(s<n)for(;a<=n;a++)e.push(a);else for(;a>=n;a--)e.push(a);return e}spriteFactory.prototype=Sprite.prototype,spriteFactory.class=Sprite;class SpriteSheet{constructor({image:t,frameWidth:e,frameHeight:i,frameMargin:s,animations:n}={}){if(!t)throw Error("You must provide an Image for the SpriteSheet");this.animations={},this.image=t,this.frame={width:e,height:i,margin:s},this._f=t.width/e|0,this.createAnimations(n)}createAnimations(t){let e,i;for(i in t){let{frames:s,frameRate:n,loop:a}=t[i];if(e=[],void 0===s)throw Error("Animation "+i+" must provide a frames property");[].concat(s).map(t=>{e=e.concat(parseFrames(t))}),this.animations[i]=animationFactory({spriteSheet:this,frames:e,frameRate:n,loop:a})}}}function spriteSheetFactory(t){return new SpriteSheet(t)}function setStoreItem(t,e){void 0===e?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(e))}function getStoreItem(t){let e=localStorage.getItem(t);try{e=JSON.parse(e)}catch(t){}return e}function TileEngine(t={}){let{width:e,height:i,tilewidth:s,tileheight:n,context:a=getContext(),tilesets:r,layers:o}=t,h=e*s,c=i*n,d=document.createElement("canvas"),l=d.getContext("2d");d.width=h,d.height=c;let u={},p={},g=[],m=Object.assign({context:a,mapwidth:h,mapheight:c,_sx:0,_sy:0,_d:!1,get sx(){return this._sx},get sy(){return this._sy},set sx(t){this._sx=Math.min(Math.max(0,t),h-getCanvas().width),g.forEach(t=>t.sx=this._sx)},set sy(t){this._sy=Math.min(Math.max(0,t),c-getCanvas().height),g.forEach(t=>t.sy=this._sy)},render(){this._d&&(this._d=!1,this._p()),w(d)},renderLayer(t){let e=p[t],i=u[t];e||((e=document.createElement("canvas")).width=h,e.height=c,p[t]=e,m._r(i,e.getContext("2d"))),w(e)},layerCollidesWith(t,e){let i=e.x,s=e.y;e.anchor&&(i-=e.width*e.anchor.x,s-=e.height*e.anchor.y);let n=f(s),a=y(i),r=f(s+e.height),o=y(i+e.width),h=u[t];for(let t=n;t<=r;t++)for(let e=a;e<=o;e++)if(h.data[e+t*this.width])return!0;return!1},tileAtLayer(t,e){let i=e.row||f(e.y),s=e.col||y(e.x);return u[t]?u[t].data[s+i*m.width]:-1},setTileAtLayer(t,e,i){let s=e.row||f(e.y),n=e.col||y(e.x);u[t]&&(this._d=!0,u[t].data[n+s*m.width]=i)},addObject(t){g.push(t),t.sx=this._sx,t.sy=this._sy},removeObject(t){let e=g.indexOf(t);-1!==e&&(g.splice(e,1),t.sx=t.sy=0)},_r:function(t,e){e.save(),e.globalAlpha=t.opacity,t.data.map((t,i)=>{if(!t)return;let s;for(let e=m.tilesets.length-1;e>=0&&(s=m.tilesets[e],!(t/s.firstgid>=1));e--);let n=s.tilewidth||m.tilewidth,a=s.tileheight||m.tileheight,r=s.margin||0,o=s.image,h=t-s.firstgid,c=s.columns||o.width/(n+r)|0,d=i%m.width*n,l=(i/m.width|0)*a,u=h%c*(n+r),p=(h/c|0)*(a+r);e.drawImage(o,u,p,n,a,d,l,n,a)}),e.restore()},_p:_,layerCanvases:p},t);function f(t){return t/m.tileheight|0}function y(t){return t/m.tilewidth|0}function _(){m.layers&&m.layers.map(t=>{u[t.name]=t,!1!==t.visible&&m._r(t,l)})}function w(t){const{width:e,height:i}=getCanvas(),s=Math.min(t.width,e),n=Math.min(t.height,i);m.context.drawImage(t,m.sx,m.sy,s,n,0,0,s,n)}return m.tilesets.map(e=>{let i=(window.__k?window.__k.dm.get(t):"")||window.location.href;if(e.source){if(!window.__k)throw Error('You must use "load" or "loadData" to resolve tileset.source');let t=window.__k.d[window.__k.u(e.source,i)];if(!t)throw Error(`You must load the tileset source "${e.source}" before loading the tileset`);Object.keys(t).map(i=>{e[i]=t[i]})}if(""+e.image===e.image){if(!window.__k)throw Error('You must use "load" or "loadImage" to resolve tileset.image');let t=window.__k.i[window.__k.u(e.image,i)];if(!t)throw Error(`You must load the image "${e.image}" before loading the tileset`);e.image=t}}),_(),m}spriteSheetFactory.prototype=SpriteSheet.prototype,spriteSheetFactory.class=SpriteSheet;let kontra={Animation:animationFactory,imageAssets:imageAssets,audioAssets:audioAssets,dataAssets:dataAssets,setImagePath:setImagePath,setAudioPath:setAudioPath,setDataPath:setDataPath,loadImage:loadImage,loadAudio:loadAudio,loadData:loadData,load:load,init:init,getCanvas:getCanvas,getContext:getContext,on:on,off:off,emit:emit,GameLoop:GameLoop,keyMap:keyMap,initKeys:initKeys,bindKeys:bindKeys,unbindKeys:unbindKeys,keyPressed:keyPressed,registerPlugin:registerPlugin,unregisterPlugin:unregisterPlugin,extendObject:extendObject,initPointer:initPointer,pointer:pointer,track:track,untrack:untrack,pointerOver:pointerOver,onPointerDown:onPointerDown,onPointerUp:onPointerUp,pointerPressed:pointerPressed,Pool:poolFactory,Quadtree:quadtreeFactory,Sprite:spriteFactory,SpriteSheet:spriteSheetFactory,setStoreItem:setStoreItem,getStoreItem:getStoreItem,TileEngine:TileEngine,Vector:vectorFactory};export{animationFactory as Animation,imageAssets,audioAssets,dataAssets,setImagePath,setAudioPath,setDataPath,loadImage,loadAudio,loadData,load,init,getCanvas,getContext,on,off,emit,GameLoop,keyMap,initKeys,bindKeys,unbindKeys,keyPressed,registerPlugin,unregisterPlugin,extendObject,initPointer,pointer,track,untrack,pointerOver,onPointerDown,onPointerUp,pointerPressed,poolFactory as Pool,quadtreeFactory as Quadtree,spriteFactory as Sprite,spriteSheetFactory as SpriteSheet,setStoreItem,getStoreItem,TileEngine,vectorFactory as Vector};export default kontra;