-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo-asteroids.js
More file actions
1 lines (1 loc) · 130 KB
/
Copy pathdemo-asteroids.js
File metadata and controls
1 lines (1 loc) · 130 KB
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["demo-asteroids"]=e():t["demo-asteroids"]=e()}(self,(()=>(()=>{var t={375:(t,e,n)=>{var i,r;self,r=()=>(()=>{"use strict";var r={d:(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[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})}},o={};r.r(o),r.d(o,{Background:()=>Qt,Clock:()=>Y,Core:()=>S,Device:()=>O,Effects:()=>F,Emitter:()=>Ht,Fonts:()=>G,GUI:()=>a,INPUT:()=>s,Item:()=>j,Localization:()=>Q,Logs:()=>Ct,MATH:()=>l,Options:()=>u,Particles:()=>M,Player:()=>Tt,Preloader:()=>Et,Scene:()=>gt,Sounds:()=>K,Sprites:()=>D,engine:()=>_t,init:()=>Xt});var s={};r.r(s),r.d(s,{COMBO_TYPES:()=>w,Controller:()=>b,KEYS:()=>g,Receiver:()=>d});var a={};r.r(a),r.d(a,{ALIGN:()=>yt,EVENTS:()=>pt,GuiConsole:()=>ut,GuiElement:()=>tt,GuiText:()=>ot,ORDENATION:()=>ft});var l={};function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}r.r(l),r.d(l,{Point:()=>p,Rotation:()=>x,angleToDirectionVector:()=>Ft,pointDistance:()=>It});var u=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.useAnimationFrame=!1,this.useSmoothParticles=!1,this.drawBoundingBoxes=!1,this.drawMaxRadius=!1,this.drawCollisionRadius=!1,this.drawOrigins=!1,this.drawCenters=!1,this.drawTrackers=!1,this.drawDirectionVectors=!1,this.showFps=!1,this.showStatistics=!1,this.showResizeMessage=!0,this.outputPressedKeys=!1,this.outputPressedCombos=!1,this.outputClicks=!1,this.debugInConsole=!1,this.debugInHtml=!1,this.debugFunctionNames=!1,this.allowPause=!0,this.allowHalt=!1,this.allowFForFps=!0,this.pauseOnWindowChange=!1,this.avoidLeavingPage=!1,this.preventDefaultKeyStrokes=!0,this.useLanguageScreen=!1,this.defaultLanguage="english",this.assetsURLPrefix=null}var e,n;return e=t,(n=[{key:"addOptions",value:function(t){for(var e in t)this[e]=t[e]}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==c(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==c(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===c(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}var p=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.x=void 0===e?0:e,this.y=void 0===n?0:n}var e,n;return e=t,(n=[{key:"magnitude",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y)}},{key:"normalize",value:function(){var e=this.magnitude();return new t(this.x/e,this.y/e)}},{key:"equals",value:function(e){return e instanceof t!=0&&this.x==e.x&&this.y==e.y}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==f(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==f(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===f(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function y(t,e,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n}function h(){var t="";return window.location.href?window.location.href:("file:"!=window.location.protocol&&(t+=window.location.protocol+"//"),""!==window.location.host&&(t+=window.location.host+"/"),t)}function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}var d=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.inverseKeyboard={},this.pressed={},this.lastPressed=[],this.lastPressedTime=(new Date).getTime(),this.currentInputController=null}var e,n;return e=t,(n=[{key:"initialize",value:function(){for(var t in g)Object.prototype.hasOwnProperty.call(g,t)&&(this.inverseKeyboard[g[t]]=t);y("keyup",document,(function(t){_t.input.onKeyup(t)})),y("keydown",document,(function(t){_t.input.onKeydown(t),_t.input.isTargetInput(t)||!0!==_t.options.preventDefaultKeyStrokes&&8!=t.keyCode&&46!=t.keyCode||t.preventDefault()})),y("blur",window,(function(){_t.input.resetKeys(),_t.options.pauseOnWindowChange&&_t.pauseGame()})),y("touchstart",_t.core.canvas,(function(t){return _t.input.onClickStart(t.touches[0].clientX,t.touches[0].clientY),navigator.userAgent.match(/Android/i)&&t.preventDefault(),!1})),y("touchmove",_t.core.canvas,(function(t){return t.preventDefault(),!1})),y("touchend",_t.core.canvas,(function(t){return t.preventDefault(),!1})),y("click",_t.core.canvas,(function(t){return _t.input.onClickStart(t.clientX,t.clientY),t.preventDefault(),!1})),y("mousedown",_t.core.canvas,(function(t){return t.preventDefault(),!1}))}},{key:"activate",value:function(){}},{key:"getCurrentInputcontroller",value:function(){return this.currentInputController}},{key:"setCurrentInputController",value:function(t){this.currentInputController=t}},{key:"isKeyPressed",value:function(t){return this.pressed[t]}},{key:"onKeydown",value:function(t){!0!==this.pressed[t.keyCode]&&(this.pressed[t.keyCode]=!0,this.addLastPressed(t.keyCode))}},{key:"onKeyup",value:function(t){delete this.pressed[t.keyCode]}},{key:"onClickStart",value:function(t,e){if(!0!==_t.device.isResizing){var n=new p(t,e),i=_t.device.getGlobalScroll();n.x+=i.x,n.y+=i.y,n.x<_t.device.canvasGlobalOffset.x||n.y<_t.device.canvasGlobalOffset.y||n.x>_t.device.canvasGlobalOffset.x+_t.core.canvas.width||n.y>_t.device.canvasGlobalOffset.y+_t.core.canvas.height||(n.x-=_t.device.canvasGlobalOffset.x,n.y-=_t.device.canvasGlobalOffset.y,this.currentInputController.detectClick(n))}}},{key:"resetKeys",value:function(){for(var t in this.pressed)this.pressed[t]=!1}},{key:"addLastPressed",value:function(t){this.currentInputController.informKeyPressed(t);var e=(new Date).getTime();e-this.lastPressedTime>1e3&&(this.lastPressed=[]),this.lastPressedTime=e,this.lastPressed.push(t),this.lastPressed.length>10&&this.lastPressed.shift(),!0===_t.options.outputPressedKeys&&_t.logs.log("Input.addLastPressed","Pressed key: "+this.inverseKeyboard[t],e);var n=this.currentInputController.detectCombo();null!==n&&this.currentInputController.informComboPerformed(n,e)}},{key:"addClick",value:function(t){this.currentInputController.informClick(t),!0===_t.options.outputClicks&&_t.logs.log("Input.addClick","Click over: "+t)}},{key:"getKeyFromCode",value:function(t){return this.inverseKeyboard[t]}},{key:"convertKeyToNumber",value:function(t){switch(t){case g.NINE:return 9;case g.EIGTH:return 8;case g.SEVEN:return 7;case g.SIX:return 6;case g.FIVE:return 5;case g.FOUR:return 4;case g.THREE:return 3;case g.TWO:return 2;case g.ONE:return 1;case g.ZERO:return 0}return-1}},{key:"convertNumberToKey",value:function(t){switch(t){case 9:return g.NINE;case 8:return g.EIGTH;case 7:return g.SEVEN;case 6:return g.SIX;case 5:return g.FIVE;case 4:return g.FOUR;case 3:return g.THREE;case 2:return g.TWO;case 1:return g.ONE;case 0:return g.ZERO}return g.ZERO}},{key:"isTargetInput",value:function(t){return"textarea"==t.target.type||"text"==t.target.type||"number"==t.target.type||"email"==t.target.type||"password"==t.target.type||"search"==t.target.type||"tel"==t.target.type||"url"==t.target.type||t.target.isContentEditable}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==v(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==v(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===v(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}var b=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.combos={},this.comboListeners={},this.keyListeners={},this.clickableZones={},this.clickListeners=[]}var e,n;return e=t,(n=[{key:"initialize",value:function(){}},{key:"activate",value:function(){_t.input.setCurrentInputController(this),this.addKeyListener(_t.core,"eventKeyPressed",[g.P,g.ESC,g.F],!0)}},{key:"addKeyListener",value:function(t,e,n,i){void 0===i&&(i=!1);var r={};r.listeningOb=t,r.listeningFunc=e,r.onPause=i;for(var o=0,s=n.length;o<s;o++)void 0===this.keyListeners[n[o]]?this.keyListeners[n[o]]=[r]:this.keyListeners[n[o]].push(r)}},{key:"addClickListener",value:function(t,e,n){void 0===n&&(n=!1);var i={};i.listeningOb=t,i.listeningFunc=e,i.onPause=n,this.clickListeners.push(i)}},{key:"removeListeners",value:function(t){var e,n,i,r;for(e in this.keyListeners)for(n=0,r=this.keyListeners[e].length;n<r;n++)this.keyListeners[e][n].listeningOb==t&&(this.keyListeners[e].splice(n,1),this.keyListeners[e].length||delete this.keyListeners[e]);for(e=0,i=this.clickListeners.length;e<i;e++)for(n=0,r=this.clickListeners[e].length;n<r;n++)this.clickListeners[e][n].listeningOb==t&&this.clickListeners[e].splice(n,1)}},{key:"informKeyPressed",value:function(t){var e=[];if(void 0!==this.keyListeners[t]&&(e=e.concat(this.keyListeners[t])),void 0!==this.keyListeners[g.ANY_KEY]&&(e=e.concat(this.keyListeners[g.ANY_KEY])),void 0!==e)for(var n=0,i=e.length;n<i;n++){var r=e[n];!r.onPause&&_t.paused||void 0!==r.listeningOb[r.listeningFunc]&&r.listeningOb[r.listeningFunc](t)}}},{key:"informClick",value:function(t){if(void 0!==this.clickListeners)for(var e=0,n=this.clickListeners.length;e<n;e++){var i=this.clickListeners[e];!i.onPause&&_t.paused||void 0!==i.listeningOb[i.listeningFunc]&&i.listeningOb[i.listeningFunc](t)}}},{key:"defineCombo",value:function(t,e,n){this.combos[t]={comboType:e,comboKeys:n,lastTime:0}}},{key:"addComboListener",value:function(t,e,n,i){void 0===i&&(i=!1);var r=[];r.listeningOb=t,r.listeningFunc=e,r.onPause=i;for(var o=0,s=n.length;o<s;o++)void 0===this.comboListeners[n[o]]?this.comboListeners[n[o]]=[r]:this.comboListeners[n[o]].push(r)}},{key:"informComboPerformed",value:function(t,e){!0===_t.options.outputPressedCombos&&_t.logs.log("Input.informComboPerformed","Combo activated: "+t,e),this.combos[t].lastTime=e;var n=this.comboListeners[t];if(void 0!==n)for(var i=0,r=n.length;i<r;i++){var o=n[i];!o.onPause&&_t.paused||void 0!==o.listeningOb[o.listeningFunc]&&o.listeningOb[o.listeningFunc](t)}}},{key:"detectCombo",value:function(){for(var t in this.combos){var e=this.combos[t],n=void 0,i=void 0;if(e.comboType==w.SIMULTANEOUS){for(n=0,i=e.comboKeys.length;n<i&&_t.input.isKeyPressed(e.comboKeys[n]);n++)if(n==i-1&&_t.input.isKeyPressed(e.comboKeys[n]))return t}else if(e.comboType==w.CONSECUTIVE){var r=_t.input.lastPressed.length,o=e.comboKeys.length;if(r<o)return null;for(n=1;n<=o&&n<=r&&e.comboKeys[o-n]==_t.input.lastPressed[r-n];n++)if(n>=o||n>=r)return t}}return null}},{key:"addClickZone",value:function(t,e,n,i){this.clickableZones[t]={position:e,size:n,character:i}}},{key:"detectClick",value:function(t){for(var e in this.clickableZones){var n=this.clickableZones[e];t.x>=n.position.x-n.size.x/2&&t.x<=n.position.x+n.size.x/2&&t.y>=n.position.y-n.size.y/2&&t.y<=n.position.y+n.size.y/2&&(null!==n.character&&_t.input.addLastPressed(n.character),_t.input.addClick(e))}}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==m(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==m(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===m(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}(),g={ANY_KEY:-1,INSERT:45,DELETE:46,SPACEBAR:32,ESC:27,BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,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,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,LEFT_WINDOW_KEY:91,RIGHT_WINDOW_KEY:92,SELECT_KEY:93,NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,MULTIPLY:106,ADD:107,SUBTRACT:109,DECIMAL_POINT:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUM_LOCK:144,SCROLL_LOCK:145,SEMI_COLON:186,EQUAL_SIGN:187,COMMA:188,DASH:189,PERIOD:190,FORWARD_SLASH:191,GRAVE_ACCENT:192,OPEN_BRACKET:219,BACK_SLASH:220,CLOSE_BRAKET:221,SINGLE_QUOTE:222,NTILDE:209},w={CONSECUTIVE:1,SIMULTANEOUS:2};function A(t){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}var S=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.FRAMES_PER_SECOND=60,this.TIME_PER_FRAME=1e3/this.FRAMES_PER_SECOND,this.paused=!1,this.halted=!1,this.canvas=null,this.ctx=null,this.size=new p(500,500),this.useAnimationFrame=!1,this.timeLastRender=(new Date).getTime(),this.timeGameStart=(new Date).getTime(),this.fpsPassed=0,this.fps=this.FRAMES_PER_SECOND}var e,n;return e=t,(n=[{key:"initialize",value:function(t){return _t.logs.log("Engine::Core.initialize","Initializing engine core object"),this.canvas=document.getElementById(t),this.size.x=this.canvas.width,this.size.y=this.canvas.height,this.timeLastRender=(new Date).getMilliseconds(),this.ctx=this.canvas.getContext&&this.canvas.getContext("2d"),this.ctx?(_t.logs.log("Engine::Core.initialize","UserAgent: "+_t.device.getUserAgent()),!1===_t.options.useAnimationFrame||null===window.requestAnimationFrame?(this.useAnimationFrame=!1,_t.logs.log("Engine::Core.initialize","NOT using requestAnimationFrame")):(this.useAnimationFrame=!0,_t.logs.log("Engine::Core.initialize","Modern browser, using requestAnimationFrame")),this.loop(),1):(_t.logs.log("Engine::Core.initialize","Old browser, unable to create canvas context"),alert("Unable to get canvas context. Old browser?"),null)}},{key:"activate",value:function(){_t.logs.log("Engine::activate","Starting engine"),_t.game.activate(),_t.scenes.advanceScene()}},{key:"eventKeyPressed",value:function(t){t==g.P&&!0===_t.options.allowPause?this.paused?this.unpauseGame():!1!==_t.scenes.getCurrentScene().playable&&this.pauseGame():t==g.ESC&&!0===_t.options.allowHalt?this.halted?(this.halted=!1,_t.logs.log("Engine::eventKeyPressed","Engine un-halted"),this.timeLastRender=(new Date).getTime(),this.loop()):(this.halted=!0,_t.logs.log("Engine::eventKeyPressed","Engine halted"),_t.scenes.getCurrentScene().gui.get("console").addText("halt","Engine halted"),_t.scenes.getCurrentScene().gui.draw(this.ctx)):t!=g.F||!0!==_t.options.allowFForFps||this.paused||this.halted||(!0===_t.options.showFps?_t.options.showFps=!1:_t.options.showFps=!0)}},{key:"loop",value:function(){var t=(new Date).getTime(),e=t-this.timeLastRender;if(e>=_t.core.TIME_PER_FRAME){this.timeLastRender=t;var n=_t.scenes.getCurrentScene();if(this.halted)return;n&&!0===n.isCurrent&&(!1===this.paused&&(n.step(e),void 0!==_t.game&&_t.game.step(e),_t.effects.step(e),_t.particles.step(e)),_t.clock.step(e),_t.player.step(e),n.draw(this.ctx),_t.effects.draw(this.ctx),_t.particles.draw(this.ctx),this.fpsPassed++,!0===_t.options.showStatistics&&(n.getAttachedItems().length>0&&n.gui.get("console").addText("numItems",n.getAttachedItems().length+" "+_t.localization.get("items")),_t.effects.effects.length>0&&n.gui.get("console").addText("numEffects",_t.effects.effects.length+" "+_t.localization.get("effects")),_t.particles.particles.length>0&&n.gui.get("console").addText("numParticles",_t.particles.particles.length+" "+_t.localization.get("particles")))),e=0}!0===this.useAnimationFrame?window.requestAnimationFrame((function(){_t.core.loop()})):setTimeout((function(){_t.core.loop()}),_t.core.TIME_PER_FRAME-e)}},{key:"clearScreen",value:function(){this.ctx.clearRect(0,0,this.size.x,this.size.y)}},{key:"pauseGame",value:function(){!1!==_t.options.allowPause&&(this.paused=!0,_t.scenes.getCurrentScene().pauseGame())}},{key:"unpauseGame",value:function(){!1!==_t.options.allowPause&&(this.paused=!1,_t.scenes.getCurrentScene().unpauseGame())}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==A(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==A(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===A(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}var O=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.canvasGlobalOffset=new p,this.isTouchDevice=!1,this.isResizing=!1,this._clearTimeOutId=null}var e,n;return e=t,(n=[{key:"initialize",value:function(){var t=this;this.isTouchDevice=this.detectTouchDevice(),this.isTouchDevice?_t.logs.log("Engine::Initialize","Touch device detected"):_t.logs.log("Engine::Initialize","Touch device NOT detected"),this.canvasGlobalOffset=_t.device.getGlobalOffset(_t.core.canvas),y("resize",window,(function(){_t.device.isResizing=!0,!0===_t.options.showResizeMessage&&_t.gui.get("console").addText("resize","Resizing!"),_t.device.canvasGlobalOffset=_t.device.getGlobalOffset(_t.core.canvas),clearTimeout(t._clearTimeOutId),t._clearTimeOutId=setTimeout(_t.device.doneResizing,1e3)})),!0===_t.options.avoidLeavingPage&&this.avoidLeavingPage()}},{key:"doneResizing",value:function(){_t.device.isResizing=!1,!0===_t.options.showResizeMessage&&_t.gui.get("console").addText("resize","Resizing done")}},{key:"activate",value:function(){}},{key:"getGlobalScroll",value:function(){var t=new p(0,0);if(window.pageYOffset)t.x=window.pageXOffset,t.y=window.pageYOffset;else{var e=document.getElementsByTagName("html")[0];e.scrollTop&&(t.x=e.scrollLeft,t.y=e.scrollTop)}return t}},{key:"getGlobalOffset",value:function(t){var e=new p(0,0);for(e.x=t.offsetLeft,e.y=t.offsetTop;t=t.offsetParent;)e.x+=t.offsetLeft,e.y+=t.offsetTop;return e}},{key:"detectTouchDevice",value:function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)}},{key:"getUserAgent",value:function(){return navigator.userAgent}},{key:"avoidLeavingPage",value:function(){window.onbeforeunload=function(){return""}}},{key:"createAndDownloadFile",value:function(t,e){if(window.navigator.msSaveOrOpenBlob){var n=new Blob([e],{type:"text/csv;charset=utf-8;"});window.navigator.msSaveOrOpenBlob(n,t)}else{var i=document.createElement("a");i.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e)),i.setAttribute("download",t),document.body.appendChild(i),i.click(),document.body.removeChild(i)}}},{key:"detectIE",value:function(){var t=navigator.userAgent.toLowerCase();return/msie/.test(t)?parseFloat((t.match(/.*(?:rv|ie)[/: ](.+?)([ );]|$)/)||[])[1]):navigator.appVersion.indexOf("Trident/")>0?11:-1}},{key:"isIE",value:function(){return-1!==navigator.userAgent.indexOf("MSIE")||navigator.appVersion.indexOf("Trident/")>0}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==P(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==P(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===P(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}var x=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.angle=0,this.a=1,this.b=0,this.c=0,this.d=1}var e,n;return e=t,(n=[{key:"getAngle",value:function(){return this.angle}},{key:"rotate",value:function(t){this.update(this.angle+t)}},{key:"update",value:function(t){this.angle=t,this.a=Math.cos(this.angle),this.b=-Math.sin(this.angle),this.c=Math.sin(this.angle),this.d=Math.cos(this.angle)}},{key:"transformPosition",value:function(t){return new p(t.x*this.a+t.y*this.b,t.x*this.c+t.y*this.d)}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==k(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==k(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===k(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function E(t){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(t)}var j=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.spriteName=null,this._visible=!0,this.position=new p,this.size=new p,this.scaling=new p(1,1),this.speed=new p,this.maxVel=0,this.accel=0,this.vRot=0,this.maxVRot=0,this.accelRot=0,this.rotation=new x,this.globalAlpha=1,this.maxRadius=0,this.collisionRadius=0,this.isAnimated=!1,this.currentFrame=0,this.numLoops=1,this.forceFrameSpeed=0,this.timeLastFrame=0,this._attachedItems=[],this._removedItems=[],this._parent=null}var e,n;return e=t,(n=[{key:"initialize",value:function(){}},{key:"activate",value:function(){for(var t=0,e=this._attachedItems.length;t<e;t++)this._attachedItems[t].activate()}},{key:"getVisible",value:function(){return this._visible}},{key:"setVisible",value:function(t){this._visible=t}},{key:"getParent",value:function(){return this._parent}},{key:"setParent",value:function(t){this._parent=t}},{key:"getParentScene",value:function(){for(var t=this;null!==t.getParent();)t=t.getParent();return t===this?_t.scenes.getCurrentScene():t}},{key:"getAttachedItems",value:function(){return this._attachedItems}},{key:"attachItem",value:function(t){this._attachedItems.push(t),t.setParent(this)}},{key:"detachItem",value:function(t){var e=this.getParentScene();e.input.removeListeners(t);for(var n=t.children(),i=0,r=n.length;i<r;i++)e.input.removeListeners(n[i]);this._removedItems.push(t),t.setParent(null)}},{key:"detachAllItems",value:function(){for(var t=0,e=this._attachedItems.length;t<e;t++){var n=this._attachedItems[t];n.detachAllItems(),this.detachItem(n)}this._finalizeRemoved()}},{key:"children",value:function(){for(var t=[],e=0,n=this._attachedItems.length;e<n;e++)t=(t=t.concat(this._attachedItems[e])).concat(this._attachedItems[e].children());return t}},{key:"_resetItems",value:function(){this._attachedItems.length=0}},{key:"_resetRemoved",value:function(){this._removedItems.length=0}},{key:"_finalizeRemoved",value:function(){for(var t=0,e=this._removedItems.length;t<e;t++){var n=this._removedItems[t],i=this._attachedItems.indexOf(n);-1!=i&&this._attachedItems.splice(i,1)}this._resetRemoved()}},{key:"setImage",value:function(t){this.spriteName=t,this.size=_t.sprites.getSpriteSize(t)}},{key:"getOrigin",value:function(){var t=this.getPosition();return new p(t.x-this.size.x/2,t.y-this.size.y/2)}},{key:"getPosition",value:function(){var t=new p,e=new p,n=new p;return null!==this._parent?(e=this._parent.getPosition(),n=this._parent.rotation.transformPosition(this.position),t.x=n.x+e.x,t.y=n.y+e.y):(t.x=this.position.x,t.y=this.position.y),t}},{key:"setPosition",value:function(t,e){this.position.x=t,this.position.y=e}},{key:"getSize",value:function(){return this.size}},{key:"setSize",value:function(t,e){this.size.x=t,this.size.y=e}},{key:"getScaling",value:function(){return this.scaling}},{key:"setScaling",value:function(t,e){this.scaling.x=t,this.scaling.y=e}},{key:"getSpeed",value:function(){return this.speed}},{key:"setSpeed",value:function(t,e){this.speed.x=t,this.speed.y=e}},{key:"getParentPosition",value:function(){return null!==this._parent?this._parent.getPosition():new p}},{key:"getParentSpeed",value:function(){return null!==this._parent?this._parent.getSpeed():new p}},{key:"getRadius",value:function(){return Math.sqrt(Math.pow(this.size.x/2,2)+Math.pow(this.size.y/2,2))}},{key:"getMagnitude",value:function(){return Math.sqrt(this.speed.x*this.speed.x+this.speed.y*this.speed.y)}},{key:"move",value:function(t,e){this.position.x+=t,this.position.y+=e}},{key:"rotate",value:function(t){this.rotation.rotate(t)}},{key:"setRotation",value:function(t){this.rotation.update(t)}},{key:"getRotation",value:function(){return null!==this._parent?this.rotation.getAngle()+this._parent.getRotation():this.rotation.getAngle()}},{key:"draw",value:function(t){if(!0===this._visible){for(var e=0,n=this._attachedItems.length;e<n;e++)this._attachedItems[e].draw(t);null!==this.spriteName&&_t.sprites.draw(t,this),!0===_t.options.drawBoundingBoxes&&this.drawHelper(t,"spriteBox"),!0===_t.options.drawMaxRadius&&this.drawHelper(t,"maxRadius"),!0===_t.options.drawCollisionRadius&&this.drawHelper(t,"collisionRadius"),!0===_t.options.drawOrigins&&this.drawHelper(t,"origin"),!0===_t.options.drawCenters&&this.drawHelper(t,"center"),!0===_t.options.drawDirectionVectors&&this.drawHelper(t,"direction")}}},{key:"step",value:function(t){0===this.speed.x&&0===this.speed.y||this.move(this.speed.x*t/_t.core.TIME_PER_FRAME,this.speed.y*t/_t.core.TIME_PER_FRAME),0!==this.vRot&&this.rotate(this.vRot*t/_t.core.TIME_PER_FRAME),!0===this.isAnimated&&null!==this.spriteName&&_t.sprites.step(t,this);for(var e=0,n=this._attachedItems.length;e<n;e++)this._attachedItems[e].step(t);this._finalizeRemoved()}},{key:"eventAnimationRestart",value:function(){}},{key:"drawHelper",value:function(t,e){var n=this.getPosition(),i=this.getSize(),r=this.getScaling();if("maxRadius"==e)t.beginPath(),t.arc(n.x,n.y,this.maxRadius,0,2*Math.PI,!1),t.closePath(),t.lineWidth=1,t.strokeStyle="#FF0000",t.stroke();else if("collisionRadius"==e)t.beginPath(),t.arc(n.x,n.y,this.collisionRadius,0,2*Math.PI,!1),t.closePath(),t.lineWidth=1,t.strokeStyle="#FF0000",t.stroke();else if("origin"==e)t.fillStyle="#FF0000",t.fillRect(n.x-i.x/2*r.x,n.y-i.y/2*r.y,2,2);else if("center"==e)t.fillStyle="#FF0000",t.fillRect(n.x,n.y,2,2);else if("spriteBox"==e)t.lineWidth=1,t.strokeStyle="#FF0000",t.strokeRect(n.x-i.x/2*r.x,n.y-i.y/2*r.y,i.x*r.x,i.y*r.y);else if("direction"==e){var o=this.getSpeed();t.lineWidth=1,t.strokeStyle="#FF0000",t.beginPath(),t.moveTo(n.x,n.y),t.lineTo(n.x+10*o.x,n.y+10*o.y),t.stroke()}}},{key:"collide",value:function(){return this.detachAllItems(),!0}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==E(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==E(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===E(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function T(t){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T(t)}function R(){return R="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=z(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},R.apply(this,arguments)}function _(t,e){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_(t,e)}function z(t){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},z(t)}var C=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_(t,e)}(s,t);var e,n,i,r,o=(i=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=z(i);if(r){var n=z(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===T(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function s(t,e,n,i,r){var a;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),a=o.call(this);var l=_t.sprites.sprites[t];return a.size=new p(l[3],l[4]),a.numFrames=l[5],a.position=new p(e,n),a.speed=new p(i,r),a.lived=0,a.lifeTime=0,a.maxLoops=1,a.spriteName=t,a.initialScaling=1,a.finalScaling=1,a.transparencyMethod=0,a.globalAlpha=1,a}return e=s,(n=[{key:"step",value:function(t){R(z(s.prototype),"step",this).call(this,t),this.lived++;var e=1;1==this.initialScaling&&1==this.finalScaling||(e=this.initialScaling+(this.finalScaling-this.initialScaling)*this.lived/this.lifeTime,this.scaling.x=e,this.scaling.y=e),2==this.transparencyMethod?0!==this.lifeTime?this.globalAlpha=1-this.lived/this.lifeTime:this.globalAlpha=1-this.currentFrame/this.numFrames:1==this.transparencyMethod&&(0!==this.lifeTime?this.globalAlpha=this.lived/this.lifeTime:this.globalAlpha=this.currentFrame/this.numFrames),!0===this.isAnimated&&_t.sprites.step(t,this)}},{key:"draw",value:function(t){R(z(s.prototype),"draw",this).call(this,t)}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==T(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==T(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===T(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(j);function I(t){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},I(t)}var F=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.effects=[],this.removed=[]}var e,n;return e=t,(n=[{key:"initialize",value:function(){this.effects.length=0}},{key:"removeEffect",value:function(t){this.removed.push(t)}},{key:"_resetRemoved",value:function(){this.removed.length=0}},{key:"_finalizeRemoved",value:function(){for(var t=0,e=this.removed.length;t<e;t++){var n=this.effects.indexOf(this.removed[t]);-1!=n&&this.effects.splice(n,1)}}},{key:"step",value:function(t){this._resetRemoved();for(var e=0,n=this.effects.length;e<n;e++){var i=this.effects[e];i.step(t),i.lifeTime>0&&i.lived>i.lifeTime&&this.removeEffect(i),i.maxLoops>0&&i.numLoops>i.maxLoops&&this.removeEffect(i)}this._finalizeRemoved()}},{key:"draw",value:function(t){for(var e=0,n=this.effects.length;e<n;e++)this.effects[e].draw(t)}},{key:"addEffect",value:function(t,e,n,i,r){var o=new C(t,e,n,i,r);return this.effects.push(o),o}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==I(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==I(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===I(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}var M=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.particles=[],this.maxParticles=1e4,this._removedParticles=[],this.effectField=document.createElement("canvas"),this.effectField.width=_t.core.size.x,this.effectField.height=_t.core.size.y,this.effectField.ctx=this.effectField.getContext("2d")}var e,n;return e=t,(n=[{key:"initialize",value:function(){this.particles=[],this.maxParticles=1e4,this._removedParticles=[]}},{key:"addParticle",value:function(t){this.particles.length>this.maxParticles||this.particles.push(t)}},{key:"removeParticle",value:function(t){this._removedParticles.push(t)}},{key:"_resetItems",value:function(){this.particles.length=0}},{key:"_resetRemoved",value:function(){this._removedParticles.length=0}},{key:"_finalizeRemoved",value:function(){for(var t=0,e=this._removedParticles.length;t<e;t++){var n=this._removedParticles[t],i=this.particles.indexOf(n);-1!=i&&this.particles.splice(i,1)}}},{key:"step",value:function(t){var e,n,i=this.particles.length;for(e=0;e<i;e++)(n=this.particles[e]).lived>n.ttl?this.removeParticle(n):n.step(t);this._finalizeRemoved()}},{key:"draw",value:function(t){if(this.particles.length>0){this.effectField.ctx.clearRect(0,0,_t.core.size.x,_t.core.size.y);for(var e,n=-1;e=this.particles[++n];){var i=[e.color[0]-3*e.lived,e.color[1]-e.lived,e.color[2],e.color[3]];this.effectField.ctx.fillStyle="rgba("+i.join(",")+")",this.effectField.ctx.fillRect(e.position.x,e.position.y,e.size,e.size)}t.drawImage(this.effectField,0,0,_t.core.size.x,_t.core.size.y)}}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==L(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==L(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===L(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}var D=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sprites={},this.images={}}var e,n;return e=t,(n=[{key:"initialize",value:function(){this.sprites.length=0,this.images.length=0}},{key:"step",value:function(t,e){var n=this.sprites[e.spriteName][7],i=this.sprites[e.spriteName][5],r=this.sprites[e.spriteName][6];if(0!==e.forceFrameSpeed&&(n=e.forceFrameSpeed),i>1){var o=(new Date).getTime();if(0===e.timeLastFrame&&(e.timeLastFrame=o),o-e.timeLastFrame>1e3/n){var s=e.currentFrame;e.currentFrame++,e.currentFrame>=r+i&&(e.currentFrame=r),e.timeLastFrame=o,s==i-1&&(e.numLoops+=1,void 0!==e.eventAnimationRestart&&e.eventAnimationRestart())}}}},{key:"draw",value:function(t,e){if(!1!==e.getVisible()){var n=this.sprites[e.spriteName][0],i=this.sprites[e.spriteName][1],r=this.sprites[e.spriteName][2],o=this.sprites[e.spriteName][3],s=this.sprites[e.spriteName][4],a=e.getPosition();t.globalAlpha=e.globalAlpha,0!==e.rotation.getAngle()?(t.save(),t.translate(a.x,a.y),t.rotate(e.rotation.getAngle()),t.drawImage(this.images[n],i+e.currentFrame*o,r,o,s,-o/2*e.scaling.x,-s/2*e.scaling.y,o*e.scaling.x,s*e.scaling.y),t.restore()):t.drawImage(this.images[n],i+e.currentFrame*o,r,o,s,a.x-o/2*e.scaling.x,a.y-s/2*e.scaling.y,o*e.scaling.x,s*e.scaling.y),t.globalAlpha=1}}},{key:"imageExists",value:function(t){return Object.prototype.hasOwnProperty.call(this.images,t)}},{key:"spriteExists",value:function(t){return Object.prototype.hasOwnProperty.call(this.sprites,t)}},{key:"addImage",value:function(t,e){this.images[t]=e}},{key:"addSprite",value:function(t,e,n,i,r,o,s,a,l){this.sprites[t]=[e,n,i,r,o,s,a,l]}},{key:"getImage",value:function(t){return this.images[this.sprites[t][0]]}},{key:"getImageFromPath",value:function(t){return this.images[t]}},{key:"getSpriteData",value:function(t){var e=this.sprites[t];return void 0!==e?e:null}},{key:"getSpriteInfo",value:function(t,e){var n=this.sprites[t];if(void 0!==n){var i=n[e];if(void 0!==i)return i}return null}},{key:"getSpriteSize",value:function(t){var e=this.sprites[t],n=0,i=0;return void 0!==e&&(n=e[3],i=e[4]),new p(n,i)}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==N(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==N(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===N(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function B(t){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(t)}var K=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sounds={}}var e,n;return e=t,(n=[{key:"initialize",value:function(){this.sounds.length=0}},{key:"step",value:function(){}},{key:"soundExists",value:function(t){for(var e=Object.keys(this.sounds),n=0,i=e.length;n<i;n++)if(this.sounds[e[n]][1]==t)return!0;return!1}},{key:"addSound",value:function(t,e,n){this.sounds[t]=[n,e]}},{key:"get",value:function(t){if(void 0===this.sounds[t])return null;var e=this.sounds[t][0];return e.currentTime>0&&(e=e.cloneNode()),e}},{key:"play",value:function(t){var e=this.get(t);null!==e&&(e.currentTime>0&&(e.currentTime=0),e.play())}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==B(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==B(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===B(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function U(t){return U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},U(t)}var G=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.fonts={}}var e,n;return e=t,(n=[{key:"initialize",value:function(){this.fonts.length=0}},{key:"step",value:function(){}},{key:"fontExists",value:function(t){for(var e=Object.keys(this.fonts),n=0,i=e.length;n<i;n++)if(this.fonts[e[n]][1]==t)return!0;return!1}},{key:"addFont",value:function(t,e,n){this.fonts[t]=[n,e]}},{key:"get",value:function(t){return void 0===this.fonts[t]?null:this.fonts[t][0]}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==U(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==U(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===U(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function H(t){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(t)}var V=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.collection=null,this.currentSceneIndex=null,this.currentSceneName=null,this.currentScene=null}var e,n;return e=t,(n=[{key:"initialize",value:function(){this.collection=[],this.currentSceneIndex=0,this.currentSceneName="",this.currentScene=null}},{key:"activate",value:function(){}},{key:"draw",value:function(){}},{key:"step",value:function(){}},{key:"getCurrentScene",value:function(){return this.currentScene}},{key:"setScene",value:function(t){void 0!==this.currentScene&&null!==this.currentScene&&(this.currentScene.isCurrent=!1),_t.core.clearScreen(),this.currentSceneIndex=t,this.currentSceneName=_t.scenes.collection[t].name,this.currentScene=_t.scenes.collection[t].scene,this.currentScene.isCurrent=!0,this.currentScene.activate(),void 0!==_t.player&&null!==_t.player&&_t.player.activate(),_t.logs.log("Scenes::setScene","Set Scene: "+this.currentSceneName+" ("+this.currentSceneIndex+")"),_t.external("SCENE_CHANGE",null,null)}},{key:"addScene",value:function(t,e){_t.logs.log("Scenes::addScene","Add Scene: "+e),t.isCurrent=!1,this.collection.push({scene:t,name:e})}},{key:"insertScene",value:function(t,e,n){t.isCurrent=!1,this.collection.splice(n,0,{scene:t,name:e})}},{key:"advanceScene",value:function(){_t.scenes.currentSceneIndex+1>=_t.scenes.collection.length||_t.scenes.setScene(_t.scenes.currentSceneIndex+1)}},{key:"goBackScene",value:function(){this.currentSceneIndex-1<0||this.setScene(this.currentSceneIndex-1)}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==H(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==H(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===H(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function W(t){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(t)}var Y=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.startTime=0,this.passedTime=0,this.ticker500=0,this.listeners500={},this.ticker1=0,this.listeners1={},this.ticker5=0,this.listeners5={}}var e,n;return e=t,(n=[{key:"initialize",value:function(){this.startTime=(new Date).getTime()}},{key:"activate",value:function(){}},{key:"step",value:function(t){this.ticker1+=t,this.ticker5+=t,this.ticker500+=t,this.ticker1>=1e3&&(this.informListeners(this.listeners1),this.ticker1=0),this.ticker5>=5e3&&(this.informListeners(this.listeners5),this.ticker5=0),this.ticker500>=500&&(this.informListeners(this.listeners500),this.ticker500=0)}},{key:"draw",value:function(){}},{key:"suscribe500",value:function(t,e){this.listeners500[t]=e}},{key:"suscribeOneSecond",value:function(t,e){this.listeners1[t]=e}},{key:"suscribeFiveSeconds",value:function(t,e){this.listeners5[t]=e}},{key:"informListeners",value:function(t){for(var e in t)t[e]()}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==W(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==W(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===W(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function q(t){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q(t)}var Q=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.fallbackLanguage="english",this.selectedLanguage="",this.stringTables={},this.baseTexts={english:{paused:"Paused, press P to continue",loaded:"Loading",items:"items",effects:"effects",particles:"particles",choose_language:"Choose language",english:"English",spanish:"Spanish"},spanish:{paused:"Pausa, pulsa P para continuar",loaded:"Cargando",items:"elementos",effects:"efectos",particles:"partículas",choose_language:"Escoge el idioma",english:"English",spanish:"Español"}}}var e,n;return e=t,(n=[{key:"initialize",value:function(){for(var t in this.selectedLanguage="english",this.baseTexts)this.stringTables[t]=[],this.addTextsToStringTable(t,this.baseTexts[t])}},{key:"get",value:function(t){var e=this.stringTables[this.selectedLanguage][t];return void 0!==e?e:this.stringTables[this.fallbackLanguage][t]}},{key:"addStringTable",value:function(t,e){this.stringTables[t]=e}},{key:"setBaseTexts",value:function(t){this.baseTexts=t}},{key:"addTextsToStringTable",value:function(t,e){for(var n in e)this.stringTables[t][n]=e[n]}},{key:"selectLanguage",value:function(t){this.selectedLanguage=t}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==q(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==q(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===q(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function X(t){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},X(t)}function Z(){return Z="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=$(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},Z.apply(this,arguments)}function J(t,e){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},J(t,e)}function $(t){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},$(t)}var tt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&J(t,e)}(s,t);var e,n,i,r,o=(i=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=$(i);if(r){var n=$(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===X(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=o.call(this,t)).guiId=null,void 0!==t?e.setParent(t):e.guiId="globalGUI",e.inputCallbacks={},e.guiElements={},e.blink=!1,e}return e=s,(n=[{key:"initialize",value:function(){Z($(s.prototype),"initialize",this).call(this)}},{key:"activate",value:function(){Z($(s.prototype),"activate",this).call(this)}},{key:"draw",value:function(t){Z($(s.prototype),"draw",this).call(this,t)}},{key:"step",value:function(t){Z($(s.prototype),"step",this).call(this,t)}},{key:"setBlink",value:function(t){var e=this.getParentScene();null!==e&&(!0===t?(this.blink=!0,e.clock.suscribe(this.guiId+"_clock",this,"blinkStep",350)):(this.blink=!1,this.setVisible(!0),e.clock.unsuscribe(this.guiId+"_clock")))}},{key:"blinkStep",value:function(){!0===this.blink&&!0===this.getVisible()?this.setVisible(!1):(!0===this.blink&&!1===this.getVisible()||!1===this.blink)&&this.setVisible(!0)}},{key:"addInputCallback",value:function(t,e){var n=this.getParentScene();null!==n&&(n.input.addKeyListener(this,"eventKeyPressed",[t],!0),this.inputCallbacks[t]=e)}},{key:"eventKeyPressed",value:function(t){void 0!==this.inputCallbacks[t]&&this.inputCallbacks[t]()}},{key:"getElement",value:function(t){var e=this.guiElements[t];return void 0!==e?e:null}},{key:"get",value:function(t){return this.getElement(t)}},{key:"attachItem",value:function(t,e){this.guiElements[e]=t,t.guiId=e,Z($(s.prototype),"attachItem",this).call(this,t)}},{key:"detachItem",value:function(t){void 0!==t&&(Z($(s.prototype),"detachItem",this).call(this,this.get(t)),delete this.guiElements[t])}},{key:"detachAllItems",value:function(){for(var t=Object.keys(this.guiElements),e=0,n=t.length;e<n;e++)this.guiElements[t[e]].detachAllItems(),this.detachItem(t[e]);this.guiElements={},this._finalizeRemoved()}},{key:"_resetItems",value:function(){this.attachedItems.length=0,this.guiElements={}}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==X(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==X(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===X(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(j);function et(t){return et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},et(t)}function nt(){return nt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=rt(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},nt.apply(this,arguments)}function it(t,e){return it=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},it(t,e)}function rt(t){return rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},rt(t)}var ot=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&it(t,e)}(s,t);var e,n,i,r,o=(i=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=rt(i);if(r){var n=rt(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===et(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function s(t,e,n){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(i=o.call(this)).text=t,i.font='base,BaseFont,"Courier New"',i.fontSize=20,i.fontColor="#FFFFFF",i.fontBorderColor="#000000",i.textAlign=yt.LEFT,i.verticalOffset=20,i.horizontalOffset=10,void 0===e||void 0===n?(i.size.x=100,i.size.y=30):(i.size.x=e,i.size.y=n),i._canvasRendering=!0,i._innerCanvas=document.createElement("canvas"),i._innerCanvas.width=i.size.x,i._innerCanvas.height=i.size.y,i._innerContext=i._innerCanvas.getContext("2d"),i._innerChange=!0,i}return e=s,(n=[{key:"initialize",value:function(){nt(rt(s.prototype),"initialize",this).call(this)}},{key:"activate",value:function(){nt(rt(s.prototype),"activate",this).call(this)}},{key:"setSize",value:function(t,e){nt(rt(s.prototype),"setSize",this).call(this,t,e),this._innerCanvas.width=this.size.x,this._innerCanvas.height=this.size.y,this._innerChange=!0}},{key:"setText",value:function(t){this.text!=t&&(this.text=t,this._innerChange=!0)}},{key:"getText",value:function(){return this.text}},{key:"_updateInnerRender",value:function(t){var e=new p(this.horizontalOffset,this.verticalOffset);this.textAlign==yt.CENTER?e.x=this.size.x/2:this.textAlign==yt.RIGHT&&(e.x=this.size.x-this.horizontalOffset),this._innerContext.lineWidth=t.lineWidth,this._innerContext.clearRect(0,0,this.size.x,this.size.y),this._innerContext.strokeStyle=this.fontBorderColor,this._innerContext.fillStyle=this.fontColor,this._innerContext.textAlign=this.textAlign,this._innerContext.font="bold "+this.fontSize+"px "+this.font;for(var n=this.getText().split("\n"),i=0,r=n.length;i<r;i++)this._innerContext.strokeText(n[i],e.x,e.y),this._innerContext.fillText(n[i],e.x,e.y),e.y+=this.verticalOffset;this._innerChange=!1}},{key:"draw",value:function(t){if(!0===this.getVisible()){var e=this.getPosition(),n=this.getSize();if(!1===this._canvasRendering){var i=new p(this.horizontalOffset,this.verticalOffset);this.textAlign==yt.CENTER?i.x=this.size.x/2:this.textAlign==yt.RIGHT&&(i.x=this.size.x-this.horizontalOffset),t.strokeStyle=this.fontBorderColor,t.fillStyle=this.fontColor,t.textAlign=this.textAlign,t.font="bold "+this.fontSize+"px "+this.font;for(var r=this.getText().split("\n"),o=0,a=r.length;o<a;o++)t.strokeText(r[o],e.x-n.x/2+i.x,e.y-n.y/2+i.y),t.fillText(r[o],e.x-n.x/2+i.x,e.y-n.y/2+i.y),i.y+=this.verticalOffset}else!0===this._innerChange&&this._updateInnerRender(t),t.drawImage(this._innerCanvas,e.x-this.size.x/2,e.y-this.size.y/2)}nt(rt(s.prototype),"draw",this).call(this,t)}},{key:"step",value:function(t){nt(rt(s.prototype),"step",this).call(this,t)}},{key:"setFont",value:function(t){this.font=t}},{key:"setFontSize",value:function(t){this.fontSize=t}},{key:"setFontColor",value:function(t){this.fontColor=t}},{key:"setFontBorderColor",value:function(t){this.fontBorderColor=t}},{key:"setAlign",value:function(t){this.textAlign=t}},{key:"setCanvasRendering",value:function(t){this._canvasRendering=t}},{key:"setVerticalOffset",value:function(t){this.verticalOffset=t}},{key:"setHorizontalOffset",value:function(t){this.horizontalOffset=t}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==et(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==et(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===et(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(tt);function st(t){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},st(t)}function at(){return at="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ct(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},at.apply(this,arguments)}function lt(t,e){return lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},lt(t,e)}function ct(t){return ct=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ct(t)}var ut=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&<(t,e)}(s,t);var e,n,i,r,o=(i=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ct(i);if(r){var n=ct(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===st(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function s(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(t=o.call(this))._texts={},t._textKeys=[],t._textsToRemove=[],t.order=ft.DOWN,t}return e=s,(n=[{key:"initialize",value:function(){at(ct(s.prototype),"initialize",this).call(this)}},{key:"activate",value:function(){at(ct(s.prototype),"activate",this).call(this)}},{key:"draw",value:function(t){at(ct(s.prototype),"draw",this).call(this,t)}},{key:"step",value:function(t){var e=this._textKeys.length;if(0!==e){for(var n=0,i=(new Date).getTime(),r=0;r<e;r++){var o=this._texts[this._textKeys[r]],a=o[1];o[2]+2e3<i?this._textsToRemove.push(this._textKeys[r]):(a.setPosition(0,n),this.order==ft.DOWN?n+=20:n-=20)}if(at(ct(s.prototype),"step",this).call(this,t),(e=this._textsToRemove.length)>0){for(var l=0;l<e;l++)this.detachItem(this._textsToRemove[l]),delete this._texts[this._textsToRemove[l]];this._textKeys=Object.keys(this._texts),this._textsToRemove=[]}}}},{key:"addText",value:function(t,e){if(void 0!==this._texts[t])this._texts[t][0]!=e&&(this._texts[t][0]=e,this._texts[t][1].setText(e)),this._texts[t][2]=(new Date).getTime();else{var n=new ot(e,this.size.x,this.size.y);n.setSize(this.size.x,this.size.y),this._texts[t]=[e,n,(new Date).getTime()],this._textKeys=Object.keys(this._texts),this.attachItem(n,t)}}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==st(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==st(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===st(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(tt),ft={UP:0,DOWN:1},pt={SELECTION:0},yt={LEFT:"left",RIGHT:"right",CENTER:"center"};function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function vt(){return vt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=bt(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},vt.apply(this,arguments)}function dt(t,e){return dt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},dt(t,e)}function mt(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function bt(t){return bt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},bt(t)}var gt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&dt(t,e)}(s,t);var e,n,i,r,o=(i=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=bt(i);if(r){var n=bt(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===ht(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return mt(t)}(this,t)});function s(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(t=o.call(this)).playable=!1,t.backgrounds=[],t.isCurrent=!1,t.gui=new tt(mt(t)),t.clock=new Y,t.input=new b,t}return e=s,(n=[{key:"initialize",value:function(){var t=this;vt(bt(s.prototype),"initialize",this).call(this);var e=new ut;e.setSize(170,30),e.setPosition(15+e.size.x/2,15+e.size.y/2),e.order=ft.DOWN,this.gui.initialize(),this.gui.attachItem(e,"console"),this.clock.initialize(),_t.clock.suscribeOneSecond("FPS",(function(){_t.options.showFps&&t.gui.get("console").addText("fps",_t.core.fpsPassed+" fps"),_t.core.fpsPassed=0})),this.input.initialize()}},{key:"activate",value:function(){vt(bt(s.prototype),"activate",this).call(this),this.gui.activate(),this.clock.activate(),this.input.activate();for(var t=0,e=this.backgrounds.length;t<e;t++)this.backgrounds[t].activate()}},{key:"draw",value:function(t){t.clearRect(0,0,_t.core.size.x,_t.core.size.y);for(var e=0,n=this.backgrounds.length;e<n;e++)this.backgrounds[e].draw(t);vt(bt(s.prototype),"draw",this).call(this,t),this.gui.draw(t)}},{key:"step",value:function(t){for(var e=0,n=this.backgrounds.length;e<n;e++)this.backgrounds[e].step(t);this.clock.step(t),vt(bt(s.prototype),"step",this).call(this,t),this.gui.step(t)}},{key:"addBackground",value:function(t){this.backgrounds.push(t)}},{key:"pauseGame",value:function(){if(null===this.gui.get("pause")){var t=new ot(_t.localization.get("paused"),500,30);t.setFontColor("#FF2222"),t.setAlign(yt.CENTER),t.setPosition(_t.core.size.x/2,_t.core.size.y/2+100),this.gui.attachItem(t,"pause")}}},{key:"unpauseGame",value:function(){this.gui.detachItem("pause")}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==ht(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==ht(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===ht(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(j);function wt(t){return wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wt(t)}if(!Object.defineProperty)throw"Font.js requires Object.defineProperty, which this browser does not support.";if(!document.createElement("canvas").getContext)throw"Font.js requires <canvas> and the Canvas2D API, which this browser does not support.";function At(){this.fontFamily="fjs"+(999999*Math.random()|0)}!function(t){try{return void new Uint8Array(1)}catch(t){}function e(t,e){return this.slice(t,e)}function n(t,e){var n,i=t.length;for(arguments.length<2&&(e=0),n=0;n<i;++n,++e)this[e]=255&t[n]}function i(t){var i,r;if("number"==typeof t)for(i=new Array(t),r=0;r<t;++r)i[r]=0;else i=t.slice(0);return i.subarray=e,i.buffer=i,i.byteLength=i.length,i.set=n,"object"===wt(t)&&t.buffer&&(i.buffer=t.buffer),i}t.Uint8Array=i,t.Uint32Array=i,t.Int32Array=i}(window),function(t){var e;t.opera||"response"in XMLHttpRequest.prototype||"mozResponseArrayBuffer"in XMLHttpRequest.prototype||"mozResponse"in XMLHttpRequest.prototype||"responseArrayBuffer"in XMLHttpRequest.prototype||(e=t.VBArray?function(){return new Uint8Array(new VBArray(this.responseBody).toArray())}:function(){this.responseBody},Object.defineProperty(XMLHttpRequest.prototype,"response",{get:e}))}(window),window.btoa||(window.btoa=function(t){var e,n,i,r,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!t)return t;do{e=(o=t.charCodeAt(a++)<<16|t.charCodeAt(a++)<<8|t.charCodeAt(a++))>>18&63,n=o>>12&63,i=o>>6&63,r=63&o,u[l++]=s.charAt(e)+s.charAt(n)+s.charAt(i)+s.charAt(r)}while(a<t.length);c=u.join("");var f=t.length%3;return(f?c.slice(0,f-3):c)+"===".slice(f||3)}),At.prototype.url="",At.prototype.format="",At.prototype.data="",At.prototype.base64="AAEAAAAKAIAAAwAgT1MvMgAAAAAAAACsAAAAWGNtYXAAAAAAAAABBAAAACxnbHlmAAAAAAAAATAAAAAQaGVhZAAAAAAAAAFAAAAAOGhoZWEAAAAAAAABeAAAACRobXR4AAAAAAAAAZwAAAAIbG9jYQAAAAAAAAGkAAAACG1heHAAAAAAAAABrAAAACBuYW1lAAAAAAAAAcwAAAAgcG9zdAAAAAAAAAHsAAAAEAAEAAEAZAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAABAAMAAQAAAAwABAAgAAAABAAEAAEAAABB//8AAABB////wAABAAAAAAABAAAAAAAAAAAAAAAAMQAAAQAAAAAAAAAAAABfDzz1AAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAEAAgAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAIAAAAAQAAAAIAAQABAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAIAHgADAAEECQABAAAAAAADAAEECQACAAIAAAAAAAEAAAAAAAAAAAAAAAAAAA==",At.prototype.metrics={quadsize:0,leading:0,ascent:0,descent:0,weightclass:400},At.prototype.systemfont=!1,At.prototype.loaded=!1,At.prototype.onload=function(){},At.prototype.onerror=function(){},At.prototype.canvas=!1,At.prototype.context=!1,At.prototype.validate=function(t,e,n,i,r){!1!==r&&r<0?this.onerror("Requested system font '"+this.fontFamily+"' could not be loaded (it may not be installed)."):getComputedStyle(t,null).getPropertyValue("width").replace("px","")>0?(document.head.removeChild(e),document.body.removeChild(t),this.loaded=!0,this.onload()):(console.log("timing out"),setTimeout((function(){i.validate(t,e,n,i,!1!==r&&r-50)}),1e3))},At.prototype.ondownloaded=function(){var t=this,e=function(t){return String.fromCharCode(t)},n=function(t){if(t<256)return e(0)+e(t);var n=255&t;return e(t>>8)+e(n)},i=function(t,e){return 256*t+e},r=function(t,e){var n,i=t>>7==1;return n=256*(t&=127)+e,i?n-32768:n},o=function(t,e,n,i){return 16777216*t+65536*e+256*n+i},s=function(e){t.onerror(e)},a=e(0)+e(1)+e(0)+e(0),l=this.data,c=e(l[0])+e(l[1])+e(l[2])+e(l[3]),u=c===a,f=!u&&"OTTO"===c;if(u)this.format="truetype";else{if(!f)return void s("Error: file at "+this.url+" cannot be interpreted as OpenType font.");this.format="opentype"}var p,y,h=i(l[4],l[5]),v=12+16*h,d={};for(p=12;p<v;p+=16)y=e(l[p])+e(l[p+1])+e(l[p+2])+e(l[p+3]),d[y]={name:y,checksum:o(l[p+4],l[p+5],l[p+6],l[p+7]),offset:o(l[p+8],l[p+9],l[p+10],l[p+11]),length:o(l[p+12],l[p+13],l[p+14],l[p+15])};var m=function(t){return d[t]?t:(s("Error: font is missing the required OpenType '"+t+"' table."),!1)};if(!1!==(y=m("head"))){p=d[y].offset,d[y].version=""+l[p]+l[p+1]+l[p+2]+l[p+3];var b=i(l[p+18],l[p+19]);if(this.metrics.quadsize=b,!1!==(y=m("hhea"))&&(p=d[y].offset,d[y].version=""+l[p]+l[p+1]+l[p+2]+l[p+3],this.metrics.ascent=r(l[p+4],l[p+5])/b,this.metrics.descent=r(l[p+6],l[p+7])/b,this.metrics.leading=r(l[p+8],l[p+9])/b,!1!==(y=m("OS/2"))&&(p=d[y].offset,d[y].version=""+l[p]+l[p+1],this.metrics.weightclass=i(l[p+4],l[p+5]),!1!==(y=m("cmap"))))){p=d[y].offset,d[y].version=""+l[p]+l[p+1],h=i(l[p+2],l[p+3]);for(var g,w,A,S,P=!1,O=0;O<h;O++)w=i(l[g=p+4+8*O],l[g+1]),A=i(l[g+2],l[g+3]),S=o(l[g+4],l[g+5],l[g+6],l[g+7]),3===w&&1===A&&(P=S);var k="A";if(!1!==P&&4===(c=i(l[p+=P],l[p+1]))){for(var x=function(t){return-1===[9,10,11,12,13,32,127,128,129,141,142,143,144,149,157,158,160,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8203,8204,8205,8206,8207,8232,8233,8234,8235,8235,8236,8237,8238,8239,8287,8288,8289,8290,8291,8292,12288].indexOf(t)},E=p+14,j=p+14+i(l[p+6],l[p+7])/2*2,T=!1;E<j&&!x(T=i(l[E],l[E+1]));E+=2)T=!1;if(0!=T){k=String.fromCharCode(T);var R=(65536-(T-1))%65536,_=e(0)+n(T)+n(65535)+n(0)+n(T)+n(65535)+n(R)+n(1),z=btoa(_);this.base64=this.base64.substring(0,380)+z+this.base64.substring(380+z.length)}}this.bootstrapValidation(k,!1)}}},At.prototype.bootstrapValidation=function(t,e){var n=this.fontFamily+" testfont",i=document.createElement("style");i.setAttribute("type","text/css"),i.innerHTML="@font-face {\n font-family: '"+n+"';\n src: url('data:application/x-font-ttf;base64,"+this.base64+"')\n format('truetype');}",document.head.appendChild(i);var r=!1;this.systemfont||(r=this.toStyleNode(),document.head.appendChild(r));var o=document.createElement("p");if(o.style.cssText="position: absolute; top: 0; left: 0; opacity: 0;",o.style.fontFamily="'"+this.fontFamily+"', '"+n+"'",o.innerHTML=t+t+t+t+t+t+t+t+t+t,document.body.appendChild(o),"undefined"==typeof getComputedStyle)this.onload(),error("Error: getComputedStyle is not supported by this browser.\nConsequently, Font.onload() cannot be trusted.");else{var s=this.systemfont?1e3:this.metrics.quadsize,a=document.createElement("canvas");a.width=s,a.height=s,this.canvas=a;var l=a.getContext("2d");l.font="1em '"+this.fontFamily+"'",l.fillStyle="white",l.fillRect(-1,-1,s+2,s+2),l.fillStyle="black",l.fillText("test text",50,s/2),this.context=l;var c=this;setTimeout((function(){c.validate(o,i,r,c,e)}),50)}},At.prototype.processSystemFont=function(){this.systemfont=!0,this.metrics=!1,this.bootstrapValidation("A",1e3)},At.prototype.loadFont=function(){var t=this;if(-1!==this.url.indexOf(".")){var e=new XMLHttpRequest;e.open("GET",t.url,!0),e.responseType="arraybuffer",e.onload=function(n){var i=e.response;i?(t.data=new Uint8Array(i),t.ondownloaded()):t.onerror("Error downloading font resource from "+t.url)},e.onerror=function(e){t.onerror("Error downloading font resource from "+t.url)},e.send(null)}else setTimeout((function(){t.processSystemFont()}),10)},At.prototype.styleNode=!1,At.prototype.toStyleNode=function(){if(this.styleNode)return this.styleNode;this.styleNode=document.createElement("style"),this.styleNode.type="text/css",this.url.replace(".ttf",".eot");var t="@font-face {\n";return t+=" font-family: '"+this.fontFamily+"';\n",t+=" src: url('"+this.url+"') format('"+this.format+"');\n",t+="}",this.styleNode.innerHTML=t,this.styleNode},At.prototype.measureText=function(t,e){if(!this.loaded)return this.onerror("measureText() was called while the font was not yet loaded"),!1;this.context.font=e+"px '"+this.fontFamily+"'";var n=this.context.measureText(t);n.fontsize=e,n.ascent=0,n.descent=0,n.bounds={minx:0,maxx:n.width,miny:0,maxy:0},n.height=0;var i=[];n.width,this.metrics.quadsize,i.push(t);var r,o=i.length;for(r=0;r<o;r++)this.measureSegment(i[r],e,n);return n},At.prototype.measureSegment=function(t,e,n){var i=document.createElement("div");for(i.style.position="absolute",i.style.opacity=0,i.style.font=e+"px '"+this.fontFamily+"'",i.innerHTML=t,m=1;m<10;m++)i.innerHTML+="<br/>"+t;document.body.appendChild(i),n.leading=1.2*e;var r,o=(r=i,document.defaultView.getComputedStyle(r,null).getPropertyValue("height"));if((o=o.replace("px",""))>=10*e&&(n.leading=o/10|0),document.body.removeChild(i),/^\s*$/.test(t))return n;this.canvas;var s=this.context,a=this.systemfont?1e3:this.metrics.quadsize,l=a,c=a,u=a/2,f=(a-n.width)/2;f!==(0|f)&&(f|=0),s.fillStyle="white",s.fillRect(-50,-50,l+100,c+100),s.fillStyle="black",s.fillText(t,f,u);for(var p=n.width+50|0,y=4*e,h=f-25,v=u-y/2,d=s.getImageData(h,v,p,y).data,m=0,b=0,g=4*p,w=d.length,A=y/2;++m<w&&255===d[m];);var S=m/g|0;for(m=w-1;--m>0&&255===d[m];);var P=m/g|0;for(m=0,b=0;b<p&&255===d[m];)(m+=g)>=w&&(b++,m=m-w+4);var O=b,k=1;for(m=w-3,b=0;b<p&&255===d[m];)(m-=g)<0&&(b++,m=w-3-4*k++);var x=p-b;return n.ascent=A-S,n.descent=P-A,n.bounds={minx:O-25,maxx:x-25,miny:-n.descent,maxy:n.ascent},n.height=P-S+1,n},Object.defineProperty(At.prototype,"src",{set:function(t){this.url=t,this.loadFont()}}),void 0===(i=function(){return At}.call(e,n,e,t))||(t.exports=i);const St=At;function Pt(t){return Pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pt(t)}function Ot(){return Ot="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=xt(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},Ot.apply(this,arguments)}function kt(t,e){return kt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},kt(t,e)}function xt(t){return xt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},xt(t)}var Et=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&kt(t,e)}(s,t);var e,n,i,r,o=(i=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=xt(i);if(r){var n=xt(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===Pt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function s(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(t=o.call(this)).timeStarted=0,t.percentageLoaded=0,t.incremental=0,t.imageAssets=[],t.totalImages=0,t.soundAssets=[],t.totalFonts=0,t.message=null,t}return e=s,(n=[{key:"initialize",value:function(){Ot(xt(s.prototype),"initialize",this).call(this)}},{key:"activate",value:function(){var t,e,n;for(_t.logs.log("Preloader::activate","Loading assets"),Ot(xt(s.prototype),"activate",this).call(this),this.timeStarted=(new Date).getTime(),t=0,e=this.imageAssets.length;t<e;t++)n=this.imageAssets[t],this.addImageToLoad(n);for(t=0,e=this.soundAssets.length;t<e;t++)n=this.soundAssets[t],this.addSoundToLoad(n);this.message=new ot(_t.localization.get("loaded")+" "+this.percentageLoaded+"%",300,30),this.message.setPosition(_t.core.size.x/2,_t.core.size.y/2+100),this.message.setAlign(yt.CENTER),this.message.setVerticalOffset(20),this.message.setFontColor("#FF2222"),this.gui.attachItem(this.message,"msg_loading")}},{key:"addAnimation",value:function(t){this.imageAssets.push(t)}},{key:"addSprite",value:function(t){t.xStart=0,t.yStart=0,t.frames=1,t.initFrame=0,t.speed=0,this.addAnimation(t)}},{key:"addImageToLoad",value:function(t){var e=null;_t.sprites.imageExists(t.path)||(y("load",e=new Image,(function(){_t.preloader.incrementalLoader()})),null!==_t.options.assetsURLPrefix?e.src=_t.options.assetsURLPrefix+t.path:e.src=h()+t.path,this.totalImages++,_t.sprites.addImage(t.path,e)),_t.sprites.spriteExists(t.name)||_t.sprites.addSprite(t.name,t.path,t.xStart,t.yStart,t.width,t.height,t.frames,t.initFrame,t.speed)}},{key:"addSound",value:function(t){this.soundAssets.push(t)}},{key:"addSoundToLoad",value:function(t){var e=null;if(!_t.sounds.soundExists(t.path)){var n=t.path;n=null!==_t.options.assetsURLPrefix?_t.options.assetsURLPrefix+n:h()+n,(e=new Audio(n)).load(),y("canplaythrough",e,(function(){_t.preloader.incrementalLoader("sound")})),_t.sounds.addSound(t.name,t.path,e)}}},{key:"addFont",value:function(t){var e=new St;this.totalFonts++,e.onerror=function(t){_t.logs.log("Preloader::addFont","Error loading a font: "+t)},e.onload=function(){_t.logs.log("Preloader::addFont","Font loaded <"+e.fontFamily+">"),_t.preloader.incrementalLoader("font")},e.fontFamily=t.name,void 0!==t.flag?e.src=t.path:null!==_t.options.assetsURLPrefix?e.src=_t.options.assetsURLPrefix+t.path:e.src=h()+t.path,_t.fonts.addFont(t.name,t.path,e)}},{key:"incrementalLoader",value:function(){var t=this.totalImages+this.soundAssets.length+this.totalFonts;this.incremental+=1,this.percentageLoaded=Math.floor(100*this.incremental/t)}},{key:"draw",value:function(t){Ot(xt(s.prototype),"draw",this).call(this,t);var e=_t.core.size.x/3;t.fillStyle="#FF2222",t.fillRect((_t.core.size.x-e)/2+1,_t.core.size.y/2+51,this.percentageLoaded*e/100,15),t.lineWidth=2,t.strokeStyle="#FFEEEE",t.strokeRect((_t.core.size.x-e)/2,_t.core.size.y/2+50,e+2,16)}},{key:"step",value:function(t){Ot(xt(s.prototype),"step",this).call(this,t),this.message.setText(_t.localization.get("loaded")+" "+this.percentageLoaded+"%");var e=(new Date).getTime()-this.timeStarted;this.percentageLoaded>=100&&e>1e3&&(_t.core.activate(),_t.external("LOADED",null,null))}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==Pt(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==Pt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===Pt(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(gt);function jt(t){return jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jt(t)}var Tt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),_t.logs.log("Player::initialize","Initializing player object"),this.avatar=null}var e,n;return e=t,(n=[{key:"getAvatar",value:function(){return this.avatar}},{key:"setAvatar",value:function(t){this.avatar=t}},{key:"initialize",value:function(){}},{key:"activate",value:function(){}},{key:"step",value:function(){}},{key:"draw",value:function(){}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==jt(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==jt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===jt(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function Rt(t){return Rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rt(t)}const _t=new(function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.options=null,this.logs=null,this.core=null,this.device=null,this.effects=null,this.particles=null,this.sprites=null,this.sounds=null,this.fonts=null,this.clock=null,this.localization=null,this.input=null,this.controls=null,this.scenes=null,this.preloader=null,this.game=null,this.externalCallback=null,this.player=null}var e,n;return e=t,(n=[{key:"initialize",value:function(t,e,n){this.options=new u,this.logs=new Ct,this.core=new S,this.device=new O,this.effects=new F,this.particles=new M,this.sprites=new D,this.sounds=new K,this.fonts=new G,this.clock=new Y,this.localization=new Q,this.input=new d,this.scenes=new V,this.preloader=new Et,this.player=new Tt,this.logs.log("Engine::initialize","Initializing starts..."),this.game=e,void 0!==n&&(this.externalCallback=n),this.core.initialize(t),this.device.initialize(),this.effects.initialize(),this.particles.initialize(),this.sprites.initialize(),this.sounds.initialize(),this.clock.initialize(),this.input.initialize(),this.localization.initialize(),this.scenes.initialize(),this.preloader.playable=!1,this.preloader.initialize(),this.game.initialize()}},{key:"external",value:function(t,e,n){var i=this;"undefined"!=typeof externalCallback&&setTimeout((function(){try{i.externalCallback(t,e,n)}catch(n){i.logs.log("Engine::external","Error with external callback with event "+t+" "+e)}}),1)}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==Rt(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==Rt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===Rt(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}());function zt(t){return zt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zt(t)}var Ct=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,n;return e=t,(n=[{key:"log",value:function(t,e,n){var i=[];if(!1!==_t.options.debugInConsole)if(!0===_t.options.debugFunctionNames&&i.push(t),Array.isArray(e)?i.push(e.join(" ")):i.push(e),n&&i.push(n),!0===_t.options.debugInHtml&&void 0!==_t.core.canvas){var r=document.createElement("div");r.innerHTML=i,_t.core.canvas.parentNode.appendChild(r)}else void 0===window.console||void 0===window.console.log||window.console.log(i)}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==zt(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==zt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===zt(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function It(t,e){return void 0===e.x||void 0===e.y||void 0===t.x||void 0===t.y?-1:Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Ft(t){var e=new p;return e.x=Math.cos(t),e.y=Math.sin(t),e}function Lt(t){return Lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lt(t)}function Mt(t,e){return Mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mt(t,e)}function Nt(t){return Nt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Nt(t)}var Dt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Mt(t,e)}(s,t);var e,n,i,r,o=(i=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Nt(i);if(r){var n=Nt(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===Lt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function s(t,e){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(n=o.call(this)).setPosition(t.x,t.y),n.setSpeed(e.x,e.y),n.ttl=-1,n.lived=0,n.color=[],n.size=2,n}return e=s,(n=[{key:"initialize",value:function(){}},{key:"activate",value:function(){}},{key:"step",value:function(t){this.move(this.speed.x*t/_t.core.TIME_PER_FRAME,this.speed.y*t/_t.core.TIME_PER_FRAME),this.lived++}},{key:"draw",value:function(){}},{key:"collide",value:function(){return!1}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==Lt(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==Lt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===Lt(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(j);function Bt(t){return Bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bt(t)}function Kt(){return Kt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Gt(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},Kt.apply(this,arguments)}function Ut(t,e){return Ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ut(t,e)}function Gt(t){return Gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Gt(t)}var Ht=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ut(t,e)}(s,t);var e,n,i,r,o=(i=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Gt(i);if(r){var n=Gt(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===Bt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function s(t,e,n){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(i=o.call(this)).size=new p(10,10),i.particleSpeed=t,i.magnitude=e,i.particleColor=[255,255,255,255],i.particleLife=100,i.particleSize=3,i.started=!1,i.spread=n,i.emissionRate=3,i}return e=s,(n=[{key:"start",value:function(){this.started=!0}},{key:"stop",value:function(){this.started=!1}},{key:"createParticle",value:function(){var t=Math.random()*this.spread-this.spread/2,e=Ft(this.getRotation()+t);e=e.normalize();var n=new p(e.x*this.particleSpeed,e.y*this.particleSpeed),i=this.getPosition(),r=new Dt(i,n);r.ttl=Math.random()*this.particleLife,r.color=this.particleColor,r.size=this.particleSize,_t.particles.addParticle(r)}},{key:"step",value:function(t){if(Kt(Gt(s.prototype),"step",this).call(this,t),!0===this.started)for(var e=0;e<this.emissionRate;e++)this.createParticle()}},{key:"draw",value:function(t){Kt(Gt(s.prototype),"draw",this).call(this,t)}},{key:"collide",value:function(){return!1}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==Bt(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==Bt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===Bt(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(j);function Vt(t){return Vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vt(t)}function Wt(){return Wt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=qt(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},Wt.apply(this,arguments)}function Yt(t,e){return Yt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Yt(t,e)}function qt(t){return qt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},qt(t)}var Qt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Yt(t,e)}(s,t);var e,n,i,r,o=(i=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=qt(i);if(r){var n=qt(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===Vt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function s(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(t=o.call(this)).backgroundType="image",t.color="black",t.spriteName=null,t.position.x=_t.core.size.x/2,t.position.y=_t.core.size.y/2,t.pauseScroll=!1,t.verticalScroll=!1,t.verticalOffset=0,t.verticalSpeed=0,t.horizontalScroll=!1,t.horizontalOffset=0,t.horizontalSpeed=0,t}return e=s,(n=[{key:"initialize",value:function(){Wt(qt(s.prototype),"initialize",this).call(this)}},{key:"activate",value:function(){Wt(qt(s.prototype),"activate",this).call(this),this.verticalOffset=0,this.horizontalOffset=0}},{key:"step",value:function(t){Wt(qt(s.prototype),"step",this).call(this,t),!1===this.pauseScroll&&(!0===this.verticalScroll?(this.verticalOffset+=this.verticalSpeed*t/_t.core.TIME_PER_FRAME,this.verticalOffset=Math.floor(this.verticalOffset%_t.core.size.y)):!0===this.horizontalScroll&&(this.horizontalOffset+=this.horizontalSpeed*t/_t.core.TIME_PER_FRAME,this.horizontalOffset=Math.floor(this.horizontalOffset%_t.core.size.x)))}},{key:"draw",value:function(t){if("color"==this.backgroundType)t.fillStyle=this.color,t.fillRect(0,0,_t.core.size.x,_t.core.size.y);else if("image"==this.backgroundType){var e,n;!0===this.verticalScroll?(e=Math.floor(this.verticalOffset),n=_t.core.size.y-e,e>0&&t.drawImage(_t.sprites.getImage(this.spriteName),0,n,_t.core.size.x,e,0,0,_t.core.size.x,e),n>0&&t.drawImage(_t.sprites.getImage(this.spriteName),0,0,_t.core.size.x,n,0,e,_t.core.size.x,n)):!0===this.horizontalScroll?(e=Math.floor(this.horizontalOffset),n=_t.core.size.x-e,e>0&&t.drawImage(_t.sprites.getImage(this.spriteName),0,0,e,_t.core.size.y,n,0,e,_t.core.size.y),n>0&&t.drawImage(_t.sprites.getImage(this.spriteName),e,0,n,_t.core.size.y,0,0,n,_t.core.size.y)):_t.sprites.draw(t,this)}}}])&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(r=function(t,e){if("object"!==Vt(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==Vt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===Vt(r)?r:String(r)),i)}var r}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(j);function Xt(t,e,n){return"complete"===document.readyState?_t.initialize(t,e,n):y("load",window,(function(){_t.initialize(t,e,n)})),_t}return o})(),t.exports=r()}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";n.r(i),n.d(i,{default:()=>ct});var t=n(375);function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,n){for(var i=0;i<n.length;i++){var r=n[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,o=function(t,n){if("object"!==e(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!==e(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key),"symbol"===e(o)?o:String(o)),r)}var o}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}var s=o((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.defaultLanguage="english",this.debugInConsole=!0,this.meteorPeriodicity=500,this.shotPeriodicity=200}));function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function l(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==a(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==a(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===a(r)?r:String(r)),i)}var r}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}var f=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(f,e);var n,i,r,o,s=(r=f,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=u(r);if(o){var n=u(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===a(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function f(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,f),(t=s.call(this)).BACKGROUND_SPEED=8,t.BACKGROUND_STARS=30,t.speeds=[],t.offsets=[],t.parallaxDisplacement=5,t.starfields=[],t}return n=f,(i=[{key:"initialize",value:function(){for(var e=0;e<3;e++){this.starfields[e]=document.createElement("canvas"),this.starfields[e].layer=e,this.starfields[e].width=t.engine.core.size.x+(e+1)*this.parallaxDisplacement,this.starfields[e].height=t.engine.core.size.y,this.starfields[e].ctx=this.starfields[e].getContext("2d"),this.speeds[e]=this.BACKGROUND_SPEED+7*(e+1),this.offsets[e]=0,0===e&&(this.starfields[e].ctx.fillStyle="#000",this.starfields[e].ctx.fillRect(0,0,this.starfields[e].width,this.starfields[e].height)),this.starfields[e].ctx.fillStyle="#FFF",this.starfields[e].ctx.globalAlpha=2*(e+1)/10;for(var n=0;n<this.BACKGROUND_STARS;n++)this.starfields[e].ctx.fillRect(Math.floor(Math.random()*this.starfields[e].width),Math.floor(Math.random()*this.starfields[e].height),e+1,e+1)}}},{key:"step",value:function(t){for(var e=0;e<3;e++)this.offsets[e]+=this.speeds[e]/t,this.offsets[e]=this.offsets[e]%this.starfields[e].height}},{key:"draw",value:function(e){for(var n=0;n<3;n++){var i=Math.floor(this.offsets[n]),r=this.starfields[n].height-i,o=this.starfields[n].width,s=void 0;if(void 0===t.engine.player||null===t.engine.player||t.engine.currentScene<=2)s=(n+1)*this.parallaxDisplacement*(t.engine.core.size.x/2)/t.engine.core.size.x;else{var a=t.engine.player.getAvatar().getPosition().x;(s=Math.round((n+1)*this.parallaxDisplacement*a/t.engine.core.size.x))<0?s=0:s+t.engine.core.size.x>o&&(s=o-t.engine.core.size.x)}i>0&&e.drawImage(this.starfields[n],0+s,r,t.engine.core.size.x,i,0,0,t.engine.core.size.x,i),r>0&&e.drawImage(this.starfields[n],0+s,0,t.engine.core.size.x,r,0,i,t.engine.core.size.x,r)}}}])&&l(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),f}(t.Background);function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function y(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==p(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==p(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===p(r)?r:String(r)),i)}var r}function h(){return h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=d(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},h.apply(this,arguments)}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}var m=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}(a,e);var n,i,r,o,s=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=d(r);if(o){var n=d(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===p(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function a(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),s.call(this)}return n=a,(i=[{key:"initialize",value:function(){h(d(a.prototype),"initialize",this).call(this),this.input.addKeyListener(this,"eventKeyPressed",[t.INPUT.KEYS.SPACEBAR])}},{key:"activate",value:function(){var e=t.engine.player.getAvatar();e.setPosition(t.engine.core.size.x/2,t.engine.core.size.y/2),this.attachItem(e),h(d(a.prototype),"activate",this).call(this)}},{key:"draw",value:function(t){h(d(a.prototype),"draw",this).call(this,t)}},{key:"step",value:function(t){h(d(a.prototype),"step",this).call(this,t)}},{key:"eventKeyPressed",value:function(e){e==t.INPUT.KEYS.SPACEBAR&&t.engine.scenes.advanceScene()}}])&&y(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),a}(t.Scene);function b(t){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(t)}function g(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==b(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==b(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===b(r)?r:String(r)),i)}var r}function w(){return w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=S(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},w.apply(this,arguments)}function A(t,e){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},A(t,e)}function S(t){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},S(t)}var P=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&A(t,e)}(a,e);var n,i,r,o,s=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=S(r);if(o){var n=S(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===b(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function a(e,n){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(i=s.call(this)).spriteName="meteor",i.size.x=t.engine.sprites.sprites[i.spriteName][3],i.size.y=t.engine.sprites.sprites[i.spriteName][4],i.linearSpeed=n,i.vRot=Math.PI/600,i.scaling.x=e,i.scaling.y=e,i.maxRadius=i.getRadius(),i.collisionRadius=29,i}return n=a,(i=[{key:"step",value:function(t){w(S(a.prototype),"step",this).call(this,t)}},{key:"draw",value:function(t){w(S(a.prototype),"draw",this).call(this,t)}},{key:"collide",value:function(e){w(S(a.prototype),"collide",this).call(this);var n=e.speed.x,i=e.speed.y;e instanceof T&&(n=e.speed.x/10,i=e.speed.y/10);var r=t.engine.effects.addEffect("halo",this.position.x,this.position.y,this.speed.x+n,this.speed.y+i);r.initialScaling=2,r.finalScaling=3,r.lifeTime=20,r.vRot=Math.PI/100,r.transparencyMethod=2;for(var o=0;o<10;o++)(r=t.engine.effects.addEffect("explosion",this.position.x+40*(Math.random()-.5),this.position.y+40*(Math.random()-.5),this.speed.x+(Math.random()-.5),this.speed.y+(Math.random()-.5))).scaling.x=Math.abs(Math.random()-.1),r.scaling.y=r.scaling.x,r.vRot=(Math.random()-.5)*Math.PI/50,r.lifeTime=100,r.isAnimated=!0,r.transparencyMethod=Math.floor(3*Math.random());return t.engine.sounds.play("explosion"),!0}}])&&g(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),a}(t.Item);function O(t){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(t)}function k(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==O(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==O(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===O(r)?r:String(r)),i)}var r}function x(){return x="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=j(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},x.apply(this,arguments)}function E(t,e){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},E(t,e)}function j(t){return j=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},j(t)}var T=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&E(t,e)}(a,e);var n,i,r,o,s=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=j(r);if(o){var n=j(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===O(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function a(e,n,i){var r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(r=s.call(this)).spriteName="shot",r.creator=e,r.size.x=t.engine.sprites.sprites[r.spriteName][3],r.size.y=t.engine.sprites.sprites[r.spriteName][4],r.position=n,r.speedMagnitude=5,r.setRotation(i);var o=t.MATH.angleToDirectionVector(i);return o=o.normalize(),r.speed.x=o.x*r.speedMagnitude,r.speed.y=o.y*r.speedMagnitude,r.maxRadius=r.getRadius(),r.collisionRadius=12,r}return n=a,(i=[{key:"step",value:function(t){x(j(a.prototype),"step",this).call(this,t)}},{key:"draw",value:function(t){x(j(a.prototype),"draw",this).call(this,t)}},{key:"collide",value:function(e){return!(e instanceof a||e==this.creator||(e instanceof P&&t.engine.game.points.add(50),x(j(a.prototype),"collide",this).call(this),0))}}])&&k(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),a}(t.Item);function R(t){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(t)}function _(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==R(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==R(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===R(r)?r:String(r)),i)}var r}function z(){return z="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=I(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},z.apply(this,arguments)}function C(t,e){return C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},C(t,e)}function I(t){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},I(t)}var F=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&C(t,e)}(a,e);var n,i,r,o,s=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=I(r);if(o){var n=I(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===R(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function a(){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(e=s.call(this)).size=new t.MATH.Point(10,10),e}return n=a,(i=[{key:"step",value:function(t){z(I(a.prototype),"step",this).call(this,t)}},{key:"draw",value:function(t){z(I(a.prototype),"draw",this).call(this,t)}},{key:"shoot",value:function(e){var n=new T(e,this.getPosition(),this.getRotation());t.engine.scenes.getCurrentScene().attachItem(n)}},{key:"collide",value:function(){return!1}}])&&_(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),a}(t.Item);function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}function M(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==L(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==L(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===L(r)?r:String(r)),i)}var r}function N(){return N="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=B(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},N.apply(this,arguments)}function D(t,e){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},D(t,e)}function B(t){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},B(t)}var K=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&D(t,e)}(a,e);var n,i,r,o,s=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=B(r);if(o){var n=B(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===L(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function a(e){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(n=s.call(this)).spriteName=e,n.size.x=t.engine.sprites.sprites[n.spriteName][3],n.size.y=t.engine.sprites.sprites[n.spriteName][4],n.maxRadius=n.getRadius(),n.collisionRadius=24,n.gunRack=[],n.motorEffect=null,n}return n=a,(i=[{key:"initialize",value:function(){N(B(a.prototype),"initialize",this).call(this),this.motorEffect=new t.Emitter(1,1,Math.PI/5),this.motorEffect.setPosition(-20,-1),this.motorEffect.setRotation(Math.PI),this.attachItem(this.motorEffect);var e=new F;e.setPosition(20,0),this.gunRack.push(e),this.attachItem(e),this.setRotation(-Math.PI/2)}},{key:"step",value:function(e){N(B(a.prototype),"step",this).call(this,e),!0===t.engine.player.isThrusting?this.motorEffect.start():this.motorEffect.stop()}},{key:"draw",value:function(t){N(B(a.prototype),"draw",this).call(this,t)}},{key:"collide",value:function(e){return e instanceof T&&e.creator==this||(this.speed.x=this.speed.x/10,this.speed.y=this.speed.y/10,t.engine.game.points.add(-10)),!1}},{key:"shoot",value:function(){for(var e=0,n=this.gunRack.length;e<n;e++)this.gunRack[e].shoot(this);t.engine.sounds.play("shot")}}])&&M(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),a}(t.Item);function U(t){return U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},U(t)}function G(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==U(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==U(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===U(r)?r:String(r)),i)}var r}function H(){return H="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=W(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},H.apply(this,arguments)}function V(t,e){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},V(t,e)}function W(t){return W=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},W(t)}var Y=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&V(t,e)}(a,e);var n,i,r,o,s=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=W(r);if(o){var n=W(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===U(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function a(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(t=s.call(this)).timeLastMeteor=0,t}return n=a,(i=[{key:"initialize",value:function(){H(W(a.prototype),"initialize",this).call(this);var e=new t.GUI.GuiText;e.setSize(250,30),e.setPosition(15+e.size.x/2,t.engine.core.size.y-15-e.size.y/2),e.setText(t.engine.localization.get("points")+": 0"),this.gui.attachItem(e,"points")}},{key:"activate",value:function(){this.attachItem(t.engine.player.getAvatar()),H(W(a.prototype),"activate",this).call(this)}},{key:"draw",value:function(t){H(W(a.prototype),"draw",this).call(this,t)}},{key:"step",value:function(e){H(W(a.prototype),"step",this).call(this,e),this.checkBoundaries(),this.checkCollisions();var n=(new Date).getTime();if(n-this.timeLastMeteor>t.engine.options.meteorPeriodicity){this.timeLastMeteor=n;var i=new P(1,1.5),r=Math.floor(4*Math.random()),o=Math.random()*Math.PI;switch(r){case 0:i.position.x=Math.random()*t.engine.core.size.x,i.position.y=1-i.size.y;break;case 1:i.position.x=1-i.size.x,i.position.y=Math.random()*t.engine.core.size.y,o+=Math.PI/2;break;case 2:i.position.x=Math.random()*t.engine.core.size.x,i.position.y=t.engine.core.size.y+i.size.y-1,o-=Math.PI;break;default:i.position.x=t.engine.core.size.x+i.size.x-1,i.position.y=Math.random()*t.engine.core.size.y,o-=Math.PI/2}var s=t.MATH.angleToDirectionVector(o);s=s.normalize(),i.speed.x=s.x*i.linearSpeed,i.speed.y=s.y*i.linearSpeed,this.attachItem(i)}}},{key:"checkBoundaries",value:function(){var e;this._resetRemoved();for(var n=0;n<this.getAttachedItems().length;n++)((e=this.getAttachedItems()[n]).position.x>t.engine.core.size.x+e.size.x||e.position.x<0-e.size.x||e.position.y<0-e.size.y||e.position.y>t.engine.core.size.y+e.size.y)&&this.detachItem(e);this._finalizeRemoved()}},{key:"checkCollisions",value:function(){var e,n;this._resetRemoved();for(var i=0;i<this.getAttachedItems().length;i++)if(0!==(e=this.getAttachedItems()[i]).collisionRadius)for(var r=i+1;r<this.getAttachedItems().length;r++)0!==(n=this.getAttachedItems()[r]).collisionRadius&&(Math.abs(e.position.x-n.position.x)>e.size.x/2+n.size.x/2||Math.abs(e.position.y-n.position.y)>e.size.y/2+n.size.y/2||t.MATH.pointDistance(e.position,n.position)<=e.collisionRadius+n.collisionRadius&&(!0===e.collide(n)&&this.detachItem(e),!0===n.collide(e)&&this.detachItem(n)));this._finalizeRemoved()}}])&&G(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),a}(t.Scene);function q(t){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q(t)}function Q(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==q(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==q(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===q(r)?r:String(r)),i)}var r}var X=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var n,i;return n=e,(i=[{key:"initialize",value:function(){t.engine.preloader.addSprite({name:"starship",path:"assets/images/ship.png",width:50,height:50}),t.engine.preloader.addSprite({name:"meteor",path:"assets/images/meteor.png",width:60,height:60}),t.engine.preloader.addSprite({name:"shot",path:"assets/images/shot.png",width:10,height:10}),t.engine.preloader.addAnimation({name:"explosion",path:"assets/images/effect.explosion.png",xStart:0,yStart:0,width:48,height:47,frames:11,initFrame:0,speed:14}),t.engine.preloader.addSprite({name:"halo",path:"assets/images/effect.halo.png",width:63,height:63}),t.engine.preloader.addSound({name:"explosion",path:"assets/sounds/fridobeck_explosion.mp3"}),t.engine.preloader.addSound({name:"shot",path:"assets/sounds/halgrimm_shot.mp3"}),t.engine.preloader.addFont({name:"baseFont",path:"assets/fonts/visitor1.ttf"}),t.engine.preloader.addBackground(t.engine.game.commonBackground),t.engine.preloader.initialize(),t.engine.scenes.addScene(t.engine.preloader,"preloader"),t.engine.scenes.setScene(0),t.engine.localization.addTextsToStringTable("english",this.localization_en()),t.engine.localization.addTextsToStringTable("spanish",this.localization_es()),t.engine.localization.selectLanguage(t.engine.game.options.defaultLanguage)}},{key:"localization_en",value:function(){return{game_name:"Game",press_spacebar:"Press the spacebar to start",touch_screen:"Touch the screen to continue",points:"Points",accumulated:"Accumulated points",totals:"Total points"}}},{key:"localization_es",value:function(){return{game_name:"Juego",press_spacebar:"Pulsa espacio para comenzar",touch_screen:"Toca la pantalla para continuar",points:"Puntos",accumulated:"Puntos acumulados",totals:"Puntos totales"}}}])&&Q(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),e}();function Z(t){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(t)}function J(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==Z(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==Z(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===Z(r)?r:String(r)),i)}var r}function $(){return $="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=et(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},$.apply(this,arguments)}function tt(t,e){return tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},tt(t,e)}function et(t){return et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},et(t)}var nt=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&tt(t,e)}(a,e);var n,i,r,o,s=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=et(r);if(o){var n=et(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===Z(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function a(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(t=s.call(this)).avatar=null,t.timeLastShot=0,t.isTurningLeft=!1,t.isTurningRight=!1,t.isThrusting=!1,t.rotationSpeed=Math.PI/50,t.flightSpeed=.05,t}return n=a,(i=[{key:"initialize",value:function(){$(et(a.prototype),"initialize",this).call(),this.avatar=new K("starship"),this.avatar.initialize()}},{key:"activate",value:function(){$(et(a.prototype),"activate",this).call(),this.timeLastShot=0,this.isTurningLeft=!1,this.isTurningRight=!1,this.isThrusting=!1,this.getAvatar().getParentScene().input.addKeyListener(this,"eventKeyPressed",[t.INPUT.KEYS.SPACEBAR])}},{key:"eventKeyPressed",value:function(e){if(!0!==t.engine.core.paused&&e==t.INPUT.KEYS.SPACEBAR){var n=(new Date).getTime();n-this.timeLastShot>t.engine.options.shotPeriodicity&&(this.avatar.shoot(),this.timeLastShot=n)}}},{key:"step",value:function(){if(void 0===this.getAvatar().getParentScene()||null===this.getAvatar().getParentScene()||!1!==this.getAvatar().getParentScene().playable){if(t.engine.input.isKeyPressed(t.INPUT.KEYS.LEFT)?this.isTurningLeft=!0:this.isTurningLeft=!1,t.engine.input.isKeyPressed(t.INPUT.KEYS.RIGHT)?this.isTurningRight=!0:this.isTurningRight=!1,t.engine.input.isKeyPressed(t.INPUT.KEYS.UP)?this.isThrusting=!0:this.isThrusting=!1,!0===this.isTurningLeft?this.avatar.vRot=-this.rotationSpeed:!0===this.isTurningRight?this.avatar.vRot=this.rotationSpeed:this.avatar.vRot=0,!0===this.isThrusting){var e=t.MATH.angleToDirectionVector(this.avatar.rotation.getAngle());e=e.normalize(),this.avatar.speed.x+=e.x*this.flightSpeed,this.avatar.speed.y+=e.y*this.flightSpeed}this.avatar.position.x>t.engine.core.size.x?(this.avatar.move(-this.avatar.size.x/4,0),this.avatar.speed.x=-this.avatar.speed.x/2):this.avatar.position.x<0&&(this.avatar.move(this.avatar.size.x/4,0),this.avatar.speed.x=-this.avatar.speed.x/2),this.avatar.position.y>t.engine.core.size.y?(this.avatar.move(0,-this.avatar.size.y/4),this.avatar.speed.y=-this.avatar.speed.y/2):this.avatar.position.y<0&&(this.avatar.move(0,this.avatar.size.y/4),this.avatar.speed.y=-this.avatar.speed.y/2)}}}])&&J(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),a}(t.Player);function it(t){return it="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},it(t)}function rt(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==it(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==it(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===it(r)?r:String(r)),i)}var r}var ot=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.totalPoints=0,this.gameInitTime=0}var n,i;return n=e,(i=[{key:"initialize",value:function(){}},{key:"add",value:function(e){this.totalPoints+=e;var n=t.engine.scenes.getCurrentScene().gui.get("points");void 0!==n&&n.setText(t.engine.localization.get("points")+": "+this.totalPoints)}}])&&rt(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),e}();function st(t){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},st(t)}function at(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(void 0,r=function(t,e){if("object"!==st(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!==st(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key),"symbol"===st(r)?r:String(r)),i)}var r}const lt=new(function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.options=null,this.loader=null,this.player=null,this.commonBackground=null,this.points=null}var n,i;return n=e,(i=[{key:"initialize",value:function(){this.options=new s,t.engine.options.addOptions(this.options),this.commonBackground=new f,this.commonBackground.initialize(),this.loader=new X,this.loader.initialize(),t.engine.player=new nt,t.engine.player.initialize(),this.points=new ot,this.points.initialize()}},{key:"activate",value:function(){t.engine.logs.log("activate","Starting game");var e=new m;e.addBackground(this.commonBackground),e.playable=!0,e.initialize(),t.engine.scenes.addScene(e,"start_game"),(e=new Y).addBackground(this.commonBackground),e.playable=!0,e.initialize(),t.engine.scenes.addScene(e,"main_game")}},{key:"step",value:function(){}}])&&at(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),e}()),ct=t.init("game-canvas",lt)})(),i})()));