/** * melonJS Game Engine v4.0.0 * http://www.melonjs.org * @license {@link http://www.opensource.org/licenses/mit-license.php|MIT} * @copyright (C) 2011 - 2016, Olivier Biot, Jason Oster, Aaron McLeod */ if(function(){function a(){if(!c){if(!document.body)return setTimeout(a,13);for(document.removeEventListener&&document.removeEventListener("DOMContentLoaded",a,!1),window.removeEventListener("load",a,!1);d.length;)d.shift().call(window,[]);c=!0,"function"==typeof define&&define.amd&&define("me",[],function(){return me})}}window.me=window.me||{};var b=!1,c=!1,d=[];window.onReady=function(e){c?e.call(window,[]):(d.push(e),b||("complete"===document.readyState?window.setTimeout(a,0):(document.addEventListener&&document.addEventListener("DOMContentLoaded",a,!1),window.addEventListener("load",a,!1)),b=!0))},me.skipAutoInit!==!0?window.onReady(function(){me.boot()}):me.init=function(){me.boot(),a()},window.throttle||(window.throttle=function(a,b,c){var d,e=window.performance.now();return"boolean"!=typeof b&&(b=!1),function(){var f=window.performance.now(),g=f-e,h=arguments;return a>g?void(b===!1&&(clearTimeout(d),d=setTimeout(function(){return e=f,c.apply(null,h)},g))):(e=f,c.apply(null,h))}}),"undefined"==typeof console&&(console={log:function(){},info:function(){},error:function(){alert(Array.prototype.slice.call(arguments).join(", "))}})}(),!Function.prototype.bind){var Empty=function(){};Function.prototype.bind=function(a){var b=this;if("function"!=typeof b)throw new TypeError("Function.prototype.bind called on incompatible "+b);var c=Array.prototype.slice.call(arguments,1),d=function(){if(this instanceof d){var e=b.apply(this,c.concat(Array.prototype.slice.call(arguments)));return Object(e)===e?e:this}return b.apply(a,c.concat(Array.prototype.slice.call(arguments)))};return b.prototype&&(Empty.prototype=b.prototype,d.prototype=new Empty,Empty.prototype=null),d}}if(Function.prototype.defer=function(){return setTimeout(this.bind.apply(this,arguments),.01)},Object.defineProperty||(Object.defineProperty=function(a,b,c){if(!a.__defineGetter__)throw new TypeError("Object.defineProperty not supported");c.get&&a.__defineGetter__(b,c.get),c.set&&a.__defineSetter__(b,c.set)}),Object.create||(Object.create=function(a){var b=function(){};return b.prototype=a,new b}),Object.is||(Object.is=function(a,b){return a===b?0!==a||1/a===1/b:a!==a&&b!==b}),Object.assign||!function(){Object.assign=function(a){"use strict";if(void 0===a||null===a)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(a),c=1;c0?1:-1}),Number.prototype.clamp=function(a,b){return a>this?a:this>b?b:+this},Number.prototype.random=function(a,b){return b||(b=a,a=this),~~(Math.random()*(b-a))+a},Number.prototype.randomFloat=function(a,b){return b||(b=a,a=this),Math.random()*(b-a)+a},Number.prototype.weightedRandom=function(a,b){return b||(b=a,a=this),~~(Math.pow(Math.random(),2)*(b-a))+a},Number.prototype.round=function(a,b){a=arguments.length<2?this:a;var c=Math.pow(10,b||a||0);return~~(.5+a*c)/c},Number.prototype.toHex=function(){return"0123456789ABCDEF".charAt(this-this%16>>4)+"0123456789ABCDEF".charAt(this%16)},Number.prototype.degToRad=function(a){return(a||this)/180*Math.PI},Number.prototype.radToDeg=function(a){return(a||this)*(180/Math.PI)},String.prototype.trim||String.prototype.trim||!function(){var a=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(a,"")}}(),String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/,"")}),String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/,"")}),String.prototype.isNumeric=function(){return!isNaN(this)&&""!==this.trim()},String.prototype.isBoolean=function(){var a=this.trim();return"true"===a||"false"===a},String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)}),String.prototype.toHex=function(){for(var a="",b=0;bb;b++)this.push(0)}},me.TypedArray.prototype=Array.prototype,me.TypedArray.prototype.set=function(a,b){if(b=b||0,a.length+b>this.length)throw new me.Error("TypedArray pollyfill: Buffer overflow in set");for(var c=0;c-1}function e(a){return this.has(a)?this._values[s]:void 0}function f(a,b){if(this.objectOnly&&b!==Object(b))throw new TypeError("Invalid value used as weak collection key");if(b!=b||0===b)for(s=a.length;s--&&!u(a[s],b););else s=a.indexOf(b);return s>-1}function g(a){return f.call(this,this._values,a)}function h(a){return f.call(this,this._keys,a)}function i(a,b){return this.has(a)?this._values[s]=b:this._values[this._keys.push(a)-1]=b,this}function j(a){return this.has(a)||this._values.push(a),this}function k(){(this._keys||0).length=this._values.length=0}function l(){return p(this._itp,this._keys)}function m(){return p(this._itp,this._values)}function n(){return p(this._itp,this._keys,this._values)}function o(){return p(this._itp,this._values,this._values)}function p(a,b,c){var d=[0],e=!1;return a.push(d),{next:function(){var f,g=d[0];return!e&&ga;a+=2){var b=aa[a],c=aa[a+1];b(c),aa[a]=void 0,aa[a+1]=void 0}V=0}function k(){try{var a=require,b=a("vertx");return R=b.runOnLoop||b.runOnContext,f()}catch(a){return i()}}function l(a,b){var c=this,d=new this.constructor(n);void 0===d[da]&&G(d);var e=c._state;if(e){var f=arguments[e-1];W(function(){D(e,d,f,c._result)})}else z(c,d,a,b);return d}function m(a){var b=this;if(a&&"object"==typeof a&&a.constructor===b)return a;var c=new b(n);return v(c,a),c}function n(){}function o(){return new TypeError("You cannot resolve a promise with itself")}function p(){return new TypeError("A promises callback cannot return that same promise.")}function q(a){try{return a.then}catch(a){return ha.error=a,ha}}function r(a,b,c,d){try{a.call(b,c,d)}catch(a){return a}}function s(a,b,c){W(function(a){var d=!1,e=r(c,b,function(c){d||(d=!0,b!==c?v(a,c):x(a,c))},function(b){d||(d=!0,y(a,b))},"Settle: "+(a._label||" unknown promise"));!d&&e&&(d=!0,y(a,e))},a)}function t(a,b){b._state===fa?x(a,b._result):b._state===ga?y(a,b._result):z(b,void 0,function(b){v(a,b)},function(b){y(a,b)})}function u(a,c,d){c.constructor===a.constructor&&d===ba&&constructor.resolve===ca?t(a,c):d===ha?y(a,ha.error):void 0===d?x(a,c):b(d)?s(a,c,d):x(a,c)}function v(b,c){b===c?y(b,o()):a(c)?u(b,c,q(c)):x(b,c)}function w(a){a._onerror&&a._onerror(a._result),A(a)}function x(a,b){a._state===ea&&(a._result=b,a._state=fa,0!==a._subscribers.length&&W(A,a))}function y(a,b){a._state===ea&&(a._state=ga,a._result=b,W(w,a))}function z(a,b,c,d){var e=a._subscribers,f=e.length;a._onerror=null,e[f]=b,e[f+fa]=c,e[f+ga]=d,0===f&&a._state&&W(A,a)}function A(a){var b=a._subscribers,c=a._state;if(0!==b.length){for(var d,e,f=a._result,g=0;gf;f++)b.resolve(a[f]).then(c,d)}:function(a,b){b(new TypeError("You must pass an array to race."))})}function J(a){var b=this,c=new b(n);return y(c,a),c}function K(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function L(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function M(a){this[da]=F(),this._result=this._state=void 0,this._subscribers=[],n!==a&&("function"!=typeof a&&K(),this instanceof M?E(this,a):L())}function N(a,b){this._instanceConstructor=a,this.promise=new a(n),this.promise[da]||G(this.promise),Array.isArray(b)?(this._input=b,this.length=b.length,this._remaining=b.length,this._result=new Array(this.length),0===this.length?x(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&x(this.promise,this._result))):y(this.promise,O())}function O(){return new Error("Array Methods must be provided an Array")}function P(){var a;if("undefined"!=typeof global)a=global;else if("undefined"!=typeof self)a=self;else try{a=Function("return this")()}catch(a){throw new Error("polyfill failed because global object is unavailable in this environment")}var b=a.Promise;b&&"[object Promise]"===Object.prototype.toString.call(b.resolve())&&!b.cast||(a.Promise=na)}var Q;Q=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)};var R,S,T,U=Q,V=0,W=function(a,b){aa[V]=a,aa[V+1]=b,V+=2,2===V&&(S?S(j):T())},X="undefined"!=typeof window?window:void 0,Y=X||{},Z=Y.MutationObserver||Y.WebKitMutationObserver,$="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),_="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,aa=new Array(1e3);T=$?e():Z?g():_?h():void 0===X&&"function"==typeof require?k():i();var ba=l,ca=m,da=Math.random().toString(36).substring(16),ea=void 0,fa=1,ga=2,ha=new B,ia=new B,ja=0,ka=H,la=I,ma=J,na=M;M.all=ka,M.race=la,M.resolve=ca,M.reject=ma,M._setScheduler=c,M._setAsap=d,M._asap=W,M.prototype={constructor:M,then:ba,catch:function(a){return this.then(null,a)}};var oa=N;N.prototype._enumerate=function(){for(var a=this.length,b=this._input,c=0;this._state===ea&&a>c;c++)this._eachEntry(b[c],c)},N.prototype._eachEntry=function(a,b){var c=this._instanceConstructor,d=c.resolve;if(d===ca){var e=q(a);if(e===ba&&a._state!==ea)this._settledAt(a._state,b,a._result);else if("function"!=typeof e)this._remaining--,this._result[b]=a;else if(c===na){var f=new c(n);u(f,a,e),this._willSettleAt(f,b)}else this._willSettleAt(new c(function(b){b(a)}),b)}else this._willSettleAt(d(a),b)},N.prototype._settledAt=function(a,b,c){var d=this.promise;d._state===ea&&(this._remaining--,a===ga?y(d,c):this._result[b]=c),0===this._remaining&&x(d,this._result)},N.prototype._willSettleAt=function(a,b){var c=this;z(a,void 0,function(a){c._settledAt(fa,b,a)},function(a){c._settledAt(ga,b,a)})};var pa=P,qa={Promise:na,polyfill:pa};"function"==typeof define&&define.amd?define(function(){return qa}):"undefined"!=typeof module&&module.exports?module.exports=qa:"undefined"!=typeof this&&(this.ES6Promise=qa),pa()}.call(this),function(){function a(){var a={};return document.location.hash&&document.location.hash.substr(1).split("&").filter(function(a){return""!==a}).forEach(function(b){var c=b.split("="),d=c.shift(),e=c.join("=");a[d]=e||!0}),a}me.mod="melonJS",me.version="4.0.0",me.sys={fps:60,updatesPerSecond:60,interpolation:!1,scale:null,gravity:void 0,stopOnAudioError:!0,pauseOnBlur:!0,resumeOnFocus:!0,stopOnBlur:!1,preRender:!1,checkVersion:function(a,b){b=b||me.version;for(var c=a.split("."),d=b.split("."),e=Math.min(c.length,d.length),f=0,g=0;e>g&&!(f=+c[g]-+d[g]);g++);return f?f:c.length-d.length}};var b=!1;Object.defineProperty(me,"initialized",{get:function(){return b}}),me.boot=function(){b||(me.device._check(),me.save._init(),me.game.HASH=a(),me.loader.setNocache(me.game.HASH.nocache||!1),me.timer.init(),me.state.init(),me.pool.init(),me.device.isMobile===!1&&me.input._enableKeyboardEvent(),me.levelDirector.reset(),b=!0)}}(),function(){me.game=function(){var a={},b=!1,c=!0,d=!1,e=0,f=1,g=0,h=0,i=0,j=1e3/60,k=0,l=null,m=0,n=null;return a.viewport=null,a.world=null,a.mergeGroup=!0,a.sortOn="z",a.tmxRenderer=null,a.onLevelLoaded=function(){},a.HASH=null,a.init=function(d,e){b||(d=d||me.video.renderer.getWidth(),e=e||me.video.renderer.getHeight(),a.viewport=new me.Viewport(0,0,d,e),a.world=new me.Container(0,0,d,e),a.world.name="rootContainer",a.world._root=!0,me.collision.init(),n=me.video.renderer,me.event.publish(me.event.GAME_INIT),me.input._translatePointerEvents(),c=!0,b=!0)},a.reset=function(){me.collision.quadTree.clear(),a.world.destroy(),a.viewport&&a.viewport.reset(),n.reset(),me.event.publish(me.event.GAME_RESET),a.updateFrameRate()},a.updateFrameRate=function(){e=0,f=~~(.5+60/me.sys.fps),j=1e3/me.sys.updatesPerSecond,g=0,h=10*j,d=me.sys.fps>me.sys.updatesPerSecond},a.getParentContainer=function(a){return a.ancestor},a.repaint=function(){c=!0},a.update=function(b){if(++e%f===0)for(e=0,me.timer.update(b),me.input._updateGamepads(),g+=me.timer.getDelta(),g=Math.min(g,h),k=me.sys.interpolation?me.timer.getDelta():j,i=me.sys.interpolation?k:Math.max(k,m);g>=i||me.sys.interpolation;)if(l=window.performance.now(),me.collision.quadTree.clear(),me.collision.quadTree.insertContainer(a.world),c=a.world.update(k)||c,c=a.viewport.update(k)||c,me.timer.lastUpdate=window.performance.now(),m=me.timer.lastUpdate-l,g-=i,me.sys.interpolation){g=0;break}},a.draw=function(){if(c||d){var b=a.viewport.pos.x+a.viewport.offset.x,e=a.viewport.pos.y+a.viewport.offset.y;a.world.currentTransform.translate(-b,-e),me.video.renderer.clear(),a.world.draw(n,a.viewport),a.world.currentTransform.translate(b,e),a.viewport.draw(n)}c=!1,me.video.renderer.flush()},a}()}(),function(){var a=function(a){return a.substring(0,1).toUpperCase()+a.substring(1,a.length)};me.agent=function(){var b={},c=["ms","MS","moz","webkit","o"];return b.prefixed=function(b,d){if(d=d||window,b in d)return d[b];var e,f=a(b);return c.some(function(a){var b=a+f;return e=b in d?d[b]:void 0}),e},b.setPrefixed=function(b,d,e){if(e=e||window,b in e)return void(e[b]=d);var f=a(b);c.some(function(a){var b=a+f;return b in e?(e[b]=d,!0):!1})},b}()}(),function(){me.device=function(){function a(a){a.reading?(c.accelerationX=a.reading.accelerationX,c.accelerationY=a.reading.accelerationY,c.accelerationZ=a.reading.accelerationZ):(c.accelerationX=a.accelerationIncludingGravity.x,c.accelerationY=a.accelerationIncludingGravity.y,c.accelerationZ=a.accelerationIncludingGravity.z)}function b(a){c.gamma=a.gamma,c.beta=a.beta,c.alpha=a.alpha}var c={},d=!1,e=!1,f=null;return c._check=function(){me.device._detectDevice(),me.device.isMobile&&!me.device.cocoon&&window.document.addEventListener("touchmove",function(a){return a.preventDefault(),window.scroll(0,0),!1},!1),me.device.pointerEvent=me.agent.prefixed("PointerEvent",window),me.device.maxTouchPoints=me.agent.prefixed("maxTouchPoints",navigator)||0,window.gesture=me.agent.prefixed("gesture"),me.device.touch="createTouch"in document||"ontouchstart"in window||me.device.cocoon||me.device.pointerEvent&&me.device.maxTouchPoints>0,me.device.hasAccelerometer="undefined"!=typeof window.DeviceMotionEvent||"undefined"!=typeof window.Windows&&"function"==typeof Windows.Devices.Sensors.Accelerometer,this.hasPointerLockSupport=me.agent.prefixed("pointerLockElement",document),this.hasPointerLockSupport&&(document.exitPointerLock=me.agent.prefixed("exitPointerLock",document)),window.DeviceOrientationEvent&&(me.device.hasDeviceOrientation=!0),this.hasFullscreenSupport=me.agent.prefixed("fullscreenEnabled",document)||document.mozFullScreenEnabled,document.exitFullscreen=me.agent.prefixed("cancelFullScreen",document)||me.agent.prefixed("exitFullscreen",document),navigator.vibrate=me.agent.prefixed("vibrate",navigator);try{c.localStorage=!!window.localStorage}catch(a){c.localStorage=!1}window.addEventListener("blur",function(){me.sys.stopOnBlur&&me.state.stop(!0),me.sys.pauseOnBlur&&me.state.pause(!0)},!1),window.addEventListener("focus",function(){me.sys.stopOnBlur&&me.state.restart(!0),me.sys.resumeOnFocus&&me.state.resume(!0)},!1);var a,b;"undefined"!=typeof document.hidden?(a="hidden",b="visibilitychange"):"undefined"!=typeof document.mozHidden?(a="mozHidden",b="mozvisibilitychange"):"undefined"!=typeof document.msHidden?(a="msHidden",b="msvisibilitychange"):"undefined"!=typeof document.webkitHidden&&(a="webkitHidden",b="webkitvisibilitychange"),"string"==typeof b&&document.addEventListener(b,function(){document[a]?(me.sys.stopOnBlur&&me.state.stop(!0),me.sys.pauseOnBlur&&me.state.pause(!0)):(me.sys.stopOnBlur&&me.state.restart(!0),me.sys.resumeOnFocus&&me.state.resume(!0))},!1)},c._detectDevice=function(){me.device.iOS=me.device.ua.match(/iPhone|iPad|iPod/i)||!1,me.device.android=me.device.ua.match(/Android/i)||!1,me.device.android2=me.device.ua.match(/Android 2/i)||!1,me.device.wp=me.device.ua.match(/Windows Phone/i)||!1,me.device.BlackBerry=me.device.ua.match(/BlackBerry/i)||!1,me.device.Kindle=me.device.ua.match(/Kindle|Silk.*Mobile Safari/i)||!1,me.device.isMobile=me.device.ua.match(/Mobi/i)||me.device.iOS||me.device.android||me.device.wp||me.device.BlackBerry||me.device.Kindle||me.device.iOS||!1,me.device.ejecta="undefined"!=typeof window.ejecta,me.device.cocoon=navigator.isCocoonJS||"undefined"!=typeof window.Cocoon},c.ua=navigator.userAgent,c.localStorage=!1,c.hasAccelerometer=!1,c.hasDeviceOrientation=!1,c.hasFullscreenSupport=!1,c.hasPointerLockSupport=!1,c.nativeBase64="function"==typeof window.atob,c.maxTouchPoints=0,c.touch=!1,c.isMobile=!1,c.iOS=!1,c.android=!1,c.android2=!1,c.ejecta=!1,c.cocoon=!1,c.wp=!1,c.BlackBerry=!1,c.Kindle=!1,c.orientation=0,c.accelerationX=0,c.accelerationY=0,c.accelerationZ=0,c.gamma=0,c.beta=0,c.alpha=0,c.language=navigator.language||navigator.browserLanguage||navigator.userLanguage||"en",c.requestFullscreen=function(a){this.hasFullscreenSupport&&(a=a||me.video.getWrapper(),a.requestFullscreen=me.agent.prefixed("requestFullscreen",a)||a.mozRequestFullScreen,a.requestFullscreen())},c.exitFullscreen=function(){this.hasFullscreenSupport&&document.exitFullscreen()},c.getPixelRatio=function(){if(null===f){var a;a="undefined"!=typeof me.video.renderer?me.video.renderer.getScreenContext():me.Renderer.prototype.getContext2d(document.createElement("canvas"));var b=window.devicePixelRatio||1,c=me.agent.prefixed("backingStorePixelRatio",a)||1;f=b/c}return f},c.getStorage=function(a){switch(a=a||"local"){case"local":return me.save;default:throw new me.Error("storage type "+a+" not supported")}},c.turnOnPointerLock=function(){if(this.hasPointerLockSupport){var a=me.video.getWrapper();if(me.device.ua.match(/Firefox/i)){var b=function(){(me.agent.prefixed("fullscreenElement",document)||document.mozFullScreenElement)===a&&(document.removeEventListener("fullscreenchange",b),document.removeEventListener("mozfullscreenchange",b),a.requestPointerLock=me.agent.prefixed("requestPointerLock",a),a.requestPointerLock())};document.addEventListener("fullscreenchange",b,!1),document.addEventListener("mozfullscreenchange",b,!1),me.device.requestFullscreen()}else a.requestPointerLock()}},c.turnOffPointerLock=function(){this.hasPointerLockSupport&&document.exitPointerLock()},c.watchAccelerometer=function(){if(me.device.hasAccelerometer){if(!d){if("undefined"==typeof Windows)window.addEventListener("devicemotion",a,!1);else{var b=Windows.Devices.Sensors.Accelerometer.getDefault();if(b){var c=b.minimumReportInterval,e=c>=16?c:25;b.reportInterval=e,b.addEventListener("readingchanged",a,!1)}}d=!0}return!0}return!1},c.unwatchAccelerometer=function(){if(d){if("undefined"==typeof Windows)window.removeEventListener("devicemotion",a,!1);else{var b=Windows.Device.Sensors.Accelerometer.getDefault();b.removeEventListener("readingchanged",a,!1)}d=!1}},c.watchDeviceOrientation=function(){return me.device.hasDeviceOrientation&&!e&&(window.addEventListener("deviceorientation",b,!1),e=!0),!1},c.unwatchDeviceOrientation=function(){e&&(window.removeEventListener("deviceorientation",b,!1),e=!1)},c.vibrate=function(a){navigator.vibrate&&navigator.vibrate(a)},c}(),Object.defineProperty(me.device,"isFullscreen",{get:function(){if(me.device.hasFullscreenSupport){var a=me.agent.prefixed("fullscreenElement",document)||document.mozFullScreenElement;return a===me.video.getWrapper()}return!1}}),Object.defineProperty(me.device,"sound",{get:function(){return!Howler.noAudio}})}(),function(){me.timer=function(){var a={},b=0,c=0,d=0,e=0,f=0,g=Math.ceil(1e3/me.sys.fps),h=1e3/me.sys.fps*1.25,i=[],j=0,k=function(a){for(var b=0,c=i.length;c>b;b++)if(i[b].timerId===a){i.splice(b,1);break}},l=function(a){for(var b=0,c=i.length;c>b;b++){var d=i[b];d.pauseable&&me.state.isPaused()||(d.elapsed+=a),d.elapsed>=d.delay&&(d.fn.apply(this),d.repeat===!0?d.elapsed-=d.delay:me.timer.clearTimeout(d.timerId))}};return a.tick=1,a.fps=0,a.lastUpdate=window.performance.now(),a.init=function(){a.reset(),e=d=0},a.reset=function(){d=e=window.performance.now(),f=0,c=0,b=0},a.setTimeout=function(a,b,c){return i.push({fn:a,delay:b,elapsed:0,repeat:!1,timerId:++j,pauseable:c===!0||!0}),j},a.setInterval=function(a,b,c){return i.push({fn:a,delay:b,elapsed:0,repeat:!0,timerId:++j,pauseable:c===!0||!0}),j},a.clearTimeout=function(a){k.defer(this,a)},a.clearInterval=function(a){k.defer(this,a)},a.getTime=function(){return e},a.getDelta=function(){return f},a.countFPS=function(){b++,c+=f,b%10===0&&(this.fps=(~~(1e3*b/c)).clamp(0,me.sys.fps),c=0,b=0)},a.update=function(b){return d=e,e=b,f=e-d,a.tick=f>h&&me.sys.interpolation?f/g:1,l(f),f},a}()}(),function(){me.pool=function(){var a={},b={};return a.init=function(){a.register("me.Entity",me.Entity),a.register("me.CollectableEntity",me.CollectableEntity),a.register("me.LevelEntity",me.LevelEntity),a.register("me.Tween",me.Tween,!0),a.register("me.Color",me.Color,!0),a.register("me.Particle",me.Particle,!0),a.register("me.Sprite",me.Sprite),a.register("me.Vector2d",me.Vector2d,!0),a.register("me.Glyph",me.Glyph,!0),a.register("me.Matrix2d",me.Matrix2d,!0)},a.register=function(a,c,d){b[a]={class:c,pool:d?[]:void 0}},a.pull=function(a){for(var c=new Array(arguments.length),d=0;da.x?this.x:a.x,this.y>a.y?this.y:a.y)},floor:function(){return new me.Vector2d(Math.floor(this.x),Math.floor(this.y))},floorSelf:function(){return this._set(Math.floor(this.x),Math.floor(this.y))},ceil:function(){return new me.Vector2d(Math.ceil(this.x),Math.ceil(this.y))},ceilSelf:function(){return this._set(Math.ceil(this.x),Math.ceil(this.y))},negate:function(){return new me.Vector2d(-this.x,-this.y)},negateSelf:function(){return this._set(-this.x,-this.y)},copy:function(a){return this._set(a.x,a.y)},equals:function(a){return this.x===a.x&&this.y===a.y},normalize:function(){var a=this.length();return a>0?this._set(this.x/a,this.y/a):this},perp:function(){return this._set(this.y,-this.x)},rotate:function(a){var b=this.x,c=this.y;return this._set(b*Math.cos(a)-c*Math.sin(a),b*Math.sin(a)+c*Math.cos(a))},dotProduct:function(a){return this.x*a.x+this.y*a.y},length2:function(){return this.dotProduct(this)},length:function(){return Math.sqrt(this.length2())},distance:function(a){var b=this.x-a.x,c=this.y-a.y;return Math.sqrt(b*b+c*c)},angle:function(a){return Math.acos((this.dotProduct(a)/(this.length()*a.length())).clamp(-1,1))},project:function(a){return this.scale(this.dotProduct(a)/a.length2())},projectN:function(a){return this.scale(this.dotProduct(a))},clone:function(){return new me.Vector2d(this.x,this.y)},toString:function(){return"x:"+this.x+",y:"+this.y}}),me.Vector2d.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Vector2d.Error"}})}(),function(){me.Vector3d=me.Object.extend({init:function(a,b,c){return this.set(a||0,b||0,c||0)},_set:function(a,b,c){return this.x=a,this.y=b,this.z=c,this},set:function(a,b,c){if(a!==+a||b!==+b||c!==+c)throw new me.Vector3d.Error("invalid x, y, z parameters (not a number)");return this._set(a,b,c)},setZero:function(){return this.set(0,0,0)},setV:function(a){return this._set(a.x,a.y,"undefined"!=typeof a.z?a.z:this.z)},add:function(a){return this._set(this.x+a.x,this.y+a.y,this.z+(a.z||0))},sub:function(a){return this._set(this.x-a.x,this.y-a.y,this.z-(a.z||0))},scale:function(a,b,c){return b="undefined"!=typeof b?b:a,c="undefined"!=typeof c?c:a,this._set(this.x*a,this.y*b,this.z*c)},scaleV:function(a){return this._set(this.x*a.x,this.y*a.y,this.z*(a.z||1))},div:function(a){return this._set(this.x/a,this.y/a,this.z/a)},abs:function(){return this._set(this.x<0?-this.x:this.x,this.y<0?-this.y:this.y,this.z<0?-this.Z:this.z)},clamp:function(a,b){return new me.Vector3d(this.x.clamp(a,b),this.y.clamp(a,b),this.z.clamp(a,b))},clampSelf:function(a,b){return this._set(this.x.clamp(a,b),this.y.clamp(a,b),this.z.clamp(a,b))},minV:function(a){var b=a.z||0;return this._set(this.xa.x?this.x:a.x,this.y>a.y?this.y:a.y,this.z>b?this.z:b)},floor:function(){return new me.Vector3d(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},floorSelf:function(){return this._set(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},ceil:function(){return new me.Vector3d(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},ceilSelf:function(){return this._set(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},negate:function(){return new me.Vector3d(-this.x,-this.y,-this.z)},negateSelf:function(){return this._set(-this.x,-this.y,-this.z)},copy:function(a){return this._set(a.x,a.y,"undefined"!=typeof a.z?a.z:this.z)},equals:function(a){return this.x===a.x&&this.y===a.y&&this.z===(a.z||this.z)},normalize:function(){var a=this.length();return a>0?this._set(this.x/a,this.y/a,this.z/a):this},perp:function(){return this._set(this.y,-this.x,this.z)},rotate:function(a){var b=this.x,c=this.y;return this._set(b*Math.cos(a)-c*Math.sin(a),b*Math.sin(a)+c*Math.cos(a),this.z)},dotProduct:function(a){return this.x*a.x+this.y*a.y+this.z*(a.z||1)},length2:function(){return this.dotProduct(this)},length:function(){return Math.sqrt(this.length2())},distance:function(a){var b=this.x-a.x,c=this.y-a.y,d=this.z-(a.z||0);return Math.sqrt(b*b+c*c+d*d)},angle:function(a){return Math.acos((this.dotProduct(a)/(this.length()*a.length())).clamp(-1,1))},project:function(a){return this.scale(this.dotProduct(a)/a.length2())},projectN:function(a){return this.scale(this.dotProduct(a))},clone:function(){return new me.Vector3d(this.x,this.y,this.z)},toString:function(){return"x:"+this.x+",y:"+this.y+",z:"+this.z}}),me.Vector3d.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Vector3d.Error"}})}(),function(){me.ObservableVector2d=me.Vector2d.extend({init:function(a,b,c){if(Object.defineProperty(this,"x",{get:function(){return this._x},set:function(a){this.onUpdate(a,this._y,this._x,this._y),this._x=a}}),Object.defineProperty(this,"y",{get:function(){return this._y},set:function(a){this.onUpdate(this._x,a,this._x,this._y),this._y=a}}),"undefined"==typeof c)throw new me.ObservableVector2d.Error("undefined `onUpdate` callback");this.setCallback(c.onUpdate),this._x=a||0,this._y=b||0},_set:function(a,b){return this.onUpdate(a,b,this._x,this._y),this._x=a,this._y=b,this},setMuted:function(a,b){return this._x=a,this._y=b,this},setCallback:function(a){if("function"!=typeof a)throw new me.ObservableVector2d.Error("invalid `onUpdate` callback");return this.onUpdate=a,this},add:function(a){return this._set(this._x+a.x,this._y+a.y)},sub:function(a){return this._set(this._x-a.x,this._y-a.y)},scale:function(a,b){return this._set(this._x*a,this._y*("undefined"!=typeof b?b:a))},scaleV:function(a){return this._set(this._x*a.x,this._y*a.y)},div:function(a){return this._set(this._x/a,this._y/a)},abs:function(){return this._set(this._x<0?-this._x:this._x,this._y<0?-this._y:this._y)},clamp:function(a,b){return new me.ObservableVector2d(this.x.clamp(a,b),this.y.clamp(a,b),{onUpdate:this.onUpdate})},clampSelf:function(a,b){return this._set(this._x.clamp(a,b),this._y.clamp(a,b))},minV:function(a){return this._set(this._xa.x?this._x:a.x,this._y>a.y?this._y:a.y)},floor:function(){return new me.ObservableVector2d(Math.floor(this._x),Math.floor(this._y),{onUpdate:this.onUpdate})},floorSelf:function(){return this._set(Math.floor(this._x),Math.floor(this._y))},ceil:function(){return new me.ObservableVector2d(Math.ceil(this._x),Math.ceil(this._y),{onUpdate:this.onUpdate})},ceilSelf:function(){return this._set(Math.ceil(this._x),Math.ceil(this._y))},negate:function(){return new me.ObservableVector2d(-this._x,-this._y,{onUpdate:this.onUpdate})},negateSelf:function(){return this._set(-this._x,-this._y)},copy:function(a){return this._set(a.x,a.y)},equals:function(a){return this._x===a.x&&this._y===a.y},normalize:function(){var a=this.length();return a>0?this._set(this._x/a,this._y/a):this},perp:function(){return this._set(this._y,-this._x)},rotate:function(a){var b=this._x,c=this._y;return this._set(b*Math.cos(a)-c*Math.sin(a),b*Math.sin(a)+c*Math.cos(a))},dotProduct:function(a){return this._x*a.x+this._y*a.y},distance:function(a){return Math.sqrt((this._x-a.x)*(this._x-a.x)+(this._y-a.y)*(this._y-a.y))},clone:function(){return new me.ObservableVector2d(this._x,this._y,{onUpdate:this.onUpdate})},toVector2d:function(){return new me.Vector2d(this._x,this._y)},toString:function(){return"x:"+this._x+",y:"+this._y}}),me.ObservableVector2d.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.ObservableVector2d.Error"}})}(),function(){me.ObservableVector3d=me.Vector3d.extend({init:function(a,b,c,d){if(Object.defineProperty(this,"x",{get:function(){return this._x},set:function(a){this.onUpdate(a,this._y,this._z,this._x,this._y,this._z),this._x=a}}),Object.defineProperty(this,"y",{get:function(){return this._y},set:function(a){this.onUpdate(this._x,a,this._z,this._x,this._y,this._z),this._y=a}}),Object.defineProperty(this,"z",{get:function(){return this._z},set:function(a){this.onUpdate(this._x,this._y,a,this._x,this._y,this._z),this._z=a}}),"undefined"==typeof d)throw new me.ObservableVector3d.Error("undefined `onUpdate` callback");this.setCallback(d.onUpdate),this._x=a||0,this._y=b||0,this._z=c||0},_set:function(a,b,c){return this.onUpdate(a,b,c,this._x,this._y,this._z),this._x=a,this._y=b,this._z=c,this},setMuted:function(a,b,c){return this._x=a,this._y=b,this._z=c,this},setCallback:function(a){if("function"!=typeof a)throw new me.ObservableVector2d.Error("invalid `onUpdate` callback");return this.onUpdate=a,this},add:function(a){return this._set(this._x+a.x,this._y+a.y,this._z+(a.z||0))},sub:function(a){return this._set(this._x-a.x,this._y-a.y,this._z-(a.z||0))},scale:function(a,b,c){return b="undefined"!=typeof b?b:a,c="undefined"!=typeof c?c:a,this._set(this._x*a,this._y*b,this._z*c)},scaleV:function(a){return this._set(this._x*a.x,this._y*a.y,this._z*(a.z||1))},div:function(a){return this._set(this._x/a,this._y/a,this._z/a)},abs:function(){return this._set(this._x<0?-this._x:this._x,this._y<0?-this._y:this._y,this._Z<0?-this._z:this._z)},clamp:function(a,b){return new me.ObservableVector3d(this._x.clamp(a,b),this._y.clamp(a,b),this._z.clamp(a,b),{onUpdate:this.onUpdate})},clampSelf:function(a,b){return this._set(this._x.clamp(a,b),this._y.clamp(a,b),this._z.clamp(a,b))},minV:function(a){var b=a.z||0;return this._set(this._xa.x?this._x:a.x,this._y>a.y?this._y:a.y,this._z>b?this._z:b)},floor:function(){return new me.ObservableVector3d(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z),{onUpdate:this.onUpdate})},floorSelf:function(){return this._set(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))},ceil:function(){return new me.ObservableVector3d(Math.ceil(this._x),Math.ceil(this._y),Math.ceil(this._z),{onUpdate:this.onUpdate})},ceilSelf:function(){return this._set(Math.ceil(this._x),Math.ceil(this._y),Math.ceil(this._z))},negate:function(){return new me.ObservableVector3d(-this._x,-this._y,-this._z,{onUpdate:this.onUpdate})},negateSelf:function(){return this._set(-this._x,-this._y,-this._z)},copy:function(a){return this._set(a.x,a.y,"undefined"!=typeof a.z?a.z:this._z)},equals:function(a){return this._x===a.x&&this._y===a.y&&this._z===(a.z||this._z)},normalize:function(){var a=this.length();return a>0?this._set(this._x/a,this._y/a,this._z/a):this},perp:function(){return this._set(this._y,-this._x,this._z)},rotate:function(a){var b=this._x,c=this._y;return this._set(b*Math.cos(a)-c*Math.sin(a),b*Math.sin(a)+c*Math.cos(a),this._z)},dotProduct:function(a){return this._x*a.x+this._y*a.y+this._z*(a.z||1)},distance:function(a){var b=this._x-a.x,c=this._y-a.y,d=this._z-(a.z||0);return Math.sqrt(b*b+c*c+d*d)},clone:function(){return new me.ObservableVector3d(this._x,this._y,this._z,{onUpdate:this.onUpdate})},toVector3d:function(){return new me.Vector3d(this._x,this._y,this._z)},toString:function(){return"x:"+this._x+",y:"+this._y+",z:"+this._z}}),me.ObservableVector3d.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.ObservableVector3d.Error"}})}(),function(){me.Matrix2d=me.Object.extend({init:function(){"undefined"==typeof this.val&&(this.val=new Float32Array(9)),arguments.length&&arguments[0]instanceof me.Matrix2d?this.copy(arguments[0]):arguments.length>=6?this.setTransform.apply(this,arguments):this.onResetEvent()},onResetEvent:function(){this.identity()},identity:function(){return this.setTransform(1,0,0,0,1,0,0,0,1),this},setTransform:function(){var a=this.val;return 9===arguments.length?(a[0]=arguments[0],a[1]=arguments[1],a[2]=arguments[2],a[3]=arguments[3],a[4]=arguments[4],a[5]=arguments[5],a[6]=arguments[6],a[7]=arguments[7],a[8]=arguments[8]):6===arguments.length&&(a[0]=arguments[0],a[1]=arguments[2],a[2]=arguments[4],a[3]=arguments[1],a[4]=arguments[3],a[5]=arguments[5],a[6]=0,a[7]=0,a[8]=1),this},copy:function(a){return this.val.set(a.val),this},multiply:function(a){a=a.val;var b=this.val,c=b[0],d=b[1],e=b[3],f=b[4],g=a[0],h=a[1],i=a[3],j=a[4],k=a[6],l=a[7];return b[0]=c*g+e*h,b[1]=d*g+f*h,b[3]=c*i+e*j,b[4]=d*i+f*j,b[6]+=c*k+e*l,b[7]+=d*k+f*l,this},transpose:function(){var a,b=this.val;return a=b[1],b[1]=b[3],b[3]=a,a=b[2],b[2]=b[6],b[6]=a,a=b[5],b[5]=b[7],b[7]=a,this},invert:function(){var a=this.val,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8],k=j*f-g*i,l=g*h-j*e,m=i*e-f*h,n=b*k+c*l+d*m;return a[0]=k/n,a[1]=(d*i-j*c)/n,a[2]=(g*c-d*f)/n,a[3]=l/n,a[4]=(j*b-d*h)/n,a[5]=(d*e-g*b)/n,a[6]=m/n,a[7]=(c*h-i*b)/n,a[8]=(f*b-c*e)/n,this},multiplyVector:function(a){var b=this.val,c=a.x,d=a.y;return a.x=c*b[0]+d*b[3]+b[6],a.y=c*b[1]+d*b[4]+b[7],a},scale:function(a,b){var c=this.val,d=a,e="undefined"==typeof b?d:b;return c[0]*=d,c[1]*=d,c[3]*=e,c[4]*=e,this},scaleV:function(a){return this.scale(a.x,a.y)},scaleX:function(a){return this.scale(a,1)},scaleY:function(a){return this.scale(1,a)},rotate:function(a){if(0!==a){var b=this.val,c=b[0],d=b[1],e=b[3],f=b[4],g=Math.sin(a),h=Math.cos(a);b[0]=c*h+e*g,b[1]=d*h+f*g, b[3]=c*-g+e*h,b[4]=d*-g+f*h}return this},translate:function(a,b){var c=this.val;return c[6]+=c[0]*a+c[3]*b,c[7]+=c[1]*a+c[4]*b,this},translateV:function(a){return this.translate(a.x,a.y)},isIdentity:function(){var a=this.val;return 1===a[0]&&0===a[1]&&0===a[2]&&0===a[3]&&1===a[4]&&0===a[5]&&0===a[6]&&0===a[7]&&1===a[8]},clone:function(){return me.pool.pull("me.Matrix2d").copy(this)},toString:function(){var a=this.val;return"me.Matrix2d("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"}})}(),function(){me.Ellipse=me.Object.extend({init:function(a,b,c,d){this.pos=new me.Vector2d,this._bounds=void 0,this.radius=NaN,this.radiusV=new me.Vector2d,this.radiusSq=new me.Vector2d,this.ratio=new me.Vector2d,this.shapeType="Ellipse",this.setShape(a,b,c,d)},setShape:function(a,b,c,d){var e=c/2,f=d/2;this.pos.set(a,b),this.radius=Math.max(e,f),this.ratio.set(e/this.radius,f/this.radius),this.radiusV.set(this.radius,this.radius).scaleV(this.ratio);var g=this.radius*this.radius;return this.radiusSq.set(g,g).scaleV(this.ratio),this.updateBounds(),this},rotate:function(){return this},scale:function(a,b){return b="undefined"!=typeof b?b:a,this.setShape(this.pos.x,this.pos.y,2*this.radiusV.x*a,2*this.radiusV.y*b)},scaleV:function(a){return this.scale(a.x,a.y)},transform:function(){return this},translate:function(a,b){return this.pos.x+=a,this.pos.y+=b,this._bounds.translate(a,b),this},translateV:function(a){return this.pos.add(a),this._bounds.translateV(a),this},containsPointV:function(a){return this.containsPoint(a.x,a.y)},containsPoint:function(a,b){return a-=this.pos.x,b-=this.pos.y,a*a/this.radiusSq.x+b*b/this.radiusSq.y<=1},getBounds:function(){return this._bounds},updateBounds:function(){var a=this.radiusV.x,b=this.radiusV.y,c=this.pos.x-a,d=this.pos.y-b,e=2*a,f=2*b;return this._bounds?this._bounds.setShape(c,d,e,f):this._bounds=new me.Rect(c,d,e,f),this._bounds},clone:function(){return new me.Ellipse(this.pos.x,this.pos.y,2*this.radiusV.x,2*this.radiusV.y)}})}(),function(){me.Polygon=me.Object.extend({init:function(a,b,c){this.pos=new me.Vector2d,this._bounds=void 0,this.points=null,this.shapeType="Polygon",this.setShape(a,b,c)},setShape:function(a,b,c){return this.pos.set(a,b),this.points=c,this.recalc(),this.updateBounds(),this},transform:function(a){for(var b=this.points,c=b.length,d=0;c>d;d++)a.multiplyVector(b[d]);return this.recalc(),this.updateBounds(),this},rotate:function(a){if(0!==a){for(var b=this.points,c=b.length,d=0;c>d;d++)b[d].rotate(a);this.recalc(),this.updateBounds()}return this},scale:function(a,b){b="undefined"!=typeof b?b:a;for(var c=this.points,d=c.length,e=0;d>e;e++)c[e].scale(a,b);return this.recalc(),this.updateBounds(),this},scaleV:function(a){return this.scale(a.x,a.y)},recalc:function(){var a,b=this.edges=[],c=this.normals=[],d=this.points,e=d.length;if(3>e)throw new me.Polygon.Error("Requires at least 3 points");for(a=0;e>a;a++){var f=(new me.Vector2d).copy(d[(a+1)%e]).sub(d[a]);b.push(f),c.push((new me.Vector2d).copy(f).perp().normalize())}return this},translate:function(a,b){return this.pos.x+=a,this.pos.y+=b,this._bounds.translate(a,b),this},translateV:function(a){return this.pos.add(a),this._bounds.translateV(a),this},containsPointV:function(a){return this.containsPoint(a.x,a.y)},containsPoint:function(a,b){for(var c=!1,d=this.pos.x,e=this.pos.y,f=this.points,g=f.length,h=0,i=g-1;g>h;i=h++){var j=f[h].y+e,k=f[h].x+d,l=f[i].y+e,m=f[i].x+d;j>b!=l>b&&(m-k)*(b-j)/(l-j)+k>a&&(c=!c)}return c},getBounds:function(){return this._bounds},updateBounds:function(){return this._bounds||(this._bounds=new me.Rect(0,0,0,0)),this._bounds.setPoints(this.points),this._bounds.translateV(this.pos),this._bounds},clone:function(){var a=[];return this.points.forEach(function(b){a.push(new me.Vector2d(b.x,b.y))}),new me.Polygon(this.pos.x,this.pos.y,a)}}),me.Polygon.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Polygon.Error"}})}(),function(){me.Rect=me.Polygon.extend({init:function(a,b,c,d){this.pos=new me.Vector2d,this.points=[new me.Vector2d,new me.Vector2d,new me.Vector2d,new me.Vector2d],this.shapeType="Rectangle",this.setShape(a,b,c,d)},setShape:function(a,b,c,d){return this.points[0].set(0,0),this.points[1].set(c,0),this.points[2].set(c,d),this.points[3].set(0,d),me.Polygon.prototype.setShape.apply(this,[a,b,this.points]),this._width=c,this._height=d,this},resize:function(a,b){return this.width=a,this.height=b,this},getBounds:function(){return this},setPoints:function(a){var b=1/0,c=1/0,d=-(1/0),e=-(1/0);return a.forEach(function(a){b=Math.min(b,a.x),c=Math.min(c,a.y),d=Math.max(d,a.x),e=Math.max(e,a.y)}),this.setShape(b,c,d-b,e-c),this},recalc:function(){return me.Polygon.prototype.recalc.apply(this),this._width=this.points[2].x,this._height=this.points[2].y,this},updateBounds:function(){return this},clone:function(){return new me.Rect(this.pos.x,this.pos.y,this._width,this._height)},copy:function(a){return this.setShape(a.pos.x,a.pos.y,a._width,a._height)},translate:function(a,b){return this.pos.x+=a,this.pos.y+=b,this},translateV:function(a){return this.translate(a.x,a.y)},union:function(a){var b=Math.min(this.left,a.left),c=Math.min(this.top,a.top);return this.resize(Math.max(this.right,a.right)-b,Math.max(this.bottom,a.bottom)-c),this.pos.set(b,c),this},overlaps:function(a){return this.left=this.left&&a.right<=this.right&&a.top>=this.top&&a.bottom<=this.bottom},containsPoint:function(a,b){return a>=this.left&&a<=this.right&&b>=this.top&&b<=this.bottom},toPolygon:function(){return new me.Polygon(this.pos.x,this.pos.y,this.points)}}),Object.defineProperty(me.Rect.prototype,"left",{get:function(){return this.pos.x},configurable:!0}),Object.defineProperty(me.Rect.prototype,"right",{get:function(){var a=this._width;return this.pos.x+a||a},configurable:!0}),Object.defineProperty(me.Rect.prototype,"top",{get:function(){return this.pos.y},configurable:!0}),Object.defineProperty(me.Rect.prototype,"bottom",{get:function(){var a=this._height;return this.pos.y+a||a},configurable:!0}),Object.defineProperty(me.Rect.prototype,"width",{get:function(){return this._width},set:function(a){this.points[1].x=this.points[2].x=a,this.recalc()},configurable:!0}),Object.defineProperty(me.Rect.prototype,"height",{get:function(){return this._height},set:function(a){this.points[2].y=this.points[3].y=a,this.recalc()},configurable:!0})}(),function(){me.Line=me.Polygon.extend({containsPointV:function(a){return this.containsPoint(a.x,a.y)},containsPoint:function(a,b){a-=this.pos.x,b-=this.pos.y;var c=this.points[0],d=this.points[1];return(b-c.y)*(d.x-c.x)===(d.y-c.y)*(a-c.x)},recalc:function(){var a=this.edges=[],b=this.normals=[],c=this.points;if(2!==c.length)throw new me.Line.Error("Requires exactly 2 points");var d=(new me.Vector2d).copy(c[1]).sub(c[0]);return a.push(d),b.push((new me.Vector2d).copy(d).perp().normalize()),this},clone:function(){var a=[];return this.points.forEach(function(b){a.push(new me.Vector2d(b.x,b.y))}),new me.Line(this.pos.x,this.pos.y,a)}}),me.Line.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Line.Error"}})}(),function(){me.Body=me.Rect.extend({init:function(a,b){this.entity=a,this.shapes=[],this.collisionMask=me.collision.types.ALL_OBJECT,this.collisionType=me.collision.types.ENEMY_OBJECT,"undefined"==typeof this.vel&&(this.vel=new me.Vector2d),this.vel.set(0,0),"undefined"==typeof this.accel&&(this.accel=new me.Vector2d),this.accel.set(0,0),"undefined"==typeof this.friction&&(this.friction=new me.Vector2d),this.friction.set(0,0),"undefined"==typeof this.maxVel&&(this.maxVel=new me.Vector2d),this.maxVel.set(1e3,1e3),this.gravity="undefined"!=typeof me.sys.gravity?me.sys.gravity:.98,this.falling=!1,this.jumping=!1,me.Rect.prototype.init.apply(this,[0,0,a.width,a.height]);for(var c=0;c=1,this.jumping=b.y<=-1)},updateBounds:function(){if(this.shapes.length>0){var a=this.shapes[0].getBounds();this.pos.setV(a.pos),this.resize(a.width,a.height);for(var b=1;bc?c:d>0?d:0,a.y=0>f?f:g>0?g:0},computeVelocity:function(a){this.gravity&&(a.y+=this.gravity*me.timer.tick,this.falling=a.y>0,this.jumping=this.falling?!1:this.jumping),(this.friction.x||this.friction.y)&&this.applyFriction(a),0!==a.y&&(a.y=a.y.clamp(-this.maxVel.y,this.maxVel.y)),0!==a.x&&(a.x=a.x.clamp(-this.maxVel.x,this.maxVel.x))},update:function(){return this.computeVelocity(this.vel),this.entity.pos.add(this.vel),0!==this.vel.x||0!==this.vel.y},destroy:function(){this.entity=null,this.shapes=[]}}),me.Body.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Body.Error"}})}(),function(){function a(a,b,c,d){this.max_objects=b||4,this.max_levels=c||4,this.level=d||0,this.bounds=a,this.objects=[],this.nodes=[]}var b=[],c=function(a,c,d,e){if(b.length>0){var f=b.pop();return f.bounds=a,f.max_objects=c||4,f.max_levels=d||4,f.level=e||0,f}return new me.QuadTree(a,c,d,e)},d=function(a){b.push(a)},e=new me.Vector2d;a.prototype.split=function(){var a=this.level+1,b=~~(.5+this.bounds.width/2),d=~~(.5+this.bounds.height/2),e=~~(.5+this.bounds.pos.x),f=~~(.5+this.bounds.pos.y);this.nodes[0]=c({pos:{x:e+b,y:f},width:b,height:d},this.max_objects,this.max_levels,a),this.nodes[1]=c({pos:{x:e,y:f},width:b,height:d},this.max_objects,this.max_levels,a),this.nodes[2]=c({pos:{x:e,y:f+d},width:b,height:d},this.max_objects,this.max_levels,a),this.nodes[3]=c({pos:{x:e+b,y:f+d},width:b,height:d},this.max_objects,this.max_levels,a)},a.prototype.getIndex=function(a){var b=a.getBounds(),c=b.pos;(a.floating||a.ancestor&&a.ancestor.floating)&&(c=me.game.viewport.localToWorld(c.x,c.y,e));var d=-1,f=c.x,g=c.y,h=b.width,i=b.height,j=this.bounds.pos.x+this.bounds.width/2,k=this.bounds.pos.y+this.bounds.height/2,l=k>g&&k>g+i,m=g>k;return j>f&&j>f+h?l?d=1:m&&(d=2):f>j&&(l?d=0:m&&(d=3)),d},a.prototype.insertContainer=function(a){for(var b,c=a.children.length;c--,b=a.children[c];)b instanceof me.Container?("rootContainer"!==b.name&&this.insert(b),this.insertContainer(b)):"function"==typeof b.getBounds&&this.insert(b)},a.prototype.insert=function(a){var b=-1;if(this.nodes.length>0&&(b=this.getIndex(a),-1!==b))return void this.nodes[b].insert(a);if(this.objects.push(a),this.objects.length>this.max_objects&&this.level0){var d=this.getIndex(a);if(-1!==d)c=c.concat(this.nodes[d].retrieve(a));else for(var e=0;e0){var c=this.getIndex(a);-1!==c&&(b=this.nodes[c].remove(a),b&&this.nodes[c].isPrunable()&&this.nodes.splice(c,1))}return b===!1&&-1!==this.objects.indexOf(a)&&(this.objects.remove(a),b=!0),b},a.prototype.isPrunable=function(){return!(this.hasChildren()||this.objects.length>0)},a.prototype.hasChildren=function(){for(var a=0;a0||b.objects.length>0)return!0}return!1},a.prototype.clear=function(a){this.objects.length=0;for(var b=0;bg;g++){var h=a[g].dotProduct(b);d>h&&(d=h),h>e&&(e=h)}c[0]=d,c[1]=e}function b(b,c,d,e,f,h){var j=i.pop(),k=i.pop(),l=g.pop().copy(c).sub(b),m=l.dotProduct(f);if(a(d,f,j),a(e,f,k),k[0]+=m,k[1]+=m,j[0]>k[1]||k[0]>j[1])return g.push(l),i.push(j),i.push(k),!0;if(h){var n=0;if(j[0]o?o:-p}else if(h.bInA=!1,j[1]>k[1])n=j[0]-k[1],h.aInB=!1;else{var q=j[1]-k[0],r=k[1]-j[0];n=r>q?q:-r}var s=Math.abs(n);sn&&h.overlapN.negateSelf())}return g.push(l),i.push(j),i.push(k),!1}function c(a,b){var c=a.length2(),g=b.dotProduct(a);return 0>g?d:g>c?f:e}for(var d=-1,e=0,f=1,g=[],h=0;10>h;h++)g.push(new me.Vector2d);for(var i=[],j=0;5>j;j++)i.push([]);me.collision=function(){var a={};return a.quadTree=null,a.maxDepth=4,a.maxChildren=8,a.bounds=null,a.types={NO_OBJECT:0,PLAYER_OBJECT:1,NPC_OBJECT:2,ENEMY_OBJECT:4,COLLECTABLE_OBJECT:8,ACTION_OBJECT:16,PROJECTILE_OBJECT:32,WORLD_SHAPE:64,USER:128,ALL_OBJECT:4294967295},a.init=function(){a.bounds=me.game.viewport.clone(),a.quadTree=new me.QuadTree(a.bounds,a.maxChildren,a.maxDepth),me.event.subscribe(me.event.LEVEL_LOADED,function(){a.bounds=me.game.world.clone(),a.quadTree.clear(a.bounds)})},a.ResponseObject=function(){this.a=null,this.b=null,this.overlapN=new me.Vector2d,this.overlapV=new me.Vector2d,this.aInB=!0,this.bInA=!0,this.indexShapeA=-1,this.indexShapeB=-1,this.overlap=Number.MAX_VALUE},a.ResponseObject.prototype.clear=function(){return this.aInB=!0,this.bInA=!0,this.overlap=Number.MAX_VALUE,this.indexShapeA=-1,this.indexShapeB=-1,this},a.response=new a.ResponseObject,a.shouldCollide=function(a,b){return a.body&&b.body&&0!==(a.body.collisionMask&b.body.collisionType)&&0!==(a.body.collisionType&b.body.collisionMask)},a.check=function(b,c){for(var d,e=0,f=c||a.response,g=a.quadTree.retrieve(b),h=g.length;h--,d=g[h];)if(d!==b&&a.shouldCollide(b,d)&&b.getBounds().overlaps(d.getBounds())){var i=b.body.shapes.length,j=d.body.shapes.length;if(0===i||0===j)continue;var k=0;do{var l=b.body.getShape(k),m=0;do{var n=d.body.getShape(m);a["test"+l.shapeType+n.shapeType].call(this,b,l,d,n,f.clear())===!0&&(e++,f.indexShapeA=k,f.indexShapeB=m,b.onCollision(f,d)!==!1&&b.body.respondToCollision.call(b.body,f),d.onCollision(f,b)!==!1&&d.body.respondToCollision.call(d.body,f)),m++}while(j>m);k++}while(i>k)}return e>0},a.testPolygonPolygon=function(a,c,d,e,f){var h,i=c.points,j=c.normals,k=j.length,l=e.points,m=e.normals,n=m.length,o=g.pop().copy(a.pos).add(a.ancestor._absPos).add(c.pos),p=g.pop().copy(d.pos).add(d.ancestor._absPos).add(e.pos);for(h=0;k>h;h++)if(b(o,p,i,l,j[h],f))return g.push(o),g.push(p),!1;for(h=0;n>h;h++)if(b(o,p,i,l,m[h],f))return g.push(o),g.push(p),!1;return f&&(f.a=a,f.b=d,f.overlapV.copy(f.overlapN).scale(f.overlap)),g.push(o),g.push(p),!0},a.testEllipseEllipse=function(a,b,c,d,e){var f=g.pop().copy(c.pos).add(c.ancestor._absPos).add(d.pos).sub(a.pos).add(a.ancestor._absPos).sub(b.pos),h=b.radius,i=d.radius,j=h+i,k=j*j,l=f.length2();if(l>k)return g.push(f),!1;if(e){var m=Math.sqrt(l);e.a=a,e.b=c,e.overlap=j-m,e.overlapN.copy(f.normalize()),e.overlapV.copy(f).scale(e.overlap),e.aInB=i>=h&&i-h>=m,e.bInA=h>=i&&h-i>=m}return g.push(f),!0},a.testPolygonEllipse=function(a,b,e,h,i){for(var j=g.pop().copy(e.pos).add(e.ancestor._absPos).add(h.pos).sub(a.pos).add(a.ancestor._absPos).sub(b.pos),k=h.radius,l=k*k,m=b.points,n=b.edges,o=n.length,p=g.pop(),q=g.pop(),r=g.pop(),s=0,t=0;o>t;t++){var u=t===o-1?0:t+1,v=0===t?o-1:t-1,w=0,x=null;p.copy(n[t]),r.copy(j).sub(m[t]),i&&r.length2()>l&&(i.aInB=!1);var y=c(p,r),z=!0;if(y===d){var A=null;if(o>1&&(p.copy(n[v]),A=g.pop().copy(j).sub(m[v]),y=c(p,A),y!==f&&(z=!1)),z){if(s=r.length(),s>k)return g.push(j),g.push(p),g.push(q),g.push(r),A&&g.push(A),!1;i&&(i.bInA=!1,x=r.normalize(),w=k-s)}A&&g.push(A)}else if(y===f){if(o>1&&(p.copy(n[u]),r.copy(j).sub(m[u]),y=c(p,r),y!==d&&(z=!1)),z){if(s=r.length(),s>k)return g.push(j),g.push(p),g.push(q),g.push(r),!1;i&&(i.bInA=!1,x=r.normalize(),w=k-s)}}else{q.copy(b.normals[t]),s=r.dotProduct(q);var B=Math.abs(s);if((1===o||s>0)&&B>k)return g.push(j),g.push(p),g.push(q),g.push(r),!1;i&&(x=q,w=k-s,(s>=0||2*k>w)&&(i.bInA=!1))}x&&i&&Math.abs(w)e;e++){var g,h=b[e];g="number"==typeof h||"string"==typeof h?{name:h,delay:c||this.animationspeed}:h;var i=g.name;if("number"==typeof i)"undefined"!=typeof this.textureAtlas[i]&&(this.anim[a].frames[e]=Object.assign({},this.textureAtlas[i],g),d++);else{if(null===this.atlasIndices)throw new me.Renderable.Error("string parameters for addAnimation are not allowed for standard spritesheet based Texture");this.anim[a].frames[e]=Object.assign({},this.textureAtlas[this.atlasIndices[i]],g),d++}}return this.anim[a].length=d,d},setCurrentAnimation:function(a,b,c){if(!this.anim[a])throw new me.Renderable.Error("animation id '"+a+"' not defined");this.current=this.anim[a],this.resetAnim=b||null,this.setAnimationFrame(this.current.idx),this.current.name=a,c||(this.dt=0)},isCurrentAnimation:function(a){return this.current.name===a},setAnimationFrame:function(a){this.current.idx=(a||0)%this.current.length;var b=this.getAnimationFrameObjectByIndex(this.current.idx);Object.assign(this.current,b),b.anchorPoint&&this.anchorPoint.setV(b.anchorPoint)},getCurrentAnimationFrame:function(){return this.current.idx},getAnimationFrameObjectByIndex:function(a){return this.current.frames[a]},update:function(a){var b=!1;if(!this.animationpause&&this.current&&this.current.length>1){var c=this.getAnimationFrameObjectByIndex(this.current.idx).delay;for(this.dt+=a;this.dt>=c;){if(b=!0,this.dt-=c,this.setAnimationFrame(this.current.idx+1),0===this.current.idx&&this.resetAnim)if("string"==typeof this.resetAnim)this.setCurrentAnimation(this.resetAnim,null,!0);else if(this.resetAnim()===!1){this.setAnimationFrame(this.current.length-1),this.dt%=c;break}c=this.getAnimationFrameObjectByIndex(this.current.idx).delay}}return this._flicker.isFlickering&&(this._flicker.duration-=a,this._flicker.duration<0&&("function"==typeof this._flicker.callback&&this._flicker.callback(),this.flicker(-1)),b=!0),b},draw:function(a){if(!this._flicker.isFlickering||(this._flicker.state=!this._flicker.state,this._flicker.state)){var b=this.current,c=this.pos.x,d=this.pos.y,e=b.width,f=b.height,g=b.offset;a.save(),a.setGlobalAlpha(a.globalAlpha()*this.getOpacity()),this.currentTransform.isIdentity()||a.transform(this.currentTransform),a.translate(-(e*this.anchorPoint.x),-(f*this.anchorPoint.y)),0!==b.angle&&(a.translate(-c,-d),a.rotate(b.angle),c-=f,e=b.height,f=b.width),a.drawImage(this.image,g.x,g.y,e,f,c,d,e,f),a.restore()}}}),Object.defineProperty(me.Sprite.prototype,"offset",{get:function(){return this.current.offset},set:function(a){this.current.offset.setV(a)},configurable:!0}),me.AnimationSheet=me.Sprite}(),function(){var a=Math.min,b=Math.max;me.Viewport=me.Renderable.extend({init:function(a,b,c,d){me.Renderable.prototype.init.apply(this,[a,b,c-a,d-b]),this.AXIS={NONE:0,HORIZONTAL:1,VERTICAL:2,BOTH:3},this.bounds=new me.Rect(-(1/0),-(1/0),1/0,1/0),this.offset=new me.Vector2d,this.target=null,this.follow_axis=this.AXIS.NONE,this._shake={intensity:0,duration:0,axis:this.AXIS.BOTH,onComplete:null},this._fadeOut={color:null,tween:null},this._fadeIn={color:null,tween:null},this.setDeadzone(this.width/6,this.height/6)},_followH:function(c){var d=this.pos.x;return c.x-this.pos.x>this.deadzone.right?this.pos.x=a(c.x-this.deadzone.right,this.bounds.width-this.width):c.x-this.pos.xthis.deadzone.bottom?this.pos.y=a(c.y-this.deadzone.bottom,this.bounds.height-this.height):c.y-this.pos.y0&&(this._shake.duration-=a,this._shake.duration<=0?(this._shake.duration=0,this.offset.setZero(),"function"==typeof this._shake.onComplete&&this._shake.onComplete()):(this._shake.axis!==this.AXIS.BOTH&&this._shake.axis!==this.AXIS.HORIZONTAL||(this.offset.x=(Math.random()-.5)*this._shake.intensity),this._shake.axis!==this.AXIS.BOTH&&this._shake.axis!==this.AXIS.VERTICAL||(this.offset.y=(Math.random()-.5)*this._shake.intensity)),b=!0),b===!0&&me.event.publish(me.event.VIEWPORT_ONCHANGE,[this.pos]),null==this._fadeIn.tween&&null==this._fadeOut.tween||(b=!0),b},shake:function(a,b,c,d,e){0!==this._shake.duration&&e!==!0||(this._shake.intensity=a,this._shake.duration=b,this._shake.axis=c||this.AXIS.BOTH,this._shake.onComplete="function"==typeof d?d:void 0)},fadeOut:function(a,b,c){this._fadeOut.color=me.pool.pull("me.Color").copy(a),this._fadeOut.tween=me.pool.pull("me.Tween",this._fadeOut.color).to({alpha:0},b||1e3).onComplete(c||null),this._fadeOut.tween.isPersistent=!0,this._fadeOut.tween.start()},fadeIn:function(a,b,c){this._fadeIn.color=me.pool.pull("me.Color").copy(a);var d=this._fadeIn.color.alpha;this._fadeIn.color.alpha=0,this._fadeIn.tween=me.pool.pull("me.Tween",this._fadeIn.color).to({alpha:d},b||1e3).onComplete(c||null),this._fadeIn.tween.isPersistent=!0,this._fadeIn.tween.start()},getWidth:function(){return this.width},getHeight:function(){return this.height},focusOn:function(a){var b=a.getBounds();this.moveTo(a.pos.x+b.pos.x+b.width/2,a.pos.y+b.pos.y+b.height/2)},isVisible:function(a){return a.overlaps(this)},localToWorld:function(a,b,c){return c=c||new me.Vector2d,c.set(a,b).add(this.pos).sub(me.game.world.pos)},worldToLocal:function(a,b,c){return c=c||new me.Vector2d,c.set(a,b).sub(this.pos).add(me.game.world.pos)},draw:function(){this._fadeIn.tween&&(me.video.renderer.clearColor(this._fadeIn.color),1===this._fadeIn.color.alpha&&(this._fadeIn.tween=null,me.pool.push(this._fadeIn.color),this._fadeIn.color=null)),this._fadeOut.tween&&(me.video.renderer.clearColor(this._fadeOut.color),0===this._fadeOut.color.alpha&&(this._fadeOut.tween=null,me.pool.push(this._fadeOut.color),this._fadeOut.color=null))}})}(),function(){me.GUI_Object=me.Sprite.extend({init:function(a,b,c){this.isClickable=!0,this.holdThreshold=250,this.isHoldable=!1,this.hover=!1,this.holdTimeout=null,this.updated=!1,this.released=!0,me.Sprite.prototype.init.apply(this,[a,b,c]),this.floating=!0},update:function(){return this.updated?(this.released||(this.updated=!1),!0):!1},clicked:function(a){return(1===a.which||me.device.touch)&&this.isClickable?(this.updated=!0,this.released=!1,this.isHoldable&&(null!==this.holdTimeout&&me.timer.clearTimeout(this.holdTimeout),this.holdTimeout=me.timer.setTimeout(this.hold.bind(this),this.holdThreshold,!1),this.released=!1),this.onClick(a)):void 0},onClick:function(){return!1},enter:function(a){return this.hover=!0,this.onOver(a)},onOver:function(){},leave:function(a){return this.hover=!1,this.release.call(this,a),this.onOut(a)},onOut:function(){},release:function(a){return this.released===!1?(this.released=!0,me.timer.clearTimeout(this.holdTimeout),this.onRelease(a)):void 0},onRelease:function(){return!1},hold:function(){me.timer.clearTimeout(this.holdTimeout),this.released||this.onHold()},onHold:function(){},onActivateEvent:function(){me.input.registerPointerEvent("pointerdown",this,this.clicked.bind(this)),me.input.registerPointerEvent("pointerup",this,this.release.bind(this)),me.input.registerPointerEvent("pointercancel",this,this.release.bind(this)),me.input.registerPointerEvent("pointerenter",this,this.enter.bind(this)),me.input.registerPointerEvent("pointerleave",this,this.leave.bind(this)); },onDeactivateEvent:function(){me.input.releasePointerEvent("pointerdown",this),me.input.releasePointerEvent("pointerup",this),me.input.releasePointerEvent("pointercancel",this),me.input.releasePointerEvent("pointerenter",this),me.input.releasePointerEvent("pointerleave",this),me.timer.clearTimeout(this.holdTimeout)}})}(),function(){var a=function(a,b){this.removeChildNow(a,b)},b=0;me.Container=me.Renderable.extend({init:function(a,b,c,d){this.pendingSort=null,this._root=!1,me.Renderable.prototype.init.apply(this,[a||0,b||0,c||1/0,d||1/0]),this.children=[],this.sortOn=me.game.sortOn,this.autoSort=!0,this.autoDepth=!0,this.drawCount=0,this.childBounds=this.getBounds().clone(),this.autoTransform=!1},addChild:function(a,b){return a.ancestor instanceof me.Container?a.ancestor.removeChildNow(a):a.isRenderable&&(a.GUID=me.utils.createGUID(a.id)),a.ancestor=this,this.children.push(a),"undefined"!=typeof a.pos&&("number"==typeof b?a.pos.z=b:this.autoDepth===!0&&(a.pos.z=this.children.length)),this.autoSort===!0&&this.sort(),"function"==typeof a.onActivateEvent&&this.isAttachedToRoot()&&a.onActivateEvent(),a},addChildAt:function(a,b){if(b>=0&&b1&&(c=b);e>d;)a.call(c,this.children[d],d,this.children),d++},swapChildren:function(a,b){var c=this.getChildIndex(a),d=this.getChildIndex(b);if(-1===c||-1===d)throw new me.Container.Error(a+" Both the supplied childs must be a child of the caller "+this);var e=a.pos.z;a.pos.z=b.pos.z,b.pos.z=e,this.children[c]=b,this.children[d]=a},getChildAt:function(a){if(a>=0&&a=0;e--){var f=this.children[e];c(f,a),f instanceof me.Container&&(d=d.concat(f.getChildByProp(a,b)))}return d},getChildByType:function(a){for(var b=[],c=this.children.length-1;c>=0;c--){var d=this.children[c];d instanceof a&&b.push(d),d instanceof me.Container&&(b=b.concat(d.getChildByType(a)))}return b},getChildByName:function(a){return this.getChildByProp("name",a)},getChildByGUID:function(a){var b=this.getChildByProp("GUID",a);return b.length>0?b[0]:null},updateChildBounds:function(){this.childBounds.pos.set(1/0,1/0),this.childBounds.resize(-(1/0),-(1/0));for(var a,b,c=this.children.length;c--,b=this.children[c];)b.isRenderable&&(a=b instanceof me.Container?b.childBounds:b.getBounds(),null!==a&&this.childBounds.union(a));return this.childBounds},isAttachedToRoot:function(){if(this._root)return!0;for(var a=this.ancestor;a;){if(a._root===!0)return!0;a=a.ancestor}return!1},updateBoundsPos:function(a,b){me.Renderable.prototype.updateBoundsPos.apply(this,[a,b]),this._absPos.set(a,b),this.ancestor&&this._absPos.add(this.ancestor._absPos);for(var c,d=this.children.length;d--,c=this.children[d];)c.isRenderable&&c.updateBoundsPos(c.pos.x,c.pos.y);return this.getBounds()},onActivateEvent:function(){for(var a,b=this.children.length;b--,a=this.children[b];)"function"==typeof a.onActivateEvent&&a.onActivateEvent()},removeChild:function(b,c){if(!this.hasChild(b))throw new me.Container.Error("Child is not mine.");a.defer(this,b,c)},removeChildNow:function(a,b){if(this.hasChild(a)&&this.getChildIndex(a)>=0){"function"==typeof a.onDeactivateEvent&&a.onDeactivateEvent(),b||("function"==typeof a.destroy&&a.destroy(),me.pool.push(a));var c=this.getChildIndex(a);c>=0&&(this.children.splice(c,1),a.ancestor=void 0)}},setChildsProperty:function(a,b,c){for(var d=this.children.length;d>=0;d--){var e=this.children[d];c===!0&&e instanceof me.Container&&e.setChildsProperty(a,b,c),e[a]=b}},moveUp:function(a){var b=this.getChildIndex(a);b-1>=0&&this.swapChildren(a,this.getChildAt(b-1))},moveDown:function(a){var b=this.getChildIndex(a);b>=0&&b+10&&(this.children.splice(0,0,this.children.splice(b,1)[0]),a.pos.z=this.children[1].pos.z+1)},moveToBottom:function(a){var b=this.getChildIndex(a);b>=0&&b=0;a=this.children[--b])a&&!a.isPersistent&&this.removeChildNow(a);this.currentTransform.identity()},update:function(a){me.Renderable.prototype.update.apply(this,[a]);var c=!1,d=!1,e=me.state.isPaused(),f=me.game.viewport;this._absPos.setV(this.pos),this.ancestor&&this._absPos.add(this.ancestor._absPos);for(var g,h=this.children.length;h--,g=this.children[h];)e&&!g.updateWhenPaused||(g.isRenderable?(d=b>0||g.floating,d&&b++,g.inViewport=d||f.isVisible(g.getBounds()),c=(g.inViewport||g.alwaysUpdate)&&g.update(a)||c,g._absPos.setV(this._absPos).add(g.pos),b>0&&b--):c=g.update(a)||c);return c},draw:function(a,b){var c=!1,d=!1,e=0,f=0;this.drawCount=0,a.save(),a.translate(this.pos.x,this.pos.y),this.currentTransform.isIdentity()||a.transform(this.currentTransform),a.setGlobalAlpha(a.globalAlpha()*this.getOpacity());for(var g,h=this.children.length;h--,g=this.children[h];)if(c=g.floating===!0,(g.inViewport||c)&&g.isRenderable){if(d=!g.currentTransform.isIdentity(),c)a.save(),a.resetTransform();else if(g.autoTransform===!0){var i=g.getBounds(),j=g.anchorPoint;e=i.width*j.x,f=i.height*j.y,d?(a.save(),g.currentTransform.translate(e,f),a.transform(g.currentTransform)):a.translate(e,f)}g.draw(a,b),c?a.restore():g.autoTransform===!0&&(d?(g.currentTransform.translate(-e,-f),a.restore()):a.translate(-e,-f)),this.drawCount++}a.restore()}}),me.Container.Error=me.Renderable.Error.extend({init:function(a){me.Renderable.Error.prototype.init.apply(this,[a]),this.name="me.Container.Error"}})}(),function(){me.Entity=me.Renderable.extend({init:function(a,b,c){if(this.renderable=null,"number"!=typeof c.width||"number"!=typeof c.height)throw new me.Entity.Error("height and width properties are mandatory when passing settings parameters to an object entity");me.Renderable.prototype.init.apply(this,[a,b,c.width,c.height]),c.image&&(this.renderable=new me.Sprite(0,0,{image:c.image,framewidth:~~(c.framewidth||c.width),frameheight:~~(c.frameheight||c.height),spacing:~~c.spacing,margin:~~c.margin,anchorPoint:c.anchorPoint})),c.anchorPoint&&this.anchorPoint.set(c.anchorPoint.x,c.anchorPoint.y),this.name=c.name||"",this.type=c.type||"",this.id=c.id||"",this.alive=!0;var d=Array.isArray(c.shapes)?c.shapes:[new me.Rect(0,0,this.width,this.height)];this.body?this.body.init(this,d):this.body=new me.Body(this,d);var e=this.body.updateBounds();if(0===this.width&&0===this.height&&this.resize(e.width,e.height),"undefined"!=typeof c.collisionMask&&this.body.setCollisionMask(c.collisionMask),"undefined"!=typeof c.collisionType){if("undefined"==typeof me.collision.types[c.collisionType])throw new me.Entity.Error("Invalid value for the collisionType property");this.body.collisionType=me.collision.types[c.collisionType]}this.autoTransform=!1},distanceTo:function(a){var b=this.getBounds(),c=a.getBounds(),d=b.pos.x+b.width/2-(c.pos.x+c.width/2),e=b.pos.y+b.height/2-(c.pos.y+c.height/2);return Math.sqrt(d*d+e*e)},distanceToPoint:function(a){var b=this.getBounds(),c=b.pos.x+b.width/2-a.x,d=b.pos.y+b.height/2-a.y;return Math.sqrt(c*c+d*d)},angleTo:function(a){var b=this.getBounds(),c=a.getBounds(),d=c.pos.x+c.width/2-(b.pos.x+b.width/2),e=c.pos.y+c.height/2-(b.pos.y+b.height/2);return Math.atan2(e,d)},angleToPoint:function(a){var b=this.getBounds(),c=a.x-(b.pos.x+b.width/2),d=a.y-(b.pos.y+b.height/2);return Math.atan2(d,c)},update:function(a){return this.renderable?this.renderable.update(a):me.Renderable.prototype.update.apply(this,[a])},updateBoundsPos:function(a,b){var c=this.body.pos;return me.Renderable.prototype.updateBoundsPos.apply(this,[a+c.x,b+c.y]),this.getBounds()},onBodyUpdate:function(a,b,c){var d=this.getBounds();d.pos.setV(this.pos).add(a),this.ancestor&&d.pos.add(this.ancestor._absPos),d.resize(b,c)},draw:function(a){var b=this.renderable;if(b instanceof me.Renderable){var c=this.anchorPoint.x*this.body.width,d=this.anchorPoint.y*this.body.height,e=this.pos.x+this.body.pos.x+c,f=this.pos.y+this.body.pos.y+d;if(a.translate(e,f),b.autoTransform!==!0||b.currentTransform.isIdentity())b.draw(a);else{var g=b.getBounds(),h=g.width*b.anchorPoint.x,i=g.height*b.anchorPoint.y;a.save(),a.translate(h,i),a.transform(b.currentTransform),a.translate(-h,-i),b.draw(a),a.restore()}a.translate(-e,-f)}},destroy:function(){this.renderable&&(this.renderable.destroy.apply(this.renderable,arguments),this.renderable=null),this.body.destroy.apply(this.body,arguments),this.body=null,me.Renderable.prototype.destroy.apply(this,arguments)},onDeactivateEvent:function(){this.renderable&&this.renderable.onDeactivateEvent&&this.renderable.onDeactivateEvent()},onCollision:function(){return!1}}),me.Entity.Error=me.Renderable.Error.extend({init:function(a){me.Renderable.Error.prototype.init.apply(this,[a]),this.name="me.Entity.Error"}})}(),function(){me.ScreenObject=me.Object.extend({init:function(){},reset:function(){me.game.reset(),this.onResetEvent.apply(this,arguments)},destroy:function(){this.onDestroyEvent.apply(this,arguments)},onResetEvent:function(){},onDestroyEvent:function(){}}),function(){var a=0,b=1e3/60,c=me.agent.prefixed("requestAnimationFrame"),d=me.agent.prefixed("cancelAnimationFrame")||me.agent.prefixed("cancelRequestAnimationFrame");c&&d||(c=function(c){var d=window.performance.now(),e=Math.max(0,b-(d-a)),f=window.setTimeout(function(){c(d+e)},e);return a=d+e,f},d=function(a){window.clearTimeout(a)}),window.requestAnimationFrame=c,window.cancelAnimationFrame=d}(),me.state=function(){function a(){-1===i&&-1!==h&&(me.timer.reset(),i=window.requestAnimationFrame(d))}function b(){j&&-1!==h&&(me.timer.reset(),j=!1)}function c(){j=!0}function d(a){me.game.update(a),me.game.draw(),-1!==i&&(i=window.requestAnimationFrame(d))}function e(){window.cancelAnimationFrame(i),i=-1}function f(b){e(),k[h]&&k[h].screen.destroy(),k[b]&&(h=b,k[h].screen.reset.apply(k[h].screen,n),a(),m&&m(),me.game.repaint())}var g={},h=-1,i=-1,j=!1,k={},l={color:"",duration:0},m=null,n=null,o=0;return g.LOADING=0,g.MENU=1,g.READY=2,g.PLAY=3,g.GAMEOVER=4,g.GAME_END=5,g.SCORE=6,g.CREDITS=7,g.SETTINGS=8,g.USER=100,g.onPause=null,g.onResume=null,g.onStop=null,g.onRestart=null,g.init=function(){g.set(g.LOADING,new me.DefaultLoadingScreen)},g.stop=function(a){h!==g.LOADING&&g.isRunning()&&(e(),a===!0&&me.audio.pauseTrack(),o=window.performance.now(),me.event.publish(me.event.STATE_STOP),"function"==typeof g.onStop&&g.onStop())},g.pause=function(a){h===g.LOADING||g.isPaused()||(c(),a===!0&&me.audio.pauseTrack(),o=window.performance.now(),me.event.publish(me.event.STATE_PAUSE),"function"==typeof g.onPause&&g.onPause())},g.restart=function(b){g.isRunning()||(a(),b===!0&&me.audio.resumeTrack(),o=window.performance.now()-o,me.game.repaint(),me.event.publish(me.event.STATE_RESTART,[o]),"function"==typeof g.onRestart&&g.onRestart())},g.resume=function(a){g.isPaused()&&(b(),a===!0&&me.audio.resumeTrack(),o=window.performance.now()-o,me.event.publish(me.event.STATE_RESUME,[o]),"function"==typeof g.onResume&&g.onResume())},g.isRunning=function(){return-1!==i},g.isPaused=function(){return j},g.set=function(a,b){k[a]={},k[a].screen=b,k[a].transition=!0},g.current=function(){return k[h].screen},g.transition=function(a,b,c){"fade"===a&&(l.color=b,l.duration=c)},g.setTransition=function(a,b){k[a].transition=b},g.change=function(a){if("undefined"==typeof k[a])throw new me.Error("Undefined ScreenObject for state '"+a+"'");g.isCurrent(a)||(n=null,arguments.length>1&&(n=Array.prototype.slice.call(arguments,1)),l.duration&&k[a].transition?(m=function(){me.game.viewport.fadeOut(l.color,l.duration)},me.game.viewport.fadeIn(l.color,l.duration,function(){f.defer(this,a)})):f.defer(this,a))},g.isCurrent=function(a){return h===a},g}()}(),function(){var a=me.Renderable.extend({init:function(a,b,c){me.Renderable.prototype.init.apply(this,[a.x,a.y,b,c]),this.invalidate=!1,this.barHeight=4,this.progress=0},onProgressUpdate:function(a){this.progress=~~(a*this.width),this.invalidate=!0},update:function(){return this.invalidate===!0?(this.invalidate=!1,!0):!1},draw:function(a){a.setColor("black"),a.fillRect(0,this.height/2-this.barHeight/2,this.width,this.barHeight),a.setColor("#55aa00"),a.fillRect(2,this.height/2-this.barHeight/2,this.progress,this.barHeight),a.setColor("white")}}),b=me.Renderable.extend({init:function(a,b,c){me.Renderable.prototype.init.apply(this,[b,c,100,85]),this.iconCanvas=a;var d=me.video.renderer.getContext2d(this.iconCanvas);d.translate(this.pos.x,this.pos.y),d.beginPath(),d.moveTo(.7,48.9),d.bezierCurveTo(10.8,68.9,38.4,75.8,62.2,64.5),d.bezierCurveTo(86.1,53.1,97.2,27.7,87,7.7),d.lineTo(87,7.7),d.bezierCurveTo(89.9,15.4,73.9,30.2,50.5,41.4),d.bezierCurveTo(27.1,52.5,5.2,55.8,.7,48.9),d.lineTo(.7,48.9),d.lineTo(.7,48.9),d.closePath(),d.fillStyle="rgb(255, 255, 255)",d.fill(),d.beginPath(),d.moveTo(84,7),d.bezierCurveTo(87.6,14.7,72.5,30.2,50.2,41.6),d.bezierCurveTo(27.9,53,6.9,55.9,3.2,48.2),d.bezierCurveTo(-.5,40.4,14.6,24.9,36.9,13.5),d.bezierCurveTo(59.2,2.2,80.3,-.8,84,7),d.lineTo(84,7),d.closePath(),d.lineWidth=5.3,d.strokeStyle="rgb(255, 255, 255)",d.lineJoin="miter",d.miterLimit=4,d.stroke()},draw:function(a){a.drawImage(this.iconCanvas,0,0)}}),c=me.Renderable.extend({init:function(a,b){me.Renderable.prototype.init.apply(this,[0,0,a,b]),this.logo1=new me.Font("century gothic",32,"white","middle"),this.logo2=new me.Font("century gothic",32,"#55aa00","middle"),this.logo2.bold(),this.logo1.textBaseline=this.logo2.textBaseline="alphabetic"},draw:function(a){var b=this.logo1.measureText(a,"melon").width,c=(this.width-b-this.logo2.measureText(a,"JS").width)/2,d=this.height/2+this.logo2.measureText(a,"melon").height;this.logo1.draw(a,"melon",c,d),c+=b,this.logo2.draw(a,"JS",c,d)}});me.DefaultLoadingScreen=me.ScreenObject.extend({onResetEvent:function(){me.game.world.addChild(new me.ColorLayer("background","#202020",0),0);var d=new a(new me.Vector2d,me.video.renderer.getWidth(),me.video.renderer.getHeight());this.loaderHdlr=me.event.subscribe(me.event.LOADER_PROGRESS,d.onProgressUpdate.bind(d)),this.resizeHdlr=me.event.subscribe(me.event.VIEWPORT_ONRESIZE,d.resize.bind(d)),me.game.world.addChild(d,1),this.iconCanvas=me.video.createCanvas(me.game.viewport.width,me.game.viewport.height,!1);var e=new b(this.iconCanvas,(me.video.renderer.getWidth()-100)/2,me.video.renderer.getHeight()/2-d.barHeight/2-90);me.game.world.addChild(e,1),me.game.world.addChild(new c(me.video.renderer.getWidth(),me.video.renderer.getHeight()),1)},onDestroyEvent:function(){me.event.unsubscribe(this.loaderHdlr),me.event.unsubscribe(this.resizeHdlr),this.loaderHdlr=this.resizeHdlr=null}})}(),function(){me.loader=function(){function a(){l===k?f.onload?(clearTimeout(m),setTimeout(function(){f.onload(),me.event.publish(me.event.LOADER_COMPLETE)},300)):console.error("no load callback defined"):m=setTimeout(a,100)}function b(a,b,c){g[a.name]=new Image,g[a.name].onload=b,g[a.name].onerror=c,g[a.name].src=a.src+f.nocache}function c(a,b,c){function d(b){h[a.name]=b,"tmx"===a.type&&me.levelDirector.addTMXLevel(a.name)}if(a.data)return d(a.data),void b();var e=new XMLHttpRequest,g=me.utils.getFileExtension(a.src);e.overrideMimeType&&("json"===g?e.overrideMimeType("application/json"):e.overrideMimeType("text/xml")),e.open("GET",a.src+f.nocache,!0),e.ontimeout=c,e.onreadystatechange=function(){if(4===e.readyState)if(200===e.status||0===e.status&&e.responseText){var a=null;switch(g){case"xml":case"tmx":case"tsx":if(me.device.ua.match(/msie/i)||!e.responseXML){if(!window.DOMParser)throw new f.Error("XML file format loading not supported, use the JSON file format instead");a=(new DOMParser).parseFromString(e.responseText,"text/xml")}else a=e.responseXML;var h=me.TMXUtils.parse(a);switch(g){case"tmx":a=h.map;break;case"tsx":a=h.tilesets[0]}break;case"json":a=JSON.parse(e.responseText);break;default:throw new f.Error("TMX file format "+g+"not supported !")}d(a),b()}else c()},e.send(null)}function d(a,b,c){var d=new XMLHttpRequest;d.overrideMimeType&&d.overrideMimeType("application/json"),d.open("GET",a.src+f.nocache,!0),d.ontimeout=c,d.onreadystatechange=function(){4===d.readyState&&(200===d.status||0===d.status&&d.responseText?(j[a.name]=JSON.parse(d.responseText),b()):c())},d.send(null)}function e(a,b,c){var d=new XMLHttpRequest;d.open("GET",a.src+f.nocache,!0),d.responseType="arraybuffer",d.onerror=c,d.onload=function(){var c=d.response;if(c){for(var e=new Uint8Array(c),f=[],g=0;gn;n++){var p=k.charCodeAt(n),q=this.bitmapFontData.glyphs[p],r=m&&m.kerning?m.getKerning(p):0;0!==q.width&&0!==q.height&&b.drawImage(this.fontImage,q.src.x,q.src.y,q.width,q.height,d+q.offset.x,e+q.offset.y*this.fontScale.y,q.width*this.fontScale.x,q.height*this.fontScale.y),d+=(q.xadvance+r)*this.fontScale.x,m=q}e+=h}b.setGlobalAlpha(i)}})}(),me.BitmapFontData=me.Object.extend({init:function(a){this.padTop=0,this.padRight=0,this.padBottom=0,this.padLeft=0,this.lineHeight=0,this.capHeight=1,this.descent=0,this.scale=new me.Vector2d,this.glyphs={},this.xChars=["x","e","a","o","n","s","r","c","u","m","v","w","z"],this.capChars=["M","N","B","D","C","E","F","K","A","G","H","I","J","L","O","P","Q","R","S","T","U","V","W","X","Y","Z"],this.parse(a)},_createSpaceGlyph:function(){var a=" ".charCodeAt(0),b=this.glyphs[a];b||(b=me.pool.pull("me.Glyph"),b.id=a,b.xadvance=this._getFirstGlyph().xadvance,this.glyphs[a]=b)},_getFirstGlyph:function(){for(var a=Object.keys(this.glyphs),b=0;b32)return this.glyphs[a[b]];return null},_getValueFromPair:function(a,b){var c=a.match(b);if(!c)throw"Could not find pattern "+b+" in string: "+a;return c[0].split("=")[1]},parse:function(a){if(!a)throw"File containing font data was empty, cannot load the bitmap font.";var b=a.split(/\r\n|\n/),c=a.match(/padding\=\d+,\d+,\d+,\d+/g);if(!c)throw"Padding not found in first line";var d=c[0].split("=")[1].split(",");this.padTop=parseFloat(d[0]),this.padLeft=parseFloat(d[1]),this.padBottom=parseFloat(d[2]),this.padRight=parseFloat(d[3]),this.lineHeight=parseFloat(this._getValueFromPair(b[1],/lineHeight\=\d+/g));for(var e=parseFloat(this._getValueFromPair(b[1],/base\=\d+/g)),f=this.padTop+this.padBottom,g=null,h=4;h0&&g.height>0&&(this.descent=Math.min(e+g.yoffset,this.descent)),this.glyphs[n]=g}}this.descent+=this.padBottom,this._createSpaceGlyph();var p=null;for(h=0;h>>a];if(d)return d[c&b-1]||0}return 0},setKerning:function(c,d){this.kerning||(this.kerning={});var e=this.kerning[c>>>a];"undefined"==typeof e&&(this.kerning[c>>>a]={},e=this.kerning[c>>>a]),e[c&b-1]=d}})}(),function(){me.audio=function(){function a(a,d){if(e++>3){var f="melonJS: failed loading "+a;if(me.sys.stopOnAudioError!==!1)throw new b.Error(f);me.audio.disable(),d&&d(),console.log(f+", disabling audio")}else c[a].load()}var b={},c={},d=null,e=0;return b.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.audio.Error"}}),b.init=function(a){if(!me.initialized)throw new b.Error("me.audio.init() called before engine initialization.");return a="string"==typeof a?a:"mp3",this.audioFormats=a.split(","),!Howler.noAudio},b.enable=function(){this.unmuteAll()},b.disable=function(){this.muteAll()},b.load=function(d,f,g,h){var i=[];if("undefined"==typeof this.audioFormats||0===this.audioFormats.length)throw new b.Error("target audio extension(s) should be set through me.audio.init() before calling the preloader.");for(var j=0;j1&&(c.style.width=c.width/m+"px", c.style.height=c.height/m+"px"),window.getComputedStyle){var n=window.getComputedStyle(c,null);me.video.setMaxSize(parseInt(n.maxWidth,10),parseInt(n.maxHeight,10))}return me.game.init(),me.video.onresize(),!0},b.getPos=function(a){return a=a||this.renderer.getScreenCanvas(),a.getBoundingClientRect?a.getBoundingClientRect():{left:0,top:0}},b.setMaxSize=function(a,b){h=a||1/0,i=b||1/0,this.onresize.defer(this)},b.createCanvas=function(a,d,e){if(0===a||0===d)throw new b.Error("width or height was zero, Canvas could not be initialized !");var f=document.createElement("canvas");return e===!0&&me.device.cocoon&&me.device.android2!==!0&&(f.screencanvas=!0),f.width=a||c.width,f.height=d||c.height,f},b.getWrapper=function(){return j.wrapper},b.onresize=function(){var a=1,b=1;if("undefined"!=typeof window.orientation?me.device.orientation=window.orientation:me.device.orientation=window.outerWidth>window.outerHeight?90:0,j.autoScale){var c,k,l=me.video.renderer.getScreenCanvas().parentNode;"undefined"!=typeof l&&(c=l.width,k=l.height);var m=Math.min(h,c||window.innerWidth),n=Math.min(i,k||window.innerHeight),o=m/n,p=1/0,q=1/0;"fill-min"===j.scaleMethod&&o>e||"fill-max"===j.scaleMethod&&e>o||"flex-width"===j.scaleMethod?(p=Math.min(h,g*o),a=b=m/p,p=~~(p+.5),this.renderer.resize(p,g),me.game.viewport.resize(p,g),me.game.world.updateChildBounds()):"fill-min"===j.scaleMethod&&e>o||"fill-max"===j.scaleMethod&&o>e||"flex-height"===j.scaleMethod?(q=Math.min(i,f*(n/m)),a=b=n/q,q=~~(q+.5),this.renderer.resize(f,q),me.game.viewport.resize(f,q),me.game.world.updateChildBounds()):"flex"===j.scaleMethod?(this.renderer.resize(m,n),me.game.viewport.resize(m,n),me.game.world.updateChildBounds()):"stretch"===j.scaleMethod?(a=m/f,b=n/g):a=b=e>o?m/f:n/g,a*=me.device.getPixelRatio(),b*=me.device.getPixelRatio(),d&&clearTimeout(d),d=me.video.updateDisplaySize.defer(this,a,b)}},b.updateDisplaySize=function(a,b){me.sys.scale.set(a,b),this.renderer.scaleCanvas(a,b),me.game.repaint(),me.input._offset=me.video.getPos(),d=0},b}()}(),function(){me.Renderer=me.Object.extend({init:function(a,b,c,d){return d=d||{},this.transparent=!!d.transparent,this.doubleBuffering=!!d.doubleBuffering,this.antiAlias=!!d.antiAlias,this.subPixel=!!d.subPixel,this.verbose=!!d.verbose,this.gameWidthZoom=d.zoomX||b,this.gameHeightZoom=d.zoomY||c,this.canvas=this.backBufferCanvas=a,this.context=null,this.currentColor=new me.Color(255,255,255,1),this.uvOffset=0,this},applyRGBFilter:function(a,b,c){var d,e,f=this.getContext2d(me.video.createCanvas(a.width,a.height,!1)),g=me.utils.getPixels(a),h=g.data;switch(b){case"b&w":for(d=0,e=h.length;e>d;d+=4){var i=3*h[d]+4*h[d+1]+h[d+2]>>>3;h[d]=i,h[d+1]=i,h[d+2]=i}break;case"brightness":var j=Math.abs(c).clamp(0,1);for(d=0,e=h.length;e>d;d+=4)h[d]*=j,h[d+1]*=j,h[d+2]*=j;break;case"transparent":var k=me.pool.pull("me.Color").parseCSS(c),l=me.pool.pull("me.Color");for(d=0,e=h.length;e>d;d+=4)l.setColor(h[d],h[d+1],h[d+2]),l.equals(k)&&(h[d+3]=0);me.pool.push(k),me.pool.push(l);break;default:return null}return f.putImageData(g,0,0),f},clear:function(){},reset:function(){this.resetTransform(),this.cache.reset()},getCanvas:function(){return this.backBufferCanvas},getScreenCanvas:function(){return this.canvas},getScreenContext:function(){return this.context},getContext2d:function(a,b){if("undefined"==typeof a||null===a)throw new me.video.Error("You must pass a canvas element in order to create a 2d context");if("undefined"==typeof a.getContext)throw new me.video.Error("Your browser does not support HTML5 canvas.");var c;return c=me.device.cocoon?a.getContext("2d",{antialias:this.antiAlias,alpha:!b}):a.getContext("2d",{alpha:!b}),c.canvas||(c.canvas=a),this.setAntiAlias(c,this.antiAlias),c},getWidth:function(){return this.backBufferCanvas.width},getHeight:function(){return this.backBufferCanvas.height},getColor:function(){return this.currentColor},globalAlpha:function(){return this.currentColor.glArray[3]},resize:function(a,b){this.backBufferCanvas.width=a,this.backBufferCanvas.height=b},setAntiAlias:function(a,b){"undefined"!=typeof a&&me.agent.setPrefixed("imageSmoothingEnabled",b===!0,a);var c=a.canvas.style["image-rendering"];b!==!1||""!==c&&"auto"!==c?b===!0&&"pixelated"===c&&(a.canvas.style["image-rendering"]="auto"):a.canvas.style["image-rendering"]="pixelated"},drawFont:function(){}})}(),function(){me.Renderer.TextureCache=me.Object.extend({init:function(a){this.max_size=a||1/0,this.reset()},reset:function(){this.cache=new Map,this.units=new Map,this.length=0},validate:function(){if(this.length>=this.max_size)throw new me.video.Error("Texture cache overflow: "+this.max_size+" texture units available.")},get:function(a,b){return this.cache.has(a)||(b||(b=me.video.renderer.Texture.prototype.createAtlas.apply(me.video.renderer.Texture.prototype,[a.width,a.height,a.src?me.utils.getBasename(a.src):void 0])),this.put(a,new me.video.renderer.Texture(b,a,!1))),this.cache.get(a)},put:function(a,b){this.validate(),this.cache.set(a,b),this.units.set(b,this.length++)},getUnit:function(a){return this.units.get(a)}})}(),function(){me.CanvasRenderer=me.Renderer.extend({init:function(a,b,c,d){return me.Renderer.prototype.init.apply(this,[a,b,c,d]),this.context=this.getContext2d(this.canvas,!this.transparent),this.doubleBuffering?(this.backBufferCanvas=me.video.createCanvas(b,c,!1),this.backBufferContext2D=this.getContext2d(this.backBufferCanvas),this.transparent&&(this.context.globalCompositeOperation="copy")):(this.backBufferCanvas=this.canvas,this.backBufferContext2D=this.context),this.fontContext2D=this.backBufferContext2D,this.setColor(this.currentColor),this.cache=new me.Renderer.TextureCache,d.textureSeamFix===!1||this.antiAlias||(this.uvOffset=1),this},clear:function(){this.transparent&&this.clearColor("rgba(0,0,0,0)",!0)},flush:function(){this.doubleBuffering&&this.context.drawImage(this.backBufferCanvas,0,0,this.backBufferCanvas.width,this.backBufferCanvas.height,0,0,this.gameWidthZoom,this.gameHeightZoom)},clearColor:function(a,b){var c=this.backBufferContext2D,d=c.canvas;c.save(),c.setTransform(1,0,0,1,0,0),c.globalCompositeOperation=b?"copy":"source-over",c.fillStyle=a instanceof me.Color?a.toRGBA():a,c.fillRect(0,0,d.width,d.height),c.restore()},clearRect:function(a,b,c,d){this.backBufferContext2D.clearRect(a,b,c,d)},createPattern:function(a,b){return this.backBufferContext2D.createPattern(a,b)},drawImage:function(a,b,c,d,e,f,g,h,i){this.backBufferContext2D.globalAlpha<1/255||(this.subPixel===!1?("undefined"==typeof d?(d=h=a.width,e=i=a.height,f=b,g=c,b=0,c=0):"undefined"==typeof f&&(f=b,g=c,h=d,i=e,d=a.width,e=a.height,b=0,c=0),this.backBufferContext2D.drawImage(a,b,c,d,e,~~f,~~g,h,i)):this.backBufferContext2D.drawImage.apply(this.backBufferContext2D,arguments))},drawPattern:function(a,b,c,d,e){if(!(this.backBufferContext2D.globalAlpha<1/255)){var f=this.backBufferContext2D.fillStyle;this.backBufferContext2D.fillStyle=a,this.backBufferContext2D.fillRect(b,c,d,e),this.backBufferContext2D.fillStyle=f}},fillArc:function(a,b,c,d,e,f){this.backBufferContext2D.globalAlpha<1/255||(this.translate(a+c,b+c),this.backBufferContext2D.beginPath(),this.backBufferContext2D.arc(0,0,c,d,e,f||!1),this.backBufferContext2D.fill(),this.backBufferContext2D.closePath(),this.translate(-(a+c),-(b+c)))},fillRect:function(a,b,c,d){this.backBufferContext2D.globalAlpha<1/255||this.backBufferContext2D.fillRect(a,b,c,d)},getContext:function(){return this.backBufferContext2D},resetTransform:function(){this.backBufferContext2D.setTransform(1,0,0,1,0,0)},scaleCanvas:function(a,b){this.canvas.width=this.gameWidthZoom=this.backBufferCanvas.width*a,this.canvas.height=this.gameHeightZoom=this.backBufferCanvas.height*b,me.device.getPixelRatio()>1&&(this.canvas.style.width=this.canvas.width/me.device.getPixelRatio()+"px",this.canvas.style.height=this.canvas.height/me.device.getPixelRatio()+"px"),this.doubleBuffering&&this.transparent&&(this.context.globalCompositeOperation="copy"),this.setAntiAlias(this.context,this.antiAlias),this.flush()},save:function(){this.backBufferContext2D.save()},restore:function(){this.backBufferContext2D.restore(),this.currentColor.glArray[3]=this.backBufferContext2D.globalAlpha},rotate:function(a){this.backBufferContext2D.rotate(a)},scale:function(a,b){this.backBufferContext2D.scale(a,b)},setColor:function(a){this.backBufferContext2D.strokeStyle=this.backBufferContext2D.fillStyle=a instanceof me.Color?a.toRGBA():a},setGlobalAlpha:function(a){this.backBufferContext2D.globalAlpha=this.currentColor.glArray[3]=a},setLineWidth:function(a){this.backBufferContext2D.lineWidth=a},strokeArc:function(a,b,c,d,e,f){this.backBufferContext2D.globalAlpha<1/255||(this.translate(a+c,b+c),this.backBufferContext2D.beginPath(),this.backBufferContext2D.arc(0,0,c,d,e,f||!1),this.backBufferContext2D.stroke(),this.backBufferContext2D.closePath(),this.translate(-(a+c),-(b+c)))},strokeEllipse:function(a,b,c,d){if(!(this.backBufferContext2D.globalAlpha<1/255)){var e=c,f=d,g=a-e,h=a+e,i=b-f,j=b+f,k=.551784*e,l=.551784*f,m=a-k,n=a+k,o=b-l,p=b+l;this.backBufferContext2D.beginPath(),this.backBufferContext2D.moveTo(a,i),this.backBufferContext2D.bezierCurveTo(n,i,h,o,h,b),this.backBufferContext2D.bezierCurveTo(h,p,n,j,a,j),this.backBufferContext2D.bezierCurveTo(m,j,g,p,g,b),this.backBufferContext2D.bezierCurveTo(g,o,m,i,a,i),this.backBufferContext2D.stroke()}},strokeLine:function(a,b,c,d){this.backBufferContext2D.globalAlpha<1/255||(this.backBufferContext2D.beginPath(),this.backBufferContext2D.moveTo(a,b),this.backBufferContext2D.lineTo(c,d),this.backBufferContext2D.stroke())},strokePolygon:function(a){if(!(this.backBufferContext2D.globalAlpha<1/255)){this.translate(a.pos.x,a.pos.y),this.backBufferContext2D.beginPath(),this.backBufferContext2D.moveTo(a.points[0].x,a.points[0].y);for(var b,c=1;ci;i++)b[""+i]={name:""+i,offset:new me.Vector2d(e+(d+a.framewidth)*(i%h.x),e+(d+a.frameheight)*~~(i/h.x)),anchorPoint:a.anchorPoint||null,width:a.framewidth,height:a.frameheight,angle:0};return b},getAtlas:function(){return this.atlas},getTexture:function(){return this.texture},getRegion:function(a){return this.atlas[a]},createSpriteFromName:function(a,b){return me.pool.pull("me.Sprite",0,0,Object.assign({image:this,region:a},b||{}))},createAnimationFromName:function(a,b){for(var c,d=[],e={},f=0,g=0,h=0;h1?(this.canvas.style.width=c/me.device.getPixelRatio()+"px",this.canvas.style.height=d/me.device.getPixelRatio()+"px"):(this.canvas.style.width=c+"px",this.canvas.style.height=d+"px"),this.compositor.setProjection(this.canvas.width,this.canvas.height)},restore:function(){var a=this.colorStack.pop();me.pool.push(a),this.currentColor.copy(a),this.currentTransform.copy(this._matrixStack.pop())},rotate:function(a){this.currentTransform.rotate(a)},save:function(){this.colorStack.push(this.currentColor.clone()),this._matrixStack.push(this.currentTransform.clone())},scale:function(a,b){this.currentTransform.scale(a,b)},setAntiAlias:function(a,b){me.Renderer.prototype.setAntiAlias.apply(this,[a,b])},setGlobalAlpha:function(a){this.currentColor.glArray[3]=a},setColor:function(a){var b=this.currentColor.glArray[3];this.currentColor.copy(a),this.currentColor.glArray[3]*=b},setLineWidth:function(a){this.compositor.lineWidth(a)},strokeArc:function(){},strokeEllipse:function(){},strokeLine:function(a,b,c,d){var e=this._linePoints.slice(0,2);e[0].x=a,e[0].y=b,e[1].x=c,e[1].y=d,this.compositor.drawLine(e,!0)},strokePolygon:function(a){var b,c,d=a.points.length;for(c=this._linePoints.length;d>c;c++)this._linePoints.push(new me.Vector2d);for(b=this._linePoints.slice(0,d),c=0;d>c;c++)b[c].x=a.pos.x+a.points[c].x,b[c].y=a.pos.y+a.points[c].y;this.compositor.drawLine(b)},strokeRect:function(a,b,c,d){var e=this._linePoints.slice(0,4);e[0].x=a,e[0].y=b,e[1].x=a+c,e[1].y=b,e[2].x=a+c,e[2].y=b+d,e[3].x=a,e[3].y=b+d,this.compositor.drawLine(e)},drawShape:function(a){"Rectangle"===a.shapeType?this.strokeRect(a.left,a.top,a.width,a.height):a instanceof me.Line||a instanceof me.Polygon?this.strokePolygon(a):a instanceof me.Ellipse&&(a.radiusV.x===a.radiusV.y?this.strokeArc(a.pos.x-a.radius,a.pos.y-a.radius,a.radius,0,2*Math.PI):this.strokeEllipse(a.pos.x,a.pos.y,a.radiusV.x,a.radiusV.y))},setTransform:function(a){this.resetTransform(),this.transform(a)},transform:function(a){if(this.currentTransform.multiply(a),this.subPixel===!1){var b=this.currentTransform.val;b[6]=~~b[6],b[7]=~~b[7]}},translate:function(a,b){this.subPixel===!1?this.currentTransform.translate(~~a,~~b):this.currentTransform.translate(a,b)}})}(),function(){me.WebGLRenderer.prototype.Texture=me.CanvasRenderer.prototype.Texture.extend({parse:function(a){var b=a.meta.size.w,c=a.meta.size.h,d=me.CanvasRenderer.prototype.Texture.prototype.parse.apply(this,[a]);return this._addStMap(d,b,c)},parseFromSpriteSheet:function(a){var b=a.image.width,c=a.image.height,d=me.CanvasRenderer.prototype.Texture.prototype.parseFromSpriteSheet.apply(this,[a]);return this._addStMap(d,b,c)},_addStMap:function(a,b,c){return Object.keys(a).forEach(function(d){var e=a[d].offset,f=a[d].width,g=a[d].height;a[d].stMap=new Float32Array([e.x/b,e.y/c,(e.x+f)/b,(e.y+g)/c]);var h=e.x+","+e.y+","+b+","+c;a[h]=a[d]}),a},_insertRegion:function(a,b,c,d,e){var f=this.texture.width,g=this.texture.height;return this.atlas[a]={name:a,offset:new me.Vector2d(b,c),width:d,height:e,angle:0,stMap:new Float32Array([b/f,c/g,(b+d)/f,(c+e)/g])},this.atlas[a]}}),me.WebGLRenderer.prototype.Texture.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.WebGLRenderer.Texture.Error"}})}(),function(){var a=2,b=4,c=1,d=2,e=a+b+c+d,f=e*Float32Array.BYTES_PER_ELEMENT,g=0,h=g+a,i=h+b,j=i+c,k=g*Float32Array.BYTES_PER_ELEMENT,l=h*Float32Array.BYTES_PER_ELEMENT,m=i*Float32Array.BYTES_PER_ELEMENT,n=j*Float32Array.BYTES_PER_ELEMENT,o=4,p=6,q=16e3;me.WebGLRenderer.Compositor=me.Object.extend({init:function(g){var h=g.gl;this.length=0,this.units=[],this.maxTextures=Math.min(24,h.getParameter(h.MAX_TEXTURE_IMAGE_UNITS)),this.v=[new me.Vector2d,new me.Vector2d,new me.Vector2d,new me.Vector2d],this.renderer=g,this.gl=g.gl,this.matrix=g.currentTransform,this.color=g.currentColor,this.uMatrix=new me.Matrix2d;var i=h.getShaderPrecisionFormat(h.FRAGMENT_SHADER,h.HIGH_FLOAT).precision<16?"mediump":"highp";this.lineShader=me.video.shader.createShader(this.gl,function(a){var b="precision highp float;attribute vec2 aVertex;uniform mat3 uMatrix;void main(void){gl_Position=vec4((uMatrix*vec3(aVertex,1)).xy,0,1);}";return b}(),function(a){var b="precision "+a.precision+" float;uniform vec4 uColor;void main(void){gl_FragColor=uColor;}";return b}({precision:i})),this.quadShader=me.video.shader.createShader(this.gl,function(a){var b="precision highp float;attribute vec2 aVertex;attribute vec4 aColor;attribute float aTexture;attribute vec2 aRegion;uniform mat3 uMatrix;varying vec4 vColor;varying float vTexture;varying vec2 vRegion;void main(void){gl_Position=vec4((uMatrix*vec3(aVertex,1)).xy,0,1);vColor=vec4(aColor.rgb*aColor.a,aColor.a);vTexture=aTexture;vRegion=aRegion;}";return b}(),function(a){for(var b="precision "+a.precision+" float;uniform sampler2D uSampler["+a.maxTextures+"];varying vec4 vColor;varying float vTexture;varying vec2 vRegion;void main(void){int texture=int(vTexture);if(texture==0){gl_FragColor=texture2D(uSampler[0],vRegion)*vColor;}",c=1;c=q&&this.flush(),this.length>=this.sbSize&&this.resizeSB();var m=this.matrix,n=this.v[0].set(c,d),p=this.v[1].set(c+f,d),r=this.v[2].set(c,d+k),s=this.v[3].set(c+f,d+k);m.isIdentity()||(m.multiplyVector(n),m.multiplyVector(p),m.multiplyVector(r),m.multiplyVector(s));var t=this.sbIndex,u=t+e,v=u+e,w=v+e;this.stream[t+g+0]=n.x,this.stream[t+g+1]=n.y,this.stream[u+g+0]=p.x,this.stream[u+g+1]=p.y,this.stream[v+g+0]=r.x,this.stream[v+g+1]=r.y,this.stream[w+g+0]=s.x,this.stream[w+g+1]=s.y,this.stream.set(l,t+h),this.stream.set(l,u+h),this.stream.set(l,v+h),this.stream.set(l,w+h);var x=this.uploadTexture(a);this.stream[t+i]=this.stream[u+i]=this.stream[v+i]=this.stream[w+i]=x;var y=a.getRegion(b);if("undefined"==typeof y){me.video.renderer.verbose===!0&&console.warn("Adding texture region",b,"for texture",a);var z=b.split(","),A=+z[0],B=+z[1],C=+z[2],D=+z[3];y=a._insertRegion(b,A,B,C,D)}var E=y.stMap;this.stream[t+j+0]=E[0],this.stream[t+j+1]=E[1],this.stream[u+j+0]=E[2],this.stream[u+j+1]=E[1],this.stream[v+j+0]=E[0],this.stream[v+j+1]=E[3],this.stream[w+j+0]=E[2],this.stream[w+j+1]=E[3],this.sbIndex+=e*o,this.length++}},flush:function(){if(this.length){var a=this.gl,b=this.length*e*o;a.bufferData(a.ARRAY_BUFFER,this.stream.subarray(0,b),a.STREAM_DRAW),a.drawElements(a.TRIANGLES,this.length*p,a.UNSIGNED_SHORT,0),this.sbIndex=0,this.length=0}},drawLine:function(e,g){this.useShader(this.lineShader.handle);for(var h=0,i=0;i0&&b[i]--,d[i]=!1,f[g]?a._preventDefault(c):!0}return!0},a.KEY={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,NUM0:48,NUM1:49,NUM2:50,NUM3:51,NUM4:52,NUM5:53,NUM6:54,NUM7:55,NUM8:56,NUM9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,WINDOW_KEY:91,NUMPAD0:96,NUMPAD1:97,NUMPAD2:98,NUMPAD3:99,NUMPAD4:100,NUMPAD5:101,NUMPAD6:102,NUMPAD7:103,NUMPAD8:104,NUMPAD9:105,MULTIPLY:106,ADD:107,SUBSTRACT:109,DECIMAL: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,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWAND_SLASH:191,GRAVE_ACCENT:192,OPEN_BRACKET:219,BACK_SLASH:220,CLOSE_BRACKET:221,SINGLE_QUOTE:222},a.isKeyPressed=function(a){return b[a]&&!d[a]?(c[a]&&(d[a]=!0),!0):!1},a.keyStatus=function(a){return b[a]>0},a.triggerKeyEvent=function(b,c){c?a._keydown({},b):a._keyup({},b)},a.bindKey=function(g,h,i,j){a._enableKeyboardEvent(),"boolean"!=typeof j&&(j=a.preventDefault),a._KeyBinding[g]=h,f[g]=j,b[h]=0,c[h]=i?i:!1,d[h]=!1,e[h]={}},a.unlockKey=function(a){d[a]=!1},a.unbindKey=function(d){var g=a._KeyBinding[d];b[g]=0,c[g]=!1,e[g]={},a._KeyBinding[d]=null,f[d]=null}}(me.input),function(a){function b(a,b){for(var c=2;c0;){var c=C.pop();if(j.push(c),"undefined"!=typeof a.timeStamp){if(a.timeStampd;d++){var f=b.changedTouches[d];a.globalToLocal(f.clientX,f.clientY,c),c.id=f.identifier,C.push(c)}else a.globalToLocal(b.clientX,b.clientY,c),c.id=b.pointerId||1,C.push(c);b.isPrimary!==!1&&(a.pointer.pos.set(C[0].x,C[0].y),"number"==typeof b.width&&(b.width===a.pointer.width&&b.height===a.pointer.height||a.pointer.resize(b.width||1,b.height||1)))}function g(b){return b.target===me.video.renderer.getScreenCanvas()&&(f(b),b.deltaMode=1,"mousewheel"===o&&(b.deltaY=-1/40*b.wheelDelta,b.wheelDeltaX&&(b.deltaX=-1/40*b.wheelDeltaX)),e(b))?a._preventDefault(b):!0}function h(b){return f(b),e(b)?a._preventDefault(b):!0}function i(b){if(f(b),e(b))return a._preventDefault(b);var c=b.button||0,d=a.pointer.bind[c];return d?b.type===q[w]?a._keydown(b,d,c+1):a._keyup(b,d,c+1):!0}for(var j=[],k=0;10>k;k++)j.push(new me.Vector2d);var l=new Map,m=new me.Rect(0,0,1,1),n=!1,o="mousewheel",p=0,q=null,r=["mousewheel","pointermove","pointerdown","pointerup","pointercancel","pointerenter","pointerleave"],s=["mousewheel","MSPointerMove","MSPointerDown","MSPointerUp","MSPointerCancel","MSPointerEnter","MSPointerLeave"],t=["mousewheel","mousemove","mousedown","mouseup","mousecancel","mouseenter","mouseleave"],u=[void 0,"touchmove","touchstart","touchend","touchcancel","touchenter","touchleave"],v=1,w=2,x=3,y=4,z=5,A=6,B=new me.Vector2d,C=[];a._offset=null,a.pointer=new me.Rect(0,0,1,1),a.pointer.bind=[0,0,0],a.pointer.LEFT=0,a.pointer.MIDDLE=1,a.pointer.RIGHT=2,a.throttlingInterval=void 0,a.globalToLocal=function(b,c,d){d=d||new me.Vector2d;var e=a._offset,f=me.device.getPixelRatio();b-=e.left,c-=e.top;var g=me.sys.scale;return 1===g.x&&1===g.y||(b/=g.x,c/=g.y),d.set(b*f,c*f)},a.bindPointer=function(){var b=arguments.length<2?a.pointer.LEFT:arguments[0],d=arguments.length<2?arguments[0]:arguments[1];if(c(),!a._KeyBinding[d])throw new me.Error("no action defined for keycode "+d);a.pointer.bind[b]=d},a.unbindPointer=function(b){a.pointer.bind["undefined"==typeof b?a.pointer.LEFT:b]=null},a.registerPointerEvent=function(a,b,d){if(c(),-1===r.indexOf(a))throw new me.Error("invalid event type : "+a);r!==q&&(a=q[r.indexOf(a)]),l.has(b)||l.set(b,{region:b,callbacks:{},pointerId:null});var e=l.get(b);e.callbacks[a]||(e.callbacks[a]=[]),e.callbacks[a].push(d)},a.releasePointerEvent=function(a,b,c){if(-1===r.indexOf(a))throw new me.Error("invalid event type : "+a);r!==q&&(a=q[r.indexOf(a)]);var d=l.get(b);if("undefined"==typeof c)for(;d.callbacks[a].length>0;)d.callbacks[a].pop();else d.callbacks[a].remove(c);0===Object.keys(d.callbacks).length&&l.delete(b)},a._translatePointerEvents=function(){a.registerPointerEvent("pointermove",me.game.viewport,function(a){me.event.publish(me.event.POINTERMOVE,[a])})}}(me.input),function(a){function b(a){return a}function c(b,c,d){return d===a.GAMEPAD.BUTTONS.L2||d===a.GAMEPAD.BUTTONS.R2?(b+1)/2:b}function d(b,c,d){return b=b>0?d===a.GAMEPAD.BUTTONS.L2?Math.max(0,b-2e4)/111070:(b-1)/131070:(65536+b)/131070+.5}function e(a,c){var d=a.replace(g,function(a,b,c){return"000".substr(b.length-1)+b+"-"+"000".substr(c.length-1)+c+"-"}),e=a.replace(g,function(a,b,c){return b.replace(h,"")+"-"+c.replace(h,"")+"-"});c.analog=c.analog||c.buttons.map(function(){return-1}),c.normalize_fn=c.normalize_fn||b,j.set(d,c),j.set(e,c)}var f=.1,g=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-/i,h=/^0+/,i={},j=new Map;[["45e-28e-Xbox 360 Wired Controller",{axes:[0,1,3,4],buttons:[11,12,13,14,8,9,-1,-1,5,4,6,7,0,1,2,3,10],analog:[-1,-1,-1,-1,-1,-1,2,5,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:c}],["54c-268-PLAYSTATION(R)3 Controller",{axes:[0,1,2,3],buttons:[14,13,15,12,10,11,8,9,0,3,1,2,4,6,7,5,16]}],["54c-5c4-Wireless Controller",{axes:[0,1,2,3],buttons:[1,0,2,3,4,5,6,7,8,9,10,11,14,15,16,17,12,13]}],["2836-1-OUYA Game Controller",{axes:[0,3,7,9],buttons:[3,6,4,5,7,8,15,16,-1,-1,9,10,11,12,13,14,-1],analog:[-1,-1,-1,-1,-1,-1,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:d}],["OUYA Game Controller (Vendor: 2836 Product: 0001)",{axes:[0,1,3,4],buttons:[0,3,1,2,4,5,12,13,-1,-1,6,7,8,9,10,11,-1],analog:[-1,-1,-1,-1,-1,-1,2,5,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:d}]].forEach(function(a){e(a[0],a[1])}),window.addEventListener("gamepadconnected",function(a){me.event.publish(me.event.GAMEPAD_CONNECTED,[a.gamepad])},!1),window.addEventListener("gamepaddisconnected",function(a){me.event.publish(me.event.GAMEPAD_DISCONNECTED,[a.gamepad])},!1),a._updateGamepads=navigator.getGamepads?function(){var b=navigator.getGamepads(),c={};Object.keys(i).forEach(function(d){var e=b[d];if(e){var g=null;"standard"!==e.mapping&&(g=j.get(e.id));var h=i[d];Object.keys(h.buttons).forEach(function(b){var i=h.buttons[b],j=b,k=-1;if(!(g&&(j=g.buttons[b],k=g.analog[b],0>j&&0>k))){var l=e.buttons[j]||{};if(g&&k>=0){var m=g.normalize_fn(e.axes[k],-1,+b);l={value:m,pressed:l.pressed||Math.abs(m)>=f}}me.event.publish(me.event.GAMEPAD_UPDATE,[d,"buttons",+b,l]),!i.pressed&&l.pressed?a._keydown(c,i.keyCode,j+256):i.pressed&&!l.pressed&&a._keyup(c,i.keyCode,j+256),i.value=l.value,i.pressed=l.pressed}}),Object.keys(h.axes).forEach(function(b){var i=h.axes[b],j=b;if(!(g&&(j=g.axes[b],0>j))){var k=e.axes[j];if("undefined"!=typeof k){g&&(k=g.normalize_fn(k,+b,-1));var l=Math.sign(k)||1;if(i[l]){var m=Math.abs(k)>=f+Math.abs(i[l].threshold);me.event.publish(me.event.GAMEPAD_UPDATE,[d,"axes",+b,k]),!i[l].pressed&&m?a._keydown(c,i[l].keyCode,j+256):(i[l].pressed||i[-l]&&i[-l].pressed)&&!m&&(l=i[l].pressed?l:-l,a._keyup(c,i[l].keyCode,j+256)),i[l].value=k,i[l].pressed=m}}}})}})}:function(){},a.GAMEPAD={AXES:{LX:0,LY:1,RX:2,RY:3,EXTRA_1:4,EXTRA_2:5,EXTRA_3:6,EXTRA_4:7},BUTTONS:{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L1:4,R1:5,L2:6,R2:7,SELECT:8,BACK:8,START:9,FORWARD:9,L3:10,R3:11,UP:12,DOWN:13,LEFT:14,RIGHT:15,HOME:16,EXTRA_1:17,EXTRA_2:18,EXTRA_3:19,EXTRA_4:20}},a.bindGamepad=function(b,c,d){if(!a._KeyBinding[d])throw new me.Error("no action defined for keycode "+d);"object"!=typeof c&&(c={type:"buttons",code:c},console.warn("Deprecated: me.input.bindGamepad parameteres have changed")),i[b]||(i[b]={axes:{},buttons:{}});var e={keyCode:d,value:0,pressed:!1,threshold:c.threshold},f=i[b][c.type];if("buttons"===c.type)f[c.code]=e;else if("axes"===c.type){var g=Math.sign(c.threshold)||1;f[c.code]||(f[c.code]={}),f[c.code][g]=e}},a.unbindGamepad=function(a,b){if(!i[a])throw new me.Error("no bindings for gamepad "+a);i[a].buttons[b]={}},a.setGamepadDeadzone=function(a){f=a},a.setGamepadMapping=e}(me.input),function(){var a=function(){var a={},b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return a.decode=function(a){if(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,""),me.device.nativeBase64)return window.atob(a);for(var c,d,e,f,g,h,i,j=[],k=0;k>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,j.push(String.fromCharCode(c)),64!==h&&j.push(String.fromCharCode(d)),64!==i&&j.push(String.fromCharCode(e));return j=j.join("")},a.encode=function(a){if(a=a.replace(/\r\n/g,"\n"),me.device.nativeBase64)return window.btoa(a);for(var c,d,e,f,g,h,i,j=[],k=0;k>2,g=(3&c)<<4|d>>4,h=(15&d)<<2|e>>6,i=63&e,isNaN(d)?h=i=64:isNaN(e)&&(i=64),j.push(b.charAt(f)),j.push(b.charAt(g)),j.push(b.charAt(h)),j.push(b.charAt(i));return j=j.join("")},a}();me.utils=function(){var b={},c="",d=0,e=/^.*(\\|\/|\:)/,f=/\.[^\.]*$/;return b.decodeBase64=function(b){return a.decode(b)},b.encodeBase64=function(b){return a.encode(b)},b.decodeBase64AsArray=function(b,c){c=c||1;var d,e,f,g=a.decode(b),h=new Uint32Array(g.length/c);for(d=0,f=g.length/c;f>d;d++)for(h[d]=0,e=c-1;e>=0;--e)h[d]+=g.charCodeAt(d*c+e)<<(e<<3);return h},b.decompress=function(){throw new me.Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},b.decodeCSV=function(a){for(var b=a.replace("\n","").trim().split(","),c=[],d=0;d0)for(var c=0;ca;a++)c=e[a],d=e[a+1].clone(),0!==this.rotation&&(c=c.rotate(this.rotation),d=d.rotate(this.rotation)),b.push(new me.Line(0,0,[c,d]))}else b.push(new me.Polygon(0,0,[new me.Vector2d,new me.Vector2d(this.width,0),new me.Vector2d(this.width,this.height),new me.Vector2d(0,this.height)]).rotate(this.rotation));if("isometric"===this.orientation)for(a=0;a=this.firstgid&&a<=this.lastgid},getViewTileId:function(a){return this.animations.has(a)?a=this.animations.get(a).cur.tileid:a-=this.firstgid,a},getTileProperties:function(a){return this.TileProperties[a]},update:function(a){var b=0,c=me.timer.getTime(),d=!1;return this._lastUpdate!==c&&(this._lastUpdate=c,this.animations.forEach(function(c){for(c.dt+=a,b=c.cur.duration;c.dt>=b;)c.dt-=b,c.idx=(c.idx+1)%c.frames.length,c.cur=c.frames[c.idx],b=c.cur.duration,d=!0})),d},drawTile:function(a,b,c,d){d.flipped&&(a.save(),a.translate(b,c),a.transform(d.currentTransform),b=c=0);var e=this.atlas[this.getViewTileId(d.tileId)].offset;a.drawImage(this.image,e.x,e.y,this.tilewidth,this.tileheight,b,c,this.tilewidth+a.uvOffset,this.tileheight+a.uvOffset),d.flipped&&a.restore()}}),me.TMXTilesetGroup=me.Object.extend({init:function(){this.tilesets=[],this.length=0},add:function(a){this.tilesets.push(a),this.length++},getTilesetByIndex:function(a){return this.tilesets[a]},getTilesetByGid:function(b){var c=-1;b&=a;for(var d=0,e=this.tilesets.length;e>d;d++){if(this.tilesets[d].contains(b))return this.tilesets[d];this.tilesets[d].firstgid===this.tilesets[d].lastgid&&b>=this.tilesets[d].firstgid&&(c=d)}if(-1!==c)return this.tilesets[c];throw new me.Error("no matching tileset found for gid "+b)}}),me.TMXTileset.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.TMXTileset.Error"}})}(),function(){var a=[{x:0,y:0},{x:1,y:-1},{x:1,y:0},{x:2,y:0}],b=[{x:0,y:0},{x:-1,y:1},{x:0,y:1},{x:0,y:2}];me.TMXRenderer=me.Object.extend({init:function(a,b,c,d){this.cols=a,this.rows=b,this.tilewidth=c,this.tileheight=d},canRender:function(a){return this.cols===a.cols&&this.rows===a.rows&&this.tilewidth===a.tilewidth&&this.tileheight===a.tileheight}}),me.TMXOrthogonalRenderer=me.TMXRenderer.extend({canRender:function(a){return"orthogonal"===a.orientation&&me.TMXRenderer.prototype.canRender.apply(this,[a])},pixelToTileCoords:function(a,b,c){var d=c||new me.Vector2d;return d.set(this.pixelToTileX(a),this.pixelToTileY(b))},pixelToTileX:function(a){return a/this.tilewidth},pixelToTileY:function(a){return a/this.tileheight},tileToPixelCoords:function(a,b,c){var d=c||new me.Vector2d;return d.set(a*this.tilewidth,b*this.tileheight)},adjustPosition:function(a){"number"==typeof a.gid&&(a.y-=a.height)},drawTile:function(a,b,c,d,e){e.drawTile(a,e.tileoffset.x+b*this.tilewidth,e.tileoffset.y+(c+1)*this.tileheight-e.tileheight,d)},drawTileLayer:function(a,b,c){var d=this.pixelToTileCoords(Math.max(c.pos.x-(b.maxTileSize.width-b.tilewidth),0),Math.max(c.pos.y-(b.maxTileSize.height-b.tileheight),0),me.pool.pull("me.Vector2d")).floorSelf(),e=this.pixelToTileCoords(c.pos.x+c.width+this.tilewidth,c.pos.y+c.height+this.tileheight,me.pool.pull("me.Vector2d")).ceilSelf();e.x=e.x>this.cols?this.cols:e.x,e.y=e.y>this.rows?this.rows:e.y;for(var f=d.y;f>1,-e.tilewidth+(b+c)*e.tileheight>>2,d)},drawTileLayer:function(a,b,c){var d=b.tileset,e=d.tileoffset,f=this.pixelToTileCoords(c.pos.x-d.tilewidth,c.pos.y-d.tileheight,me.pool.pull("me.Vector2d")).floorSelf(),g=this.pixelToTileCoords(c.pos.x+c.width+d.tilewidth,c.pos.y+c.height+d.tileheight,me.pool.pull("me.Vector2d")).ceilSelf(),h=this.tileToPixelCoords(g.x,g.y,me.pool.pull("me.Vector2d")),i=this.tileToPixelCoords(f.x,f.y,me.pool.pull("me.Vector2d"));i.x-=this.hTilewidth,i.y+=this.tileheight;var j=i.y-c.pos.y>this.hTileheight,k=c.pos.x-i.x=0&&m.y>=0&&m.xr;++r)o=Math.pow(this.centers[r].x-j.x,2)+Math.pow(this.centers[r].y-j.y,2),q>o&&(q=o,p=r);var s="x"===this.staggeraxis?a:b;return f=i.x+s[p].x,g=i.y+s[p].y,me.pool.push(i),me.pool.push(j),h.set(f,g)},pixelToTileX:function(a,b){var c=me.pool.pull("me.Vector2d");return this.pixelToTileCoords(a,b,c),me.pool.push(c),c.x},pixelToTileY:function(a,b){var c=me.pool.pull("me.Vector2d");return this.pixelToTileCoords(b,a,c),me.pool.push(c),c.y},tileToPixelCoords:function(a,b,c){var d,e,f=c||new me.Vector2d;return"x"===this.staggeraxis?(d=a*this.columnwidth,"odd"===this.staggerindex?(e=b*(this.tileheight+this.sidelengthy),e+=this.rowheight*(1&a)):(e=b*(this.tileheight+this.sidelengthy),e+=this.rowheight*(1-(1&a)))):(e=b*this.rowheight,"odd"===this.staggerindex?(d=a*(this.tilewidth+this.sidelengthx),d+=this.columnwidth*(1&b)):(d=a*(this.tilewidth+this.sidelengthx),d+=this.columnwidth*(1-(1&b)))),f.set(d,e)},adjustPosition:function(a){"number"==typeof a.gid&&(a.y-=a.height)},drawTile:function(a,b,c,d,e){var f=this.tileToPixelCoords(b,c,me.pool.pull("me.Vector2d"));e.drawTile(a,e.tileoffset.x+f.x,e.tileoffset.y+f.y+(this.tileheight-e.tileheight),d),me.pool.push(f)},drawTileLayer:function(a,b,c){var d=this.pixelToTileCoords(c.pos.x,c.pos.y).floorSelf(),e=this.pixelToTileCoords(c.pos.x+c.width+this.tilewidth,c.pos.y+c.height+this.tileheight).ceilSelf();d.x=d.x<0?0:d.x,d.y=d.y<0?0:d.y,e.x=e.x>this.cols?this.cols:e.x,e.y=e.y>this.rows?this.rows:e.y;for(var f=d.y;f0,this.isAnimated&&(this.preRender=!1),this.getBounds().resize(this.width,this.height)},onDeactivateEvent:function(){this.animatedTilesets=void 0},setRenderer:function(a){this.renderer=a},initArray:function(a,b){this.layerData=[];for(var c=0;a>c;c++){this.layerData[c]=[];for(var d=0;b>d;d++)this.layerData[c][d]=null}},getTileId:function(a,b){var c=this.getTile(a,b);return c?c.tileId:null},getTile:function(a,b){return this.layerData[~~this.renderer.pixelToTileX(a,b)][~~this.renderer.pixelToTileY(b,a)]},setTile:function(a,b,c){this.tileset.contains(c)||(this.tileset=this.tilesets.getTilesetByGid(c));var d=this.layerData[a][b]=new me.Tile(a,b,c,this.tileset);return this.preRender&&this.renderer.drawTile(this.canvasRenderer,a,b,d,d.tileset),d},clearTile:function(a,b){this.layerData[a][b]=null,this.preRender&&this.canvasRenderer.clearRect(a*this.tilewidth,b*this.tileheight,this.tilewidth,this.tileheight)},update:function(a){if(this.isAnimated){for(var b=!1,c=0;c0&&(b.autoSort=!0,b.autoDepth=!0,c.push(b))}return c},getLayers:function(){return this.readMapObjects(this.data),this.layers},destroy:function(){this.tilesets=void 0,this.layers=[],this.objectGroups=[],this.initialized=!1}})}(),function(){me.levelDirector=function(){function a(a,g,h){g.container.destroy(),me.video.renderer.reset(),d[c.getCurrentLevelId()]&&d[c.getCurrentLevelId()].destroy(),f=e.indexOf(a),b(a,g.container,g.flatten,g.setViewportBounds),me.event.publish(me.event.LEVEL_LOADED,[a]),g.onLoaded(a),h&&me.state.restart()}function b(a,b,c,e){function f(){b.pos.set(Math.max(0,~~((me.game.viewport.width-h.width)/2)),Math.max(0,~~((me.game.viewport.height-h.height)/2)),0)}var h=d[a],i=b.autoSort;b.autoSort=!1,e&&me.game.viewport.setBounds(0,0,Math.max(h.width,me.game.viewport.width),Math.max(h.height,me.game.viewport.height)),me.utils.resetGUID(a,h.nextobjectid),h.addTo(b,c),b.sort(!0),b.autoSort=i,b.resize(h.width,h.height),e&&(f(),g&&me.event.unsubscribe(g),g=me.event.subscribe(me.event.VIEWPORT_ONRESIZE,f))}var c={},d={},e=[],f=0,g=null;return c.reset=function(){},c.addLevel=function(){throw new me.Error("no level loader defined")},c.addTMXLevel=function(a,b){return null!=d[a]?!1:(d[a]=new me.TMXTileMap(a,me.loader.getTMX(a)),e.push(a),b&&b(),!0)},c.loadLevel=function(b,c){if(c=Object.assign({container:me.game.world,onLoaded:me.game.onLevelLoaded,flatten:me.game.mergeGroup,setViewportBounds:!0},c||{}),"undefined"==typeof d[b])throw new me.Error("level "+b+" not found");if(!(d[b]instanceof me.TMXTileMap))throw new me.Error("no level loader defined");var e=me.state.isRunning();return e?(me.state.stop(),a.defer(this,b,c,!0)):a(b,c),!0},c.getCurrentLevelId=function(){return e[f]},c.getCurrentLevel=function(){return d[c.getCurrentLevelId()]},c.reloadLevel=function(a){return c.loadLevel(c.getCurrentLevelId(),a)},c.nextLevel=function(a){return f+1=0?c.loadLevel(e[f-1],a):!1},c.levelCount=function(){return e.length},c}()}(),/** * @preserve Tween JS * https://github.com/sole/Tween.js */ function(){me.Tween=function(a){var b=null,c=null,d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=null,o=null,p=null,q=null,r=null,s=null;this._resumeCallback=function(a){k&&(k+=a)},this.setProperties=function(a){b=a,c={},d={},e={},f=1e3,g=0,h=!1,i=!1,j=0,k=null,l=me.Tween.Easing.Linear.None,m=me.Tween.Interpolation.Linear,n=[],o=null,p=!1,q=null,r=null,s=me.timer.lastUpdate,this.isPersistent=!1;for(var t in a)"object"!=typeof a&&(c[t]=parseFloat(a[t],10))},this.setProperties(a),this.onResetEvent=function(a){this.setProperties(a)},this.onActivateEvent=function(){me.event.subscribe(me.event.STATE_RESUME,this._resumeCallback)},this.onDeactivateEvent=function(){me.event.unsubscribe(me.event.STATE_RESUME,this._resumeCallback)},this.to=function(a,b){return void 0!==b&&(f=b),d=a,this},this.start=function(a){p=!1,me.game.world.addChild(this),k=("undefined"==typeof a?me.timer.getTime():a)+j;for(var f in d){if(d[f]instanceof Array){if(0===d[f].length)continue;d[f]=[b[f]].concat(d[f])}c[f]=b[f],c[f]instanceof Array==!1&&(c[f]*=1),e[f]=c[f]||0}return this},this.stop=function(){return me.game.world.removeChildNow(this),this},this.delay=function(a){return j=a,this},this.repeat=function(a){return g=a,this},this.yoyo=function(a){return h=a,this},this.easing=function(a){if("function"!=typeof a)throw new me.Tween.Error("invalid easing function for me.Tween.easing()");return l=a,this},this.interpolation=function(a){return m=a,this},this.chain=function(){return n=arguments,this},this.onStart=function(a){return o=a,this},this.onUpdate=function(a){return q=a,this},this.onComplete=function(a){return r=a,this},this.update=function(a){s=me.timer.lastUpdate>s?me.timer.lastUpdate:s+a;var t,u=s;if(k>u)return!0;p===!1&&(null!==o&&o.call(b),p=!0);var v=(u-k)/f;v=v>1?1:v;var w=l(v);for(t in d){var x=c[t]||0,y=d[t];y instanceof Array?b[t]=m(y,w):("string"==typeof y&&(y=x+parseFloat(y,10)),"number"==typeof y&&(b[t]=x+(y-x)*w))}if(null!==q&&q.call(b,w),1===v){if(g>0){isFinite(g)&&g--;for(t in e){if("string"==typeof d[t]&&(e[t]=e[t]+parseFloat(d[t],10)),h){var z=e[t];e[t]=d[t],d[t]=z}c[t]=e[t]}return h&&(i=!i),k=u+j,!0}me.game.world.removeChildNow(this),null!==r&&r.call(b);for(var A=0,B=n.length;B>A;A++)n[A].start(u);return!1}return!0}},me.Tween.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)))},Out:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*(2*Math.PI)/d)+1)},InOut:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)):c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)*.5+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?.5*(a*a*((b+1)*a-b)):.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-me.Tween.Easing.Bounce.Out(1-a)},Out:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return.5>a?.5*me.Tween.Easing.Bounce.In(2*a):.5*me.Tween.Easing.Bounce.Out(2*a-1)+.5}}},me.Tween.Interpolation={Linear:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d),f=me.Tween.Interpolation.Utils.Linear;return 0>b?f(a[0],a[1],d):b>1?f(a[c],a[c-1],c-d):f(a[e],a[e+1>c?c:e+1],d-e)},Bezier:function(a,b){var c,d=0,e=a.length-1,f=Math.pow,g=me.Tween.Interpolation.Utils.Bernstein;for(c=0;e>=c;c++)d+=f(1-b,e-c)*f(b,c)*a[c]*g(e,c);return d},CatmullRom:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d),f=me.Tween.Interpolation.Utils.CatmullRom;return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),f(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(f(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(f(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):f(a[e?e-1:0],a[e],a[e+1>c?c:e+1],a[e+2>c?c:e+2],d-e)},Utils:{Linear:function(a,b,c){return(b-a)*c+a},Bernstein:function(a,b){var c=me.Tween.Interpolation.Utils.Factorial;return c(a)/c(b)/c(a-b)},Factorial:function(){var a=[1];return function(b){var c,d=1;if(a[b])return a[b];for(c=b;c>1;c--)d*=c;return a[b]=d}}(),CatmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b}}},me.Tween.Error=me.Error.extend({init:function(a){me.Error.prototype.init.apply(this,[a]),this.name="me.Tween.Error"}})}(),/** * @preserve MinPubSub * a micro publish/subscribe messaging framework * @see https://github.com/daniellmb/MinPubSub * @author Daniel Lamb * * Released under the MIT License */ function(){me.event=function(){var a={},b={};return a.STATE_PAUSE="me.state.onPause",a.STATE_RESUME="me.state.onResume",a.STATE_STOP="me.state.onStop",a.STATE_RESTART="me.state.onRestart",a.GAME_INIT="me.game.onInit",a.GAME_RESET="me.game.onReset",a.LEVEL_LOADED="me.game.onLevelLoaded",a.LOADER_COMPLETE="me.loader.onload",a.LOADER_PROGRESS="me.loader.onProgress",a.KEYDOWN="me.input.keydown",a.KEYUP="me.input.keyup",a.GAMEPAD_CONNECTED="gamepad.connected",a.GAMEPAD_DISCONNECTED="gamepad.disconnected",a.GAMEPAD_UPDATE="gamepad.update",a.POINTERMOVE="me.event.pointermove",a.DRAGSTART="me.game.dragstart",a.DRAGEND="me.game.dragend",a.WINDOW_ONRESIZE="window.onresize",a.VIEWPORT_ONRESIZE="viewport.onresize",a.WINDOW_ONORIENTATION_CHANGE="window.orientationchange",a.WINDOW_ONSCROLL="window.onscroll",a.VIEWPORT_ONCHANGE="viewport.onchange",a.publish=function(a,c){for(var d=b[a],e=d?d.length:0;e--;)d[e].apply(window,c||[])},a.subscribe=function(a,c){return b[a]||(b[a]=[]),b[a].push(c),[a,c]},a.unsubscribe=function(a,c){var d=b[c?a:a[0]],e=d?d.length:0;for(c=c||a[1];e--;)d[e]===c&&d.splice(e,1)},a}()}(),/*! * howler.js v2.0.1 * howlerjs.com * * (c) 2013-2016, James Simpson of GoldFire Studios * goldfirestudios.com * * MIT License */ function(){"use strict";var a=function(){this.init()};a.prototype={init:function(){var a=this||b;return a._codecs={},a._howls=[],a._muted=!1,a._volume=1,a._canPlayEvent="canplaythrough",a._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,a.masterGain=null,a.noAudio=!1,a.usingWebAudio=!0,a.autoSuspend=!0,a.ctx=null,a.mobileAutoEnable=!0,a._setup(),a},volume:function(a){var c=this||b;if(a=parseFloat(a),c.ctx||j(),"undefined"!=typeof a&&a>=0&&1>=a){if(c._volume=a,c._muted)return c;c.usingWebAudio&&(c.masterGain.gain.value=a);for(var d=0;d=0;c--)a._howls[c].unload();return a.usingWebAudio&&"undefined"!=typeof a.ctx.close&&(a.ctx.close(),a.ctx=null,j()),a},codecs:function(a){return(this||b)._codecs[a.replace(/^x-/,"")]},_setup:function(){var a=this||b;return a.state=a.ctx?a.ctx.state||"running":"running",a._autoSuspend(),a.noAudio||a._setupCodecs(),a},_setupCodecs:function(){var a=this||b,c="undefined"!=typeof Audio?new Audio:null;if(!c||"function"!=typeof c.canPlayType)return a;var d=c.canPlayType("audio/mpeg;").replace(/^no$/,""),e=a._navigator&&a._navigator.userAgent.match(/OPR\/([0-6].)/g),f=e&&parseInt(e[0].split("/")[1],10)<33;return a._codecs={mp3:!(f||!d&&!c.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!d,opus:!!c.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!c.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!c.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!c.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),aac:!!c.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!c.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(c.canPlayType("audio/x-m4a;")||c.canPlayType("audio/m4a;")||c.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(c.canPlayType("audio/x-mp4;")||c.canPlayType("audio/mp4;")||c.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!c.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,""),webm:!!c.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,""),dolby:!!c.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(c.canPlayType("audio/x-flac;")||c.canPlayType("audio/flac;")).replace(/^no$/,"")},a},_enableMobileAudio:function(){var a=this||b,c=/iPhone|iPad|iPod|Android|BlackBerry|BB10|Silk|Mobi/i.test(a._navigator&&a._navigator.userAgent),d=!!("ontouchend"in window||a._navigator&&a._navigator.maxTouchPoints>0||a._navigator&&a._navigator.msMaxTouchPoints>0);if(!a._mobileEnabled&&a.ctx&&(c||d)){a._mobileEnabled=!1,a._mobileUnloaded||44100===a.ctx.sampleRate||(a._mobileUnloaded=!0,a.unload()),a._scratchBuffer=a.ctx.createBuffer(1,1,22050);var e=function(){var b=a.ctx.createBufferSource();b.buffer=a._scratchBuffer,b.connect(a.ctx.destination),"undefined"==typeof b.start?b.noteOn(0):b.start(0),b.onended=function(){b.disconnect(0),a._mobileEnabled=!0,a.mobileAutoEnable=!1,document.removeEventListener("touchend",e,!0)}};return document.addEventListener("touchend",e,!0),a}},_autoSuspend:function(){var a=this;if(a.autoSuspend&&a.ctx&&"undefined"!=typeof a.ctx.suspend&&b.usingWebAudio){for(var c=0;c0?h._seek:d._sprite[a][0]/1e3,j=(d._sprite[a][0]+d._sprite[a][1])/1e3-i,k=1e3*j/Math.abs(h._rate);h._paused=!1,h._ended=!1,h._sprite=a,h._seek=i,h._start=d._sprite[a][0]/1e3,h._stop=(d._sprite[a][0]+d._sprite[a][1])/1e3,h._loop=!(!h._loop&&!d._sprite[a][2]);var l=h._node;if(d._webAudio){var m=function(){d._refreshBuffer(h);var a=h._muted||d._muted?0:h._volume;l.gain.setValueAtTime(a,b.ctx.currentTime),h._playStart=b.ctx.currentTime,"undefined"==typeof l.bufferSource.start?h._loop?l.bufferSource.noteGrainOn(0,i,86400):l.bufferSource.noteGrainOn(0,i,j):h._loop?l.bufferSource.start(0,i,86400):l.bufferSource.start(0,i,j),k!==1/0&&(d._endTimers[h._id]=setTimeout(d._ended.bind(d,h),k)),c||setTimeout(function(){d._emit("play",h._id)},0)};"loaded"===d._state?m():(d.once("load",m,h._id),d._clearTimer(h._id))}else{var n=function(){l.currentTime=i,l.muted=h._muted||d._muted||b._muted||l.muted,l.volume=h._volume*b.volume(),l.playbackRate=h._rate,setTimeout(function(){l.play(),k!==1/0&&(d._endTimers[h._id]=setTimeout(d._ended.bind(d,h),k)),c||d._emit("play",h._id)},0)},o="loaded"===d._state&&(window&&window.ejecta||!l.readyState&&b._navigator.isCocoonJS);if(4===l.readyState||o)n();else{var p=function(){n(),l.removeEventListener(b._canPlayEvent,p,!1)};l.addEventListener(b._canPlayEvent,p,!1),d._clearTimer(h._id)}}return h._id},pause:function(a){var b=this;if("loaded"!==b._state)return b._queue.push({event:"pause",action:function(){b.pause(a)}}),b;for(var c=b._getSoundIds(a),d=0;d=0?c=parseInt(e[0],10):a=parseFloat(e[0])}else e.length>=2&&(a=parseFloat(e[0]),c=parseInt(e[1],10));var h;if(!("undefined"!=typeof a&&a>=0&&1>=a))return h=c?d._soundById(c):d._sounds[0],h?h._volume:0;if("loaded"!==d._state)return d._queue.push({event:"volume",action:function(){d.volume.apply(d,e)}}),d;"undefined"==typeof c&&(d._volume=a),c=d._getSoundIds(c);for(var i=0;ic?"out":"in",i=g/.01,j=i>0?d/i:d;if(4>j&&(i=Math.ceil(i/(4/j)),j=4),"loaded"!==f._state)return f._queue.push({event:"fade",action:function(){f.fade(a,c,d,e)}}),f;f.volume(a,e);for(var k=f._getSoundIds(e),l=0;l0&&(p+="in"===h?.01:-.01),p=Math.max(0,p),p=Math.min(1,p),p=Math.round(100*p)/100,f._webAudio?("undefined"==typeof e&&(f._volume=p),b._volume=p):f.volume(p,a,!0),p===c&&(clearInterval(b._interval),b._interval=null,f.volume(p,a),f._emit("fade",a))}.bind(f,k[l],m),j)}}return f},_stopFade:function(a){var c=this,d=c._soundById(a);return d&&d._interval&&(c._webAudio&&d._node.gain.cancelScheduledValues(b.ctx.currentTime),clearInterval(d._interval),d._interval=null,c._emit("fade",a)),c},loop:function(){var a,b,c,d=this,e=arguments;if(0===e.length)return d._loop;if(1===e.length){if("boolean"!=typeof e[0])return c=d._soundById(parseInt(e[0],10)),c?c._loop:!1;a=e[0],d._loop=a}else 2===e.length&&(a=e[0],b=parseInt(e[1],10));for(var f=d._getSoundIds(b),g=0;g=0?c=parseInt(e[0],10):a=parseFloat(e[0])}else 2===e.length&&(a=parseFloat(e[0]),c=parseInt(e[1],10));var h;if("number"!=typeof a)return h=d._soundById(c),h?h._rate:d._rate;if("loaded"!==d._state)return d._queue.push({event:"rate",action:function(){d.rate.apply(d,e)}}),d;"undefined"==typeof c&&(d._rate=a),c=d._getSoundIds(c);for(var i=0;i=0?c=parseInt(e[0],10):(c=d._sounds[0]._id,a=parseFloat(e[0]))}else 2===e.length&&(a=parseFloat(e[0]),c=parseInt(e[1],10));if("undefined"==typeof c)return d;if("loaded"!==d._state)return d._queue.push({event:"seek",action:function(){d.seek.apply(d,e)}}),d;var h=d._soundById(c);if(h){if(!("number"==typeof a&&a>=0)){if(d._webAudio){var i=d.playing(c)?b.ctx.currentTime-h._playStart:0,j=h._rateSeek?h._rateSeek-h._seek:0;return h._seek+(j+i*Math.abs(h._rate))}return h._node.currentTime}var k=d.playing(c);k&&d.pause(c,!0),h._seek=a,h._ended=!1,d._clearTimer(c),k&&d.play(c,!0),!d._webAudio&&h._node&&(h._node.currentTime=a),d._emit("seek",c)}return d},playing:function(a){var b=this;if("number"==typeof a){var c=b._soundById(a);return c?!c._paused:!1}for(var d=0;d=0&&b._howls.splice(f,1)}var g=!0;for(d=0;d=0;f--)e[f].id&&e[f].id!==b&&"load"!==a||(setTimeout(function(a){a.call(this,b,c)}.bind(d,e[f].fn),0),e[f].once&&d.off(a,e[f].fn,e[f].id));return d},_loadQueue:function(){var a=this;if(a._queue.length>0){var b=a._queue[0];a.once(b.event,function(){a._queue.shift(),a._loadQueue()}),b.action()}return a},_ended:function(a){var c=this,d=a._sprite,e=!(!a._loop&&!c._sprite[d][2]);if(c._emit("end",a._id),!c._webAudio&&e&&c.stop(a._id,!0).play(a._id),c._webAudio&&e){c._emit("play",a._id),a._seek=a._start||0,a._rateSeek=0,a._playStart=b.ctx.currentTime;var f=1e3*(a._stop-a._start)/Math.abs(a._rate);c._endTimers[a._id]=setTimeout(c._ended.bind(c,a),f)}return c._webAudio&&!e&&(a._paused=!0,a._ended=!0,a._seek=a._start||0,a._rateSeek=0,c._clearTimer(a._id),c._cleanBuffer(a._node),b._autoSuspend()),c._webAudio||e||c.stop(a._id),c},_clearTimer:function(a){var b=this;return b._endTimers[a]&&(clearTimeout(b._endTimers[a]),delete b._endTimers[a]),b},_soundById:function(a){for(var b=this,c=0;c=0;d--){if(b>=c)return;a._sounds[d]._ended&&(a._webAudio&&a._sounds[d]._node&&a._sounds[d]._node.disconnect(0),a._sounds.splice(d,1),c--)}}},_getSoundIds:function(a){var b=this;if("undefined"==typeof a){for(var c=[],d=0;d0&&(e[c._src]=a,i(c,a))},function(){c._emit("loaderror",null,"Decoding audio data failed.")})},i=function(a,b){b&&!a._duration&&(a._duration=b.duration),0===Object.keys(a._sprite).length&&(a._sprite={__default:[0,1e3*a._duration]}),"loaded"!==a._state&&(a._state="loaded",a._emit("load"),a._loadQueue()),a._autoplay&&a.play()},j=function(){b.noAudio=!1;try{"undefined"!=typeof AudioContext?b.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?b.ctx=new webkitAudioContext:b.usingWebAudio=!1}catch(a){b.usingWebAudio=!1}if(!b.usingWebAudio)if("undefined"!=typeof Audio)try{var a=new Audio;"undefined"==typeof a.oncanplaythrough&&(b._canPlayEvent="canplay")}catch(a){b.noAudio=!0}else b.noAudio=!0;try{var a=new Audio;a.muted&&(b.noAudio=!0)}catch(a){}var c=/iP(hone|od|ad)/.test(b._navigator&&b._navigator.platform),d=b._navigator&&b._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),e=d?parseInt(d[1],10):null;if(c&&e&&9>e){var f=/safari/.test(b._navigator&&b._navigator.userAgent.toLowerCase());(b._navigator&&b._navigator.standalone&&!f||b._navigator&&!b._navigator.standalone&&!f)&&(b.usingWebAudio=!1)}b.usingWebAudio&&(b.masterGain="undefined"==typeof b.ctx.createGain?b.ctx.createGainNode():b.ctx.createGain(),b.masterGain.gain.value=1,b.masterGain.connect(b.ctx.destination)),b._setup()};"function"==typeof define&&define.amd&&define([],function(){return{Howler:b,Howl:c}}),"undefined"!=typeof exports&&(exports.Howler=b,exports.Howl=c),"undefined"!=typeof window?(window.HowlerGlobal=a,window.Howler=b,window.Howl=c,window.Sound=d):"undefined"!=typeof global&&(global.HowlerGlobal=a,global.Howler=b,global.Howl=c,global.Sound=d)}(),function(){me.plugins={},me.plugin=function(){var a={};return a.Base=me.Object.extend({init:function(){this.version="4.0.0"}}),a.patch=function(a,b,c){if("undefined"!=typeof a.prototype&&(a=a.prototype),"function"==typeof a[b]){var d=a[b];Object.defineProperty(a,b,{configurable:!0,value:function(a,b){return function(){this._patched=d;var a=b.apply(this,arguments);return this._patched=null,a}}(b,c)})}else console.error(b+" is not an existing function")},a.register=function(a,b){me.plugin[b]&&console.error("plugin "+b+" already registered");var c=[];arguments.length>2&&(c=Array.prototype.slice.call(arguments,1)),c[0]=a;var d=new(a.bind.apply(a,c));if(!(d&&d instanceof me.plugin.Base))throw new me.Error("Plugin should extend the me.plugin.Base Class !");if(me.sys.checkVersion(d.version)>0)throw new me.Error("Plugin version mismatch, expected: "+d.version+", got: "+me.version);me.plugins[b]=d},a}()}(),me.DraggableEntity=function(a,b,c,d){"use strict";return a.extend({init:function(c,e,f){a.prototype.init.apply(this,[c,e,f]),this.dragging=!1,this.dragId=null,this.grabOffset=new d(0,0),this.onPointerEvent=b.registerPointerEvent,this.removePointerEvent=b.releasePointerEvent,this.initEvents()},initEvents:function(){var a=this;this.mouseDown=function(a){this.translatePointerEvent(a,c.DRAGSTART)},this.mouseUp=function(a){this.translatePointerEvent(a,c.DRAGEND)},this.onPointerEvent("pointerdown",this,this.mouseDown.bind(this)),this.onPointerEvent("pointerup",this,this.mouseUp.bind(this)),c.subscribe(c.POINTERMOVE,this.dragMove.bind(this)),c.subscribe(c.DRAGSTART,function(b,c){c===a&&a.dragStart(b)}),c.subscribe(c.DRAGEND,function(b,c){c===a&&a.dragEnd(b)})},translatePointerEvent:function(a,b){c.publish(b,[a,this])},dragStart:function(a){return this.dragging===!1?(this.dragging=!0,this.dragId=a.pointerId,this.grabOffset.set(a.gameX,a.gameY),this.grabOffset.sub(this.pos),!1):void 0},dragMove:function(a){this.dragging===!0&&this.dragId===a.pointerId&&(this.pos.set(a.gameX,a.gameY,this.pos.z),this.pos.sub(this.grabOffset))},dragEnd:function(){return this.dragging===!0?(this.pointerId=void 0,this.dragging=!1,!1):void 0},destroy:function(){c.unsubscribe(c.POINTERMOVE,this.dragMove),c.unsubscribe(c.DRAGSTART,this.dragStart),c.unsubscribe(c.DRAGEND,this.dragEnd),this.removePointerEvent("pointerdown",this),this.removePointerEvent("pointerup",this)}})}(me.Entity,me.input,me.event,me.Vector2d),me.DroptargetEntity=function(a,b){"use strict";return a.extend({init:function(c,d,e){this.CHECKMETHOD_OVERLAP="overlaps",this.CHECKMETHOD_CONTAINS="contains",this.checkMethod=null,a.prototype.init.apply(this,[c,d,e]),b.subscribe(b.DRAGEND,this.checkOnMe.bind(this)),this.checkMethod=this[this.CHECKMETHOD_OVERLAP]},setCheckMethod:function(a){"undefined"!=typeof this[a]&&(this.checkMethod=this[a])},checkOnMe:function(a,b){b&&this.checkMethod(b.getBounds())&&this.drop(b)},drop:function(){},destroy:function(){b.unsubscribe(b.DRAGEND,this.checkOnMe)}})}(me.Entity,me.event),me.CollectableEntity=me.Entity.extend({init:function(a,b,c){me.Entity.prototype.init.apply(this,[a,b,c]),this.body.collisionType=me.collision.types.COLLECTABLE_OBJECT}}),me.LevelEntity=me.Entity.extend({init:function(a,b,c){me.Entity.prototype.init.apply(this,[a,b,c]),this.nextlevel=c.to,this.fade=c.fade,this.duration=c.duration,this.fading=!1,this.name="levelEntity",this.gotolevel=c.to,this.loadLevelSettings={},["container","onLoaded","flatten","setViewportBounds"].forEach(function(a){"undefined"!=typeof c[a]&&(this.loadLevelSettings[a]=c[a])}.bind(this)),this.body.collisionType=me.collision.types.ACTION_OBJECT},getlevelSettings:function(){return"string"==typeof this.loadLevelSettings.container&&(this.loadLevelSettings.container=me.game.world.getChildByName(this.loadLevelSettings.container)[0]),this.loadLevelSettings},onFadeComplete:function(){me.levelDirector.loadLevel(this.gotolevel,this.getlevelSettings()),me.game.viewport.fadeOut(this.fade,this.duration)},goTo:function(a){this.gotolevel=a||this.nextlevel,this.fade&&this.duration?this.fading||(this.fading=!0,me.game.viewport.fadeIn(this.fade,this.duration,this.onFadeComplete.bind(this))):me.levelDirector.loadLevel(this.gotolevel,this.getlevelSettings())},onCollision:function(){return"levelEntity"===this.name&&this.goTo.apply(this),!1}}),function(){var a=function(){var a=me.video.createCanvas(1,1),b=a.getContext("2d");return b.fillStyle="#fff",b.fillRect(0,0,1,1),a}();me.ParticleEmitterSettings={width:0,height:0,image:a,totalParticles:50,angle:Math.PI/2,angleVariation:0,minLife:1e3,maxLife:3e3,speed:2,speedVariation:1,minRotation:0,maxRotation:0,minStartScale:1,maxStartScale:1,minEndScale:0,maxEndScale:0,gravity:0,wind:0,followTrajectory:!1,textureAdditive:!1,onlyInViewport:!0,floating:!1,maxParticles:10,frequency:100,duration:1/0,framesToSkip:0},me.ParticleEmitter=me.Rect.extend({init:function(a,b,c){this._stream=!1,this._frequencyTimer=0,this._durationTimer=0,this._enabled=!1,this.isRenderable=!1,me.Rect.prototype.init.apply(this,[a,b,1/0,1/0]),this.autoSort=!1,this.container=new me.ParticleContainer(this),Object.defineProperty(this.pos,"z",{get:function(){return this.container.pos.z}.bind(this),set:function(a){this.container.pos.z=a}.bind(this),enumerable:!0,configurable:!0}),Object.defineProperty(this,"floating",{get:function(){return this.container.floating},set:function(a){this.container.floating=a},enumerable:!0,configurable:!0}),this.reset(c)},onActivateEvent:function(){this.ancestor.addChild(this.container),this.container.pos.z=this.pos.z,this.ancestor.autoSort||this.ancestor.sort()},onDeactivateEvent:function(){this.ancestor.hasChild(this.container)&&this.ancestor.removeChildNow(this.container)},destroy:function(){this.reset()},getRandomPointX:function(){return this.pos.x+0..randomFloat(this.width)},getRandomPointY:function(){return this.pos.y+0..randomFloat(this.height)},reset:function(a){a=a||{};var b=me.ParticleEmitterSettings,c="number"==typeof a.width?a.width:b.width,d="number"==typeof a.height?a.height:b.height;this.resize(c,d),Object.assign(this,b,a),this.container.destroy()},addParticles:function(a){for(var b=0;~~a>b;b++){var c=me.pool.pull("me.Particle",this);this.container.addChild(c)}},isRunning:function(){return this._enabled&&this._stream},streamParticles:function(a){this._enabled=!0,this._stream=!0,this.frequency=Math.max(this.frequency,1),this._durationTimer="number"==typeof a?a:this.duration},stopStream:function(){this._enabled=!1},burstParticles:function(a){this._enabled=!0,this._stream=!1,this.addParticles("number"==typeof a?a:this.totalParticles),this._enabled=!1},update:function(a){if(this._enabled&&this._stream){if(this._durationTimer!==1/0&&(this._durationTimer-=a,this._durationTimer<=0))return this.stopStream(),!1;this._frequencyTimer+=a;var b=this.container.children.length;b=this.frequency&&(b+this.maxParticles<=this.totalParticles?this.addParticles(this.maxParticles):this.addParticles(this.totalParticles-b),this._frequencyTimer=0)}return!0}})}(),function(){me.ParticleContainer=me.Container.extend({init:function(a){this._viewport=me.game.viewport,me.Container.prototype.init.apply(this),this.autoSort=!1,this._updateCount=0,this._dt=0,this._emitter=a},getBounds:function(){return this._viewport},update:function(a){if(++this._updateCount>this._emitter.framesToSkip&&(this._updateCount=0),this._updateCount>0)return this._dt+=a,!1;a+=this._dt,this._dt=0;for(var b=me.game.viewport,c=this.children.length-1;c>=0;--c){var d=this.children[c];d.isRenderable=!0,d.inViewport=this.floating||d.pos.x0){var c,d=a.getContext();this._emitter.textureAdditive&&(c=d.globalCompositeOperation,d.globalCompositeOperation="lighter"),me.Container.prototype.draw.apply(this,[a,b]),this._emitter.textureAdditive&&(d.globalCompositeOperation=c)}}})}(),function(){me.Particle=me.Renderable.extend({init:function(a){me.Renderable.prototype.init.apply(this,[a.getRandomPointX(),a.getRandomPointY(),a.image.width,a.image.height]),this.alwaysUpdate=!0,this.isRenderable=!1,this.image=a.image;var b=a.angle+(a.angleVariation>0?(0..randomFloat(2)-1)*a.angleVariation:0),c=a.speed+(a.speedVariation>0?(0..randomFloat(2)-1)*a.speedVariation:0);this.vel=new me.Vector2d(c*Math.cos(b),-c*Math.sin(b)),this.life=a.minLife.randomFloat(a.maxLife),this.startLife=this.life,this.startScale=a.minStartScale.randomFloat(a.maxStartScale).clamp(a.minStartScale,a.maxStartScale),this.endScale=a.minEndScale.randomFloat(a.maxEndScale).clamp(a.minEndScale,a.maxEndScale),this.gravity=a.gravity,this.wind=a.wind,this.followTrajectory=a.followTrajectory,this.onlyInViewport=a.onlyInViewport,this.pos.z=a.z,this._deltaInv=me.sys.fps/1e3,a.followTrajectory||(this.angle=a.minRotation.randomFloat(a.maxRotation))},update:function(a){var b=a*this._deltaInv;this.life=this.life>a?this.life-a:0;var c=this.life/this.startLife,d=this.startScale;this.startScale>this.endScale?(d*=c,d=dthis.endScale?this.endScale:d),this.alpha=c,this.vel.x+=this.wind*b,this.vel.y+=this.gravity*b;var e=this.followTrajectory?Math.atan2(this.vel.y,this.vel.x):this.angle;return this.pos.x+=this.vel.x*b,this.pos.y+=this.vel.y*b,this.currentTransform.setTransform(d,0,0,0,d,0,this.pos.x,this.pos.y,1).rotate(e),(this.inViewport||!this.onlyInViewport)&&this.life>0},draw:function(a){a.save(),a.setGlobalAlpha(a.globalAlpha()*this.alpha),a.transform(this.currentTransform);var b=this.width,c=this.height;a.drawImage(this.image,0,0,b,c,-b/2,-c/2,b,c),a.restore()}})}(window);