From d044abb7097e36227605d319d7f3f70bd9c7f5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Wed, 28 Nov 2018 22:48:26 +0100 Subject: [PATCH] crafty itself doesnt want to webpack? Also include config file --- package.json | 3 +-- src/game.js | 12 +++++++++--- src/game/components/BigCard.coffee | 2 ++ src/game/components/Card.coffee | 1 + src/game/components/Playmat.coffee | 2 ++ src/game/scenes/Battle.coffee | 1 + src/game/test_entities.coffee | 7 ++++--- static/crafty-min.js | 14 ++++++++++++++ static/game.html | 1 + 9 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 static/crafty-min.js diff --git a/package.json b/package.json index ce19bca..964a61f 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,7 @@ "bootstrap": "^4.1.3", "jquery": "^3.3.1", - "popper.js": "^1.14.5", - "craftyjs": "^0.9.0" + "popper.js": "^1.14.5" }, "dependencies": { diff --git a/src/game.js b/src/game.js index 30094ef..0ff8988 100644 --- a/src/game.js +++ b/src/game.js @@ -1,4 +1,10 @@ -import Crafty from 'craftyjs' -import CONF from './game/config.coffee' +// libs +const $ = require('jquery') -require('./game/test_entities.coffee') +// style sheet +require('./style/custom.scss') + +// on load +$(() => { + require('./game/test_entities.coffee') +}) diff --git a/src/game/components/BigCard.coffee b/src/game/components/BigCard.coffee index 9df11c1..0839021 100644 --- a/src/game/components/BigCard.coffee +++ b/src/game/components/BigCard.coffee @@ -1,3 +1,5 @@ +CONF = require '../config.coffee' + # intermediate config bcConf = Crafty.clone CONF.bigcard diff --git a/src/game/components/Card.coffee b/src/game/components/Card.coffee index 9f040ad..e49a7ab 100644 --- a/src/game/components/Card.coffee +++ b/src/game/components/Card.coffee @@ -1,3 +1,4 @@ +CONF = require '../config.coffee' require './BigCard.coffee' ################ diff --git a/src/game/components/Playmat.coffee b/src/game/components/Playmat.coffee index 6034d36..3a0af36 100644 --- a/src/game/components/Playmat.coffee +++ b/src/game/components/Playmat.coffee @@ -1,3 +1,5 @@ +CONF = require '../config.coffee' + ################ # Playmat ################ diff --git a/src/game/scenes/Battle.coffee b/src/game/scenes/Battle.coffee index 7e1be9d..89faf85 100644 --- a/src/game/scenes/Battle.coffee +++ b/src/game/scenes/Battle.coffee @@ -1,3 +1,4 @@ +CONF = require '../config.coffee' require '../components/Playmat.coffee' Crafty.defineScene "Battle", -> diff --git a/src/game/test_entities.coffee b/src/game/test_entities.coffee index 4610e55..d4aa4f1 100644 --- a/src/game/test_entities.coffee +++ b/src/game/test_entities.coffee @@ -1,12 +1,13 @@ +CONF = require './config.coffee' +require './components/Card.coffee' +require './scenes/Battle.coffee' + # init Socket.IO socket = io() # init CraftyJS framework Crafty.init() -require './components/Card.coffee' -require './scenes/Battle.coffee' - # Load base scene Crafty.scene "Battle" diff --git a/static/crafty-min.js b/static/crafty-min.js new file mode 100644 index 0000000..a652928 --- /dev/null +++ b/static/crafty-min.js @@ -0,0 +1,14 @@ +/** + * craftyjs 0.9.0 + * http://craftyjs.com/ + * + * Copyright 2018, Louis Stowasser + * Licensed under the MIT license. + */ + + +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g1)for(var c=1;c0&&(c/=g,d/=g)}a.x=c,a.y=d},updateTriggerInput:function(a){a.active?a.input.isActive()||(a.active=!1,g.trigger("TriggerInputUp",a),a.downFor=0):a.input.isActive()&&(a.downFor=Date.now()-a.input.timeDown,a.active=!0,g.trigger("TriggerInputDown",a))},updateDpadInput:function(a,b){var c,d,e;for(c in a.directions)d=a.directions[c],d.active=!1,d.input.isActive()&&("all"===b?d.active=!0:e?("first"===b&&e.input.timeDown>d.input.timeDown&&(e=d),"last"===b&&e.input.timeDown=0?this.touchPoints[b]:null)){var c=this._touchPointsPool.pop()||{};this._setTouchPoint(c,a),this.touchPoints.push(c),this.triggerTouchEvent(c.eventName,c)}},_handleMove:function(a){var b=this._indexOfTouchPoint(a.identifier),c=b>=0?this.touchPoints[b]:null;c&&(this._setTouchPoint(c,a),this.triggerTouchEvent(c.eventName,c))},_handleEnd:function(a){var b=this._indexOfTouchPoint(a.identifier),c=b>=0?this.touchPoints[b]:null;c&&(this._setTouchPoint(c,a),this.triggerTouchEvent(c.eventName,c),this.touchPoints.splice(b,1),c.target=null,c.entity=null,c.originalEvent=null,this._touchPointsPool.push(c))}},d.c("TouchState",d.__touchStateTemplate),d.s("Touch",d.extend.call({triggerTouchEvent:function(a,b){d.trigger(a,b)}},d.__touchStateTemplate),{},!1)},{"../core/core.js":10}],9:[function(a,b,c){var d=a("../core/core.js"),e=function(a,b){this.timePerFrame=1e3/d.timer.FPS(),this.duration=a,"function"==typeof b?this.easing_function=b:"string"==typeof b&&this.standardEasingFunctions[b]?this.easing_function=this.standardEasingFunctions[b]:this.easing_function=this.standardEasingFunctions.linear,this.reset()};e.prototype={duration:0,clock:0,steps:null,complete:!1,paused:!1,reset:function(){this.loops=1,this.clock=0,this.complete=!1,this.paused=!1},repeat:function(a){this.loops=a},setProgress:function(a,b){this.clock=this.duration*a,void 0!==b&&(this.loops=b)},pause:function(){this.paused=!0},resume:function(){this.paused=!1,this.complete=!1},tick:function(a){if(!this.paused&&!this.complete)for(this.clock+=a,this.frames=Math.floor(this.clock/this.timePerFrame);this.clock>=this.duration&&!1===this.complete;)this.loops--,this.loops>0?this.clock-=this.duration:this.complete=!0},time:function(){return Math.min(this.clock/this.duration,1)},value:function(){return this.easing_function(this.time())},standardEasingFunctions:{linear:function(a){return a},smoothStep:function(a){return(3-2*a)*a*a},smootherStep:function(a){return(6*a*a-15*a+10)*a*a*a},easeInQuad:function(a){return a*a},easeOutQuad:function(a){return a*(2-a)},easeInOutQuad:function(a){return a<.5?2*a*a:(4-2*a)*a-1}}},b.exports=e},{"../core/core.js":10}],10:[function(a,b,c){function d(){var a=f++;return a in i?d():a}function e(a){if(null===a||"object"!=typeof a)return a;var b=a.constructor();for(var c in a)b[c]=e(a[c]);return b}var f,g,h,i,j,k,l,m,n,o,p=a("./version"),q=function(a){return new q.fn.init(a)};h={},m=Array.prototype.slice,n=/\s*,\s*/,o=/\s+/;var r=function(){f=1,g=0,i={},l={},j={},k=[]};r(),q.fn=q.prototype={init:function(a){if("string"!=typeof a)return a||(a=0)in i||(i[a]=this),a in i?(this[0]=a,this.length=1,this.__c||(this.__c={}),this._callbacks||q._addCallbackMethods(this),i[a]||(i[a]=this),i[a]):(this.length=0,this);var b,c,d,e,f,g,h,j,k,m=0,p=!1,r=!1;if("*"===a){j=0;for(b in i)this[j]=+b,j++;return this.length=j,1===j?i[this[0]]:this}if(-1!==a.indexOf(",")?(r=!0,c=n):-1!==a.indexOf(" ")&&(p=!0,c=o),r){for(d=a.split(c),e={},j=0,k=d.length;j=0&&(this[m++]=j)}else{f=l[a];for(h in f)this[m++]=+h}return this.length=m,1===m?i[this[m-1]]:(q._addCallbackMethods(this),this)},setName:function(a){var b=String(a);return this._entityName=b,this.trigger("NewEntityName",b),this},getName:function(a){return this._entityName},addComponent:function(a){var b,c,d,e=0;for(b=1===arguments.length&&-1!==a.indexOf(",")?a.split(n):arguments;e1)for(b=arguments.length;d-1?(d=a.split("."),c=d.shift(),d.join("."),this._attr_get(d.join("."),b[c])):b[a]},_attr_set:function(){var a,b,c;return"string"==typeof arguments[0]?(a=this._set_create_object(arguments[0],arguments[1]),b=!!arguments[2],c=arguments[3]||arguments[0].indexOf(".")>-1):(a=arguments[0],b=!!arguments[1],c=!!arguments[2]),b||this.trigger("Change",a),c?this._recursive_extend(a,this):this.extend.call(this,a),this},_set_create_object:function(a,b){var c,d,e,f={};return a.indexOf(".")>-1?(c=a.split("."),d=c.shift(),e=c.join("."),f[d]=this._set_create_object(e,b)):f[a]=b,f},_recursive_extend:function(a,b){var c;for(c in a)a[c].constructor===Object?b[c]=this._recursive_extend(a[c],b[c]):b[c]=a[c];return b},toArray:function(){return m.call(this,0)},timeout:function(a,b){return this.each(function(){var c=this;setTimeout(function(){a.call(c)},b)}),this},bind:function(a,b){if(1===this.length)this._bindCallback(a,b);else for(var c=0;c=b||a+b<0)return;return a>=0?i[this[a]]:i[this[a+b]]}for(var c=0,d=[];c0&&q.trigger("MeasureWaitTime",m-h),c+i>=m)return void(h=m);var n=m-(c+i);n>20*k&&(i+=n-k,n=k),"fixed"===d?(l=Math.ceil(n/k),l=Math.min(l,e),b=k):"variable"===d?(l=1,b=n,b=Math.min(b,f)):"semifixed"===d&&(l=Math.ceil(n/f),b=n/l);for(var o=0;o0&&(a=m,q.trigger("PreRender"),q.trigger("RenderScene"),q.trigger("PostRender"),m=Date.now(),q.trigger("MeasureRenderTime",m-a)),h=m},FPS:function(a){if(void 0===a)return j;j=a,k=1e3/j,q.trigger("FPSChange",a)},simulateFrames:function(a,b){for(b=b||k;a-- >0;){var c={frame:g++,dt:b};q.trigger("EnterFrame",c),q.trigger("UpdateFrame",c),q.trigger("ExitFrame",c)}q.trigger("PreRender"),q.trigger("RenderScene"),q.trigger("PostRender")}}}(),e:function(){var a=d();return i[a]=null,i[a]=q(a),arguments.length>0&&i[a].addComponent.apply(i[a],arguments),i[a].setName("Entity #"+a),i[a].addComponent("obj"),q.trigger("NewEntity",{id:a}),i[a]},c:function(a,b){h[a]=b},trigger:function(a,b){var c,d,e=j[a]||(j[a]={});for(c in e)e.hasOwnProperty(c)&&(d=e[c])&&0!==d.length&&d.context._runCallbacks(a,b)},bind:function(a,b){return this._bindCallback(a,b),b},uniqueBind:function(a,b){return this.unbind(a,b),this.bind(a,b)},one:function(a,b){var c=this,d=function(e){b.call(c,e),c.unbind(a,d)};return c.bind(a,d)},unbind:function(a,b){this._unbindCallbacks(a,b)},frame:function(){return g},entities:function(){return i},components:function(){return h},isComp:function(a){return a in h},debug:function(a){return"handlers"===a?j:i},settings:function(){var a={},b={};return{register:function(a,c){b[a]=c},modify:function(c,d){b[c]&&(b[c].call(a[c],d),a[c]=d)},get:function(b){return a[b]}}}(),defineField:function(a,b,c,d){Object.defineProperty(a,b,{get:c,set:d,configurable:!1,enumerable:!0})},clone:e}),"function"==typeof define&&define("crafty",[],function(){return q}),b.exports=q},{"./version":19}],11:[function(a,b,c){(function(b){var c=a("../core/core.js"),d="undefined"!=typeof window&&window.document;!function(){var a=c.support={},e="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase()||void 0!==b&&b.version,f=/(webkit)[ \/]([\w.]+)/.exec(e)||/(o)pera(?:.*version)?[ \/]([\w.]+)/.exec(e)||/(ms)ie ([\w.]+)/.exec(e)||/(moz)illa(?:.*? rv:([\w.]+))?/.exec(e)||/(v)\d+\.(\d+)/.exec(e)||[],g=/iPad|iPod|iPhone|Android|webOS|IEMobile/i.exec(e);if(g&&(c.mobile=g[0]),a.defineProperty=function(){if(!("defineProperty"in Object))return!1;try{Object.defineProperty({},"x",{})}catch(a){return!1}return!0}(),a.audio="undefined"!=typeof window&&"canPlayType"in d.createElement("audio"),a.prefix=f[1]||f[0],"moz"===a.prefix&&(a.prefix="Moz"),"o"===a.prefix&&(a.prefix="O"),"v"===a.prefix&&(a.prefix="node"),f[2]&&(a.versionName=f[2],a.version=+f[2].split(".")[0]),a.canvas="undefined"!=typeof window&&"getContext"in d.createElement("canvas"),a.canvas){var h;try{var i=d.createElement("canvas");h=i.getContext("webgl")||i.getContext("experimental-webgl"),h.viewportWidth=a.canvas.width,h.viewportHeight=a.canvas.height}catch(a){}a.webgl=!!h}else a.webgl=!1;a.css3dtransform="undefined"!=typeof window&&(void 0!==d.createElement("div").style.Perspective||void 0!==d.createElement("div").style[a.prefix+"Perspective"]),a.deviceorientation="undefined"!=typeof window&&(void 0!==window.DeviceOrientationEvent||void 0!==window.OrientationEvent),a.devicemotion="undefined"!=typeof window&&void 0!==window.DeviceMotionEvent}()}).call(this,a("_process"))},{"../core/core.js":10,_process:1}],12:[function(a,b,c){var d=a("../core/core.js");b.exports={assets:{},__paths:{audio:"",images:""},paths:function(a){if(void 0===a)return this.__paths;a.audio&&(this.__paths.audio=a.audio),a.images&&(this.__paths.images=a.images)},asset:function(a,b){return 1===arguments.length?d.assets[a]:d.assets[a]?void 0:(d.assets[a]=b,this.trigger("NewAsset",{key:a,value:b}),b)},imageWhitelist:["jpg","jpeg","gif","png","svg"],load:function(a,b,c,e){function f(){var a=this.src;this.removeEventListener&&this.removeEventListener("canplaythrough",f,!1),m++,c&&c({loaded:m,total:n,percent:m/n*100,src:a}),m===n&&b&&b()}function g(){var a=this.src;e&&e({loaded:m,total:n,percent:m/n*100,src:a}),++m===n&&b&&b()}if(Array.isArray(a))return void d.log("Calling Crafty.load with an array of assets no longer works; see the docs for more details.");a="string"==typeof a?JSON.parse(a):a;var h,i,j,k,l,m=0,n=(a.audio?Object.keys(a.audio).length:0)+(a.images?Object.keys(a.images).length:0)+(a.sprites?Object.keys(a.sprites).length:0),o=d.paths(),p=function(a){return a.substr(a.lastIndexOf(".")+1).toLowerCase()},q=function(a,b){return-1===b.search("://")?"audio"===a?o.audio+b:o.images+b:b},r=function(a){return d.asset(a)||null},s=function(a){return d.support.audio&&d.audio.supports(p(a))};for(k in a)for(l in a[k])if(a[k].hasOwnProperty(l)){if(h=a[k][l],j=null,"audio"===k){if("object"==typeof h){var t=[];for(var u in h)i=q(k,h[u]),r(i)||!s(h[u])||d.audio.sounds[l]||t.push(i);t.length>0&&(j=d.audio.add(l,t))}else"string"==typeof h&&(i=q(k,h),r(i)||!s(h)||d.audio.sounds[l]||(j=d.audio.add(l,i)));j&&(j=j.obj),j&&j.addEventListener&&j.addEventListener("canplaythrough",f,!1)}else l="sprites"===k?l:h,i=q(k,l),!r(i)&&function(a){return-1!==d.imageWhitelist.indexOf(p(a))}(l)&&(j=new Image,"sprites"===k&&d.sprite(h.tile,h.tileh,i,h.map,h.paddingX,h.paddingY,h.paddingAroundBorder),d.asset(i,j),function(a,b){a.onload=f,"webkit"===d.support.prefix&&(a.src=""),a.src=b}(j,i));j?j.onerror=g:g.call({src:i})}0===n&&b&&b()},removeAssets:function(a){a="string"==typeof a?JSON.parse(a):a;var b,c,e,f,g=d.paths(),h=function(a,b){return-1===b.search("://")?"audio"===a?g.audio+b:g.images+b:b};for(e in a)for(f in a[e])if(a[e].hasOwnProperty(f))if(b=a[e][f],"audio"===e)if("object"==typeof b)for(var i in b)c=h(e,b[i]),d.asset(c)&&d.audio.remove(f);else"string"==typeof b&&(c=h(e,b),d.asset(c)&&d.audio.remove(f));else if(f="sprites"===e?f:b,c=h(e,f),d.asset(c)){if("sprites"===e)for(var j in b.map)delete d.components()[j];delete d.assets[c]}}}},{ +"../core/core.js":10}],13:[function(a,b,c){var d=a("../core/core.js");b.exports={init:function(){this.changed=[],this.bind("Change",this._changed_attributes),this.bind("Change",this._changed_triggers)},_changed_triggers:function(a,b){var c;b=d.extend.call({pre:""},b);for(c in a)this.trigger("Change["+b.pre+c+"]",a[c]),a[c].constructor===Object&&this._changed_triggers(a[c],{pre:b.pre+c+"."})},_changed_attributes:function(a){var b;for(b in a)this.changed.push(b);return this},is_dirty:function(a){return 0===arguments.length?!!this.changed.length:this.changed.indexOf(a)>-1}}},{"../core/core.js":10}],14:[function(a,b,c){var d=a("../core/core.js");b.exports={_scenes:{},_current:null,scene:function(a,b,c){if(1===arguments.length||"function"!=typeof arguments[1])return void d.enterScene(a,arguments[1]);d.defineScene(a,b,c)},defineScene:function(a,b,c){if("function"!=typeof b)throw"Init function is the wrong type.";this._scenes[a]={},this._scenes[a].initialize=b,void 0!==c&&(this._scenes[a].uninitialize=c)},enterScene:function(a,b){if("function"==typeof b)throw"Scene data cannot be a function";d.trigger("SceneDestroy",{newScene:a}),d.viewport.reset(),d("2D").each(function(){this.has("Persist")||this.destroy()}),null!==this._current&&"uninitialize"in this._scenes[this._current]&&this._scenes[this._current].uninitialize.call(this);var c=this._current;this._current=a,d.trigger("SceneChange",{oldScene:c,newScene:a}),this._scenes.hasOwnProperty(a)?this._scenes[a].initialize.call(this,b):d.error('The scene "'+a+'" does not exist')}}},{"../core/core.js":10}],15:[function(a,b,c){var d=a("../core/core.js");try{var e="undefined"!=typeof window&&window.localStorage||new a("node-localstorage").LocalStorage("./localStorage")}catch(a){var e=null}var f=function(a,b){var c=b;if(!e)return d.error("Local storage is not accessible. (Perhaps you are including crafty.js cross-domain?)"),!1;if(1===arguments.length)try{return JSON.parse(e.getItem(a))}catch(b){return e.getItem(a)}else"object"==typeof b&&(c=JSON.stringify(b)),e.setItem(a,c)};f.remove=function(a){if(!e)return void d.error("Local storage is not accessible. (Perhaps you are including crafty.js cross-domain?)");e.removeItem(a)},b.exports=f},{"../core/core.js":10}],16:[function(a,b,c){function d(a,b){var c={};for(var d in b)c[d]=b[d];for(d in a)d in b||(c[d]=a[d]);return c}var e=a("../core/core.js");e._systems={},e.s=function(a,b,c,d){if(!b)return e._systems[a];"boolean"==typeof c&&(d=c,c=null),!1===d?(e._systems[a]=new e.CraftySystem(a,b,c),e.trigger("SystemLoaded",a)):e._registerLazySystem(a,b,c)},e._registerLazySystem=function(a,b,c){Object.defineProperty(e._systems,a,{get:function(){return Object.defineProperty(e._systems,a,{value:new e.CraftySystem(a,b,c),writable:!0,enumerable:!0,configurable:!0}),e.trigger("SystemLoaded",a),e._systems[a]},configurable:!0})},e.CraftySystem=function(){var a=1;return function(b,c,f){if(this.name=b,!c)return this;if(this._systemTemplate=c,this.extend(c),this.options=d(this.options,f),e._addCallbackMethods(this),this[0]="system"+a++,"properties"in c){var g=c.properties;for(var h in g)Object.defineProperty(this,h,g[h])}if("events"in c){var i=c.events;for(var j in i){var k="function"==typeof i[j]?i[j]:c[i[j]];this.bind(j,k)}}"function"==typeof this.init&&this.init(b)}}(),e.CraftySystem.prototype={extend:function(a){for(var b in a)void 0===this[b]&&(this[b]=a[b])},bind:function(a,b){return this._bindCallback(a,b),this},trigger:function(a,b){return this._runCallbacks(a,b),this},unbind:function(a,b){return this._unbindCallbacks(a,b),this},one:function(a,b){var c=this,d=function(e){b.call(c,e),c.unbind(a,d)};return c.bind(a,d)},uniqueBind:function(a,b){return this.unbind(a,b),this.bind(a,b)},destroy:function(){e.trigger("SystemDestroyed",this),"function"==typeof this.remove&&this.remove(),this._unbindAll(),delete e._systems[this.name]}}},{"../core/core.js":10}],17:[function(a,b,c){b.exports={delaySpeed:1,init:function(){this._delays=[],this._delaysPaused=!1,this.bind("UpdateFrame",function(a){if(!this._delaysPaused)for(var b=this._delays.length;--b>=0;){var c=this._delays[b];if(!1===c)this._delays.splice(b,1);else{for(c.accumulator+=a.dt*this.delaySpeed;c.accumulator>=c.delay&&c.repeat>=0;)c.accumulator-=c.delay,c.repeat--,c.callback.call(this);c.repeat<0&&(this._delays.splice(b,1),"function"==typeof c.callbackOff&&c.callbackOff.call(this))}}})},delay:function(a,b,c,d){return this._delays.push({accumulator:0,callback:a,callbackOff:d,delay:b,repeat:(c<0?1/0:c)||0}),this},cancelDelay:function(a){for(var b=this._delays.length;--b>=0;){var c=this._delays[b];c&&c.callback===a&&(this._delays[b]=!1)}return this},pauseDelays:function(){this._delaysPaused=!0},resumeDelays:function(){this._delaysPaused=!1}}},{}],18:[function(a,b,c){var d=a("../core/core.js");b.exports={tweenSpeed:1,init:function(){this.tweenGroup={},this.tweenStart={},this.tweens=[],this.uniqueBind("UpdateFrame",this._tweenTick)},_tweenTick:function(a){var b,c,d;for(d=this.tweens.length-1;d>=0;d--)b=this.tweens[d],b.easing.tick(a.dt*this.tweenSpeed),c=b.easing.value(),this._doTween(b.props,c),b.easing.complete&&(this.tweens.splice(d,1),this._endTween(b.props))},_doTween:function(a,b){for(var c in a)this[c]=(1-b)*this.tweenStart[c]+b*a[c]},tween:function(a,b,c){var e={props:a,easing:new d.easing(b,c)};for(var f in a)void 0!==this.tweenGroup[f]&&this.cancelTween(f),this.tweenStart[f]=this[f],this.tweenGroup[f]=a;return this.tweens.push(e),this},cancelTween:function(a){if("string"==typeof a)"object"==typeof this.tweenGroup[a]&&delete this.tweenGroup[a][a];else if("object"==typeof a)for(var b in a)this.cancelTween(b);return this},pauseTweens:function(){this.tweens.map(function(a){a.easing.pause()})},resumeTweens:function(){this.tweens.map(function(a){a.easing.resume()})},_endTween:function(a){var b=!1;for(var c in a)b=!0,delete this.tweenGroup[c];b&&this.trigger("TweenEnd",a)}}},{"../core/core.js":10}],19:[function(a,b,c){b.exports="0.9.0"},{}],20:[function(a,b,c){b.exports=function(b){b&&(a=b);var c=a("./core/core");a("./core/extensions"),c.easing=a("./core/animation"),c.c("Model",a("./core/model")),c.extend(a("./core/scenes")),c.storage=a("./core/storage"),c.c("Delay",a("./core/time")),c.c("Tween",a("./core/tween"));var d=a("./spatial/spatial-grid");return c.HashMap=d,c.map=new d,a("./core/systems"),a("./spatial/2d"),a("./spatial/motion"),a("./spatial/platform"),a("./spatial/collision"),a("./spatial/rect-manager"),a("./spatial/math"),a("./controls/controls-system"),a("./controls/controls"),a("./controls/keyboard"),a("./controls/keycodes"),a("./controls/mouse"),a("./controls/touch"),a("./debug/logging"),c}},{"./controls/controls":4,"./controls/controls-system":3,"./controls/keyboard":5,"./controls/keycodes":6,"./controls/mouse":7,"./controls/touch":8,"./core/animation":9,"./core/core":10,"./core/extensions":11,"./core/model":13,"./core/scenes":14,"./core/storage":15,"./core/systems":16,"./core/time":17,"./core/tween":18,"./debug/logging":23,"./spatial/2d":54,"./spatial/collision":55,"./spatial/math":56,"./spatial/motion":57,"./spatial/platform":58,"./spatial/rect-manager":59,"./spatial/spatial-grid":60}],21:[function(a,b,c){var d=a("./crafty-common.js")();d.extend(a("./core/loader")),d.extend(a("./inputs/dom-events")),a("./graphics/layers"),a("./graphics/canvas"),a("./graphics/canvas-layer"),a("./graphics/webgl"),a("./graphics/webgl-layer"),a("./graphics/color"),a("./graphics/dom"),a("./graphics/dom-helper"),a("./graphics/dom-layer"),a("./graphics/drawing"),a("./graphics/gl-textures"),a("./graphics/renderable"),a("./graphics/html"),a("./graphics/image"),a("./graphics/particles"),a("./graphics/sprite-animation"),a("./graphics/sprite"),a("./graphics/text"),a("./graphics/viewport"),a("./isometric/diamond-iso"),a("./isometric/isometric"),a("./inputs/util"),a("./inputs/device"),a("./inputs/keyboard"),a("./inputs/lifecycle"),a("./inputs/mouse"),a("./inputs/pointer"),a("./inputs/touch"),a("./sound/sound"),a("./debug/debug-layer"),a("./aliases").defineAliases(d),window&&(window.Crafty=d),b.exports=d},{"./aliases":2,"./core/loader":12,"./crafty-common.js":20,"./debug/debug-layer":22,"./graphics/canvas":25,"./graphics/canvas-layer":24,"./graphics/color":26,"./graphics/dom":29,"./graphics/dom-helper":27,"./graphics/dom-layer":28,"./graphics/drawing":30,"./graphics/gl-textures":31,"./graphics/html":32,"./graphics/image":33,"./graphics/layers":34,"./graphics/particles":35,"./graphics/renderable":36,"./graphics/sprite":38,"./graphics/sprite-animation":37,"./graphics/text":39,"./graphics/viewport":40,"./graphics/webgl":42,"./graphics/webgl-layer":41,"./inputs/device":43,"./inputs/dom-events":44,"./inputs/keyboard":45,"./inputs/lifecycle":46,"./inputs/mouse":47,"./inputs/pointer":48,"./inputs/touch":49,"./inputs/util":50,"./isometric/diamond-iso":51,"./isometric/isometric":52,"./sound/sound":53}],22:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.c("DebugCanvas",{init:function(){this.requires("2D"),d.DebugCanvas.context||d.DebugCanvas.init(),d.DebugCanvas.add(this),this._debug={alpha:1,lineWidth:1},this.bind("RemoveComponent",this.onDebugRemove),this.bind("Remove",this.onDebugDestroy)},onDebugRemove:function(a){"DebugCanvas"===a&&d.DebugCanvas.remove(this)},onDebugDestroy:function(a){d.DebugCanvas.remove(this)},debugAlpha:function(a){return this._debug.alpha=a,this},debugFill:function(a){return void 0===a&&(a="red"),this._debug.fillStyle=a,this},debugStroke:function(a){return void 0===a&&(a="red"),this._debug.strokeStyle=a,this},debugDraw:function(a){var b=a.globalAlpha,c=this._debug;c.alpha&&(a.globalAlpha=this._debug.alpha),c.strokeStyle&&(a.strokeStyle=c.strokeStyle),c.lineWidth&&(a.lineWidth=c.lineWidth),c.fillStyle&&(a.fillStyle=c.fillStyle),this.trigger("DebugDraw",a),a.globalAlpha=b}}),d.c("DebugRectangle",{init:function(){this.requires("2D, DebugCanvas")},debugRectangle:function(a){return this.debugRect=a,this.unbind("DebugDraw",this.drawDebugRect),this.bind("DebugDraw",this.drawDebugRect),this},drawDebugRect:function(a){var b=this.debugRect;null!==b&&void 0!==b&&b._h&&b._w&&(this._debug.fillStyle&&a.fillRect(b._x,b._y,b._w,b._h),this._debug.strokeStyle&&a.strokeRect(b._x,b._y,b._w,b._h))}}),d.c("WiredMBR",{init:function(){this.requires("DebugRectangle").debugStroke("purple")},events:{PreRender:function(){this.debugRectangle(this._mbr||this)}}});var f={init:function(){this.requires("DebugRectangle").debugFill("pink")},events:{PreRender:function(){this.debugRectangle(this._mbr||this)}}};d.c("SolidMBR",f),d.c("VisibleMBR",f),d.c("DebugPolygon",{init:function(){this.requires("2D, DebugCanvas")},debugPolygon:function(a){return this.polygon=a,this.unbind("DebugDraw",this.drawDebugPolygon),this.bind("DebugDraw",this.drawDebugPolygon),this},drawDebugPolygon:function(a){if(void 0!==this.polygon){a.beginPath();for(var b=this.polygon.points,c=b.length,d=0;d=0;c--)b[c]===a&&b.splice(c,1)},init:function(){if(!d.DebugCanvas.context){if(!d.support.canvas)return d.trigger("NoCanvas"),void d.stop();var a;a=e.createElement("canvas"),a.width=d.viewport.width,a.height=d.viewport.height,a.style.position="absolute",a.style.left="0px",a.style.top="0px",a.id="debug-canvas",a.style.zIndex=1e5,d.stage.elem.appendChild(a),d.DebugCanvas.context=a.getContext("2d"),d.DebugCanvas._canvas=a}d.unbind("RenderScene",d.DebugCanvas.renderScene),d.bind("RenderScene",d.DebugCanvas.renderScene)},renderScene:function(a){a=a||d.viewport.rect();var b,c=d.DebugCanvas.entities,e=0,f=c.length,g=d.DebugCanvas.context,h=d.viewport;g.setTransform(h._scale,0,0,h._scale,Math.round(h._x*h._scale),Math.round(h._y*h._scale)),g.clearRect(a._x,a._y,a._w,a._h);for(var i=null;e.6||a?this._drawAll():this._drawDirtyCells(),this._clean()}},_drawDirtyCells:function(a){var b,c,e=this._viewportRect(),f=this.__tempRect,g=this._dirtyRects,h=d.rectManager.integerBounds,i=this.context;for(a=h(a||e),this._createDirtyCells(a),this._createDirtyRects(),b=0,c=g.length;bg&&f._visible&&f._drawLayer===this&&(f.draw(i),f._changed=!1,g=f._globalZ);i.restore()},debug:function(){d.log(this._changedObjs)},_clean:function(){var a,b,c,d,e,f=this._changedObjs;for(d=0,e=f.length;d>16,b=c<0?~(a>>16):a>>16,g.push(b*e,c*e,e,e)},_resize:function(){var a=this._canvas;a.width=d.viewport.width,a.height=d.viewport.height},_setPixelart:function(a){var b=this.context;b.imageSmoothingEnabled=!a,b.mozImageSmoothingEnabled=!a,b.webkitImageSmoothingEnabled=!a,b.oImageSmoothingEnabled=!a,b.msImageSmoothingEnabled=!a}})},{"../core/core.js":10}],25:[function(a,b,c){var d=a("../core/core.js");d.c("Canvas",{init:function(){this.requires("Renderable"),this.currentRect={},this._customLayer||this._attachToLayer(d.s("DefaultCanvasLayer"))},remove:function(){this._detachFromLayer()},drawVars:{type:"canvas",pos:{},ctx:null,coord:[0,0,0,0],co:{x:0,y:0,w:0,h:0}},draw:function(a,b,c,d,e){if(this.ready){var f=this.drawVars.pos;f._x=this._x+(b||0),f._y=this._y+(c||0),f._w=d||this._w,f._h=e||this._h;var g=a||this._drawContext,h=this.__coord||[0,0,0,0],i=this.drawVars.co;i.x=h[0]+(b||0),i.y=h[1]+(c||0),i.w=d||h[2],i.h=e||h[3],(this._flipX||this._flipY||this._rotation)&&g.save(),0!==this._rotation&&(g.translate(this._origin.x+this._x,this._origin.y+this._y),f._x=-this._origin.x,f._y=-this._origin.y,g.rotate(this._rotation%360*(Math.PI/180))),(this._flipX||this._flipY)&&(g.scale(this._flipX?-1:1,this._flipY?-1:1),this._flipX&&(f._x=-(f._x+f._w)),this._flipY&&(f._y=-(f._y+f._h)));var j;return this._alpha<1&&(j=g.globalAlpha,g.globalAlpha=this._alpha),this.drawVars.ctx=g,this.trigger("Draw",this.drawVars),(0!==this._rotation||this._flipX||this._flipY)&&g.restore(),j&&(g.globalAlpha=j),this}}})},{"../core/core.js":10}],26:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.extend({assignColor:function(){function a(a){return a._red=a._blue=a._green=0,a}function b(a){var b=a.toString(16);return 1===b.length&&(b="0"+b),b}function c(a,c,d){return"#"+b(a)+b(c)+b(d)}function d(b,c){var d,e,f,g=b.length;if(7===g)d=b.substr(1,2),e=b.substr(3,2),f=b.substr(5,2);else{if(4!==g)return a(c);d=b.substr(1,1),d+=d,e=b.substr(2,1),e+=e,f=b.substr(3,1),f+=f}return c._red=parseInt(d,16),c._green=parseInt(e,16),c._blue=parseInt(f,16),c}function f(b,c){var d=l.exec(b);return null===d||4!==d.length&&5!==d.length?a(c):(c._red=Math.round(parseFloat(d[1])),c._green=Math.round(parseFloat(d[2])),c._blue=Math.round(parseFloat(d[3])),d[4]&&(c._strength=parseFloat(d[4])),c)}function g(a,b){if(void 0===k[a]){!1===j&&(window.document.body.appendChild(i),j=!0),i.style.color=a;f(window.getComputedStyle(i).color,b),k[a]=c(b._red,b._green,b._blue)}else d(k[a],b);return b}function h(a){return"rgba("+a._red+", "+a._green+", "+a._blue+", "+a._strength+")"}var i=e.createElement("div");i.style.display="none";var j=!1,k={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#00ff00",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#ffa500",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00"},l=/rgba?\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,?\s*([0-9.]+)?\)/;return function(a,b){b=b||{},a=a.trim().toLowerCase();"#"===a[0]?d(a,b):"r"===a[0]&&"g"===a[1]&&"b"===a[2]?f(a,b):g(a,b),b._strength=b._strength||1,b._color=h(b)}}()}),d.defaultShader("Color",new d.WebGLShader("attribute vec2 aPosition;\nattribute vec3 aOrientation;\nattribute vec2 aLayer;\nattribute vec4 aColor;\n\nvarying lowp vec4 vColor;\n\nuniform vec4 uViewport;\n\nmat4 viewportScale = mat4(2.0 / uViewport.z, 0, 0, 0, 0, -2.0 / uViewport.w, 0,0, 0, 0,1,0, -1,+1,0,1);\nvec4 viewportTranslation = vec4(uViewport.xy, 0, 0);\n\nvoid main() {\n vec2 pos = aPosition;\n vec2 entityOrigin = aOrientation.xy;\n mat2 entityRotationMatrix = mat2(cos(aOrientation.z), sin(aOrientation.z), -sin(aOrientation.z), cos(aOrientation.z));\n\n pos = entityRotationMatrix * (pos - entityOrigin) + entityOrigin;\n gl_Position = viewportScale * (viewportTranslation + vec4(pos, 1.0/(1.0+exp(aLayer.x) ), 1) );\n vColor = vec4(aColor.rgb*aColor.a*aLayer.y, aColor.a*aLayer.y);\n}","precision mediump float;\nvarying lowp vec4 vColor;\nvoid main(void) {\n\tgl_FragColor = vColor;\n}",[{name:"aPosition",width:2},{name:"aOrientation",width:3},{name:"aLayer",width:2},{name:"aColor",width:4}],function(a,b){a.program.writeVector("aColor",b._red/255,b._green/255,b._blue/255,b._strength)})),d.c("Color",{_red:0,_green:0,_blue:0,_strength:1,_color:"",ready:!0,init:function(){this.__coord=this.__coord||[0,0,0,0],this.bind("Draw",this._drawColor),this._drawLayer&&this._setupColor(this._drawLayer),this.trigger("Invalidate")},events:{LayerAttached:"_setupColor"},remove:function(){this.unbind("Draw",this._drawColor),this.has("DOM")&&(this._element.style.backgroundColor="transparent"),this.trigger("Invalidate")},_setupColor:function(a){"WebGL"===a.type&&this._establishShader("Color",d.defaultShader("Color"))},_drawColor:function(a){this._color&&("DOM"===a.type?(a.style.backgroundColor=this._color,a.style.lineHeight=0):"canvas"===a.type?(a.ctx.fillStyle=this._color,a.ctx.fillRect(a.pos._x,a.pos._y,a.pos._w,a.pos._h)):"webgl"===a.type&&a.program.draw(a,this))},color:function(a){return 0===arguments.length?this._color:(arguments.length>=3?(this._red=arguments[0],this._green=arguments[1],this._blue=arguments[2],"number"==typeof arguments[3]&&(this._strength=arguments[3])):(d.assignColor(a,this),"number"==typeof arguments[1]&&(this._strength=arguments[1])),this._color="rgba("+this._red+", "+this._green+", "+this._blue+", "+this._strength+")",this.trigger("Invalidate"),this)}})},{"../core/core.js":10}],27:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.extend({domHelper:{innerPosition:function(a,b){b=b||{};var c=a.getBoundingClientRect(),d=c.left+(window.pageXOffset?window.pageXOffset:e.body.scrollLeft),f=c.top+(window.pageYOffset?window.pageYOffset:e.body.scrollTop),g=parseInt(this.getStyle(a,"border-left-width")||0,10)||parseInt(this.getStyle(a,"borderLeftWidth")||0,10)||0,h=parseInt(this.getStyle(a,"border-top-width")||0,10)||parseInt(this.getStyle(a,"borderTopWidth")||0,10)||0;return b.x=d+g,b.y=f+h,b},getStyle:function(a,b){var c;return a.currentStyle?c=a.currentStyle[this.camelize(b)]:window.getComputedStyle&&(c=e.defaultView.getComputedStyle(a,null).getPropertyValue(this.csselize(b))),c},camelize:function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},csselize:function(a){return a.replace(/[A-Z]/g,function(a){return a?"-"+a.toLowerCase():""})},translate:function(a,b,c,f){f=f||{};var g,h=e.documentElement,i=e.body;return c?(g=c._viewportRect(),f.x=(a-d.stage.x+(h&&h.scrollLeft||i&&i.scrollLeft||0))/g._scale+g._x,f.y=(b-d.stage.y+(h&&h.scrollTop||i&&i.scrollTop||0))/g._scale+g._y):(g=d.viewport,f.x=(a-d.stage.x+(h&&h.scrollLeft||i&&i.scrollLeft||0))/g._scale-g._x,f.y=(b-d.stage.y+(h&&h.scrollTop||i&&i.scrollTop||0))/g._scale-g._y),f}}})},{"../core/core.js":10}],28:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d._registerLayerTemplate("DOM",{type:"DOM",_changedObjs:[],_div:null,events:{LayerInit:"layerInit",LayerRemove:"layerRemove",RenderScene:"_render",PixelartSet:"_setPixelart"},layerInit:function(){this._changedObjs=[];var a=this._div=e.createElement("div");d.stage.elem.appendChild(a),a.style.position="absolute",a.style.zIndex=this.options.z,a.style.transformStyle="preserve-3d"},layerRemove:function(){this._div.parentNode.removeChild(this._div)},_setPixelArt:function(a){var b=this._div.style,c=d.domHelper.camelize;a?(b[c("image-rendering")]="optimizeSpeed",b[c("image-rendering")]="-moz-crisp-edges",b[c("image-rendering")]="-o-crisp-edges",b[c("image-rendering")]="-webkit-optimize-contrast",b[c("-ms-interpolation-mode")]="nearest-neighbor",b[c("image-rendering")]="optimize-contrast",b[c("image-rendering")]="pixelated",b[c("image-rendering")]="crisp-edges"):(b[c("image-rendering")]="optimizeQuality",b[c("-ms-interpolation-mode")]="bicubic",b[c("image-rendering")]="auto")},debug:function(){d.log(this._changedObjs)},_render:function(){var a=this._changedObjs;if(this._dirtyViewport&&(this._setViewport(),this._dirtyViewport=!1),a.length){for(var b=0,c=a.length;b=0&&this._drawLayers.splice(b,1),this._drawLayers.sort(function(a,b){return a.options.z-b.options.z})},_registerLayerTemplate:function(a,b){this._drawLayerTemplates[a]=b;var c=this._commonLayerProperties;for(var d in c)b[d]||(b[d]=c[d])},_commonLayerProperties:{options:{xResponse:1,yResponse:1,scaleResponse:1,z:0},_pointerEntities:0,_dirtyViewport:!1,_cachedViewportRect:null,init:function(){this._cachedViewportRect={},this.trigger("LayerInit"),this.uniqueBind("InvalidateViewport",function(){this._dirtyViewport=!0}),this.trigger("PixelartSet",d._pixelartEnabled),d._addDrawLayerInstance(this)},remove:function(){this.trigger("LayerRemove"),d._removeDrawLayerInstance(this)},_sort:function(a,b){return a._globalZ-b._globalZ},_viewportRect:function(a){var b=this._cachedViewportRect;if(a)return b;var c=d.viewport,e=this.options,f=Math.pow(c._scale,e.scaleResponse);return b._scale=f,b._w=c._width/f,b._h=c._height/f,b._x=e.xResponse*-c._x-.5*(e.xResponse-1)*(1-1/f)*c._width,b._y=e.yResponse*-c._y-.5*(e.yResponse-1)*(1-1/f)*c._height,b},_viewTransformRect:function(a,b,c){var d=this._viewportRect(c),e=d._scale;return b=b||{},b._x=a._x*e+Math.round(-d._x*e),b._y=a._y*e+Math.round(-d._y*e),b._w=a._w*e,b._h=a._h*e,b}},createLayer:function(a,b,c){var e=this._drawLayerTemplates[b];d.s(a,e,c),d.c(a,{init:function(){this.requires("Renderable"),this._customLayer=!0,this.requires(e.type),this._attachToLayer(d.s(a))},remove:function(){this._detachFromLayer()}})}})},{"../core/core.js":10}],35:[function(a,b,c){var d=a("../core/core.js");d.c("Particles",{required:"Renderable",ready:!0,_particlesPaused:!1,init:function(){this._Particles=d.clone(this._Particles),this._Particles.init(),this._Particles.parentEntity=this},events:{UpdateFrame:function(){!this._particlesPaused&&this._Particles.active&&(this._Particles.update(),this.trigger("Invalidate"))},Draw:function(a){this._Particles.active&&"canvas"===a.type&&this._Particles.render(a)}},particles:function(a){return this._Particles.config(a),this._Particles.start(),this},_Particles:{presets:{maxParticles:150,size:18,sizeRandom:4,speed:1,speedRandom:1.2,lifeSpan:29,lifeSpanRandom:7,angle:65,angleRandom:34,startColour:[255,131,0,1],startColourRandom:[48,50,45,0],endColour:[245,35,0,0],endColourRandom:[60,60,60,0],sharpness:20,sharpnessRandom:10,spread:10,duration:-1,fastMode:!1,gravity:{x:0,y:.1},jitter:0,originOffset:{x:0,y:0}},emissionRate:0,elapsedFrames:0,emitCounter:0,active:!0,particles:[],init:function(){for(var a in this.presets)this[a]=this.presets[a]},config:function(a){a=a||{};for(var b in a)this[b]=a[b];if(this.emissionRate=this.maxParticles/this.lifeSpan,this.particles.length!==this.maxParticles){this.particles.length=0;for(var c=0,d=this.maxParticles;c100?100:f<0?0:f,a.sizeSmall=~~(d/200*f),g=h=this.startColour[0]+this.startColourRandom[0]*this.RANDM1TO1(),a.colourR=g>255?255:g<0?0:~~g,g=i=this.startColour[1]+this.startColourRandom[1]*this.RANDM1TO1(),a.colourG=g>255?255:g<0?0:~~g,g=j=this.startColour[2]+this.startColourRandom[2]*this.RANDM1TO1(),a.colourB=g>255?255:g<0?0:~~g,g=k=this.startColour[3]+this.startColourRandom[3]*this.RANDM1TO1(),a.colourA=g>1?1:g<0?0:~~(100*g)/100,l=this.endColour[0]+this.endColourRandom[0]*this.RANDM1TO1(),m=this.endColour[1]+this.endColourRandom[1]*this.RANDM1TO1(),n=this.endColour[2]+this.endColourRandom[2]*this.RANDM1TO1(),o=this.endColour[3]+this.endColourRandom[3]*this.RANDM1TO1(),a.deltaColourR=(l-h)/e,a.deltaColourG=(m-i)/e,a.deltaColourB=(n-j)/e,a.deltaColourA=(o-k)/e},update:function(){var a=this.RANDM1TO1,b=this.gravity.x,c=this.gravity.y,d=this.jitter;this.elapsedFrames++,this.duration>=0&&this.duration0?1/this.emissionRate:1/0;this.emitCounter++;for(var f,g,h=this.particles,i=0,j=h.length;i0?(g.directionX+=b,g.directionY+=c,g.positionX+=g.directionX,g.positionY+=g.directionY,d&&(g.positionX+=d*a(),g.positionY+=d*a()),f=g.colourR+g.deltaColourR,g.colourR=f>255?255:f<0?0:~~f,f=g.colourG+g.deltaColourG,g.colourG=f>255?255:f<0?0:~~f,f=g.colourB+g.deltaColourB,g.colourB=f>255?255:f<0?0:~~f,f=g.colourA+g.deltaColourA,g.colourA=f>1?1:f<0?0:~~(100*f)/100,g.timeToLive--):this.emitCounter>e&&(this.initParticle(g),this.emitCounter-=e)},render:function(a){for(var b,c=a.ctx,d=this.particles,e=0,f=d.length;e>1;if(!(b.positionX<0||b.positionX+g>a.pos._w||b.positionY<0||b.positionY+g>a.pos._h)){var i=~~(a.pos._x+b.positionX),j=~~(a.pos._y+b.positionY),k=b.colourR,l=b.colourG,m=b.colourB,n=b.colourA,o="rgba("+k+","+l+","+m+","+n+")";if(this.fastMode)c.fillStyle=o;else{var p="rgba("+k+","+l+","+m+",0)",q=c.createRadialGradient(i+h,j+h,b.sizeSmall,i+h,j+h,h);q.addColorStop(0,o),q.addColorStop(.9,p),c.fillStyle=q}c.fillRect(i,j,g,g)}}},Particle:function(){this.positionX=0,this.positionY=0,this.directionX=0,this.directionY=0,this.size=0,this.sizeSmall=0,this.timeToLive=0,this.colourR=0,this.colourG=0,this.colourB=0,this.colourA=0,this.deltaColourR=0,this.deltaColourG=0,this.deltaColourB=0,this.deltaColourA=0,this.sharpness=0},RANDM1TO1:function(){return 2*Math.random()-1}},pauseParticles:function(){this._particlesPaused=!0},resumeParticles:function(){this._particlesPaused=!1}})},{"../core/core.js":10}],36:[function(a,b,c){a("../core/core.js").c("Renderable",{_changed:!1,_alpha:1,_visible:!0,_setterRenderable:function(a,b){this[a]!==b&&(this[a]=b,this.trigger("Invalidate"))},properties:{alpha:{set:function(a){this._setterRenderable("_alpha",a)},get:function(){return this._alpha},configurable:!0,enumerable:!0},_alpha:{enumerable:!1},visible:{set:function(a){this._setterRenderable("_visible",a)},get:function(){return this._visible},configurable:!0,enumerable:!0},_visible:{enumerable:!1}},init:function(){},_hideOnUnfreeze:!1,events:{Freeze:function(){this._hideOnUnfreeze=!this._visible,this._visible=!1,this.trigger("Invalidate")},Unfreeze:function(){this._visible=!this._hideOnUnfreeze,this.trigger("Invalidate")}},_invalidateRenderable:function(){!1===this._changed&&(this._changed=!0,this._drawLayer.dirty(this))},_attachToLayer:function(a){this._drawLayer&&this._detachFromLayer(),this._drawLayer=a,a.attach(this),this.bind("Invalidate",this._invalidateRenderable),this.trigger("LayerAttached",a),this.trigger("Invalidate")},_detachFromLayer:function(){this._drawLayer&&(this._drawLayer.detach(this),this.unbind("Invalidate",this._invalidateRenderable),this.trigger("LayerDetached",this._drawLayer),delete this._drawLayer)},flip:function(a){return a=a||"X",this["_flip"+a]||(this["_flip"+a]=!0,this.trigger("Invalidate")),this},unflip:function(a){return a=a||"X",this["_flip"+a]&&(this["_flip"+a]=!1,this.trigger("Invalidate")),this}})},{"../core/core.js":10}],37:[function(a,b,c){var d=a("../core/core.js");d.c("SpriteAnimation",{_reels:null,_currentReelId:null,_currentReel:null,_isPlaying:!1,animationSpeed:1,init:function(){this._reels={}},reel:function(a,b,c,e,f,g){if(0===arguments.length)return this._currentReelId;if(1===arguments.length&&"string"==typeof a){if(void 0===this._reels[a])throw"The specified reel "+a+" is undefined.";return this.pauseAnimation(),this._currentReelId!==a&&(this._currentReelId=a,this._currentReel=this._reels[a],this._updateSprite(),this.trigger("ReelChange",this._currentReel)),this}var h,i;if(h={id:a,frames:[],currentFrame:0,easing:new d.easing(b),defaultLoops:1},h.duration=h.easing.duration,"number"==typeof c)if(g=g||1/0,f>=0)for(i=0;i=g&&(c=0,e++);else for(i=0;i>f;--i)h.frames.push([c,e]),--c<0&&(c=g-1,e--);else{if(3!==arguments.length||"object"!=typeof c)throw"Unrecognized arguments. Please see the documentation for 'reel(...)'.";h.frames=c}return this._reels[a]=h,this},animate:function(a,b){"string"==typeof a&&this.reel(a);var c=this._currentReel;if(void 0===c||null===c)throw"No reel is specified, and there is no currently active reel.";return this.pauseAnimation(),void 0===b&&(b="number"==typeof a?a:1),c.easing.reset(),this.loops(b),this._setFrame(0),this.bind("UpdateFrame",this._animationTick),this._isPlaying=!0,this.trigger("StartAnimation",c),this},resumeAnimation:function(){return!1===this._isPlaying&&null!==this._currentReel&&(this.bind("UpdateFrame",this._animationTick),this._isPlaying=!0,this._currentReel.easing.resume(),this.trigger("StartAnimation",this._currentReel)),this},pauseAnimation:function(){return!0===this._isPlaying&&(this.unbind("UpdateFrame",this._animationTick),this._isPlaying=!1,this._reels[this._currentReelId].easing.pause()),this},resetAnimation:function(){var a=this._currentReel;if(null===a)throw"No active reel to reset.";return this.reelPosition(0),a.easing.repeat(a.defaultLoops),this},loops:function(a){return 0===arguments.length?null!==this._currentReel?this._currentReel.easing.loops:0:(null!==this._currentReel&&(a<0&&(a=1/0),this._currentReel.easing.repeat(a),this._currentReel.defaultLoops=a),this)},reelPosition:function(a){if(null===this._currentReel)throw"No active reel.";if(0===arguments.length)return this._currentReel.currentFrame;var b,c=this._currentReel.frames.length;if("end"===a&&(a=c-1),a<1&&a>0)b=a,a=Math.floor(c*b);else{if(a!==Math.floor(a))throw"Position "+a+" is invalid.";a<0&&(a=c-1+a),b=a/c}return a=Math.min(a,c-1),a=Math.max(a,0),this._setProgress(b),this._setFrame(a),this},reelFrame:function(a){if(null===this._currentReel)throw"No active reel.";var b=this._currentReel.frames.indexOf(a);if(-1===b)throw"Frame name "+a+" is invalid.";return this.reelPosition(b),this},_animationTick:function(a){var b=this._reels[this._currentReelId];b.easing.tick(a.dt*this.animationSpeed);var c=b.easing.value(),d=Math.min(Math.floor(b.frames.length*c),b.frames.length-1);this._setFrame(d),!0===b.easing.complete&&(this.pauseAnimation(),this.trigger("AnimationEnd",this._currentReel))},_setFrame:function(a){var b=this._currentReel;a!==b.currentFrame&&(b.currentFrame=a,this._updateSprite(),this.trigger("FrameChange",b))},_updateSprite:function(){var a=this._currentReel,b=a.frames[a.currentFrame];"string"==typeof b?this.sprite(b):this.sprite(b[0],b[1])},_setProgress:function(a,b){this._currentReel.easing.setProgress(a,b)},isPlaying:function(a){return!!this._isPlaying&&(a?this._currentReelId===a:!!this._currentReelId)},getReel:function(a){if(0===arguments.length){if(!this._currentReelId)return null;a=this._currentReelId}return this._reels[a]}})},{"../core/core.js":10}],38:[function(a,b,c){var d=a("../core/core.js");d.defaultShader("Sprite",new d.WebGLShader("attribute vec2 aPosition;\nattribute vec3 aOrientation;\nattribute vec2 aLayer;\nattribute vec2 aTextureCoord;\n\nvarying mediump vec3 vTextureCoord;\n\nuniform vec4 uViewport;\nuniform mediump vec2 uTextureDimensions;\n\nmat4 viewportScale = mat4(2.0 / uViewport.z, 0, 0, 0, 0, -2.0 / uViewport.w, 0,0, 0, 0,1,0, -1,+1,0,1);\nvec4 viewportTranslation = vec4(uViewport.xy, 0, 0);\n\nvoid main() {\n vec2 pos = aPosition;\n vec2 entityOrigin = aOrientation.xy;\n mat2 entityRotationMatrix = mat2(cos(aOrientation.z), sin(aOrientation.z), -sin(aOrientation.z), cos(aOrientation.z));\n \n pos = entityRotationMatrix * (pos - entityOrigin) + entityOrigin ;\n gl_Position = viewportScale * (viewportTranslation + vec4(pos, 1.0/(1.0+exp(aLayer.x) ), 1) );\n vTextureCoord = vec3(aTextureCoord, aLayer.y);\n}","varying mediump vec3 vTextureCoord;\n \nuniform sampler2D uSampler;\nuniform mediump vec2 uTextureDimensions;\n\nvoid main(void) {\n highp vec2 coord = vTextureCoord.xy / uTextureDimensions;\n mediump vec4 base_color = texture2D(uSampler, coord);\n gl_FragColor = vec4(base_color.rgb*base_color.a*vTextureCoord.z, base_color.a*vTextureCoord.z);\n}",[{name:"aPosition",width:2},{name:"aOrientation",width:3},{name:"aLayer",width:2},{name:"aTextureCoord",width:2}],function(a,b){var c=a.co;a.program.writeVector("aTextureCoord",c.x,c.y,c.x,c.y+c.h,c.x+c.w,c.y,c.x+c.w,c.y+c.h)})),d.extend({sprite:function(a,b,c,e,f,g,h){var i,j,k;"string"==typeof a&&(g=f,f=e,e=b,c=a,a=1,b=1),"string"==typeof b&&(g=f,f=e,e=c,c=b,b=a),!g&&f&&(g=f),f=parseInt(f||0,10),g=parseInt(g||0,10);var l=function(){this.ready=!0,this.trigger("Invalidate")};(k=d.asset(c))||(k=new Image,k.src=c,d.asset(c,k),k.onload=function(){for(var a in e)d(a).each(l)});var m=function(){this.requires("2D, Sprite"),this.__trim=[0,0,0,0],this.__image=c,this.__map=e,this.__coord=[this.__coord[0],this.__coord[1],this.__coord[2],this.__coord[3]],this.__tile=a,this.__tileh=b,this.__padding=[f,g],this.__padBorder=h,this.sprite(this.__coord[0],this.__coord[1],this.__coord[2],this.__coord[3]),this.img=k,this.img.complete&&this.img.width>0&&(this.ready=!0,this.trigger("Invalidate")),this.w=this.__coord[2],this.h=this.__coord[3],this._setupSpriteImage(this._drawLayer)};for(i in e)e.hasOwnProperty(i)&&(j=e[i],d.c(i,{ready:!1,__coord:[j[0],j[1],j[2]||1,j[3]||1],init:m}));return this}}),d.c("Sprite",{__image:"",__tile:0,__tileh:0,__padding:null,__trim:null,img:null,ready:!1,init:function(){this.__trim=[0,0,0,0],this.bind("Draw",this._drawSprite),this.bind("LayerAttached",this._setupSpriteImage)},remove:function(){this.unbind("Draw",this._drawSprite),this.unbind("LayerAttached",this._setupSpriteImage)},_setupSpriteImage:function(a){this.__image&&this.img&&a&&"WebGL"===a.type&&(this._establishShader(this.__image,d.defaultShader("Sprite")),this.program.setTexture(a.makeTexture(this.__image,this.img,!1)))},_drawSprite:function(a){var b=a.co,c=a.pos,d=a.ctx;if("canvas"===a.type)d.drawImage(this.img,b.x,b.y,b.w,b.h,c._x,c._y,c._w,c._h);else if("DOM"===a.type){var e=this._h/b.h,f=this._w/b.w,g=this._element.style,h=g.backgroundColor;"initial"===h&&(h="");var i=h+" url('"+this.__image+"') no-repeat";i!==g.background&&(g.background=i),g.backgroundPosition="-"+b.x*f+"px -"+b.y*e+"px",1===e&&1===f||(g.backgroundSize=this.img.width*f+"px "+this.img.height*e+"px")}else"webgl"===a.type&&a.program.draw(a,this)},sprite:function(a,b,c,d){if("string"==typeof a){var e=this.__map[a];if(!e)return this;a=e[0],b=e[1],c=e[2]||1,d=e[3]||1}return this.__coord=this.__coord||[0,0,0,0],this.__coord[0]=a*(this.__tile+this.__padding[0])+(this.__padBorder?this.__padding[0]:0)+this.__trim[0],this.__coord[1]=b*(this.__tileh+this.__padding[1])+(this.__padBorder?this.__padding[1]:0)+this.__trim[1],void 0!==c&&void 0!==d&&(this.__coord[2]=this.__trim[2]||c*this.__tile||this.__tile,this.__coord[3]=this.__trim[3]||d*this.__tileh||this.__tileh),this.trigger("Invalidate"),this},crop:function(a,b,c,d){var e=this._mbr||this.pos();return this.__trim=[],this.__trim[0]=a,this.__trim[1]=b,this.__trim[2]=c,this.__trim[3]=d,this.__coord[0]+=a,this.__coord[1]+=b,this.__coord[2]=c,this.__coord[3]=d,this._w=c,this._h=d,this.trigger("Invalidate",e),this}})},{"../core/core.js":10}],39:[function(a,b,c){var d=a("../core/core.js");d.c("Text",{_text:"",defaultSize:"10px",defaultFamily:"sans-serif",defaultVariant:"normal",defaultLineHeight:"normal",defaultTextAlign:"left",ready:!0,init:function(){this.requires("2D"),this._textFont={type:"",weight:"",size:this.defaultSize,lineHeight:this.defaultLineHeight,family:this.defaultFamily,variant:this.defaultVariant},this._textAlign=this.defaultTextAlign},events:{Draw:function(a){var b=this._fontString();if("DOM"===a.type){var c=this._element,d=c.style;d.color=this._textColor,d.font=b,d.textAlign=this._textAlign,c.innerHTML=this._text}else if("canvas"===a.type){var e=a.ctx;e.save(),e.textBaseline="top",e.fillStyle=this._textColor||"rgb(0,0,0)",e.font=b,e.textAlign=this._textAlign,e.fillText(this._text,a.pos._x,a.pos._y),e.restore()}},SetStyle:function(a){switch(a){case"textAlign":this._textAlign=this._element.style.textAlign;break;case"color":this.textColor(this._element.style.color);break;case"fontType":this._textFont.type=this._element.style.fontType;break;case"fontWeight":this._textFont.weight=this._element.style.fontWeight;break;case"fontSize":this._textFont.size=this._element.style.fontSize;break;case"fontFamily":this._textFont.family=this._element.style.fontFamily;break;case"fontVariant":this._textFont.variant=this._element.style.fontVariant;break;case"lineHeight":this._textFont.lineHeight=this._element.style.lineHeight}}},remove:function(){this.unbind(this._textUpdateEvent,this._dynamicTextUpdate)},_getFontHeight:function(){var a=/([a-zA-Z]+)\b/,b={px:1,pt:4/3,pc:16,cm:96/2.54,mm:96/25.4,in:96,em:void 0,ex:void 0};return function(c){var d=parseFloat(c),e=a.exec(c),f=e?e[1]:"px";return void 0!==b[f]?Math.ceil(d*b[f]):Math.ceil(d)}}(),_textGenerator:null,text:function(a,b){return void 0===a||null===a?this._text:("function"==typeof a?(this._text=a.call(this,b),this._textGenerator=a):(this._text=a,this._textGenerator=null),this.has("Canvas")&&this._resizeForCanvas(),this.trigger("Invalidate"),this)},_dynamicTextOn:!1,_textUpdateEvent:null,_dynamicTextUpdate:function(a){this._textGenerator&&this.text(this._textGenerator,a)},dynamicTextGeneration:function(a,b){return this.unbind(this._textUpdateEvent,this._dynamicTextUpdate),a&&(this._textUpdateEvent=b||"UpdateFrame",this.bind(this._textUpdateEvent,this._dynamicTextUpdate)),this},_resizeForCanvas:function(){var a=this._drawContext;a.font=this._fontString(),this.w=a.measureText(this._text).width;var b=this._textFont.size||this.defaultSize;this.h=1.1*this._getFontHeight(b),"left"===this._textAlign||"start"===this._textAlign?this.offsetBoundary(0,0,0,0):"center"===this._textAlign?this.offsetBoundary(this.w/2,0,-this.w/2,0):"end"!==this._textAlign&&"right"!==this._textAlign||this.offsetBoundary(this.w,0,-this.w,0)},_fontString:function(){return this._textFont.type+" "+this._textFont.variant+" "+this._textFont.weight+" "+this._textFont.size+" / "+this._textFont.lineHeight+" "+this._textFont.family},textColor:function(a){return d.assignColor(a,this),this._textColor="rgba("+this._red+", "+this._green+", "+this._blue+", "+this._strength+")",this.trigger("Invalidate"),this},textAlign:function(a){return this._textAlign=a,this.has("Canvas")&&this._resizeForCanvas(),this.trigger("Invalidate"),this},textFont:function(a,b){if(1===arguments.length){if("string"==typeof a)return this._textFont[a];if("object"==typeof a)for(var c in a)this._textFont[c]="family"===c?"'"+a[c]+"'":a[c]}else this._textFont[a]=b;return this.has("Canvas")&&this._resizeForCanvas(),this.trigger("Invalidate"),this},unselectable:function(){return this.has("DOM")&&(this.css({"-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",cursor:"default"}),this.trigger("Invalidate")),this}})},{"../core/core.js":10}],40:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.extend({viewport:{clampToEntities:!0,_width:0,_height:0,_x:0,_y:0,_scale:1,bounds:null,scroll:function(a,b){this[a]=b,d.trigger("ViewportScroll"),d.trigger("InvalidateViewport")},rect_object:{_x:0,_y:0,_w:0,_h:0},rect:function(a){return a=a||this.rect_object,a._x=-this._x,a._y=-this._y,a._w=this._width/this._scale,a._h=this._height/this._scale,a},pan:function(){function a(a){h.tick(a.dt);var i=h.value();d.viewport.x=(1-i)*f+i*c,d.viewport.y=(1-i)*g+i*e,d.viewport._clamp(),h.complete&&(b(),d.trigger("CameraAnimationDone"))}function b(){d.unbind("UpdateFrame",a)}var c,e,f,g,h;return d._preBind("StopCamera",b),function(b,i,j,k){d.trigger("StopCamera"),"reset"!==b&&(f=d.viewport._x,g=d.viewport._y,c=f-b,e=g-i,h=new d.easing(j,k),d.uniqueBind("UpdateFrame",a))}}(),follow:function(){function a(){var a=d.viewport._scale;d.viewport.scroll("_x",-(this.x+this.w/2-d.viewport.width/2/a-e*a)),d.viewport.scroll("_y",-(this.y+this.h/2-d.viewport.height/2/a-f*a)),d.viewport._clamp()}function b(){c&&(c.unbind("Move",a),c.unbind("ViewportScale",a),c.unbind("ViewportResize",a))}var c,e,f;return d._preBind("StopCamera",b),function(b,g,h){b&&b.has("2D")&&(d.trigger("StopCamera"),c=b,e=void 0!==g?g:0,f=void 0!==h?h:0,b.bind("Move",a),b.bind("ViewportScale",a),b.bind("ViewportResize",a),a.call(b))}}(),centerOn:function(a,b){var c=a.x+d.viewport.x,e=a.y+d.viewport.y,f=a.w/2,g=a.h/2,h=d.viewport.width/2/d.viewport._scale,i=d.viewport.height/2/d.viewport._scale,j=c+f-h,k=e+g-i;d.viewport.pan(j,k,b)},zoom:function(){function a(){d.unbind("UpdateFrame",b)}function b(b){var e,l;k.tick(b.dt),e=Math.pow(f,k.value()),l=1===f?k.value():(1/e-1)/(1/f-1),d.viewport.scale(e*c),d.viewport.scroll("_x",g*(1-l)+h*l),d.viewport.scroll("_y",i*(1-l)+j*l),d.viewport._clamp(),k.complete&&(a(),d.trigger("CameraAnimationDone"))}d._preBind("StopCamera",a);var c,e,f,g,h,i,j,k;return function(a,l,m,n,o){if(!a)return void d.viewport.scale(1);arguments.length<=2&&(n=l,l=d.viewport.x-d.viewport.width,m=d.viewport.y-d.viewport.height),d.trigger("StopCamera"),c=d.viewport._scale,f=a,e=c*f,g=d.viewport.x,i=d.viewport.y,h=-(l-d.viewport.width/(2*e)),j=-(m-d.viewport.height/(2*e)),k=new d.easing(n,o),d.uniqueBind("UpdateFrame",b)}}(),scale:function(){return function(a){this._scale=a||1,d.trigger("InvalidateViewport"),d.trigger("ViewportScale")}}(),mouselook:function(){function a(a){g||a.target||(d.trigger("StopCamera"),h.x=a.clientX,h.y=a.clientY,g=!0)}function b(a){if(g){i.x=a.clientX-h.x,i.y=a.clientY-h.y,h.x=a.clientX,h.y=a.clientY;var b=d.viewport;b.x+=i.x/b._scale,b.y+=i.y/b._scale,b._clamp()}}function c(a){g&&(g=!1)}var e,f=!1,g=!1,h={x:0,y:0},i={x:0,y:0};return function(g){e=d.s("Mouse"),g&&!f?(e.bind("MouseDown",a),e.bind("MouseMove",b),e.bind("MouseUp",c),f=g):!g&&f&&(e.unbind("MouseDown",a),e.unbind("MouseMove",b),e.unbind("MouseUp",c),f=g)}}(),_clamp:function(){if(this.clampToEntities){var a=d.clone(this.bounds)||d.map.boundaries();a.max.x*=this._scale,a.min.x*=this._scale,a.max.y*=this._scale,a.min.y*=this._scale,a.max.x-a.min.x>d.viewport.width?d.viewport.x<(-a.max.x+d.viewport.width)/this._scale?d.viewport.x=(-a.max.x+d.viewport.width)/this._scale:d.viewport.x>-a.min.x&&(d.viewport.x=-a.min.x):d.viewport.x=-1*(a.min.x+(a.max.x-a.min.x)/2-d.viewport.width/2),a.max.y-a.min.y>d.viewport.height?d.viewport.y<(-a.max.y+d.viewport.height)/this._scale?d.viewport.y=(-a.max.y+d.viewport.height)/this._scale:d.viewport.y>-a.min.y&&(d.viewport.y=-a.min.y):d.viewport.y=-1*(a.min.y+(a.max.y-a.min.y)/2-d.viewport.height/2)}},init:function(a,b,c){void 0===c&&void 0===b&&void 0!==a&&"number"!=typeof a&&(c=a,a=window.innerWidth,b=window.innerHeight),d.createLayer("DefaultCanvasLayer","Canvas",{z:20}),d.createLayer("DefaultDOMLayer","DOM",{z:30}),d.createLayer("DefaultWebGLLayer","WebGL",{z:10}),this._defineViewportProperties(),this._x=0,this._y=0,this._scale=1,this.bounds=null,this._width=a||window.innerWidth,this._height=b||window.innerHeight,void 0===c&&(c="cr-stage");var f;if("string"==typeof c)f=e.getElementById(c);else{if(!("undefined"!=typeof HTMLElement?c instanceof HTMLElement:c instanceof Element))throw new TypeError("stage_elem must be a string or an HTMLElement");f=c}d.stage={x:0,y:0,fullscreen:!1,elem:f||e.createElement("div")},a||b||(e.body.style.overflow="hidden",d.stage.fullscreen=!0),d.addEvent(this,window,"resize",d.viewport.reload),d.addEvent(this,window,"blur",function(){d.settings.get("autoPause")&&(d._paused||d.pause())}),d.addEvent(this,window,"focus",function(){d._paused&&d.settings.get("autoPause")&&d.pause()}),d.settings.register("stageSelectable",function(a){d.stage.elem.onselectstart=a?function(){return!0}:function(){return!1}}),d.settings.modify("stageSelectable",!1),d.settings.register("stageContextMenu",function(a){d.stage.elem.oncontextmenu=a?function(){return!0}:function(){return!1}}),d.settings.modify("stageContextMenu",!1),d.settings.register("autoPause",function(){}),d.settings.modify("autoPause",!1),f||(e.body.appendChild(d.stage.elem),d.stage.elem.id=c);var g,h=d.stage.elem.style;if(h.width=this.width+"px",h.height=this.height+"px",h.overflow="hidden",d.bind("ViewportResize",function(){d.trigger("InvalidateViewport")}),d.mobile){void 0!==typeof h.webkitTapHighlightColor&&(h.webkitTapHighlightColor="rgba(0,0,0,0)");var i=e.createElement("meta"),j=e.getElementsByTagName("head")[0];i=e.createElement("meta"),i.setAttribute("name","apple-mobile-web-app-capable"),i.setAttribute("content","yes"),j.appendChild(i),d.addEvent(this,d.stage.elem,"touchmove",function(a){a.preventDefault()})}h.position="relative",g=d.domHelper.innerPosition(d.stage.elem),d.stage.x=g.x,d.stage.y=g.y,d.uniqueBind("ViewportResize",this._resize)},_resize:function(){d.stage.elem.style.width=d.viewport.width+"px",d.stage.elem.style.height=d.viewport.height+"px"},_defineViewportProperties:function(){Object.defineProperty(this,"x",{set:function(a){this.scroll("_x",a)},get:function(){return this._x},configurable:!0}),Object.defineProperty(this,"y",{set:function(a){this.scroll("_y",a)},get:function(){return this._y},configurable:!0}),Object.defineProperty(this,"width",{set:function(a){this._width=a,d.trigger("ViewportResize")},get:function(){return this._width},configurable:!0}),Object.defineProperty(this,"height",{set:function(a){this._height=a,d.trigger("ViewportResize")},get:function(){return this._height},configurable:!0})},reload:function(){var a,b=window.innerWidth,c=window.innerHeight;d.stage.fullscreen&&(this._width=b,this._height=c,d.trigger("ViewportResize")),a=d.domHelper.innerPosition(d.stage.elem),d.stage.x=a.x,d.stage.y=a.y},reset:function(){d.viewport.mouselook(!1),d.trigger("StopCamera"),d.viewport.scroll("_x",0),d.viewport.scroll("_y",0),d.viewport.scale(1)},onScreen:function(a){return d.viewport._x+a._x+a._w>0&&d.viewport._y+a._y+a._h>0&&d.viewport._x+a._x=this.max_size)){var b=Math.min(a,this.max_size),c=new Float32Array(4*b*this.stride),d=new Uint16Array(6*b);c.set(this._attributeArray),d.set(this._indexArray),this._attributeArray=c,this._indexArray=d,this.array_size=b}},registerEntity:function(a){if(0===this._registryHoles.length){if(this._registrySize>=this.max_size)throw"Number of entities exceeds maximum limit.";this._registrySize>=this.array_size&&this.growArrays(2*this.array_size),a._glBufferIndex=this._registrySize,this._registrySize++}else a._glBufferIndex=this._registryHoles.pop()},unregisterEntity:function(a){"number"==typeof a._glBufferIndex&&this._registryHoles.push(a._glBufferIndex),a._glBufferIndex=null},resetRegistry:function(){this._maxElement=0,this._registryHoles.length=0},setCurrentEntity:function(a){this.ent_offset=4*a._glBufferIndex,this.ent=a},switchTo:function(){var a=this.context;a.useProgram(this.shader),a.bindBuffer(a.ARRAY_BUFFER,this._attributeBuffer);for(var b,c=this.attributes,d=0;d0?1:-1,e={acceleration:b,rawAcceleration:"["+Math.round(b.x)+", "+Math.round(b.y)+", "+Math.round(b.z)+"]",facingUp:c,tiltLR:Math.round(b.x/9.81*-90),tiltFB:Math.round((b.y+9.81)/9.81*90*c)};d.device._deviceMotionCallback(e)},deviceOrientation:function(a){this._deviceOrientationCallback=a,d.support.deviceorientation&&(window.DeviceOrientationEvent?d.addEvent(this,window,"deviceorientation",this._normalizeDeviceOrientation):window.OrientationEvent&&d.addEvent(this,window,"MozOrientation",this._normalizeDeviceOrientation))},deviceMotion:function(a){this._deviceMotionCallback=a,d.support.devicemotion&&window.DeviceMotionEvent&&d.addEvent(this,window,"devicemotion",this._normalizeDeviceMotion)}}})},{"../core/core.js":10}],44:[function(a,b,c){b.exports={_events:{},addEvent:function(a,b,c,d){3===arguments.length&&(d=c,c=b,b=window.document);var e=a[0]||"",f=function(b){d.call(a,b)};this._events[e+b+c+d]||(this._events[e+b+c+d]=f,b.addEventListener(c,f,!1))},removeEvent:function(a,b,c,d){3===arguments.length&&(d=c,c=b,b=window.document);var e=a[0]||"",f=this._events[e+b+c+d];f&&(b.removeEventListener(c,f,!1),delete this._events[e+b+c+d])}}},{}],45:[function(a,b,c){var d=a("../core/core.js");d.s("Keyboard",d.extend.call(d.extend.call(new d.__eventDispatcher,{_evt:{eventName:"",key:0,which:0,originalEvent:null},prepareEvent:function(a){var b=this._evt,c=a.type;return b.eventName="keydown"===c?"KeyDown":"keyup"===c?"KeyUp":c,b.which=null!==a.charCode?a.charCode:a.keyCode,b.key=a.keyCode||a.which,b.originalEvent=a,b},triggerKeyEvent:function(a,b){d.trigger(a,b)},dispatchEvent:function(a){var b=this.prepareEvent(a);this.triggerKey(b.eventName,b)}}),d.__keyboardStateTemplate),{},!1),d.c("Keyboard",{isDown:function(a){return d.s("Keyboard").isKeyDown(a)}})},{"../core/core.js":10}],46:[function(a,b,c){var d=a("../core/core.js"),e=window.document,f=void 0!==e.onwheel?"wheel":void 0!==e.onmousewheel?"mousewheel":"DOMMouseScroll";d._preBind("Load",function(){d.addEvent(this,e.body,"mouseup",d.detectBlur),d.addEvent(d.s("Keyboard"),window,"blur",d.s("Keyboard").resetKeyDown),d.addEvent(d.s("Mouse"),window,"mouseup",d.s("Mouse").resetButtonDown),d.addEvent(d.s("Touch"),window,"touchend",d.s("Touch").resetTouchPoints),d.addEvent(d.s("Touch"),window,"touchcancel",d.s("Touch").resetTouchPoints),d.addEvent(d.s("Keyboard"),"keydown",d.s("Keyboard").processEvent),d.addEvent(d.s("Keyboard"),"keyup",d.s("Keyboard").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"mousedown",d.s("Mouse").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"mouseup",d.s("Mouse").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"mousemove",d.s("Mouse").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"click",d.s("Mouse").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"dblclick",d.s("Mouse").processEvent),d.addEvent(this,d.stage.elem,"touchstart",this._touchDispatch),d.addEvent(this,d.stage.elem,"touchmove",this._touchDispatch),d.addEvent(this,d.stage.elem,"touchend",this._touchDispatch),d.addEvent(this,d.stage.elem,"touchcancel",this._touchDispatch),d.addEvent(this,d.stage.elem,"touchleave",this._touchDispatch),d.addEvent(d.s("MouseWheel"),d.stage.elem,f,d.s("MouseWheel").processEvent)}),d.bind("Pause",function(){d.s("Keyboard").resetKeyDown(),d.s("Mouse").resetButtonDown()}),d._preBind("CraftyStop",function(){d.s("Keyboard").resetKeyDown(),d.s("Mouse").resetButtonDown()}),d._preBind("CraftyStop",function(){d.removeEvent(this,e.body,"mouseup",d.detectBlur),d.removeEvent(d.s("Keyboard"),window,"blur",d.s("Keyboard").resetKeyDown),d.removeEvent(d.s("Mouse"),window,"mouseup",d.s("Mouse").resetButtonDown),d.removeEvent(d.s("Touch"),window,"touchend",d.s("Touch").resetTouchPoints),d.removeEvent(d.s("Touch"),window,"touchcancel",d.s("Touch").resetTouchPoints),d.removeEvent(d.s("Keyboard"),"keydown",d.s("Keyboard").processEvent),d.removeEvent(d.s("Keyboard"),"keyup",d.s("Keyboard").processEvent),d.stage&&(d.removeEvent(d.s("Mouse"),d.stage.elem,"mousedown",d.s("Mouse").processEvent),d.removeEvent(d.s("Mouse"),d.stage.elem,"mouseup",d.s("Mouse").processEvent),d.removeEvent(d.s("Mouse"),d.stage.elem,"mousemove",d.s("Mouse").processEvent),d.removeEvent(d.s("Mouse"),d.stage.elem,"click",d.s("Mouse").processEvent),d.removeEvent(d.s("Mouse"),d.stage.elem,"dblclick",d.s("Mouse").processEvent),d.removeEvent(this,d.stage.elem,"touchstart",this._touchDispatch),d.removeEvent(this,d.stage.elem,"touchmove",this._touchDispatch),d.removeEvent(this,d.stage.elem,"touchend",this._touchDispatch),d.removeEvent(this,d.stage.elem,"touchcancel",this._touchDispatch),d.removeEvent(this,d.stage.elem,"touchleave",this._touchDispatch),d.removeEvent(d.s("MouseWheel"),d.stage.elem,f,d.s("MouseWheel").processEvent))})},{"../core/core.js":10}],47:[function(a,b,c){var d=a("../core/core.js");d.s("MouseWheel",d.extend.call(new d.__eventDispatcher,{_evt:{eventName:"",direction:0,target:null,clientX:0,clientY:0,realX:0,realY:0,originalEvent:null},_mouseSystem:null,prepareEvent:function(a){var b=this._mouseSystem;b||(this._mouseSystem=b=d.s("Mouse"));var c=this._evt;return c.eventName="MouseWheelScroll",c.direction=a.detail<0||a.wheelDelta>0||a.deltaY<0?1:-1,c.clientX=void 0!==a.clientX?a.clientX:b.lastMouseEvent.clientX,c.clientY=void 0!==a.clientY?a.clientY:b.lastMouseEvent.clientY,d.translatePointerEventCoordinates(a,c),c.target=b.mouseObjs?d.findPointerEventTargetByComponent("Mouse",a):null,c.originalEvent=a,c},dispatchEvent:function(a){var b=this.prepareEvent(a);d.trigger("MouseWheelScroll",b)}}),{},!1),d.s("Mouse",d.extend.call(d.extend.call(new d.__eventDispatcher,{normedEventNames:{mousedown:"MouseDown",mouseup:"MouseUp",dblclick:"DoubleClick",click:"Click",mousemove:"MouseMove"},_evt:{eventName:"",mouseButton:-1,target:null,clientX:0,clientY:0,realX:0,realY:0,originalEvent:null},mouseObjs:0,over:null,prepareEvent:function(a){var b=this._evt,c=a.type;return b.eventName=this.normedEventNames[c]||c,void 0===a.which?b.mouseButton=a.button<2?d.mouseButtons.LEFT:4===a.button?d.mouseButtons.MIDDLE:d.mouseButtons.RIGHT:b.mouseButton=a.which<2?d.mouseButtons.LEFT:2===a.which?d.mouseButtons.MIDDLE:d.mouseButtons.RIGHT,b.clientX=a.clientX,b.clientY=a.clientY,d.translatePointerEventCoordinates(a,b),b.target=this.mouseObjs?d.findPointerEventTargetByComponent("Mouse",a):null,b.originalEvent=a,b},triggerMouseEvent:function(a,b){this.trigger(a,b);var c=this.over,d=b.target;"MouseMove"===a&&c!==d&&(c&&(b.eventName="MouseOut",b.target=c,c.trigger("MouseOut",b),b.eventName="MouseMove",b.target=d),this.over=d,d&&(b.eventName="MouseOver",d.trigger("MouseOver",b),b.eventName="MouseMove")),d&&d.trigger(a,b)},dispatchEvent:function(a){var b=this.prepareEvent(a);this.triggerMouse(b.eventName,b)}}),d.__mouseStateTemplate),{},!1),d.c("Mouse",{required:"AreaMap",init:function(){d.s("Mouse").mouseObjs++},remove:function(){d.s("Mouse").mouseObjs--}}),d.c("MouseDrag",{_dragging:!1,required:"Mouse",events:{MouseDown:"_ondown"},init:function(){this._ondown=this._ondown.bind(this),this._ondrag=this._ondrag.bind(this),this._onup=this._onup.bind(this)},_ondown:function(a){a.mouseButton===d.mouseButtons.LEFT&&this.startDrag(a)},_ondrag:function(a){if(!this._dragging||0===a.realX||0===a.realY)return!1;this.trigger("Dragging",a)},_onup:function(a){a.mouseButton===d.mouseButtons.LEFT&&this.stopDrag(a)},startDrag:function(a){if(!this._dragging)return this._dragging=!0,d.s("Mouse").bind("MouseMove",this._ondrag),d.s("Mouse").bind("MouseUp",this._onup),this.trigger("StartDrag",a||d.s("Mouse").lastMouseEvent),this},stopDrag:function(a){if(this._dragging)return this._dragging=!1,d.s("Mouse").unbind("MouseMove",this._ondrag),d.s("Mouse").unbind("MouseUp",this._onup),this.trigger("StopDrag",a||d.s("Mouse").lastMouseEvent),this}})},{"../core/core.js":10}],48:[function(a,b,c){var d=a("../core/core.js");d.extend({findPointerEventTargetByComponent:function(a,b,c){var e=b.target||b.srcElement||d.stage.elem;c=void 0!==c?c:b.clientY,b=void 0!==b.clientX?b.clientX:b;var f,g,h,i,j,k=null,l=-1/0;if("CANVAS"!==e.nodeName){for(;"string"!=typeof e.id&&-1===e.id.indexOf("ent");)e=e.parentNode;var m=d(parseInt(e.id.replace("ent",""),10));j=d.domHelper.translate(b,c,m._drawLayer),m.__c[a]&&m.isAt(j.x,j.y)&&(k=m)}if(!k)for(var n in d._drawLayers){var o=d._drawLayers[n];if(!(o._pointerEntities<=0))for(j=d.domHelper.translate(b,c,o),g=d.map.unfilteredSearch({_x:j.x,_y:j.y,_w:1,_h:1}),i=0,h=g.length;il&&f.__c[a]&&f.isAt(j.x,j.y)&&(l=f._globalZ,k=f)}return k},translatePointerEventCoordinates:function(a,b){b=b||a;var c=d.domHelper.translate(a.clientX,a.clientY,void 0,this.__pointerPos);b.realX=c.x,b.realY=c.y},__pointerPos:{x:0,y:0}}),d.c("AreaMap",{init:function(){this.has("Renderable")&&this._drawLayer&&this._drawLayer._pointerEntities++},remove:function(a){!a&&this.has("Renderable")&&this._drawLayer&&this._drawLayer._pointerEntities--},events:{LayerAttached:function(a){a._pointerEntities++},LayerDetached:function(a){a._pointerEntities--}},areaMap:function(a){if(arguments.length>1){var b=Array.prototype.slice.call(arguments,0);a=new d.polygon(b)}else a=a.constructor===Array?new d.polygon(a.slice()):a.clone();return a.shift(this._x,this._y),this.mapArea=a,this.attach(this.mapArea),this.trigger("NewAreaMap",a),this}}),d.c("Button",{init:function(){var a=!d.mobile||d.mobile&&!d.multitouch()?"Mouse":"Touch";this.requires(a)}})},{"../core/core.js":10}],49:[function(a,b,c){var d=a("../core/core.js");d.extend({multitouch:function(a){return"boolean"!=typeof a?this._multitouch:(this._multitouch=a,this)},_multitouch:!1,_touchDispatch:function(){function a(a){var b,d;"touchstart"===a.type?b="mousedown":"touchmove"===a.type?b="mousemove":"touchend"===a.type?b="mouseup":"touchcancel"===a.type?b="mouseup":"touchleave"===a.type&&(b="mouseup"),a.touches&&a.touches.length?d=a.touches[0]:a.changedTouches&&a.changedTouches.length&&(d=a.changedTouches[0]);var f=document.createEvent("MouseEvent");if(f.initMouseEvent(b,!0,!0,window,1,d.screenX,d.screenY,d.clientX,d.clientY,!1,!1,!1,!1,0,a.relatedTarget),d.target.dispatchEvent(f),"mousedown"===b)c=d.clientX,e=d.clientY;else if("mouseup"===b){var g=d.clientX-c,h=d.clientY-e;g*g+h*h<=256&&(b="click",f=document.createEvent("MouseEvent"),f.initMouseEvent(b,!0,!0,window,1,d.screenX,d.screenY,d.clientX,d.clientY,!1,!1,!1,!1,0,a.relatedTarget),d.target.dispatchEvent(f))}a.preventDefault()}var b,c=0,e=0;return function(c){d._multitouch?(b||(b=d.s("Touch")),b.processEvent(c)):a(c)}}()}),d.s("Touch",d.extend.call(d.extend.call(new d.__eventDispatcher,{normedEventNames:{touchstart:"TouchStart",touchmove:"TouchMove",touchend:"TouchEnd",touchcancel:"TouchCancel"},_evt:{eventName:"",identifier:-1,target:null,entity:null,realX:0,realY:0,originalEvent:null},touchObjs:0,overs:{},prepareEvent:function(a,b){var c=this._evt;return c.eventName=this.normedEventNames[b]||b,c.identifier=a.identifier,d.translatePointerEventCoordinates(a,c),c.target=this.touchObjs?d.findPointerEventTargetByComponent("Touch",a):null,c.entity=c.target,c},triggerTouchEvent:function(a,b){this.trigger(a,b);var c=b.identifier,d=b.target,e=this.overs[c];e&&("TouchMove"===a&&e!==d||"TouchEnd"===a||"TouchCancel"===a)&&(b.eventName="TouchOut",b.target=e,b.entity=e,e.trigger("TouchOut",b),b.eventName=a,b.target=d,b.entity=d,delete this.overs[c]),d&&d.trigger(a,b),d&&("TouchStart"===a||"TouchMove"===a&&e!==d)&&(b.eventName="TouchOver",d.trigger("TouchOver",b),b.eventName=a,this.overs[c]=d)},dispatchEvent:function(a){for(var b,c=a.changedTouches,d=0,e=c.length;d=112&&a.key<=135))return a.stopPropagation?a.stopPropagation():a.cancelBubble=!0,!(!a.target||"INPUT"!==a.target.nodeName&&"TEXTAREA"!==a.target.nodeName)||(a.preventDefault?a.preventDefault():a.returnValue=!1,!1)}},d.extend({selected:!0,detectBlur:function(a){var b=a.clientX>d.stage.x&&a.clientXd.stage.y&&a.clientY0&&e0&&f0?b:a/2,this},place:function(a,b,c,e){var f=this.pos2px(a,b);return f.top-=c*(this._tile.height/2),e.x=f.left+d.viewport._x,e.y=f.top+d.viewport._y,e.z+=c,this},pos2px:function(a,b){return{left:a*this._tile.width+(1&b)*(this._tile.width/2),top:b*this._tile.height/2}},px2pos:function(a,b){return{x:-Math.ceil(-a/this._tile.width-.5*(1&b)),y:b/this._tile.height*2}},centerAt:function(a,b){if("number"==typeof a&&"number"==typeof b){var c=this.pos2px(a,b);return d.viewport._x=-c.left+d.viewport.width/2-this._tile.width/2,d.viewport._y=-c.top+d.viewport.height/2-this._tile.height/2,this}return{top:-d.viewport._y+d.viewport.height/2-this._tile.height/2,left:-d.viewport._x+d.viewport.width/2-this._tile.width/2}},area:function(){var a=this.centerAt(),b=this.px2pos(-a.left+d.viewport.width/2,-a.top+d.viewport.height/2),c=this.px2pos(-a.left-d.viewport.width/2,-a.top-d.viewport.height/2);return{x:{start:b.x,end:c.x},y:{start:b.y,end:c.y}}}}})},{"../core/core.js":10}],53:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.extend({audio:{sounds:{},supported:null,codecs:{ogg:'audio/ogg; codecs="vorbis"',wav:'audio/wav; codecs="1"',webma:'audio/webm; codecs="vorbis"',mp3:'audio/mpeg; codecs="mp3"',m4a:'audio/mp4; codecs="mp4a.40.2"'},volume:1,muted:!1,paused:!1,playCheck:null,_canPlay:function(){if(this.supported={},d.support.audio){var a,b=this.audioElement();for(var c in this.codecs)a=b.canPlayType(this.codecs[c]),this.supported[c]=""!==a&&"no"!==a}},supports:function(a){return null===this.supported&&this._canPlay(),!!this.supported[a]},audioElement:function(){return"undefined"!=typeof Audio?new Audio(""):e.createElement("audio")},create:function(a,b){var c=b.substr(b.lastIndexOf(".")+1).toLowerCase();if(!this.supports(c))return!1;var e=this.audioElement();return e.id=a,e.preload="auto",e.volume=d.audio.volume,e.src=b,d.asset(b,e),this.sounds[a]={obj:e,played:0,volume:d.audio.volume},this.sounds[a]},add:function(a,b){if(d.support.audio){var c,e;if(1===arguments.length&&"object"==typeof a)for(var f in a)for(c in a[f])if(e=d.audio.create(f,a[f][c]))break;if("string"==typeof a&&("string"==typeof b&&(e=d.audio.create(a,b)),"object"==typeof b))for(c in b)if(e=d.audio.create(a,b[c]))break;return e}},play:function(a,b,c){if(0!==b&&d.support.audio&&this.sounds[a]){var e=this.sounds[a],f=this.getOpenChannel();if(!f)return null;f.id=a,f.repeat=b;var g=f.obj;return f.volume=e.volume=e.obj.volume=c||d.audio.volume,g.volume=e.volume,g.src=e.obj.src,this.muted&&(g.volume=0),g.play(),e.played++,f.onEnd=function(){e.played0&&this._cascade(a)}),this.bind("Rotate",function(a){var b=this._cbr||this._mbr||this;this._entry.update(b),this._children.length>0&&this._cascadeRotation(a)}),this.bind("Remove",function(){if(this._children){for(var a=0;a-1e-10?0:i,j=j<1e-10&&j>-1e-10?0:j;var k=d*i+f*j,l=-d*j+f*i,m=e*i+f*j,n=-e*j+f*i,o=e*i+h*j,p=-e*j+h*i,q=d*i+h*j,r=-d*j+h*i,s=Math.floor(Math.min(k,m,o,q)+a),t=Math.floor(Math.min(l,n,p,r)+b),u=Math.ceil(Math.max(k,m,o,q)+a),v=Math.ceil(Math.max(l,n,p,r)+b);if(this._mbr?(this._mbr._x=s,this._mbr._y=t,this._mbr._w=u-s,this._mbr._h=v-t):this._mbr={_x:s,_y:t,_w:u-s,_h:v-t},this._cbr){var w=this._cbr,x=w.cx,y=w.cy,z=w.r,A=a+(x+this._x-a)*i+(y+this._y-b)*j,B=b-(x+this._x-a)*j+(y+this._y-b)*i;w._x=Math.min(A-z,s),w._y=Math.min(B-z,t),w._w=Math.max(A+z,u)-w._x,w._h=Math.max(B+z,v)-w._y}},_rotate:function(a){var b=this._rotation-a;0!==b&&(this._rotation=a,this._calculateMBR(),this.trigger("Rotate",b))},area:function(){return this._w*this._h},intersect:function(a,b,c,d){var e,f=this._mbr||this;return e="object"==typeof a?a:{_x:a,_y:b,_w:c,_h:d},f._xe._x&&f._ye._y},within:function(a,b,c,d){var e,f=this._mbr||this;return e="object"==typeof a?a:{_x:a,_y:b,_w:c,_h:d},e._x<=f._x&&e._x+e._w>=f._x+f._w&&e._y<=f._y&&e._y+e._h>=f._y+f._h},contains:function(a,b,c,d){var e,f=this._mbr||this;return e="object"==typeof a?a:{_x:a,_y:b,_w:c,_h:d},e._x>=f._x&&e._x+e._w<=f._x+f._w&&e._y>=f._y&&e._y+e._h<=f._y+f._h},pos:function(a){return a=a||{},a._x=this._x,a._y=this._y,a._w=this._w,a._h=this._h,a},mbr:function(a){return a=a||{},this._mbr?(a._x=this._mbr._x,a._y=this._mbr._y,a._w=this._mbr._w,a._h=this._mbr._h,a):this.pos(a)},isAt:function(a,b){if(this.mapArea)return this.mapArea.containsPoint(a,b);if(this.map)return this.map.containsPoint(a,b);var c=this._mbr||this;return c._x<=a&&c._x+c._w>=a&&c._y<=b&&c._y+c._h>=b},move:function(a,b){return"n"===a.charAt(0)&&(this.y-=b),"s"===a.charAt(0)&&(this.y+=b),"e"!==a&&"e"!==a.charAt(1)||(this.x+=b),"w"!==a&&"w"!==a.charAt(1)||(this.x-=b),this},shift:function(a,b,c,d){return(a||b)&&this._setPosition(this._x+a,this._y+b),c&&(this.w+=c),d&&(this.h+=d),this},_cascade:function(a){if(a)for(var b,c=0,d=this._children,e=d.length,f=this._x-a._x,g=this._y-a._y,h=this._w-a._w,i=this._h-a._h;c1&&(a=Array.prototype.slice.call(arguments,0)),this.points=a},d.polygon.prototype={containsPoint:function(a,b){var c,d,e=this.points,f=e.length/2,g=!1;for(c=0,d=f-1;cb!=e[2*d+1]>b&&a<(e[2*d]-e[2*c])*(b-e[2*c+1])/(e[2*d+1]-e[2*c+1])+e[2*c]&&(g=!g);return g},shift:function(a,b){for(var c=0,d=this.points,e=d.length;c=0&&e<=1&&c>=0&&c=0&&c=0&&cthis.mtx.length||b<1||b>this.mtx[0].length?null:this.mtx[a-1][b-1]}}},{"../core/core.js":10}],55:[function(a,b,c){var d=a("../core/core.js"),e=Math.PI/180;d.extend({raycast:function(a,b){for(var c,e,f="obj",g=1/0,h=!0,i=2,j=arguments.length;ig)return!0;if(c.map&&c.__c[f]&&!o[c[0]]){o[c[0]]=!0;var e=c.map.intersectRay(a,b);e1){var b=Array.prototype.slice.call(arguments,0);a=new d.polygon(b)}else a=a.constructor===Array?new d.polygon(a.slice()):a.clone();this._findBounds(a.points)}else a=new d.polygon([0,0,this._w,0,this._w,this._h,0,this._h]),this.bind("Resize",this._resizeMap),this._cbr=null;return this.rotation&&a.rotate(this.rotation,this._origin.x,this._origin.y,Math.cos(-this.rotation*e),Math.sin(-this.rotation*e)),this.map=a,this.attach(this.map),this.map.shift(this._x,this._y),this.trigger("NewHitbox",a),this},cbr:function(a){return a=a||{},this._cbr?(a._x=this._cbr._x,a._y=this._cbr._y,a._w=this._cbr._w,a._h=this._cbr._h,a):this.mbr(a)},_findBounds:function(a){for(var b=1/0,c=-1/0,d=1/0,e=-1/0,f=a.length,g=0;gc&&(c=a[g]),a[g+1]e&&(e=a[g+1]);var h={cx:(b+c)/2,cy:(d+e)/2,r:Math.sqrt((c-b)*(c-b)+(e-d)*(e-d))/2};return b>=0&&d>=0&&(this._checkBounds=function(){null===this._cbr&&this._w=0&&d>=0&&c<=this._w&&e<=this._h?(this._cbr=null,!1):(this._cbr=h,this._calculateMBR(),!0)},_resizeMap:function(a){var b,c,d=this.rotation*e,f=this.map.points;"w"===a.axis?(d?(b=a.amount*Math.cos(d),c=a.amount*Math.sin(d)):(b=a.amount,c=0),f[2]+=b,f[3]+=c):(d?(c=a.amount*Math.cos(d),b=-a.amount*Math.sin(d)):(b=0,c=a.amount),f[6]+=b,f[7]+=c),f[4]+=b,f[5]+=c},_collisionHitDupes:[],_collisionHitResults:[],hit:function(a,b){var c=this._cbr||this._mbr||this,e=this._collisionHitResults;e.length=0,e=d.map.unfilteredSearch(c,e);var f=e.length;if(!f)return null;var g,h,i=0,j=this._collisionHitDupes;for(b=b||[],j.length=0;ig&&(g=j),jh&&(h=j),j=0)return!1;i>s&&(s=i,t=q,u=r)}for(l=0;lg&&(g=j),jh&&(h=j),j=0)return!1;i>s&&(s=i,t=q,u=r)}return{overlap:s,nx:t,ny:u}}})},{"../core/core.js":10}],56:[function(a,b,c){var d=a("../core/core.js");d.math={abs:function(a){return a<0?-a:a},amountOf:function(a,b,c){return bc?c:a=b&&a<=c}},d.math.Vector2D=function(){function a(b,c){if(b instanceof a)this.x=b.x,this.y=b.y;else if(2===arguments.length)this.x=b,this.y=c;else if(arguments.length>0)throw"Unexpected number of arguments for Vector2D()"}return a.prototype.x=0,a.prototype.y=0,a.prototype.add=function(a){return this.x+=a.x,this.y+=a.y,this},a.prototype.angleBetween=function(a){return Math.atan2(this.x*a.y-this.y*a.x,this.x*a.x+this.y*a.y)},a.prototype.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)},a.prototype.clone=function(){return new a(this)},a.prototype.distance=function(a){return Math.sqrt((a.x-this.x)*(a.x-this.x)+(a.y-this.y)*(a.y-this.y))},a.prototype.distanceSq=function(a){return(a.x-this.x)*(a.x-this.x)+(a.y-this.y)*(a.y-this.y)},a.prototype.divide=function(a){return this.x/=a.x,this.y/=a.y,this},a.prototype.dotProduct=function(a){return this.x*a.x+this.y*a.y},a.prototype.crossProduct=function(a){return this.x*a.y-this.y*a.x},a.prototype.equals=function(b){return b instanceof a&&this.x===b.x&&this.y===b.y},a.prototype.perpendicular=function(b){return b=b||new a,b.setValues(-this.y,this.x)},a.prototype.getNormal=function(b,c){return c=c||new a,c.setValues(b.y-this.y,this.x-b.x).normalize()},a.prototype.isZero=function(){return 0===this.x&&0===this.y},a.prototype.magnitude=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},a.prototype.magnitudeSq=function(){return this.x*this.x+this.y*this.y},a.prototype.multiply=function(a){return this.x*=a.x,this.y*=a.y,this},a.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},a.prototype.normalize=function(){var a=Math.sqrt(this.x*this.x+this.y*this.y);return 0===a?(this.x=1,this.y=0):(this.x/=a,this.y/=a),this},a.prototype.scale=function(a,b){return void 0===b&&(b=a),this.x*=a,this.y*=b,this},a.prototype.scaleToMagnitude=function(a){var b=a/this.magnitude();return this.x*=b,this.y*=b,this},a.prototype.setValues=function(b,c){return b instanceof a?(this.x=b.x,this.y=b.y):(this.x=b,this.y=c),this},a.prototype.subtract=function(a){return this.x-=a.x,this.y-=a.y,this},a.prototype.toString=function(){return"Vector2D("+this.x+", "+this.y+")"},a.prototype.translate=function(a,b){return void 0===b&&(b=a),this.x+=a,this.y+=b,this},a.tripleProduct=function(a,b,c,e){e=e||new d.math.Vector2D;var f=a.dotProduct(c),g=b.dotProduct(c);return e.setValues(b.x*f-a.x*g,b.y*f-a.y*g)},a}(),d.math.Matrix2D=function(){function a(b,c,d,e,f,g){if(b instanceof a)this.a=b.a,this.b=b.b,this.c=b.c,this.d=b.d,this.e=b.e,this.f=b.f;else if(6===arguments.length)this.a=b,this.b=c,this.c=d,this.d=e,this.e=f,this.f=g;else if(arguments.length>0)throw"Unexpected number of arguments for Matrix2D()"}return a.prototype.a=1,a.prototype.b=0,a.prototype.c=0,a.prototype.d=1,a.prototype.e=0,a.prototype.f=0,a.prototype.apply=function(a){var b=a.x;return a.x=b*this.a+a.y*this.c+this.e,a.y=b*this.b+a.y*this.d+this.f,a},a.prototype.clone=function(){return new a(this)},a.prototype.combine=function(a){var b=this.a;return this.a=b*a.a+this.b*a.c,this.b=b*a.b+this.b*a.d,b=this.c,this.c=b*a.a+this.d*a.c,this.d=b*a.b+this.d*a.d,b=this.e,this.e=b*a.a+this.f*a.c+a.e,this.f=b*a.b+this.f*a.d+a.f,this},a.prototype.equals=function(b){return b instanceof a&&this.a===b.a&&this.b===b.b&&this.c===b.c&&this.d===b.d&&this.e===b.e&&this.f===b.f},a.prototype.determinant=function(){return this.a*this.d-this.b*this.c},a.prototype.invert=function(){var a=this.determinant();if(0!==a){var b={a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f};this.a=b.d/a,this.b=-b.b/a,this.c=-b.c/a,this.d=b.a/a,this.e=(b.c*b.f-b.e*b.d)/a,this.f=(b.e*b.b-b.a*b.f)/a}return this},a.prototype.isIdentity=function(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.e&&0===this.f},a.prototype.isInvertible=function(){return 0!==this.determinant()},a.prototype.preRotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a;return this.a=b*d-c*this.b,this.b=c*d+b*this.b,d=this.c,this.c=b*d-c*this.d,this.d=c*d+b*this.d,this},a.prototype.preScale=function(a,b){return void 0===b&&(b=a),this.a*=a,this.b*=b,this.c*=a,this.d*=b,this},a.prototype.preTranslate=function(a,b){return"number"==typeof a?(this.e+=a,this.f+=b):(this.e+=a.x,this.f+=a.y),this},a.prototype.rotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a;return this.a=b*d-c*this.b,this.b=c*d+b*this.b,d=this.c,this.c=b*d-c*this.d,this.d=c*d+b*this.d,d=this.e,this.e=b*d-c*this.f,this.f=c*d+b*this.f,this},a.prototype.scale=function(a,b){return void 0===b&&(b=a),this.a*=a,this.b*=b,this.c*=a,this.d*=b,this.e*=a,this.f*=b,this},a.prototype.setValues=function(b,c,d,e,f,g){return b instanceof a?(this.a=b.a,this.b=b.b,this.c=b.c,this.d=b.d,this.e=b.e,this.f=b.f):(this.a=b,this.b=c,this.c=d,this.d=e,this.e=f,this.f=g),this},a.prototype.toString=function(){return"Matrix2D(["+this.a+", "+this.c+", "+this.e+"] ["+this.b+", "+this.d+", "+this.f+"] [0, 0, 1])"},a.prototype.translate=function(a,b){return"number"==typeof a?(this.e+=this.a*a+this.c*b,this.f+=this.b*a+this.d*b):(this.e+=this.a*a.x+this.c*a.y,this.f+=this.b*a.x+this.d*a.y),this},a}()},{"../core/core.js":10}],57:[function(a,b,c){var d=a("../core/core.js"),e=function(a,b,c,e){var f=b+c,g="_"+f,h={key:"",oldValue:0};e?d.defineField(a,f,function(){return this[g]},function(a){var b=this[g];a!==b&&(this[g]=a,h.key=f,h.oldValue=b,this.trigger("MotionChange",h))}):d.defineField(a,f,function(){return this[g]},function(a){}),Object.defineProperty(a,g,{value:0,writable:!0,enumerable:!1,configurable:!1})},f=function(a,b,c,e){var f=b+"x",g=b+"y",h="_"+f,i="_"+g;return c?(d.defineField(e,"x",function(){return a[h]},function(b){a[f]=b}),d.defineField(e,"y",function(){return a[i]},function(b){a[g]=b})):(d.defineField(e,"x",function(){return a[h]},function(a){}),d.defineField(e,"y",function(){return a[i]},function(a){})),Object.seal&&Object.seal(e),e};d.c("AngularMotion",{_vrotation:0,_arotation:0,_drotation:0,init:function(){this.requires("2D"),e(this,"v","rotation",!0),e(this,"a","rotation",!0),e(this,"d","rotation",!1),this.__oldRotationDirection=0,this.bind("UpdateFrame",this._angularMotionTick)},remove:function(a){this.unbind("UpdateFrame",this._angularMotionTick)},resetAngularMotion:function(){return this._drotation=0,this.vrotation=0,this.arotation=0,this},_angularMotionTick:function(a){var b=a.dt/1e3,c=this._rotation,d=this._vrotation,e=this._arotation,f=c+d*b+.5*e*b*b;this.vrotation=d+e*b;var g=this._vrotation,h=g?g<0?-1:1:0;this.__oldRotationDirection!==h&&(this.__oldRotationDirection=h,this.trigger("NewRotationDirection",h)),this._drotation=f-c,0!==this._drotation&&(this.rotation=f,this.trigger("Rotated",c))}}),d.c("Motion",{_vx:0,_vy:0,_ax:0,_ay:0,_dx:0,_dy:0,init:function(){this.requires("2D"),e(this,"v","x",!0),e(this,"v","y",!0),this._velocity=f(this,"v",!0,new d.math.Vector2D),e(this,"a","x",!0),e(this,"a","y",!0),this._acceleration=f(this,"a",!0,new d.math.Vector2D),e(this,"d","x",!1),e(this,"d","y",!1),this._motionDelta=f(this,"d",!1,new d.math.Vector2D),this.__oldDirection={x:0,y:0},this.bind("UpdateFrame",this._linearMotionTick)},remove:function(a){this.unbind("UpdateFrame",this._linearMotionTick)},resetMotion:function(){return this.vx=0,this.vy=0,this.ax=0,this.ay=0,this._dx=0,this._dy=0,this},motionDelta:function(){return this._motionDelta},velocity:function(){return this._velocity},acceleration:function(){return this._acceleration},ccdbr:function(a){var b=this._cbr||this._mbr||this,c=this._dx,d=this._dy,e=0,f=0,g=c>0?e=c:-c,h=d>0?f=d:-d;return a=a||{},a._x=b._x-e,a._y=b._y-f,a._w=b._w+g,a._h=b._h+h,a},_linearMotionTick:function(a){var b=a.dt/1e3,c=this._vx,d=this._ax,e=this._vy,f=this._ay,g=c*b+.5*d*b*b,h=e*b+.5*f*b*b;this.vx=c+d*b,this.vy=e+f*b;var i=this.__oldDirection,j=this._vx,k=j?j<0?-1:1:0,l=this._vy,m=l?l<0?-1:1:0;i.x===k&&i.y===m||(i.x=k,i.y=m,this.trigger("NewDirection",i)),this._dx=g,this._dy=h,this._setPosition(this._x+g,this._y+h)}})},{"../core/core.js":10}],58:[function(a,b,c){var d=a("../core/core.js");d.c("Supportable",{_ground:null,_groundComp:null,_preventGroundTunneling:!1,canLand:!0,init:function(){this.requires("2D"),this.__area={_x:0,_y:0,_w:0,_h:0},this.defineField("ground",function(){return this._ground},function(a){})},remove:function(a){this.unbind("UpdateFrame",this._detectGroundTick)},startGroundDetection:function(a){return a&&(this._groundComp=a),this.uniqueBind("UpdateFrame",this._detectGroundTick),this},stopGroundDetection:function(){return this.unbind("UpdateFrame",this._detectGroundTick),this},preventGroundTunneling:function(a){return void 0===a&&(a=!0),a&&this.requires("Motion"),this._preventGroundTunneling=a,this},_detectGroundTick:function(){var a,b=this._groundComp,c=this._ground,e=d.rectManager.overlap;if(this._preventGroundTunneling)a=this.ccdbr(this.__area);else{var f=this._cbr||this._mbr||this;a=this.__area,a._x=f._x,a._y=f._y,a._w=f._w,a._h=f._h}if(a._h++,c){var g=c._cbr||c._mbr||c;c.__c[b]&&d(c[0])===c&&e(g,a)||(this._ground=null,this.trigger("LiftedOffGround",c),c=null)}if(!c)for(var h,i,j=d.map.unfilteredSearch(a),k=0,l=j.length;kc._x+c._w?this.x=c._x+c._w-1:this._x+this._wb._x&&a._yb._y},integerBounds:function(a){return a._x=Math.floor(a._x),a._y=Math.floor(a._y),a._w=Math.ceil(a._w),a._h=Math.ceil(a._h),a},mergeSet:function(a){if(a.length<2)return a;for(var b=a.length-1;b--;)this.overlap(a[b],a[b+1])&&(this.merge(a[b],a[b+1],a[b]),a.splice(b+1,1));return a},boundingRect:function(a){if(a&&a.length){var b,c,d=1,e=a.length,f=a[0];for(f=[f._x,f._y,f._x+f._w,f._y+f._h];df[2]&&(f[2]=c[2]),c[3]>f[3]&&(f[3]=c[3]),d++;return c=f,f={_x:c[0],_y:c[1],_w:c[2]-c[0],_h:c[3]-c[1]}}},_pool:function(){var a=[],b=0;return{get:function(c,d,e,f){a.length<=b&&a.push({});var g=a[b++];return g._x=c,g._y=d,g._w=e,g._h=f,g},copy:function(c){a.length<=b&&a.push({});var d=a[b++];return d._x=c._x,d._y=c._y,d._w=c._w,d._h=c._h,d},recycle:function(a){b--}}}()}})},{"../core/core.js":10}],60:[function(a,b,c){function d(a,b,c){this.keys=a,this.map=c,this.obj=b}var e,f={},g=function(a){e=a||64,this.map={},this.boundsDirty=!1,this.coordBoundsDirty=!1,this.boundsHash={maxX:-1/0,maxY:-1/0,minX:1/0,minY:1/0},this.boundsCoords={maxX:-1/0,maxY:-1/0,minX:1/0,minY:1/0}};g.key=function(a,b){return a=a._cbr||a._mbr||a,b=b||{},b.x1=Math.floor(a._x/e),b.y1=Math.floor(a._y/e),b.x2=Math.floor((a._w+a._x)/e),b.y2=Math.floor((a._h+a._y)/e),b},g.hash=function(a){return a.x1+" "+a.y1+" "+a.x2+" "+a.y2},g.cellsize=function(){return e},g.prototype={insert:function(a,b){var c,e,f,h=g.key(a,b&&b.keys);for(b=b||new d(h,a,this),c=h.x1;c<=h.x2;c++)for(e=h.y1;e<=h.y2;e++)f=c<<16^e,this.map[f]||(this.map[f]=[]),this.map[f].push(a);return this.boundsDirty=!0,b},_searchHolder:[],search:function(a,b){var c,d,e,h,i=g.key(a,f),j=this._searchHolder;b=b||[],j.length=0;var k;for(c=i.x1;c<=i.x2;c++)for(d=i.y1;d<=i.y2;d++)if(h=this.map[c<<16^d])for(e=0;ea._x&&k._ya._y&&b.push(h[e]));return b},unfilteredSearch:function(a,b){var c,d,e,h,i=g.key(a,f);for(b=b||[],c=i.x1;c<=i.x2;c++)for(d=i.y1;d<=i.y2;d++)if(h=this.map[c<<16^d])for(e=0;e>16,h=f<<16>>16;if(h<0&&(g=~g),g>=a.maxX){a.maxX=g;for(c in e)"object"==typeof(d=e[c])&&"requires"in d&&(b.maxX=Math.max(b.maxX,d.x+d.w))}if(g<=a.minX){a.minX=g;for(c in e)"object"==typeof(d=e[c])&&"requires"in d&&(b.minX=Math.min(b.minX,d.x))}if(h>=a.maxY){a.maxY=h;for(c in e)"object"==typeof(d=e[c])&&"requires"in d&&(b.maxY=Math.max(b.maxY,d.y+d.h))}if(h<=a.minY){a.minY=h;for(c in e)"object"==typeof(d=e[c])&&"requires"in d&&(b.minY=Math.min(b.minY,d.y))}}this.boundsDirty=!1,this.coordBoundsDirty=!1}},traverseRay:function(a,b,c){var d=b.x,h=b.y;a={_x:a._x,_y:a._y,_w:0,_h:0};var i,j=this._keyBoundaries(),k=g.key(a,f),l=k.x1,m=k.y1,n=j.minX,o=j.minY,p=j.maxX,q=j.maxY,r=d>0?1:d<0?-1:0,s=h>0?1:h<0?-1:0,t=d>=0?(l+1)*e:l*e,u=h>=0?(m+1)*e:m*e,v=-1/0,w=0,x=0,y=1/0,z=1/0;for(0!==d&&(i=1/d,y=(t-a._x)*i,w=e*r*i),0!==h&&(i=1/h,z=(u-a._y)*i,x=e*s*i);1===r&&lp&&p!==-1/0||1===s&&mq&&q!==-1/0;)y Crafty Things +