/moongirl

To get this branch, use:
bzr branch http://9ix.org/moongirl

« back to all changes in this revision

Viewing changes to lib/melonJS-0.9.2-min.js

  • Committer: Josh C
  • Date: 2012-01-13 21:21:19 UTC
  • Revision ID: josh@9ix.org-20120113212119-9g0xm8b47d7u5qvj
tutorial files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!
 
2
 * MelonJS Game Engine
 
3
 * Copyright (C) 2011, Olivier BIOT
 
4
 * http://www.melonjs.org
 
5
 * 
 
6
 * melonJS is licensed under the MIT License.
 
7
 * http://www.opensource.org/licenses/mit-license.php
 
8
 *
 
9
 * @author Olivier Biot 2011
 
10
 *
 
11
 */
 
12
(function(h,c){var l=h.document;me={mod:"melonJS",nocache:"",audio:null,video:null,timer:null,input:null,state:null,game:null,entityPool:null,levelDirector:null,XMLParser:null,loadingScreen:null,TMXTileMap:null};me.debug={displayFPS:false,renderHitBox:false,renderDirty:false};me.sys={ua:navigator.userAgent.toLowerCase(),sound:false,localStorage:(typeof(h.localStorage)=="object"),gyro:(h.DeviceMotionEvent!==c),nativeBase64:(typeof(h.atob)=="function"),fps:60,interpolation:false,scale:1,useNativeAnimFrame:false,cacheImage:false,dirtyRegion:false,enableWebGL:false,stopOnAudioError:true};h.me=me;var i=false;var j=false,k=false,n=[];function d(){if(!k){if(!l.body){return setTimeout(d,13)}if(l.removeEventListener){l.removeEventListener("DOMContentLoaded",d,false)}else{h.removeEventListener("load",d,false)}k=true;for(var o=0;o<n.length;o++){n[o].call(h,[])}n=[]}}function g(){if(j){return}j=true;if(l.readyState==="complete"){return util.domReady()}else{if(l.addEventListener){l.addEventListener("DOMContentLoaded",d,false)}h.addEventListener("load",d,false)}}onReady=function(o){g();if(k){o.call(h,[])}else{n.push(function(){return o.call(h,[])})}return this};h.onReady(function(){b()});var f=false,m=/xyz/.test(function(){xyz})?/\bparent\b/:/.*/;Object.extend=function(t){var r=this.prototype;f=true;var s=new this();f=false;for(var q in t){s[q]=typeof t[q]=="function"&&typeof r[q]=="function"&&m.test(t[q])?(function(u,v){return function(){var x=this.parent;this.parent=r[u];var w=v.apply(this,arguments);this.parent=x;return w}})(q,t[q]):t[q]}function o(){if(!f&&this.init){this.init.apply(this,arguments)}}o.prototype=s;o.constructor=o;o.extend=arguments.callee;return o};if(typeof Object.create!=="function"){Object.create=function(q){function r(){}r.prototype=q;return new r()}}if(!Function.bind){Function.prototype.bind=function(){var r=this,q=Array.prototype.slice.call(arguments),o=q.shift();return function(){return r.apply(o,q.concat(Array.prototype.slice.call(arguments)))}}}Function.prototype.defer=function(){var q=this,o=Array.prototype.slice.call(arguments);return window.setTimeout(function(){return q.apply(q,o)},0.01)};if(!Object.defineProperty){Object.defineProperty=function(o,r,q){if(o.__defineGetter__){if(q.get){o.__defineGetter__(r,q.get)}if(q.set){o.__defineSetter__(r,q.set)}}else{throw"melonJS: Object.defineProperty not supported"}}}String.prototype.trim=function(){return(this.replace(/^\s+/,"")).replace(/\s+$/,"")};String.prototype.isNumeric=function(){return(this!=null&&!isNaN(this)&&this.trim()!="")};String.prototype.isBoolean=function(){return(this!=null&&("true"==this.trim()||"false"==this.trim()))};String.prototype.contains=function(o){return this.indexOf(o)>-1};String.prototype.toHex=function(){var o="",q=0;while(q<this.length){o+=this.charCodeAt(q++).toString(16)}return o};Number.prototype.clamp=function(o,q){return this<o?o:this>q?q:this};Number.prototype.random=function(q,o){return(~~(Math.random()*(o-q+1))+q)};Number.prototype.round=function(){var o=(arguments.length==1)?this:arguments[0];var q=Math.pow(10,arguments[1]||arguments[0]);return(Math.round(o*q)/q)};Number.prototype.toHex=function(){return"0123456789ABCDEF".charAt((this-this%16)>>4)+"0123456789ABCDEF".charAt(this%16)};Number.prototype.sign=function(){return this<0?-1:(this>0?1:0)};function e(){var o={xmlDoc:null,parser:null,parseFromString:function(q){if(h.DOMParser){this.parser=new DOMParser();this.xmlDoc=this.parser.parseFromString(q,"text/xml")}else{this.xmlDoc=new ActiveXObject("Microsoft.XMLDOM");this.xmlDoc.async="false";this.xmlDoc.loadXML(q)}if(this.xmlDoc==null){console.log("xml "+this.xmlDoc+" not found!")}},getFirstElementByTagName:function(q){return this.xmlDoc?this.xmlDoc.getElementsByTagName(q)[0]:null},getAllTagElements:function(){return this.xmlDoc?this.xmlDoc.getElementsByTagName("*"):null},getStringAttribute:function(r,t,s){var q=r.getAttribute(t);return q?q.trim().toLowerCase():s},getIntAttribute:function(r,t,s){var q=this.getStringAttribute(r,t,s);return q?parseInt(q):s},getFloatAttribute:function(r,t,s){var q=this.getStringAttribute(r,t,s);return q?parseFloat(q):s},getBooleanAttribute:function(r,t,s){var q=this.getStringAttribute(r,t,s);return q?(q=="true"):s},free:function(){this.xmlDoc=null;this.parser=null}};return o}function b(){if(i){return}var o=l.createElement("audio");me.utils.setNocache(l.location.href.match(/\?nocache/));if(o.canPlayType){me.audio.capabilities.mp3=("no"!=o.canPlayType("audio/mpeg"))&&(""!=o.canPlayType("audio/mpeg"));me.audio.capabilities.ogg=("no"!=o.canPlayType('audio/ogg; codecs="vorbis"'))&&(""!=o.canPlayType('audio/ogg; codecs="vorbis"'));me.audio.capabilities.wav=("no"!=o.canPlayType('audio/wav; codecs="1"'))&&(""!=o.canPlayType('audio/wav; codecs="1"'));me.sys.sound=me.audio.capabilities.mp3||me.audio.capabilities.ogg||me.audio.capabilities.wav}if((me.sys.ua.search("iphone")>-1)||(me.sys.ua.search("ipod")>-1)||(me.sys.ua.search("ipad")>-1)||(me.sys.ua.search("android")>-1)){me.sys.sound=false}me.timer.init();me.XMLParser=new e();me.loadingScreen=new me.DefaultLoadingScreen();me.state.init();me.entityPool.init();me.levelDirector.reset();i=true}var a=(function(){var q={};var s=[];var o;var r=[];q.isDirty=false;q.reset=function(){s=[];r=[];o=me.game.viewport.getRect();q.makeAllDirty()};q.makeDirty=function(v,t,u){if(t){q.isDirty=true;if(me.sys.dirtyRegion){if(u){s.push(u.union(v))}else{if(v.getRect){s.push(v.getRect())}}}}if(v.visible){r.splice(0,0,v)}};q.makeAllDirty=function(){s=[];s.push(o);q.isDirty=true};q.remove=function(u){r.splice(r.indexOf(u),1);var t=u.visible;u.visible=false;q.makeDirty(u,true);u.visible=t};q.draw=function(t){for(var v=s.length,u;v--,u=s[v];){for(var x=r.length,w;x--,w=r[x];){if(me.sys.dirtyRegion&&w.isEntity&&!w.overlaps(u)){continue}w.draw(t,u)}if(me.debug.renderDirty){u.draw(t,"white")}}};q.flush=function(){if(me.sys.dirtyRegion){s=[]}r=[];q.isDirty=false};return q})();me.game=(function(){var s={};var r=null;var t=[];var o=0;var v=false;var u=[];var q=null;s.viewport=null;s.HUD=null;s.collisionMap=null;s.currentLevel=null;s.NO_OBJECT=0;s.ENEMY_OBJECT=1;s.COLLECTABLE_OBJECT=2;s.ACTION_OBJECT=3;s.init=function(x,w){if(!v){var x=x||me.video.getWidth();var w=w||me.video.getHeight();s.viewport=new me.Viewport(0,0,x,w);r=me.video.getScreenFrameBuffer();v=true}};s.reset=function(){if(q){clearTimeout(q)}q=null;if(!v){s.init()}s.removeAll();if(s.viewport){s.viewport.reset()}if(s.HUD!=null){s.add(s.HUD)}a.reset()};s.loadTMXLevel=function(z){s.currentLevel=z;s.collisionMap=s.currentLevel.getLayerByName("collision");if(!s.collisionMap||!s.collisionMap.isCollisionMap){alert("WARNING : no collision map detected")}s.currentLevel.addTo(me.game);s.viewport.setBounds(s.currentLevel.realwidth,s.currentLevel.realheight);var w=s.currentLevel.getObjectGroups();for(var y=0;y<w.length;y++){for(var x=0;x<w[y].objects.length;x++){s.addEntity(w[y].objects[x],w[y].z)}}s.sort()};s.add=function(w,x){w.z=(x)?x:w.z;t.push(w);if(w.mouseEvent){u.push(w)}o=t.length};s.addEntity=function(w,x){s.add(me.entityPool.newIstanceOf(w),x)};s.getEntityByName=function(y){var w=[];for(var x=o,z;x--,z=t[x];){if(z.name==y){w.push(z)}}return w};s.getEntityByGUID=function(w){for(var x=o,y;x--,y=t[x];){if(y.isEntity&&y.GUID==w){return y}}return null};s.addHUD=function(z,D,A,C,B){if(s.HUD==null){s.HUD=new me.HUD_Object(z,D,A,C,B);s.add(s.HUD)}};s.disableHUD=function(){if(s.HUD!=null){s.remove(s.HUD);s.HUD=null}};s.mouseEvent=function(w,A){for(var z=u.length;z--;){if(u[z].mouseEvent(w,A)){break}}};s.update=function(){me.timer.update();var z=null;for(var x=o,y;x--,y=t[x];){z=(me.sys.dirtyRegion&&y.isEntity)?y.getRect():null;var w=y.update();if(y.isEntity){y.visible=s.viewport.isVisible(y.collisionBox)}a.makeDirty(y,w,w?z:null)}if(s.viewport.update(a.isDirty)){a.makeAllDirty()}};s.remove=function(w){if(!w.destroy||w.destroy()){w.visible=false;w.isEntity=false;a.remove(w);if(w.mouseEvent){u.splice(u.indexOf(w),1)}q=(function(y){var x=t.indexOf(y);if(x!=-1){t.splice(x,1);o=t.length}q=null}).defer(w)}};s.removeAll=function(){o=0;t=[];u=[];a.flush()};s.sort=function(){t.sort(function(x,w){return(w.z-x.z)});u.sort(function(x,w){return(x.z-w.z)});s.repaint()};s.collide=function(x){var w=null;for(var y=o,z;y--,z=t[y];){if(z.visible&&z.collidable&&z.isEntity&&(z!=x)){if(w=z.checkCollision(x)){break}}}return w};s.repaint=function(){a.makeAllDirty()};s.draw=function(){if(a.isDirty){a.draw(r);s.viewport.draw(r)}a.flush()};return s})();me.ScreenObject=Object.extend({visible:true,addAsObject:false,rect:null,init:function(o){this.addAsObject=o;this.visible=(o===true)||false;this.rect=new me.Rect(new me.Vector2d(0,0),0,0)},reset:function(){me.game.reset();if(this.addAsObject){this.visible=true;this.rect=me.game.viewport.getRect();me.game.add(this,999)}this.onResetEvent.apply(this,arguments);me.game.sort()},getRect:function(){return this.rect},destroy:function(){this.onDestroyEvent.apply(this,arguments);return true},update:function(){return false},onUpdateFrame:function(){me.game.update();me.game.draw();me.video.blitSurface()},draw:function(){},onResetEvent:function(){},onDestroyEvent:function(){}});window.requestAnimFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(){return -1}})();window.cancelRequestAnimFrame=(function(){return window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||function(){return -1}})();me.state=(function(){var w={};var t=-1;var B=-1;var s=-1;var x={};var o={color:"",duration:0};var r=null;var y=null;var z=null;var v=null;function u(){if((B==-1)&&(s==-1)){me.timer.reset();if(me.sys.useNativeAnimFrame){s=window.requestAnimFrame(C);if(s!=-1){return}me.sys.useNativeAnimFrame=false}B=setInterval(z,v)}}function C(){z();window.requestAnimFrame(C)}function q(){if(B!=-1){clearInterval(B);B=-1}if(s!=-1){cancelRequestAnimFrame(s);s=-1}}function A(D){q();if(x[t]){if(x[t].screen.visible){me.game.remove(x[t].screen)}else{x[t].screen.destroy()}}t=D;x[t].screen.reset.apply(x[t].screen,y);z=x[t].screen.onUpdateFrame.bind(x[t].screen);u();if(r){r()}me.game.repaint()}w.LOADING=0;w.MENU=1;w.READY=2;w.PLAY=3;w.GAMEOVER=4;w.GAME_END=5;w.SCORE=6;w.CREDITS=7;w.SETTINGS=8;w.onPause=null;w.onResume=null;w.init=function(){w.set(w.LOADING,me.loadingScreen);h.addEventListener("blur",function(){if(t!=w.LOADING){w.pause(true);if(w.onPause){w.onPause()}}},false);h.addEventListener("focus",function(){if(t!=w.LOADING){w.resume(true);if(w.onResume){w.onResume()}me.game.repaint()}},false);v=~~(1000/me.sys.fps)};w.pause=function(D){q();if(D){me.audio.pauseTrack()}};w.resume=function(D){u(t);if(D){me.audio.resumeTrack()}};w.isRunning=function(){return((B!=-1)||(s!=-1))};w.set=function(D,E){x[D]={};x[D].screen=E;x[D].transition=true};w.current=function(){return x[t].screen};w.transition=function(E,D,F){if(E=="fade"){o.color=D;o.duration=F}};w.setTransition=function(E,D){x[E].transition=D};w.change=function(D){switch(D){default:y=null;if(arguments.length>1){y=Array.prototype.slice.call(arguments,1)}if(o.duration&&x[D].transition){r=function(){me.game.viewport.fadeOut(o.color,o.duration)};me.game.viewport.fadeIn(o.color,o.duration,function(){A(D)})}else{A.defer(D)}break}};w.isCurrent=function(D){return t==D};return w})()})(window);(function(a,b){me.DefaultLoadingScreen=me.ScreenObject.extend({init:function(){this.parent(true);this.logo1=new me.Font("century gothic",32,"white");this.logo2=new me.Font("century gothic",32,"#89b002");this.logo2.bold();this.invalidate=false;this.loadPercent=0;me.loader.onProgress=this.onProgressUpdate.bind(this)},onDestroyEvent:function(){this.logo1=this.logo2=null},onProgressUpdate:function(c){this.loadPercent=c;this.invalidate=true},update:function(){if(this.invalidate===true){this.invalidate=false;return true}return false},draw:function(e){var g=e.canvas.height/2;var d=this.logo1.measureText(e,"melon").width;var c=d+this.logo2.measureText(e,"JS").width;me.video.clearSurface(e,"black");this.logo1.draw(e,"melon",((e.canvas.width-c)/2),(e.canvas.height+60)/2);this.logo2.draw(e,"JS",((e.canvas.width-c)/2)+d,(e.canvas.height+60)/2);g+=40;var f=Math.floor(this.loadPercent*e.canvas.width);e.strokeStyle="silver";e.strokeRect(0,g,e.canvas.width,6);e.fillStyle="#89b002";e.fillRect(2,g+2,f-4,2)},});me.loader=(function(){var k={};var e=[];var c={};var l=0;var g=0;var i=0;var h=0;function f(){if(g==(l-h)){for(var n in c){if(c[n].isTMX){me.levelDirector.addTMXLevel(n);k.onResourceLoaded()}}if(k.onload){i=setTimeout(k.onload,300)}else{alert("no load callback defined")}}else{i=setTimeout(f,100)}}function j(n){throw"melonJS: Failed loading image resource"}function m(o,q,n){e.push(o.name);e[o.name]=new Image();e[o.name].onload=q||k.onResourceLoaded.bind(k);e[o.name].onerror=n||j.bind(this);e[o.name].src=o.src+me.nocache}function d(q,n){if(a.XMLHttpRequest){var o=new XMLHttpRequest();if(o.overrideMimeType){o.overrideMimeType("text/xml")}}else{o=new ActiveXObject("Microsoft.XMLHTTP")}o.open("GET",q.src+me.nocache,false);o.onload=k.onResourceLoaded.bind(k);o.send();c[q.name]={};c[q.name].xml=o.responseText;c[q.name].isTMX=n||false;if(c[q.name].isTMX){l+=1;h+=1}}k.onload=b;k.onProgress=b;k.onResourceLoaded=function(n){g++;if(k.onProgress){k.onProgress(k.getLoadProgress())}};k.preload=function(o){me.audio.setLoadCallback(k.onResourceLoaded.bind(k));for(var n=0;n<o.length;n++){switch(o[n].type){case"image":m(o[n]);l+=1;break;case"audio":if(me.audio.isAudioEnable()){me.audio.load(o[n]);l+=1}break;case"tmx":d(o[n],true);l+=1;break;default:throw"melonJS: me.loader.preload : unknow resource type : %s"+o[n].type;break}}f()};k.load=function(o,q,n){switch(o.type){case"image":m(o,q,n);break;default:throw"melonJS: me.loader.load : unknow or invalide resource type : %s"+o.type;break}};k.getXML=function(n){if(c!=null){return c[n].xml}else{return null}};k.getImage=function(n){if(e[n]!=null){if(me.sys.cacheImage===true){var o=me.video.createCanvasSurface(e[n].width,e[n].height);o.drawImage(e[n],0,0);return o.canvas}else{return e[n]}}else{return null}};k.getLoadProgress=function(){return g/l};return k})()})(window);(function(a,b){me.Vector2d=Object.extend({x:0,y:0,init:function(c,d){this.x=c||0;this.y=d||0},set:function(c,d){this.x=c;this.y=d},setZero:function(){this.set(0,0)},setV:function(c){this.x=c.x;this.y=c.y},add:function(c){this.x+=c.x;this.y+=c.y},sub:function(c){this.x-=c.x;this.y-=c.y},scale:function(c){this.x*=c.x;this.y*=c.y},div:function(c){this.x/=c;this.y/=c},abs:function(){if(this.x<0){this.x=-this.x}if(this.y<0){this.y=-this.y}},clamp:function(c,d){return new me.Vector2d(this.x.clamp(c,d),this.y.clamp(c,d))},minV:function(c){this.x=this.x<c.x?this.x:c.x;this.y=this.y<c.y?this.y:c.y},maxV:function(c){this.x=this.x>c.x?this.x:c.x;this.y=this.y>c.y?this.y:c.y},negate:function(){return new me.Vector2d(-this.x,-this.y)},negateSelf:function(){this.x=-this.x;this.y=-this.y},copy:function(c){this.x=c.x;this.y=c.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalize:function(){var c=this.length();if(c<Number.MIN_VALUE){return 0}var d=1/c;this.x*=d;this.y*=d;return c},dotProduct:function(c){return this.x*c.x+this.y*c.y},distance:function(c){return Math.sqrt((this.x-c.x)*(this.x-c.x)+(this.y-c.y)*(this.y-c.y))},clone:function(){return new me.Vector2d(this.x,this.y)},toString:function(){return"x:"+this.x+"y:"+this.y},});me.Rect=Object.extend({pos:null,colPos:null,left:null,right:null,top:null,bottom:null,width:0,height:0,hWidth:0,hHeight:0,hProp:false,vProp:false,init:function(d,c,e){this.pos=d;this.colPos=new me.Vector2d();this.width=c;this.height=e;this.hWidth=~~(c/2);this.hHeight=~~(e/2);Object.defineProperty(this,"left",{get:function(){return this.pos.x},configurable:true});Object.defineProperty(this,"right",{get:function(){return this.pos.x+this.width},configurable:true});Object.defineProperty(this,"top",{get:function(){return this.pos.y},configurable:true});Object.defineProperty(this,"bottom",{get:function(){return this.pos.y+this.height},configurable:true})},set:function(d,c,e){this.pos=d;this.width=c;this.height=e;this.hWidth=~~(c/2);this.hHeight=~~(e/2)},getRect:function(){return new me.Rect(this.pos.clone(),this.width,this.height)},union:function(e){var c=Math.min(this.pos.x,e.pos.x);var d=Math.min(this.pos.y,e.pos.y);this.width=Math.ceil(Math.max(this.pos.x+this.width,e.pos.x+e.width)-c);this.height=Math.ceil(Math.max(this.pos.y+this.height,e.pos.y+e.height)-d);this.pos.x=~~c;this.pos.y=~~d;return this},adjustSize:function(c,d,f,e){if(c!=-1){this.colPos.x=c;this.width=d;this.hWidth=~~(this.width/2);if(!this.hProp){Object.defineProperty(this,"left",{get:function(){return this.pos.x+this.colPos.x},configurable:true});Object.defineProperty(this,"right",{get:function(){return this.pos.x+this.colPos.x+this.width},configurable:true});this.hProp=true}}if(f!=-1){this.colPos.y=f;this.height=e;this.hHeight=~~(this.height/2);if(!this.vProp){Object.defineProperty(this,"top",{get:function(){return this.pos.y+this.colPos.y},configurable:true});Object.defineProperty(this,"bottom",{get:function(){return this.pos.y+this.colPos.y+this.height},configurable:true});this.vProp=true}}},flipX:function(c){this.colPos.x=c-this.width-this.colPos.x;this.hWidth=~~(this.width/2)},flipY:function(c){this.colPos.y=c-this.height-this.colPos.y;this.hHeight=~~(this.height/2)},overlaps:function(c){return(this.left<c.right&&c.left<this.right&&this.top<c.bottom&&c.top<this.bottom)},within:function(c){return(c.left<=this.left&&c.right>=this.right&&c.top<=this.top&&c.bottom>=this.bottom)},contains:function(c){return(c.left>=this.left&&c.right<=this.right&&c.top>=this.top&&c.bottom<=this.bottom)},collideVsAABB:function(e){var f=new me.Vector2d(0,0);if(this.overlaps(e)){var d=this.left+this.hWidth-e.left-e.hWidth;var c=this.top+this.hHeight-e.top-e.hHeight;f.x=(e.hWidth+this.hWidth)-(d<0?-d:d);f.y=(e.hHeight+this.hHeight)-(c<0?-c:c);if(f.x<f.y){f.y=0;f.x=d<0?-f.x:f.x}else{f.x=0;f.y=c<0?-f.y:f.y}}return f},draw:function(d,c){d.strokeStyle=c||"red";d.strokeRect(this.left-me.game.viewport.pos.x,this.top-me.game.viewport.pos.y,this.width,this.height)}})})(window);(function(b,d){var a=Math.min,c=Math.max;me.Viewport=me.Rect.extend({AXIS:{NONE:0,HORIZONTAL:1,VERTICAL:2,BOTH:3},limits:null,target:null,follow_axis:0,_shake:null,_fadeIn:null,_fadeOut:null,_deadwidth:0,_deadheight:0,_limitwidth:0,_limitheight:0,init:function(e,j,i,h,f,g){this.parent(new me.Vector2d(e,j),i-e,h-j);this.last=new me.Vector2d(-1,-1);this.limits=new me.Vector2d(f||this.width,g||this.height);this.target=null;this.follow_axis=this.AXIS.NONE;this._shake={intensity:0,duration:0,axis:this.AXIS.BOTH,onComplete:null};this._fadeOut={color:0,alpha:0,duration:0,tween:null};this._fadeIn={color:0,alpha:1,duration:0,tween:null};this.setDeadzone(this.width/6,this.height/6)},_followH:function(e){if((e.x-this.pos.x)>(this._deadwidth)){this.pos.x=~~a((e.x)-(this._deadwidth),this._limitwidth)}else{if((e.x-this.pos.x)<(this.deadzone.x)){this.pos.x=~~c((e.x)-this.deadzone.x,0)}}},_followV:function(e){if((e.y-this.pos.y)>(this._deadheight)){this.pos.y=~~a((e.y)-(this._deadheight),this._limitheight)}else{if((e.y-this.pos.y)<(this.deadzone.y)){this.pos.y=~~c((e.y)-this.deadzone.y,0)}}},reset:function(e,f){this.pos.x=e||0;this.pos.y=f||0;this.last.set(-1,-1);this.target=null;this.follow_axis=null},setDeadzone:function(e,f){this.deadzone=new me.Vector2d(~~((this.width-e)/2),~~((this.height-f)/2-f*0.25));this._deadwidth=this.width-this.deadzone.x;this._deadheight=this.height-this.deadzone.y;this.update(true)},setBounds:function(e,f){this.limits.set(e,f);this._limitwidth=this.limits.x-this.width;this._limitheight=this.limits.y-this.height},follow:function(f,e){if(f instanceof me.ObjectEntity){this.target=f.pos}else{if(f instanceof me.Vector2d){this.target=f}else{throw"melonJS: invalid target for viewport.follow"}}this.follow_axis=e||this.AXIS.BOTH;this.update(true)},move:function(e,h){var g=~~(this.pos.x+e);var f=~~(this.pos.y+h);if((g>=0)&&(g<=this._limitwidth)){this.pos.x=g}if((f>=0)&&(f<=this._limitheight)){this.pos.y=f}},update:function(g){if(this.target&&g){switch(this.follow_axis){case this.AXIS.NONE:break;case this.AXIS.HORIZONTAL:this._followH(this.target,(this._shake.duration>0));break;case this.AXIS.VERTICAL:this._followV(this.target,(this._shake.duration>0));break;case this.AXIS.BOTH:this._followH(this.target,(this._shake.duration>0));this._followV(this.target,(this._shake.duration>0));break;default:break}g=(this.last.x!=this.pos.x)||(this.last.y!=this.pos.y);this.last.copy(this.pos)}if(this._shake.duration>0){this._shake.duration-=me.timer.tick;if(this._shake.duration<0){if(this._shake.onComplete){this._shake.onComplete()}}else{if((this._shake.axis==this.AXIS.BOTH)||(this._shake.axis==this.AXIS.HORIZONTAL)){var f=(Math.random()*this._shake.intensity);if(this.pos.x+this.width+f<this.limits.x){this.pos.x+=~~f}else{this.pos.x-=~~f}}if((this._shake.axis==this.AXIS.BOTH)||(this._shake.axis==this.AXIS.VERTICAL)){var e=(Math.random()*this._shake.intensity);if(this.pos.y+this.height+e<this.limits.y){this.pos.y+=~~e}else{this.pos.y-=~~e}}g=true}}if((this._fadeIn.tween!=null)||(this._fadeOut.tween!=null)){g=true}return g},shake:function(e,h,f,g){f=f||this.AXIS.BOTH;if(f==this.AXIS.BOTH){if(this.width==this.limits.x){f=this.AXIS.VERTICAL}else{if(this.height==this.limits.y){f=this.AXIS.HORIZONTAL}}}if((f==this.AXIS.HORIZONTAL)&&(this.width==this.limits.x)){return}if((f==this.AXIS.VERTICAL)&&(this.height==this.limits.y)){return}this._shake.intensity=e;this._shake.duration=h;this._shake.axis=f;this._shake.onComplete=g||null},fadeOut:function(e,g,f){this._fadeOut.color=e;this._fadeOut.duration=g||1000;this._fadeOut.alpha=1;this._fadeOut.tween=new me.Tween(this._fadeOut).to({alpha:0},this._fadeOut.duration).onComplete(f||null);this._fadeOut.tween.start()},fadeIn:function(e,g,f){this._fadeIn.color=e;this._fadeIn.duration=g||1000;this._fadeIn.alpha=0;this._fadeIn.tween=new me.Tween(this._fadeIn).to({alpha:1},this._fadeIn.duration).onComplete(f||null);this._fadeIn.tween.start()},getWidth:function(){return this.width},getHeight:function(){return this.height},focusOn:function(e){this.pos.x=e.x-this.width*0.5;this.pos.y=e.y-this.height*0.5},isVisible:function(e){return e.overlaps(this)},draw:function(e){if(this._fadeIn.tween){if(me.sys.enableWebGL){me.video.clearSurface(e,me.utils.HexToRGB(this._fadeIn.color,this._fadeIn.alpha))}else{e.globalAlpha=this._fadeIn.alpha;me.video.clearSurface(e,me.utils.HexToRGB(this._fadeIn.color));e.globalAlpha=1}if(this._fadeIn.alpha==1){this._fadeIn.tween=null}}if(this._fadeOut.tween){if(me.sys.enableWebGL){me.video.clearSurface(e,me.utils.HexToRGB(this._fadeOut.color,this._fadeOut.alpha))}else{e.globalAlpha=this._fadeOut.alpha;me.video.clearSurface(e,me.utils.HexToRGB(this._fadeOut.color));e.globalAlpha=1}if(this._fadeOut.alpha==0){this._fadeOut.tween=null}}}})})(window);(function(b,d){var a=Math.min;me.ObjectSettings={name:null,image:null,transparent_color:null,spritewidth:null,spriteheight:null,type:0,collidable:false};me.entityPool=(function(){var f={};var e={};f.init=function(){f.add("me.LevelEntity",me.LevelEntity);f.add("me.ObjectEntity",me.ObjectEntity);f.add("me.CollectableEntity",me.CollectableEntity);f.add("me.InvisibleEntity",me.InvisibleEntity)};f.add=function(h,g){e[h.toLowerCase()]=g};f.newIstanceOf=function(g){if(!e[g.name]){alert("cannot instance entity of type '"+g.name+"': Class not found!");return null}return new e[g.name](g.x,g.y,g)};return f})();var c=me.Rect.extend({init:function(e,g,f){this.image=me.loader.getImage(e);this.parent(new me.Vector2d(0,0),this.image.width,this.image.height);this.baseOffset=0;this.z=f||0;this.scrollspeed=g;this.vp_width=me.game.viewport.width},draw:function(h,e,i){var g=0;var f=a(this.width-e,this.vp_width);do{h.drawImage(this.image,e,0,f,this.height,g,i,f,this.height);g+=f;e=0;f=a(this.width,this.vp_width-g)}while((g<this.vp_width))}});me.ParallaxBackgroundEntity=me.Rect.extend({init:function(e){this.parent(new me.Vector2d(0,0),0,0);this.name="parallaxBackgroundEntity";this.visible=true;this.z=e||0;this.vp=me.game.viewport.pos;this.lastx=this.vp.x;this.parallaxLayers=[];this.updated=true},addLayer:function(f,h,g){var e=this.parallaxLayers.length;this.parallaxLayers.push(new c(f,h,g));if(this.parallaxLayers[e].width>this.width){this.width=this.parallaxLayers[e].width}if(this.parallaxLayers[e].height>this.height){this.height=this.parallaxLayers[e].height}},clearTile:function(e,f){},update:function(){return this.updated},getRect:function(){return new me.Rect(this.vp.clone(),this.width,this.height)},draw:function(h){var e=this.vp.x;if(e>this.lastx){for(var g=0,f;f=this.parallaxLayers[g++];){f.baseOffset=(f.baseOffset+f.scrollspeed*me.timer.tick)%f.width;f.draw(h,~~f.baseOffset,0);this.lastx=e;this.updated=true}return}else{if(e<this.lastx){for(var g=0,f;f=this.parallaxLayers[g++];){f.baseOffset=(f.width+(f.baseOffset-f.scrollspeed*me.timer.tick))%f.width;f.draw(h,~~f.baseOffset,0);this.lastx=e;this.updated=true}return}}for(var g=0,f;f=this.parallaxLayers[g++];){f.draw(h,~~f.baseOffset,0);this.lastx=e;this.updated=false}}});me.SpriteObject=me.Rect.extend({scale:null,scaleFlag:false,lastflipX:false,lastflipY:false,z:0,offset:null,autodestroy:true,visible:true,image:null,collisionBox:null,flickering:false,flickerTimer:-1,flickercb:null,flickerState:false,vp:null,init:function(e,i,g,f,h){this.parent(new me.Vector2d(e,i),f||g.width,h||g.height);this.image=g;this.scale=new me.Vector2d(1,1);this.collisionBox=new me.Rect(this.pos,this.width,this.height);this.vp=me.game.viewport;this.offset=new me.Vector2d(0,0)},setTransparency:function(e){e=(e.charAt(0)=="#")?e.substring(1,7):e;this.image=me.video.applyRGBFilter(this.image,"transparent",e.toUpperCase()).canvas},isFlickering:function(){return this.flickering},flicker:function(e,f){this.flickerTimer=e;if(this.flickerTimer<0){this.flickering=false;this.flickercb=null}else{if(!this.flickering){this.flickercb=f;this.flickering=true}}},flipX:function(e){if(e!=this.lastflipX){this.lastflipX=e;this.scale.x=-this.scale.x;this.scaleFlag=((this.scale.x!=1)||(this.scale.y!=1));this.collisionBox.flipX(this.width)}},flipY:function(e){if(e!=this.lastflipY){this.lastflipY=e;this.scale.y=-this.scale.y;this.scaleFlag=((this.scale.x!=1)||(this.scale.y!=1));this.collisionBox.flipY(this.height)}},resize:function(e){if(e>0){this.scale.x=this.scale.x<0?-e:e;this.scale.y=this.scale.y<0?-e:e;this.scaleFlag=((this.scale.x!=1)||(this.scale.y!=1))}},update:function(){if(this.flickering){this.flickerTimer-=me.timer.tick;if(this.flickerTimer<0){if(this.flickercb){this.flickercb()}this.flicker(-1)}return true}return false},draw:function(f){if(this.flickering){this.flickerState=!this.flickerState;if(!this.flickerState){return}}var e=~~(this.pos.x-this.vp.pos.x),g=~~(this.pos.y-this.vp.pos.y);if(this.scaleFlag){f.translate(e+this.hWidth,g+this.hHeight);f.scale(this.scale.x,this.scale.y);f.translate(-this.hWidth,-this.hHeight);e=g=0}f.drawImage(this.image,this.offset.x,this.offset.y,this.width,this.height,e,g,this.width,this.height);if(this.scaleFlag){f.setTransform(1,0,0,1,0,0)}if(me.debug.renderHitBox){this.parent(f,"blue");this.collisionBox.draw(f,"red")}},destroy:function(){if(this.autodestroy){this.onDestroyEvent()}return this.autodestroy},onDestroyEvent:function(){}});me.AnimationSheet=me.SpriteObject.extend({fpscount:0,animationspeed:0,init:function(e,i,g,f,h){this.anim=[];this.resetAnim=null;this.current=null;this.parent(e,i,g,f,h);this.spritecount=~~(this.image.width/this.width);if((this.image.width==this.width)&&(this.image.height==this.height)){this.setCurrentSprite=function(){}}this.animationspeed=me.sys.fps/10;this.addAnimation("default",null);this.setCurrentAnimation("default")},addAnimation:function(f,h){this.anim[f]={name:null,frame:[],idx:0,length:0};if(h==null){for(var g=0;g<this.spritecount;g++){this.anim[f].frame[g]=new me.Vector2d(g*this.width,0)}}else{var e=0;for(var g=0;g<h.length;g++){this.anim[f].frame[e]=new me.Vector2d(this.width*(h[g]%this.spritecount),this.height*~~(h[g]/this.spritecount));e++}}this.anim[f].name=f;this.anim[f].length=this.anim[f].frame.length},setCurrentAnimation:function(e,f){this.current=this.anim[e];this.resetAnim=f||null;this.offset=this.current.frame[this.current.idx]},isCurrentAnimation:function(e){return(this.current.name==e)},setCurrentSprite:function(e){this.current.idx=e;this.offset=this.current.frame[e];if((this.current.idx==0)&&this.resetAnim){if(typeof(this.resetAnim)=="string"){this.setCurrentAnimation(this.resetAnim)}else{if(typeof(this.resetAnim)=="function"){this.resetAnim()}}}},update:function(){this.parent();if(this.visible&&(this.fpscount++>this.animationspeed)){this.setCurrentSprite(++this.current.idx%this.current.length);this.fpscount=0;return true}return false}});me.ObjectEntity=me.AnimationSheet.extend({GUID:null,type:0,collidable:false,init:function(e,g,f){this.parent(e,g,(typeof f.image=="string")?me.loader.getImage(f.image):f.image,f.spritewidth,f.spriteheight);if(f.transparent_color){this.setTransparency(f.transparent_color)}this.GUID=me.utils.createGUID();this.name=f.name;this.pos.set(e,me.game.currentLevel?g+me.game.currentLevel.tileheight-this.height:g);this.vel=new me.Vector2d();this.accel=new me.Vector2d();this.friction=new me.Vector2d();this.maxVel=new me.Vector2d(1000,1000);this.gravity=0.98;this.isEntity=true;this.alive=true;this.falling=false;this.jumping=true;this.slopeY=0;this.onslope=false;this.onladder=false;this.collidable=f.collidable||false;this.type=f.type||0;this.collisionMap=me.game.collisionMap;this.canBreakTile=false;this.onTileBreak=null},updateColRect:function(e,f,i,g){this.collisionBox.adjustSize(e,f,i,g)},checkCollision:function(f){var e=this.collisionBox.collideVsAABB(f.collisionBox);if(e.x!=0||e.y!=0){this.onCollision(e,f);e.type=this.type;e.obj=this;return e}return null},onCollision:function(e,f){if(this.collidable&&(this.type==me.game.COLLECTABLE_OBJECT)){me.game.remove(this)}},setVelocity:function(e,f){this.accel.x=(e!=0)?e:this.accel.x;this.accel.y=(e!=0)?f:this.accel.y;this.setMaxVelocity(e,f)},setMaxVelocity:function(e,f){this.maxVel.x=e;this.maxVel.y=f},setFriction:function(e,f){this.friction.x=e||0;this.friction.y=f||0},doWalk:function(e){this.flipX(e);this.vel.x+=(e)?-this.accel.x*me.timer.tick:this.accel.x*me.timer.tick},doClimb:function(e){if(this.onladder){this.vel.y=(e)?-this.accel.x*me.timer.tick:this.accel.x*me.timer.tick;return true}return false},doJump:function(){if(!this.jumping&&!this.falling){this.vel.y=-this.maxVel.y*me.timer.tick;this.jumping=true;return true}return false},forceJump:function(){this.jumping=this.falling=false;this.doJump()},distanceTo:function(g){var f=(this.pos.x+(this.width>>1))-(g.pos.x+(g.width>>1));var e=(this.pos.y+(this.height>>1))-(g.pos.y+(g.height>>1));return Math.sqrt(f*f+e*e)},checkSlope:function(e,f){this.pos.y=e.pos.y-this.height;if(f){this.slopeY=e.height-(this.collisionBox.right+this.vel.x-e.pos.x)}else{this.slopeY=(this.collisionBox.left+this.vel.x-e.pos.x)}this.vel.y=0;this.pos.y+=this.slopeY.clamp(0,e.height)},computeVelocity:function(e){if(this.gravity){e.y+=!this.onladder?(this.gravity*me.timer.tick):0;this.falling=(e.y>0);this.jumping=this.falling?false:this.jumping}if(this.friction.x){e.x=me.utils.applyFriction(e.x,this.friction.x)}if(this.friction.y){e.y=me.utils.applyFriction(e.y,this.friction.y)}if(e.y!=0){e.y=e.y.clamp(-this.maxVel.y,this.maxVel.y)}if(e.x!=0){e.x=e.x.clamp(-this.maxVel.x,this.maxVel.x)}return e},updateMovement:function(){this.vel=this.computeVelocity(this.vel);var e=this.collisionMap.checkCollision(this.collisionBox,this.vel);this.onladder=e.xprop.isLadder;this.onslope=e.yprop.isSlope||e.xprop.isSlope;if(e.y){if(e.y>0){if(e.yprop.isSolid||(e.yprop.isPlatform&&(~~this.pos.y+this.height<=e.ytile.pos.y))){this.pos.y=~~this.pos.y;this.vel.y=(this.falling)?e.ytile.pos.y-this.pos.y-this.height:0;this.falling=false}else{if(e.yprop.isSlope&&!this.jumping){this.checkSlope(e.ytile,e.yprop.isLeftSlope);this.falling=false}else{if(e.yprop.isBreakable){if(this.canBreakTile){me.game.currentLevel.clearTile(e.ytile.row,e.ytile.col);if(this.onTileBreak){this.onTileBreak()}}else{this.pos.y=~~this.pos.y;this.vel.y=(this.falling)?e.ytile.pos.y-this.pos.y-this.height:0;this.falling=false}}}}}else{if(e.y<0){if(!e.yprop.isPlatform&&!e.yprop.isLadder){this.falling=true;this.vel.y=0}}}}if(e.x){if(e.xprop.isSlope&&!this.jumping){this.checkSlope(e.xtile,e.xprop.isLeftSlope);this.falling=false}else{if(!e.xprop.isPlatform&&!e.xprop.isLadder){if(e.xprop.isBreakable&&this.canBreakTile){me.game.currentLevel.clearTile(e.xtile.row,e.xtile.col);if(this.onTileBreak){this.onTileBreak()}}else{this.vel.x=0}}}}this.pos.add(this.vel);return e}});me.CollectableEntity=me.ObjectEntity.extend({init:function(e,g,f){this.parent(e,g,f);this.collidable=true;this.type=me.game.COLLECTABLE_OBJECT}});me.InvisibleEntity=me.Rect.extend({z:0,collisionBox:null,init:function(e,g,f){this.parent(new me.Vector2d(e,g),f.width,f.height);this.collisionBox=new me.Rect(this.pos,f.width,f.height);this.visible=true;this.collidable=true;this.isEntity=true},updateColRect:function(e,f,i,g){this.collisionBox.adjustSize(e,f,i,g)},checkCollision:function(f){var e=this.collisionBox.collideVsAABB(f.collisionBox);if(e.x!=0||e.y!=0){this.onCollision(e,f);e.type=this.type;return e}return null},onCollision:function(e,f){if(this.collidable&&(this.type==me.game.COLLECTABLE_OBJECT)){me.game.remove(this)}},destroy:function(){this.onDestroyEvent();return true},onDestroyEvent:function(){},update:function(){return false},draw:function(e){if(me.debug.renderHitBox){e.strokeStyle="blue";e.strokeRect(this.pos.x-me.game.viewport.pos.x,this.pos.y-me.game.viewport.pos.y,this.width,this.height);this.collisionBox.draw(e)}}});me.LevelEntity=me.InvisibleEntity.extend({init:function(e,g,f){this.parent(e,g,f);this.nextlevel=f.to;this.fade=f.fade;this.duration=f.duration;this.fading=false;this.gotolevel=f.to},onFadeComplete:function(){me.levelDirector.loadLevel(this.gotolevel);me.game.viewport.fadeOut(this.fade,this.duration)},goTo:function(e){this.gotolevel=e||this.nextlevel;if(this.fade&&this.duration){if(!this.fading){this.fading=true;me.game.viewport.fadeIn(this.fade,this.duration,this.onFadeComplete.bind(this))}}else{me.levelDirector.loadLevel(this.gotolevel)}},onCollision:function(){this.goTo()}})})(window);(function(a,b){me.Font=Object.extend({ALIGN:{LEFT:"left",CENTER:"center",RIGHT:"right"},font:null,height:null,color:null,align:null,init:function(d,e,c,f){this.set(d,e,c,f)},bold:function(){this.font="bold "+this.font},italic:function(){this.font="italic "+this.font},set:function(d,e,c,f){this.font=""+e+"px "+d;this.height=e;this.color=c;this.align=f||"top"},getRect:function(){return new me.Rect(new Vector2d(0,0),0,0)},measureText:function(c,e){c.font=this.font;c.fillStyle=this.color;c.textBaseLine=this.align;var d=c.measureText(e);d.height=this.height;return d},draw:function(d,e,c,f){d.font=this.font;d.fillStyle=this.color;d.textBaseLine=this.align;d.fillText(e,~~c,~~f)}});me.BitmapFont=me.Font.extend({size:null,sSize:null,firstChar:32,charCount:0,init:function(c,d,f,e){this.parent(c,null,null);this.size=new me.Vector2d();this.sSize=new me.Vector2d();this.firstChar=e||32;this.loadFontMetrics(c,d);this.align=this.ALIGN.RIGHT;if(f){this.resize(f)}},loadFontMetrics:function(c,d){this.font=me.loader.getImage(c);this.size.x=d.x||d;this.size.y=d.y||this.font.height;this.sSize.copy(this.size);this.charCount=~~(this.font.width/this.size.x)},set:function(d,c){this.align=d;if(c){this.resize(c)}},resize:function(c){this.sSize.copy(this.size);this.sSize.x*=c;this.sSize.y*=c},measureText:function(c){return{width:c.length*this.sSize.x,height:this.sSize.y}},draw:function(f,g,d,h){if(typeof(g)!="string"){g=g.toString()}if(this.align==this.ALIGN.RIGHT){d-=g.length*this.sSize.x}for(var e=0;e<g.length;e++){var c=g.charCodeAt(e)-this.firstChar;f.drawImage(this.font,this.size.x*(c%this.charCount),this.size.y*~~(c/this.charCount),this.size.x,this.size.y,~~d,~~h,this.sSize.x,this.sSize.y);d+=this.sSize.x}}})})(window);(function(a,b){me.GUI_Object=me.SpriteObject.extend({isClickable:true,updated:false,init:function(c,e,d){this.parent(c,e,((typeof d.image=="string")?me.loader.getImage(d.image):d.image),d.spritewidth,d.spriteheight)},update:function(){if(this.updated){this.updated=false;return true}return false},clicked:function(){return true},mouseEvent:function(c,d){if((c>this.left)&&(c<this.right)&&(d>this.top)&&(d<this.bottom)){if(this.isClickable){this.updated=this.clicked()}}return this.updated}})})(window);(function(a,b){me.HUD_Item=Object.extend({init:function(c,e,d){this.pos=new me.Vector2d(c||0,e||0);this.visible=true;this.defaultvalue=d||0;this.value=d||0;this.updated=true},reset:function(){this.set(this.defaultvalue)},set:function(c){this.value=c;this.updated=true;return true},update:function(c){return this.set(this.value+c)},draw:function(d,c,e){}});me.HUD_Object=me.Rect.extend({init:function(c,g,d,f,e){this.parent(new me.Vector2d(c||0,g||0),d||me.video.getWidth(),f||me.video.getHeight());this.bgcolor=e;this.HUDItems={};this.HUDobj=[];this.objCount=0;this.visible=true;this.HUD_invalidated=true;this.HUDCanvasSurface=me.video.createCanvasSurface(this.width,this.height);this.z=999},addItem:function(c,d){this.HUDItems[c]=d;this.HUDobj.push(this.HUDItems[c]);this.objCount++;this.HUD_invalidated=true},setItemValue:function(c,d){if(this.HUDItems[c]&&(this.HUDItems[c].set(d)==true)){this.HUD_invalidated=true}},updateItemValue:function(c,d){if(this.HUDItems[c]&&(this.HUDItems[c].update(d)==true)){this.HUD_invalidated=true}},getItemValue:function(c){return(this.HUDItems[c])?this.HUDItems[c].value:0},update:function(){return this.HUD_invalidated},reset:function(c){if(c!=b){if(this.HUDItems[c]){this.HUDItems[c].reset()}this.HUD_invalidated=true}else{this.resetAll()}},resetAll:function(){for(var c=this.objCount,d;c--,d=this.HUDobj[c];){d.reset()}this.HUD_invalidated=true},getRect:function(){p=this.pos.clone();p.add(me.game.viewport.pos);return new me.Rect(p,this.width,this.height)},draw:function(d){if(this.HUD_invalidated){if(this.bgcolor){me.video.clearSurface(this.HUDCanvasSurface,this.bgcolor)}else{this.HUDCanvasSurface.canvas.width=this.HUDCanvasSurface.canvas.width}for(var c=this.objCount,e;c--,e=this.HUDobj[c];){if(e.visible){e.draw(this.HUDCanvasSurface,0,0);if(e.updated){e.updated=false}}}}d.drawImage(this.HUDCanvasSurface.canvas,this.pos.x,this.pos.y);this.HUD_invalidated=false}})})(window);(function(a,b){me.audio=(function(){var j={};var s=[];var c=["mp3","ogg","wav"];var g=null;var r=-1;var e=null;var m=null;var k=true;var q=0;var l=0;function h(){var t=0;if(!me.sys.sound){k=false;return}if((g.search(/mp3/i)!=-1)&&j.capabilities.mp3){return c[t]}if((g.search(/ogg/i)!=-1)&&j.capabilities.ogg){return c[++t]}if((g.search(/wav/i)!=-1)&&j.capabilities.wav){return c[++t]}k=false;return -1}function f(u){var t=s[u];for(var v=0,w;w=t[v++];){if(w.ended||!w.currentTime){w.currentTime=q;return w}}t[0].pause();t[0].currentTime=q;return t[0]}function n(t){if(l++>3){var u="melonJS: failed loading "+t+"."+r;if(me.sys.stopOnAudioError===false){me.audio.disable();if(e){e()}console.log(u+", disabling audio")}else{throw u}}else{s[t][0].load()}}function d(t,x){l=0;if(x>1){var u=s[t][0];for(var w=1;w<x;w++){var v=u.cloneNode(true);if(v.currentSrc.length==0){v.src=u.src}s[t][w]=v;s[t][w].load()}}if(e){e()}}function o(u,t,w){var v=f(u);v.loop=t||false;v.play();if(w&&!t){v.addEventListener("ended",function(x){v.removeEventListener("ended",arguments.callee,false);w()},false)}}function i(u,t,v){if(v&&!t){setTimeout(v,2000)}}j.capabilities={mp3:false,ogg:false,ma4:false,wav:false,};j.init=function(t){if(t){g=new String(t)}else{g=new String("mp3")}r=h();if(k){j.play=o}else{j.play=i}return k};j.setLoadCallback=function(t){e=t};j.isAudioEnable=function(){return k};j.enable=function(){k=me.sys.sound;if(k){j.play=o}else{j.play=i}};j.disable=function(){k=false;j.play=i};j.load=function(u){if(r==-1){return 0}var t=new Audio(u.src+u.name+"."+r+me.nocache);t.preload="auto";t.addEventListener("canplaythrough",function(v){this.removeEventListener("canplaythrough",arguments.callee,false);d(u.name,u.channel)},false);t.addEventListener("error",function(v){n(u.name)},false);t.src=u.src+u.name+"."+r+me.nocache;t.load();s[u.name]=[t];return 1};j.stop=function(u){if(k){var v=s[u];for(var t=v.length;t--;){v[t].pause();v[t].currentTime=q}}};j.pause=function(u){if(k){var v=s[u];for(var t=v.length;t--;){v[t].pause()}}};j.playTrack=function(t){if(k){if(m!=null){j.stopTrack()}m=f(t);if(m){m.loop=true;m.play()}}};j.stopTrack=function(){if(k&&m){m.pause();m=null}};j.pauseTrack=function(){if(k&&m){m.pause()}};j.resumeTrack=function(){if(k&&m){m.play()}};return j})()})(window);(function(a,b){me.timer=(function(){var g={};var l=null;var c=false;var f=0;var h=0;var k=0;var d=0;var j=0;var e=Math.ceil(1000/me.sys.fps);var m=(1000/me.sys.fps)*1.25;function i(n){l.replaceChild(document.createTextNode("("+n+"/"+me.sys.fps+" fps)"),l.firstChild)}g.tick=1;g.init=function(){l=document.getElementById("framecounter");c=(l!==null);g.reset()};g.reset=function(){d=k=new Date().getTime();h=0;f=0};g.getTime=function(){return d};g.update=function(){k=d;d=new Date().getTime();j=(d-k);if(c){f++;h+=j;if(f%10==0){var n=~~((1000*f)/h);i(n.clamp(0,me.sys.fps));h=0;f=0}}g.tick=(j>m&&me.sys.interpolation)?j/e:1};return g})();me.video=(function(){var g={};var e=null;var i=null;var j=null;var h=null;var d=null;var k=false;var f=0;var c=0;g.init=function(n,r,m,l,q){k=l||false;me.sys.scale=k===true?q||1:1;f=r*me.sys.scale;c=m*me.sys.scale;d=document.getElementById(n);e=document.createElement("canvas");e.setAttribute("width",(f)+"px");e.setAttribute("height",(c)+"px");e.setAttribute("border","0px solid black");d.appendChild(e);if(me.sys.enableWebGL&&window.WebGLRenderingContext){try{WebGL2D.enable(e);i=e.getContext("webgl-2d");me.sys.cacheImage=true}catch(o){i=null}}if(i==null){me.sys.enableWebGL=false;if(!e.getContext){return false}i=e.getContext("2d")}if(k){h=g.createCanvasSurface(r,m);j=h.canvas}else{h=i;j=i.canvas}return true};g.getWrapper=function(){return d};g.getWidth=function(){return j.width};g.getHeight=function(){return j.height};g.createCanvasSurface=function(m,l){var n=document.createElement("canvas");n.width=m||j.width;n.height=l||j.height;return n.getContext("2d")};g.getScreenCanvas=function(){return e};g.getScreenFrameBuffer=function(){return h};g.updateDisplaySize=function(l){if(k){if(l){me.sys.scale=l}else{me.sys.scale=document.getElementById("screen size").value}f=j.width*me.sys.scale;c=j.height*me.sys.scale;e.width=f;e.height=c}};g.clearSurface=function(m,l){m.fillStyle=l;m.fillRect(0,0,m.canvas.width,m.canvas.height)};g.scale=function(l,m){l.translate(-(((l.canvas.width*m)-l.canvas.width)>>1),-(((l.canvas.height*m)-l.canvas.height)>>1));l.scale(m,m)};g.setAlpha=function(m,l){m.globalCompositeOperation=l?"source-over":"copy"};g.blitSurface=function(){if(k){g.blitSurface=function(){i.drawImage(j,0,0,j.width,j.height,0,0,f,c)}}else{g.blitSurface=function(){}}g.blitSurface()};g.applyRGBFilter=function(o,w,r){var s=g.createCanvasSurface(o.width,o.height);var t=me.utils.getPixels(o);var u=t.data;switch(w){case"b&w":for(var q=0,m=u.length;q<m;q+=4){var l=(3*u[q]+4*u[q+1]+u[q+2])>>>3;u[q]=l;u[q+1]=l;u[q+2]=l}break;case"brightness":var v=Math.abs(r).clamp(0,1);for(var q=0,m=u.length;q<m;q+=4){u[q]*=v;u[q+1]*=v;u[q+2]*=v}break;case"transparent":for(var q=0,m=u.length;q<m;q+=4){if(me.utils.RGBToHex(u[q],u[q+1],u[q+2])===r){u[q+3]=0}}break;default:return null}s.putImageData(t,0,0);return s};return g})()})(window);(function(a,b){me.input=(function(){var h={};var f=[];var k=[];var n=[];var d=[];var g=null;var j=null;var m=false;function o(r){if(r){if(!m){a.addEventListener("keydown",e,false);a.addEventListener("keyup",c,false)}}else{a.removeEventListener("keydown",e,false);a.removeEventListener("keyup",c,false)}m=r}function l(r){r.stopPropagation();if(r.preventDefault){r.preventDefault()}r.returnValue=false;r.cancelBubble=true}function e(s){var r=f[s.keyCode||s.which];if(r){if(!d[r]){k[r]=true;d[r]=n[r]}l(s);return false}return true}function c(s){var r=f[s.keyCode||s.which];if(r){k[r]=false;d[r]=false;l(s);return false}return true}function i(s){var r=s.clientX-me.video.getScreenCanvas().offsetLeft;var t=s.clientY-me.video.getScreenCanvas().offsetTop;g(r,t)}function q(r){}h.KEY={LEFT:37,UP:38,RIGHT:39,DOWN:40,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,ESC:27,SPACE:32,"0":48,"1":49,"2":50,"3":51,"4":52,"5":53,"6":54,"7":55,"8":56,"9":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,};h.isKeyPressed=function(r){if(k[r]){if(n[r]){d[r]=true;k[r]=false}return true}return false};h.keyStatus=function(r){return(d[r]===true)?true:k[r]};h.bindKey=function(r,t,s){if(!m){o(true)}f[r]=t;n[t]=s?s:false;d[t]=false};h.unbindKey=function(r){k[f[r]]=false;n[f[r]]=false;f[r]=null};h.enableMouseEvent=function(r,s){if(r){me.video.getScreenCanvas().addEventListener("click",i,false);g=s||me.game.mouseEvent.bind(me.game)}else{me.video.getScreenCanvas().removeEventListener("click",i,false)}};h.enableGyroscopicEvent=function(r,s){if(a.sys.gyro){a.ondevicemotion=r?q:null;j=r?s:null}};return h})()})(window);(function(a,c){var b=(function(){var e={};var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.decode=function(h){h=h.replace(/[^A-Za-z0-9\+\/\=]/g,"");if(me.sys.nativeBase64){return a.atob(h)}else{var f=[],q,n,l,o,m,k,j,g=0;while(g<h.length){o=d.indexOf(h.charAt(g++));m=d.indexOf(h.charAt(g++));k=d.indexOf(h.charAt(g++));j=d.indexOf(h.charAt(g++));q=(o<<2)|(m>>4);n=((m&15)<<4)|(k>>2);l=((k&3)<<6)|j;f.push(String.fromCharCode(q));if(k!=64){f.push(String.fromCharCode(n))}if(j!=64){f.push(String.fromCharCode(l))}}f=f.join("");return f}};return e})();me.utils=(function(){var d={};var e={};var g="";var f=0;d.decodeBase64=function(h){return b.decode(h)};d.decodeBase64AsArray=function(m,k){k=k||1;var q=b.decode(m),l=[],o,n,h;for(o=0,h=q.length/k;o<h;o++){l[o]=0;for(n=k-1;n>=0;--n){l[o]+=q.charCodeAt((o*k)+n)<<(n<<3)}}return l};d.decodeCSV=function(k,j){k=k.trim().split("\n");var h=[];for(var l=0;l<k.length;l++){entries=k[l].split(",",j);for(var m=0;m<entries.length;m++){h.push(+entries[m])}}return h};d.setNocache=function(h){me.nocache=h?"?"+parseInt(Math.random()*10000000):""};d.HexToRGB=function(j,i){j=(j.charAt(0)=="#")?j.substring(1,7):j;if(e[j]==null){e[j]=parseInt(j.substring(0,2),16)+","+parseInt(j.substring(2,4),16)+","+parseInt(j.substring(4,6),16)}return(i?"rgba(":"rgb(")+e[j]+(i?","+i+")":")")};d.RGBToHex=function(j,i,h){return j.toHex()+i.toHex()+h.toHex()};d.getPixels=function(h){if(h instanceof HTMLImageElement){var i=me.video.createCanvasSurface(h.width,h.height);i.drawImage(h,0,0);return i.getImageData(0,0,h.width,h.height)}else{return h.getContext("2d").getImageData(0,0,h.width,h.height)}};d.resetGUID=function(h){g=h.toUpperCase().toHex();f=0};d.createGUID=function(){return g+"-"+(f++)};d.applyFriction=function(h,i){return(h+i<0)?h+(i*me.timer.tick):(h-i>0)?h-(i*me.timer.tick):0};return d})()})(window);(function(b,c){function a(d){this.defaultvalue=d||0;this.value=d||0;this.updated=true}a.prototype.reset=function(){this.set(this.defaultvalue)};a.prototype.update=function(d){return this.set(this.value+d)};a.prototype.set=function(d){this.value=d;this.updated=true;return this.updated};me.gamestat=(function(){var f={};var e={};var g=[];var d=0;f.add=function(h,i){e[h]=new a(i);g.push(e[h]);d++};f.updateValue=function(h,i){if(e[h]){e[h].update(i)}};f.setValue=function(h,i){if(e[h]){e[h].set(i)}};f.getItemValue=function(h){return(e[h])?e[h].value:0};f.reset=function(h){if(h!=c){if(e[h]){e[h].reset()}}else{f.resetAll()}};f.resetAll=function(){for(var h=d,j;h--,j=g[h];){j.reset()}};return f})()})(window);(function(e,g){var c=/^.*(\\|\/|\:)/;var f=/\.[^\.]*$/;me.LevelConstants={COLLISION_MAP:"collision",PARALLAX_MAP:"parallax",};me.Tile=me.Rect.extend({init:function(i,m,j,k,l){this.parent(new me.Vector2d(i*j,m*k),j,k);this.tileId=l;this.row=i;this.col=m}});function b(k,l,j,n,m,i){this.name=k;this.tilewidth=l;this.tileheight=j;this.spacing=n;this.margin=m;this.image=(i)?me.loader.getImage(i.replace(c,"").replace(f,"")):null;this.type={SOLID:"solid",PLATFORM:"platform",L_SLOPE:"lslope",R_SLOPE:"rslope",LADDER:"ladder",BREAKABLE:"breakable"};this.TileProperties=[];if(this.image){this.hTileCount=~~((this.image.width-this.margin)/(this.tilewidth+this.spacing));this.vTileCount=~~((this.image.height-this.margin)/(this.tileheight+this.spacing))}}b.prototype.getPropertyList=function(){return{isCollidable:false,isSolid:false,isPlatform:false,isSlope:false,isLeftSlope:false,isRightSlope:false,isLadder:false,isBreakable:false}};b.prototype.getTileProperties=function(i){return this.TileProperties[i]};b.prototype.isTileCollidable=function(i){return this.TileProperties[i].isCollidable};b.prototype.getTileImage=function(j){var i=me.video.createCanvasSurface(this.tilewidth,this.tileheight);this.drawTile(i,0,0,j);return i.canvas};b.prototype.drawTile=function(l,i,q,o,k,j){var n=this.margin+(this.spacing+this.tilewidth)*(o%this.hTileCount);var m=this.margin+(this.spacing+this.tileheight)*~~(o/this.hTileCount);if(k||j){k=(k==0)?1:-1;j=(j==0)?1:-1;l.scale(k,j);i=(i*k)-(k<0?this.tilewidth:0);q=(q*j)-(j<0?this.tileheight:0)}l.drawImage(this.image,n,m,this.tilewidth,this.tileheight,i,q,this.tilewidth,this.tileheight);if(k||j){l.setTransform(1,0,0,1,0,0)}};function d(i,j){this.realwidth=i;this.realheight=j;this.isCollisionMap=true}d.prototype.checkCollision=function(l,k){var i=(k.x<0)?l.left+k.x:l.right+k.x;var m=(k.y<0)?l.top+k.y:l.bottom+k.y;var j={x:0,y:0,xprop:{},yprop:{}};if(i<=0||i>=this.realwidth){j.x=k.x}if(m<=0||m>=this.realheight){j.y=k.y}return j};function h(j,k,i,l){this.width=j;this.height=k;this.z=l;this.name=null;this.visible=false;this.layerData=null;this.xLUT={};this.yLUT={};this.tilesets=i;this.tileset=i?this.tilesets.getTilesetByIndex(0):null;this.tilewidth=this.tileset?this.tileset.tilewidth:0;this.tileheight=this.tileset?this.tileset.tileheight:0;this.realwidth=this.width*this.tilewidth;this.realheight=this.height*this.tileheight}h.prototype.initArray=function(j){this.layerData=[];for(var i=0;i<this.width+1;i++){this.layerData[i]=[];for(var k=0;k<this.height+1;k++){this.layerData[i][k]=null}}if(j){for(var i=0;i<this.width*this.tilewidth;i++){this.xLUT[i]=~~(i/this.tilewidth)}for(var k=0;k<this.height*this.tileheight;k++){this.yLUT[k]=~~(k/this.tileheight)}}};h.prototype.getTileId=function(i,k){var j=this.layerData[this.xLUT[~~i]][this.yLUT[~~k]];return j?j.tileId:null};h.prototype.getTile=function(i,j){return this.layerData[this.xLUT[~~i]][this.yLUT[~~j]]};h.prototype.setTile=function(i,k,j){this.layerData[i][k]=new me.Tile(i,k,this.tilewidth,this.tileheight,j)};h.prototype.clearTile=function(i,j){this.layerData[i][j]=null};h.prototype.checkCollision=function(l,k){var i=(k.x<0)?l.left+k.x:l.right+k.x;var m=(k.y<0)?l.top+k.y:l.bottom+k.y;var j={x:0,xtile:g,xprop:{},y:0,ytile:g,yprop:{}};if(i<=0||i>=this.realwidth){j.x=k.x}else{j.xtile=this.getTile(i,l.bottom-1);if(j.xtile&&this.tileset.isTileCollidable(j.xtile.tileId)){j.x=k.x;j.xprop=this.tileset.getTileProperties(j.xtile.tileId)}else{j.xtile=this.getTile(i,l.top);if(j.xtile&&this.tileset.isTileCollidable(j.xtile.tileId)){j.x=k.x;j.xprop=this.tileset.getTileProperties(j.xtile.tileId)}}}j.ytile=this.getTile((k.x<0)?l.left:l.right,m);if(j.ytile&&this.tileset.isTileCollidable(j.ytile.tileId)){j.y=k.y||1;j.yprop=this.tileset.getTileProperties(j.ytile.tileId)}else{j.ytile=this.getTile((k.x<0)?l.right:l.left,m);if(j.ytile&&this.tileset.isTileCollidable(j.ytile.tileId)){j.y=k.y||1;j.yprop=this.tileset.getTileProperties(j.ytile.tileId)}}return j};h.prototype.update=function(){return false};function a(i,j){this.pos=new me.Vector2d(i,j);this.z=0;this.width=0;this.height=0;this.realwidth=-1;this.realheight=-1;this.tilewidth=0;this.tileheight=0;this.tilesets=null;this.mapLayers=[];this.objectGroups=[];this.initialized=false}a.prototype.reset=function(){this.tilesets=null;this.mapLayers=[];this.objectGroups=[];this.initialized=false};a.prototype.getObjectGroupByName=function(i){return this.objectGroups[i]};a.prototype.getObjectGroups=function(){return this.objectGroups};a.prototype.getLayerByName=function(j){var l=null;j=j.trim().toLowerCase();for(var k=this.mapLayers.length;k--;){if(this.mapLayers[k].name.contains(j)){l=this.mapLayers[k];break}}if((j.contains(me.LevelConstants.COLLISION_MAP))&&(l==null)){l=new d(me.game.currentLevel.realwidth,me.game.currentLevel.realheight)}return l};a.prototype.clearTile=function(j,l){for(var k=this.mapLayers.length;k--;){if(this.mapLayers[k].visible||this.mapLayers[k].isCollisionMap){this.mapLayers[k].clearTile(j,l)}}};a.prototype.addTo=function(j){if(this.visible){j.add(this)}for(var k=this.mapLayers.length;k--;){if(this.mapLayers[k].visible){j.add(this.mapLayers[k])}}};a.prototype.update=function(){return false};me.levelDirector=(function(){var k={};var i={};var j=null;k.reset=function(){};k.addLevel=function(l){throw"melonJS: no level loader defined"};k.addTMXLevel=function(l,m){if(i[l]==null){i[l]=new me.TMXTileMap(l,0,0)}if(m){m()}};k.loadLevel=function(m){if(i[m]===g){throw ("melonJS: level "+m+" not found")}if(i[m] instanceof me.TMXTileMap){var l=me.state.isRunning();if(l){me.state.pause()}me.game.reset();me.utils.resetGUID(m);i[m].reset();i[m].load();j=m;me.game.loadTMXLevel(i[j]);if(l){me.state.resume()}}else{throw"melonJS: no level loader defined"}};k.getCurrentLevelId=function(){return j},k.reloadLevel=function(){return k.loadLevel(j)},k.nextLevel=function(){if(j+1<i.length){return k.loadLevel(j+1)}else{return false}};k.previousLevel=function(){if(j-1>=0){return k.loadLevel(j-1)}else{return false}};return k})();me.TileSet=b;me.TiledLayer=h;me.TileMap=a})(window);(function(B,l){var T="map",C="name",v="value",G="version",P="orientation",K="width",H="height",F="opacity",q="trans",o="tilewidth",a="tileheight",r="firstgid",g="gid",w="tile",x="id",n="data",t="compression",k="encoding",d="base64",h="csv",R="spacing",Q="margin",u="properties",m="property",O="image",f="source",j="visible",E="tileset",N="layer",L="objectgroup",s="object",A="x",z="y",K="width",H="height",J=2147483648,S=1073741824;function e(Y,X){var V=X.getElementsByTagName(u)[0];if(V){var U=V.getElementsByTagName(m);for(var W=0;W<U.length;W++){M(Y,U[W])}}}function M(U,X){var W=me.XMLParser.getStringAttribute(X,C);var V=me.XMLParser.getStringAttribute(X,v);if(!V||V.isBoolean()){V=V?(V=="true"):true}else{if(V.isNumeric()){V=parseInt(V)}}U[W]=V}function I(V,U,W){me.TileMap.call(this,U,W);this.xmlMap=me.loader.getXML(V);if(!this.xmlMap){throw"melonJS:"+V+" TMX map not found"}this.version="";this.orientation="";this.tileMapCanvas=null;this.tilesets=null}I.prototype=new me.TileMap();I.prototype.load=function(){if(this.initialized){return}var Z=0,ac=1;me.XMLParser.parseFromString(this.xmlMap);var ad=me.XMLParser.getAllTagElements();for(var aa=0;aa<ad.length;aa++){var X=ad.item(aa).nodeName;switch(X){case T:var V=ad.item(aa);this.version=me.XMLParser.getStringAttribute(V,G);this.orientation=me.XMLParser.getStringAttribute(V,P);this.width=me.XMLParser.getIntAttribute(V,K);this.height=me.XMLParser.getIntAttribute(V,H);this.tilewidth=me.XMLParser.getIntAttribute(V,o);this.tileheight=me.XMLParser.getIntAttribute(V,a);this.realwidth=this.width*this.tilewidth;this.realheight=this.height*this.tileheight;this.z=Z++;if(this.orientation!="orthogonal"){throw"melonJS: "+this.orientation+" type TMX Tile Map not supported!"}e(this,V);this.visible=false;if(this.background_color){this.visible=true;this.background_color=me.utils.HexToRGB(this.background_color)}if(this.background_image){this.visible=true;this.background_image=me.loader.getImage(this.background_image)}break;case E:if(!this.tilesets){this.tilesets=new y()}this.tilesets.add(new D(ad.item(aa)));break;case N:var W=me.XMLParser.getStringAttribute(ad.item(aa),C);if(W.contains(me.LevelConstants.PARALLAX_MAP)){var Y=(me.XMLParser.getIntAttribute(ad.item(aa),j,1)==1);if(Y){var ae={};e(ae,ad.item(aa));var ab=this.getLayerByName(me.LevelConstants.PARALLAX_MAP);if(!ab){ab=new me.ParallaxBackgroundEntity(Z);this.mapLayers.push(ab)}ab.addLayer(ae.imagesrc,ac++,Z++)}}else{this.mapLayers.push(new c(ad.item(aa),this.orientation,this.tilesets,Z++));Z++}break;case L:var U=me.XMLParser.getStringAttribute(ad.item(aa),C);this.objectGroups.push(new i(U,ad.item(aa),this.tilesets,Z++));break}}me.XMLParser.free();this.initialized=true};I.prototype.draw=function(U,V){if(this.background_color){U.fillStyle=this.background_color;U.fillRect(V.left,V.top,V.width,V.height)}if(this.background_image){U.drawImage(this.background_image,V.left,V.top,V.width,V.height,V.left,V.top,V.width,V.height)}};function y(){this.tilesets=[]}y.prototype.add=function(U){this.tilesets.push(U)};y.prototype.getTilesetByIndex=function(U){return this.tilesets[U]};y.prototype.getTilesetByGid=function(X){var W=-1;for(var V=0,U=this.tilesets.length;V<U;V++){if(this.tilesets[V].contains(X)){return this.tilesets[V]}if(this.tilesets[V].firstgid==this.tilesets[V].lastgid){if(X>=this.tilesets[V].firstgid){W=V}}}if(W!=-1){return this.tilesets[W]}else{throw"no matching tileset found for gid "+X}};function D(W){this.firstgid=me.XMLParser.getIntAttribute(W,r);me.TileSet.call(this,me.XMLParser.getStringAttribute(W,C),me.XMLParser.getIntAttribute(W,o),me.XMLParser.getIntAttribute(W,a),me.XMLParser.getIntAttribute(W,R,0),me.XMLParser.getIntAttribute(W,Q,0),W.getElementsByTagName(O)[0].getAttribute(f));this.lastgid=this.firstgid+(((this.hTileCount*this.vTileCount)-1)||0);this.trans=W.getElementsByTagName(O)[0].getAttribute(q);if(this.trans!==null&&this.image){this.image=me.video.applyRGBFilter(this.image,"transparent",this.trans.toUpperCase()).canvas}var U=W.getElementsByTagName(w);for(var X=0;X<U.length;X++){var Y=me.XMLParser.getIntAttribute(U[X],x)+this.firstgid;this.TileProperties[Y]={};var V=this.TileProperties[Y];e(V,U[X]);V.isSolid=V.type?V.type.toLowerCase()===this.type.SOLID:false;V.isPlatform=V.type?V.type.toLowerCase()===this.type.PLATFORM:false;V.isLeftSlope=V.type?V.type.toLowerCase()===this.type.L_SLOPE:false;V.isRightSlope=V.type?V.type.toLowerCase()===this.type.R_SLOPE:false;V.isBreakable=V.type?V.type.toLowerCase()===this.type.BREAKABLE:false;V.isLadder=V.type?V.type.toLowerCase()===this.type.LADDER:false;V.isSlope=V.isLeftSlope||V.isRightSlope;V.isCollidable=V.isSolid||V.isPlatform||V.isSlope||V.isLadder||V.isBreakable}}D.prototype=new me.TileSet();D.prototype.contains=function(U){return(U>=this.firstgid&&U<=this.lastgid)};function c(X,W,U,Z){me.TiledLayer.call(this,me.XMLParser.getIntAttribute(X,K),me.XMLParser.getIntAttribute(X,H),U,Z);this.orientation=W;this.layerInvalidated=true;this.name=me.XMLParser.getStringAttribute(X,C);this.visible=(me.XMLParser.getIntAttribute(X,j,1)==1);this.opacity=me.XMLParser.getFloatAttribute(X,F,1);e(this,X);this.isCollisionMap=(this.name.contains(me.LevelConstants.COLLISION_MAP));if(this.isCollisionMap){this.visible=false}this.vp=me.game.viewport;var aa=X.getElementsByTagName(n)[0];var Y=me.XMLParser.getStringAttribute(aa,k,null);var V=me.XMLParser.getStringAttribute(aa,t,null);if(Y==""){Y=null}if(V==""){V=null}if(this.visible){this.layerSurface=me.video.createCanvasSurface(this.width*this.tilewidth,this.height*this.tileheight);this.layerCanvas=this.layerSurface.canvas;if(this.opacity>0&&this.opacity<1){this.layerSurface.globalAlpha=this.opacity}}if(this.visible||this.isCollisionMap){this.initArray(this.isCollisionMap);this.fillArray(aa,Y,V)}}c.prototype=new me.TiledLayer();c.prototype.fillArray=function(ac,U,ag){switch(ag){case null:switch(U){case null:var V=ac.getElementsByTagName(w);break;case h:case d:var Z="";for(var W=0,aa=ac.childNodes.length;W<aa;W++){Z+=ac.childNodes[W].nodeValue}if(U==d){var V=me.utils.decodeBase64AsArray(Z,4)}else{var V=me.utils.decodeCSV(Z,this.width)}Z=null;break;default:throw"melonJS: TMX Tile Map "+U+" encoding not supported!";break}break;default:throw"melonJS: "+ag+" compressed TMX Tile Map not supported!";break}var af=V.length-1;var ab,Y;var X;for(var ad=this.height-1;ad>=0;ad--){for(var ae=this.width-1;ae>=0;ae--){X=(U==null)?me.XMLParser.getIntAttribute(V[af--],g):V[af--];ab=(X&J);Y=(X&S);X&=~(J|S);if(X>0){this.setTile(ae,ad,X);if(!this.tileset.contains(X)){this.tileset=this.tilesets.getTilesetByGid(X)}if(this.visible){if(this.orientation=="orthogonal"){this.tileset.drawTile(this.layerSurface,ae*this.tilewidth,ad*this.tileheight,X-this.tileset.firstgid,ab,Y)}else{this.tileset.drawTile(this.layerSurface,(ae-ad)*this.tilewidth>>1,(ad+ae)*this.tileheight>>2,X-this.tileset.firstgid,ab,Y)}}}}}V=null};c.prototype.clearTile=function(U,V){me.TiledLayer.prototype.clearTile.call(this,U,V);if(this.visible){this.layerSurface.clearRect(U*this.tilewidth,V*this.tileheight,this.tilewidth,this.tileheight)}};c.prototype.draw=function(U,V){U.drawImage(this.layerCanvas,this.vp.pos.x+V.pos.x,this.vp.pos.y+V.pos.y,V.width,V.height,V.pos.x,V.pos.y,V.width,V.height)};function i(W,V,U,Z){this.objects=[];this.name=W;this.width=me.XMLParser.getIntAttribute(V,K);this.height=me.XMLParser.getIntAttribute(V,H);this.z=Z;var Y=V.getElementsByTagName(s);for(var X=0;X<Y.length;X++){this.objects.push(new b(Y[X],U,Z))}}i.prototype.getObjectCount=function(){return this.objects.length};i.prototype.getObjectByIndex=function(U){return this.objects[U]};function b(W,U,X){this.name=me.XMLParser.getStringAttribute(W,C);this.x=me.XMLParser.getIntAttribute(W,A);this.y=me.XMLParser.getIntAttribute(W,z);this.z=X;this.gid=me.XMLParser.getIntAttribute(W,g,null);if(this.gid){var V=U.getTilesetByGid(this.gid);this.width=V.tilewidth;this.height=V.tileheight;this.spritewidth=this.width;this.y-=this.height;this.image=V.getTileImage(this.gid-V.firstgid)}else{this.width=me.XMLParser.getIntAttribute(W,K,0);this.height=me.XMLParser.getIntAttribute(W,H,0)}e(this,W)}b.prototype.getObjectPropertyByName=function(U){return this[U]};me.TMXTileMap=I})(window);
 
13
/*!
 
14
 * Tween JS
 
15
 * https://github.com/sole/Tween.js
 
16
 *
 
17
 * author sole / http://soledadpenades.com
 
18
 * author mr.doob / http://mrdoob.com
 
19
 * author Robert Eisele / http://www.xarg.org
 
20
 * author Philippe / http://philippe.elsass.me
 
21
 * author Robert Penner / http://www.robertpenner.com/easing_terms_of_use.html
 
22
 */
 
23
(function(a,b){me.Tween=function(f){var m=f,l={},i={},j={},g=1000,k=0,c=null,n=me.Tween.Easing.Linear.EaseNone,e=null,h=null,d=null;this.to=function(o,r){if(r!==null){g=r}for(var q in o){if(m[q]===null){continue}j[q]=o[q]}return this};this.start=function(){me.game.add(this,999);c=me.timer.getTime()+k;for(var o in j){if(m[o]===null){continue}l[o]=m[o];i[o]=j[o]-m[o]}return this};this.stop=function(){me.game.remove(this);return this};this.delay=function(o){k=o;return this};this.easing=function(o){n=o;return this};this.chain=function(o){e=o};this.onUpdate=function(o){h=o;return this};this.onComplete=function(o){d=o;return this};this.update=function(){var r,o,q;var s=me.timer.getTime();if(s<c){return true}o=(s-c)/g;o=o>1?1:o;q=n(o);for(r in i){m[r]=l[r]+i[r]*q}if(h!==null){h.call(m,q)}if(o==1){me.game.remove(this);if(d!==null){d.call(m)}if(e!==null){e.start()}return false}return true};this.destroy=function(){return true}};me.Tween.Easing={Linear:{},Quadratic:{},Cubic:{},Quartic:{},Quintic:{},Sinusoidal:{},Exponential:{},Circular:{},Elastic:{},Back:{},Bounce:{}};me.Tween.Easing.Linear.EaseNone=function(c){return c};me.Tween.Easing.Quadratic.EaseIn=function(c){return c*c};me.Tween.Easing.Quadratic.EaseOut=function(c){return -c*(c-2)};me.Tween.Easing.Quadratic.EaseInOut=function(c){if((c*=2)<1){return 0.5*c*c}return -0.5*(--c*(c-2)-1)};me.Tween.Easing.Cubic.EaseIn=function(c){return c*c*c};me.Tween.Easing.Cubic.EaseOut=function(c){return --c*c*c+1};me.Tween.Easing.Cubic.EaseInOut=function(c){if((c*=2)<1){return 0.5*c*c*c}return 0.5*((c-=2)*c*c+2)};me.Tween.Easing.Quartic.EaseIn=function(c){return c*c*c*c};me.Tween.Easing.Quartic.EaseOut=function(c){return -(--c*c*c*c-1)};me.Tween.Easing.Quartic.EaseInOut=function(c){if((c*=2)<1){return 0.5*c*c*c*c}return -0.5*((c-=2)*c*c*c-2)};me.Tween.Easing.Quintic.EaseIn=function(c){return c*c*c*c*c};me.Tween.Easing.Quintic.EaseOut=function(c){return(c=c-1)*c*c*c*c+1};me.Tween.Easing.Quintic.EaseInOut=function(c){if((c*=2)<1){return 0.5*c*c*c*c*c}return 0.5*((c-=2)*c*c*c*c+2)};me.Tween.Easing.Sinusoidal.EaseIn=function(c){return -Math.cos(c*Math.PI/2)+1};me.Tween.Easing.Sinusoidal.EaseOut=function(c){return Math.sin(c*Math.PI/2)};me.Tween.Easing.Sinusoidal.EaseInOut=function(c){return -0.5*(Math.cos(Math.PI*c)-1)};me.Tween.Easing.Exponential.EaseIn=function(c){return c==0?0:Math.pow(2,10*(c-1))};me.Tween.Easing.Exponential.EaseOut=function(c){return c==1?1:-Math.pow(2,-10*c)+1};me.Tween.Easing.Exponential.EaseInOut=function(c){if(c==0){return 0}if(c==1){return 1}if((c*=2)<1){return 0.5*Math.pow(2,10*(c-1))}return 0.5*(-Math.pow(2,-10*(c-1))+2)};me.Tween.Easing.Circular.EaseIn=function(c){return -(Math.sqrt(1-c*c)-1)};me.Tween.Easing.Circular.EaseOut=function(c){return Math.sqrt(1- --c*c)};me.Tween.Easing.Circular.EaseInOut=function(c){if((c/=0.5)<1){return -0.5*(Math.sqrt(1-c*c)-1)}return 0.5*(Math.sqrt(1-(c-=2)*c)+1)};me.Tween.Easing.Elastic.EaseIn=function(d){var e,c=0.1,f=0.4;if(d==0){return 0}if(d==1){return 1}if(!f){f=0.3}if(!c||c<1){c=1;e=f/4}else{e=f/(2*Math.PI)*Math.asin(1/c)}return -(c*Math.pow(2,10*(d-=1))*Math.sin((d-e)*(2*Math.PI)/f))};me.Tween.Easing.Elastic.EaseOut=function(d){var e,c=0.1,f=0.4;if(d==0){return 0}if(d==1){return 1}if(!f){f=0.3}if(!c||c<1){c=1;e=f/4}else{e=f/(2*Math.PI)*Math.asin(1/c)}return(c*Math.pow(2,-10*d)*Math.sin((d-e)*(2*Math.PI)/f)+1)};me.Tween.Easing.Elastic.EaseInOut=function(d){var e,c=0.1,f=0.4;if(d==0){return 0}if(d==1){return 1}if(!f){f=0.3}if(!c||c<1){c=1;e=f/4}else{e=f/(2*Math.PI)*Math.asin(1/c)}if((d*=2)<1){return -0.5*(c*Math.pow(2,10*(d-=1))*Math.sin((d-e)*(2*Math.PI)/f))}return c*Math.pow(2,-10*(d-=1))*Math.sin((d-e)*(2*Math.PI)/f)*0.5+1};me.Tween.Easing.Back.EaseIn=function(c){var d=1.70158;return c*c*((d+1)*c-d)};me.Tween.Easing.Back.EaseOut=function(c){var d=1.70158;return(c=c-1)*c*((d+1)*c+d)+1};me.Tween.Easing.Back.EaseInOut=function(c){var d=1.70158*1.525;if((c*=2)<1){return 0.5*(c*c*((d+1)*c-d))}return 0.5*((c-=2)*c*((d+1)*c+d)+2)};me.Tween.Easing.Bounce.EaseIn=function(c){return 1-Tween.Easing.Bounce.EaseOut(1-c)};me.Tween.Easing.Bounce.EaseOut=function(c){if((c/=1)<(1/2.75)){return 7.5625*c*c}else{if(c<(2/2.75)){return 7.5625*(c-=(1.5/2.75))*c+0.75}else{if(c<(2.5/2.75)){return 7.5625*(c-=(2.25/2.75))*c+0.9375}else{return 7.5625*(c-=(2.625/2.75))*c+0.984375}}}};me.Tween.Easing.Bounce.EaseInOut=function(c){if(c<0.5){return Tween.Easing.Bounce.EaseIn(c*2)*0.5}return Tween.Easing.Bounce.EaseOut(c*2-1)*0.5+0.5}})(window);
 
 
b'\\ No newline at end of file'