game-baked.js 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /*! Built with IMPACT - impactjs.com */
  2. (function(window){"use strict";Number.prototype.map=function(istart,istop,ostart,ostop){return ostart+(ostop-ostart)*((this-istart)/(istop-istart));};Number.prototype.limit=function(min,max){return Math.min(max,Math.max(min,this));};Number.prototype.round=function(precision){precision=Math.pow(10,precision||0);return Math.round(this*precision)/precision;};Number.prototype.floor=function(){return Math.floor(this);};Number.prototype.ceil=function(){return Math.ceil(this);};Number.prototype.toInt=function(){return(this|0);};Number.prototype.toRad=function(){return(this/180)*Math.PI;};Number.prototype.toDeg=function(){return(this*180)/Math.PI;};Object.defineProperty(Array.prototype,'erase',{value:function(item){for(var i=this.length;i--;){if(this[i]===item){this.splice(i,1);}}
  3. return this;}});Object.defineProperty(Array.prototype,'random',{value:function(item){return this[Math.floor(Math.random()*this.length)];}});Function.prototype.bind=Function.prototype.bind||function(oThis){if(typeof this!=="function"){throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");}
  4. var aArgs=Array.prototype.slice.call(arguments,1),fToBind=this,fNOP=function(){},fBound=function(){return fToBind.apply((this instanceof fNOP&&oThis?this:oThis),aArgs.concat(Array.prototype.slice.call(arguments)));};fNOP.prototype=this.prototype;fBound.prototype=new fNOP();return fBound;};window.ig={game:null,debug:null,version:'1.23',global:window,modules:{},resources:[],ready:false,baked:false,nocache:'',ua:{},prefix:(window.ImpactPrefix||''),lib:'lib/',_current:null,_loadQueue:[],_waitForOnload:0,$:function(selector){return selector.charAt(0)=='#'?document.getElementById(selector.substr(1)):document.getElementsByTagName(selector);},$new:function(name){return document.createElement(name);},copy:function(object){if(!object||typeof(object)!='object'||object instanceof HTMLElement||object instanceof ig.Class){return object;}
  5. else if(object instanceof Array){var c=[];for(var i=0,l=object.length;i<l;i++){c[i]=ig.copy(object[i]);}
  6. return c;}
  7. else{var c={};for(var i in object){c[i]=ig.copy(object[i]);}
  8. return c;}},merge:function(original,extended){for(var key in extended){var ext=extended[key];if(typeof(ext)!='object'||ext instanceof HTMLElement||ext instanceof ig.Class||ext===null){original[key]=ext;}
  9. else{if(!original[key]||typeof(original[key])!='object'){original[key]=(ext instanceof Array)?[]:{};}
  10. ig.merge(original[key],ext);}}
  11. return original;},ksort:function(obj){if(!obj||typeof(obj)!='object'){return[];}
  12. var keys=[],values=[];for(var i in obj){keys.push(i);}
  13. keys.sort();for(var i=0;i<keys.length;i++){values.push(obj[keys[i]]);}
  14. return values;},setVendorAttribute:function(el,attr,val){var uc=attr.charAt(0).toUpperCase()+attr.substr(1);el[attr]=el['ms'+uc]=el['moz'+uc]=el['webkit'+uc]=el['o'+uc]=val;},getVendorAttribute:function(el,attr){var uc=attr.charAt(0).toUpperCase()+attr.substr(1);return el[attr]||el['ms'+uc]||el['moz'+uc]||el['webkit'+uc]||el['o'+uc];},normalizeVendorAttribute:function(el,attr){var prefixedVal=ig.getVendorAttribute(el,attr);if(!el[attr]&&prefixedVal){el[attr]=prefixedVal;}},getImagePixels:function(image,x,y,width,height){var canvas=ig.$new('canvas');canvas.width=image.width;canvas.height=image.height;var ctx=canvas.getContext('2d');ig.System.SCALE.CRISP(canvas,ctx);var ratio=ig.getVendorAttribute(ctx,'backingStorePixelRatio')||1;ig.normalizeVendorAttribute(ctx,'getImageDataHD');var realWidth=image.width/ratio,realHeight=image.height/ratio;canvas.width=Math.ceil(realWidth);canvas.height=Math.ceil(realHeight);ctx.drawImage(image,0,0,realWidth,realHeight);return(ratio===1)?ctx.getImageData(x,y,width,height):ctx.getImageDataHD(x,y,width,height);},module:function(name){if(ig._current){throw("Module '"+ig._current.name+"' defines nothing");}
  15. if(ig.modules[name]&&ig.modules[name].body){throw("Module '"+name+"' is already defined");}
  16. ig._current={name:name,requires:[],loaded:false,body:null};ig.modules[name]=ig._current;ig._loadQueue.push(ig._current);return ig;},requires:function(){ig._current.requires=Array.prototype.slice.call(arguments);return ig;},defines:function(body){ig._current.body=body;ig._current=null;ig._initDOMReady();},addResource:function(resource){ig.resources.push(resource);},setNocache:function(set){ig.nocache=set?'?'+Date.now():'';},log:function(){},assert:function(condition,msg){},show:function(name,number){},mark:function(msg,color){},_loadScript:function(name,requiredFrom){ig.modules[name]={name:name,requires:[],loaded:false,body:null};ig._waitForOnload++;var path=ig.prefix+ig.lib+name.replace(/\./g,'/')+'.js'+ig.nocache;var script=ig.$new('script');script.type='text/javascript';script.src=path;script.onload=function(){ig._waitForOnload--;ig._execModules();};script.onerror=function(){throw('Failed to load module '+name+' at '+path+' '+'required from '+requiredFrom);};ig.$('head')[0].appendChild(script);},_execModules:function(){var modulesLoaded=false;for(var i=0;i<ig._loadQueue.length;i++){var m=ig._loadQueue[i];var dependenciesLoaded=true;for(var j=0;j<m.requires.length;j++){var name=m.requires[j];if(!ig.modules[name]){dependenciesLoaded=false;ig._loadScript(name,m.name);}
  17. else if(!ig.modules[name].loaded){dependenciesLoaded=false;}}
  18. if(dependenciesLoaded&&m.body){ig._loadQueue.splice(i,1);m.loaded=true;m.body();modulesLoaded=true;i--;}}
  19. if(modulesLoaded){ig._execModules();}
  20. else if(!ig.baked&&ig._waitForOnload==0&&ig._loadQueue.length!=0){var unresolved=[];for(var i=0;i<ig._loadQueue.length;i++){var unloaded=[];var requires=ig._loadQueue[i].requires;for(var j=0;j<requires.length;j++){var m=ig.modules[requires[j]];if(!m||!m.loaded){unloaded.push(requires[j]);}}
  21. unresolved.push(ig._loadQueue[i].name+' (requires: '+unloaded.join(', ')+')');}
  22. throw("Unresolved (or circular?) dependencies. "+"Most likely there's a name/path mismatch for one of the listed modules "+"or a previous syntax error prevents a module from loading:\n"+
  23. unresolved.join('\n'));}},_DOMReady:function(){if(!ig.modules['dom.ready'].loaded){if(!document.body){return setTimeout(ig._DOMReady,13);}
  24. ig.modules['dom.ready'].loaded=true;ig._waitForOnload--;ig._execModules();}
  25. return 0;},_boot:function(){if(document.location.href.match(/\?nocache/)){ig.setNocache(true);}
  26. ig.ua.pixelRatio=window.devicePixelRatio||1;ig.ua.viewport={width:window.innerWidth,height:window.innerHeight};ig.ua.screen={width:window.screen.availWidth*ig.ua.pixelRatio,height:window.screen.availHeight*ig.ua.pixelRatio};ig.ua.iPhone=/iPhone/i.test(navigator.userAgent);ig.ua.iPhone4=(ig.ua.iPhone&&ig.ua.pixelRatio==2);ig.ua.iPad=/iPad/i.test(navigator.userAgent);ig.ua.android=/android/i.test(navigator.userAgent);ig.ua.winPhone=/Windows Phone/i.test(navigator.userAgent);ig.ua.iOS=ig.ua.iPhone||ig.ua.iPad;ig.ua.mobile=ig.ua.iOS||ig.ua.android||ig.ua.winPhone||/mobile/i.test(navigator.userAgent);ig.ua.touchDevice=(('ontouchstart'in window)||(window.navigator.msMaxTouchPoints));},_initDOMReady:function(){if(ig.modules['dom.ready']){ig._execModules();return;}
  27. ig._boot();ig.modules['dom.ready']={requires:[],loaded:false,body:null};ig._waitForOnload++;if(document.readyState==='complete'){ig._DOMReady();}
  28. else{document.addEventListener('DOMContentLoaded',ig._DOMReady,false);window.addEventListener('load',ig._DOMReady,false);}}};ig.normalizeVendorAttribute(window,'requestAnimationFrame');if(window.requestAnimationFrame){var next=1,anims={};window.ig.setAnimation=function(callback,element){var current=next++;anims[current]=true;var animate=function(){if(!anims[current]){return;}
  29. window.requestAnimationFrame(animate,element);callback();};window.requestAnimationFrame(animate,element);return current;};window.ig.clearAnimation=function(id){delete anims[id];};}
  30. else{window.ig.setAnimation=function(callback,element){return window.setInterval(callback,1000/60);};window.ig.clearAnimation=function(id){window.clearInterval(id);};}
  31. var initializing=false,fnTest=/xyz/.test(function(){xyz;})?/\bparent\b/:/.*/;var lastClassId=0;window.ig.Class=function(){};var inject=function(prop){var proto=this.prototype;var parent={};for(var name in prop){if(typeof(prop[name])=="function"&&typeof(proto[name])=="function"&&fnTest.test(prop[name])){parent[name]=proto[name];proto[name]=(function(name,fn){return function(){var tmp=this.parent;this.parent=parent[name];var ret=fn.apply(this,arguments);this.parent=tmp;return ret;};})(name,prop[name]);}
  32. else{proto[name]=prop[name];}}};window.ig.Class.extend=function(prop){var parent=this.prototype;initializing=true;var prototype=new this();initializing=false;for(var name in prop){if(typeof(prop[name])=="function"&&typeof(parent[name])=="function"&&fnTest.test(prop[name])){prototype[name]=(function(name,fn){return function(){var tmp=this.parent;this.parent=parent[name];var ret=fn.apply(this,arguments);this.parent=tmp;return ret;};})(name,prop[name]);}
  33. else{prototype[name]=prop[name];}}
  34. function Class(){if(!initializing){if(this.staticInstantiate){var obj=this.staticInstantiate.apply(this,arguments);if(obj){return obj;}}
  35. for(var p in this){if(typeof(this[p])=='object'){this[p]=ig.copy(this[p]);}}
  36. if(this.init){this.init.apply(this,arguments);}}
  37. return this;}
  38. Class.prototype=prototype;Class.prototype.constructor=Class;Class.extend=window.ig.Class.extend;Class.inject=inject;Class.classId=prototype.classId=++lastClassId;return Class;};if(window.ImpactMixin){ig.merge(ig,window.ImpactMixin);}})(window);
  39. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/image.js
  40. ig.baked=true;ig.module('impact.image').defines(function(){"use strict";ig.Image=ig.Class.extend({data:null,width:0,height:0,loaded:false,failed:false,loadCallback:null,path:'',staticInstantiate:function(path){return ig.Image.cache[path]||null;},init:function(path){this.path=path;this.load();},load:function(loadCallback){if(this.loaded){if(loadCallback){loadCallback(this.path,true);}
  41. return;}
  42. else if(!this.loaded&&ig.ready){this.loadCallback=loadCallback||null;this.data=new Image();this.data.onload=this.onload.bind(this);this.data.onerror=this.onerror.bind(this);this.data.src=ig.prefix+this.path+ig.nocache;}
  43. else{ig.addResource(this);}
  44. ig.Image.cache[this.path]=this;},reload:function(){this.loaded=false;this.data=new Image();this.data.onload=this.onload.bind(this);this.data.src=this.path+'?'+Date.now();},onload:function(event){this.width=this.data.width;this.height=this.data.height;this.loaded=true;if(ig.system.scale!=1){this.resize(ig.system.scale);}
  45. if(this.loadCallback){this.loadCallback(this.path,true);}},onerror:function(event){this.failed=true;if(this.loadCallback){this.loadCallback(this.path,false);}},resize:function(scale){var origPixels=ig.getImagePixels(this.data,0,0,this.width,this.height);var widthScaled=this.width*scale;var heightScaled=this.height*scale;var scaled=ig.$new('canvas');scaled.width=widthScaled;scaled.height=heightScaled;var scaledCtx=scaled.getContext('2d');var scaledPixels=scaledCtx.getImageData(0,0,widthScaled,heightScaled);for(var y=0;y<heightScaled;y++){for(var x=0;x<widthScaled;x++){var index=(Math.floor(y/scale)*this.width+Math.floor(x/scale))*4;var indexScaled=(y*widthScaled+x)*4;scaledPixels.data[indexScaled]=origPixels.data[index];scaledPixels.data[indexScaled+1]=origPixels.data[index+1];scaledPixels.data[indexScaled+2]=origPixels.data[index+2];scaledPixels.data[indexScaled+3]=origPixels.data[index+3];}}
  46. scaledCtx.putImageData(scaledPixels,0,0);this.data=scaled;},draw:function(targetX,targetY,sourceX,sourceY,width,height){if(!this.loaded){return;}
  47. var scale=ig.system.scale;sourceX=sourceX?sourceX*scale:0;sourceY=sourceY?sourceY*scale:0;width=(width?width:this.width)*scale;height=(height?height:this.height)*scale;ig.system.context.drawImage(this.data,sourceX,sourceY,width,height,ig.system.getDrawPos(targetX),ig.system.getDrawPos(targetY),width,height);ig.Image.drawCount++;},drawTile:function(targetX,targetY,tile,tileWidth,tileHeight,flipX,flipY){tileHeight=tileHeight?tileHeight:tileWidth;if(!this.loaded||tileWidth>this.width||tileHeight>this.height){return;}
  48. var scale=ig.system.scale;var tileWidthScaled=Math.floor(tileWidth*scale);var tileHeightScaled=Math.floor(tileHeight*scale);var scaleX=flipX?-1:1;var scaleY=flipY?-1:1;if(flipX||flipY){ig.system.context.save();ig.system.context.scale(scaleX,scaleY);}
  49. ig.system.context.drawImage(this.data,(Math.floor(tile*tileWidth)%this.width)*scale,(Math.floor(tile*tileWidth/this.width)*tileHeight)*scale,tileWidthScaled,tileHeightScaled,ig.system.getDrawPos(targetX)*scaleX-(flipX?tileWidthScaled:0),ig.system.getDrawPos(targetY)*scaleY-(flipY?tileHeightScaled:0),tileWidthScaled,tileHeightScaled);if(flipX||flipY){ig.system.context.restore();}
  50. ig.Image.drawCount++;}});ig.Image.drawCount=0;ig.Image.cache={};ig.Image.reloadCache=function(){for(var path in ig.Image.cache){ig.Image.cache[path].reload();}};});
  51. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/font.js
  52. ig.baked=true;ig.module('impact.font').requires('impact.image').defines(function(){"use strict";ig.Font=ig.Image.extend({widthMap:[],indices:[],firstChar:32,alpha:1,letterSpacing:1,lineSpacing:0,onload:function(ev){this._loadMetrics(this.data);this.parent(ev);},widthForString:function(text){if(text.indexOf('\n')!==-1){var lines=text.split('\n');var width=0;for(var i=0;i<lines.length;i++){width=Math.max(width,this._widthForLine(lines[i]));}
  53. return width;}
  54. else{return this._widthForLine(text);}},_widthForLine:function(text){var width=0;for(var i=0;i<text.length;i++){width+=this.widthMap[text.charCodeAt(i)-this.firstChar]+this.letterSpacing;}
  55. return width;},heightForString:function(text){return text.split('\n').length*(this.height+this.lineSpacing);},draw:function(text,x,y,align){if(typeof(text)!='string'){text=text.toString();}
  56. if(text.indexOf('\n')!==-1){var lines=text.split('\n');var lineHeight=this.height+this.lineSpacing;for(var i=0;i<lines.length;i++){this.draw(lines[i],x,y+i*lineHeight,align);}
  57. return;}
  58. if(align==ig.Font.ALIGN.RIGHT||align==ig.Font.ALIGN.CENTER){var width=this._widthForLine(text);x-=align==ig.Font.ALIGN.CENTER?width/2:width;}
  59. if(this.alpha!==1){ig.system.context.globalAlpha=this.alpha;}
  60. for(var i=0;i<text.length;i++){var c=text.charCodeAt(i);x+=this._drawChar(c-this.firstChar,x,y);}
  61. if(this.alpha!==1){ig.system.context.globalAlpha=1;}
  62. ig.Image.drawCount+=text.length;},_drawChar:function(c,targetX,targetY){if(!this.loaded||c<0||c>=this.indices.length){return 0;}
  63. var scale=ig.system.scale;var charX=this.indices[c]*scale;var charY=0;var charWidth=this.widthMap[c]*scale;var charHeight=(this.height-2)*scale;ig.system.context.drawImage(this.data,charX,charY,charWidth,charHeight,ig.system.getDrawPos(targetX),ig.system.getDrawPos(targetY),charWidth,charHeight);return this.widthMap[c]+this.letterSpacing;},_loadMetrics:function(image){this.height=image.height-1;this.widthMap=[];this.indices=[];var px=ig.getImagePixels(image,0,image.height-1,image.width,1);var currentChar=0;var currentWidth=0;for(var x=0;x<image.width;x++){var index=x*4+3;if(px.data[index]>127){currentWidth++;}
  64. else if(px.data[index]<128&&currentWidth){this.widthMap.push(currentWidth);this.indices.push(x-currentWidth);currentChar++;currentWidth=0;}}
  65. this.widthMap.push(currentWidth);this.indices.push(x-currentWidth);}});ig.Font.ALIGN={LEFT:0,RIGHT:1,CENTER:2};});
  66. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/sound.js
  67. ig.baked=true;ig.module('impact.sound').defines(function(){"use strict";ig.SoundManager=ig.Class.extend({clips:{},volume:1,format:null,init:function(){if(!ig.Sound.enabled||!window.Audio){ig.Sound.enabled=false;return;}
  68. var probe=new Audio();for(var i=0;i<ig.Sound.use.length;i++){var format=ig.Sound.use[i];if(probe.canPlayType(format.mime)){this.format=format;break;}}
  69. if(!this.format){ig.Sound.enabled=false;}
  70. if(ig.Sound.enabled&&ig.Sound.useWebAudio){this.audioContext=new AudioContext();}},load:function(path,multiChannel,loadCallback){if(multiChannel&&ig.Sound.useWebAudio){return this.loadWebAudio(path,multiChannel,loadCallback);}
  71. else{return this.loadHTML5Audio(path,multiChannel,loadCallback);}},loadWebAudio:function(path,multiChannel,loadCallback){var realPath=ig.prefix+path.replace(/[^\.]+$/,this.format.ext)+ig.nocache;if(this.clips[path]){return this.clips[path];}
  72. var audioSource=new ig.Sound.WebAudioSource()
  73. this.clips[path]=audioSource;var request=new XMLHttpRequest();request.open('GET',realPath,true);request.responseType='arraybuffer';var that=this;request.onload=function(ev){that.audioContext.decodeAudioData(request.response,function(buffer){audioSource.buffer=buffer;loadCallback(path,true,ev);},function(ev){loadCallback(path,false,ev);});};request.onerror=function(ev){loadCallback(path,false,ev);};request.send();return audioSource;},loadHTML5Audio:function(path,multiChannel,loadCallback){var realPath=ig.prefix+path.replace(/[^\.]+$/,this.format.ext)+ig.nocache;if(this.clips[path]){if(this.clips[path]instanceof ig.Sound.WebAudioSource){return this.clips[path];}
  74. if(multiChannel&&this.clips[path].length<ig.Sound.channels){for(var i=this.clips[path].length;i<ig.Sound.channels;i++){var a=new Audio(realPath);a.load();this.clips[path].push(a);}}
  75. return this.clips[path][0];}
  76. var clip=new Audio(realPath);if(loadCallback){clip.addEventListener('canplaythrough',function cb(ev){clip.removeEventListener('canplaythrough',cb,false);loadCallback(path,true,ev);},false);clip.addEventListener('error',function(ev){loadCallback(path,false,ev);},false);}
  77. clip.preload='auto';clip.load();this.clips[path]=[clip];if(multiChannel){for(var i=1;i<ig.Sound.channels;i++){var a=new Audio(realPath);a.load();this.clips[path].push(a);}}
  78. return clip;},get:function(path){var channels=this.clips[path];if(channels&&channels instanceof ig.Sound.WebAudioSource){return channels;}
  79. for(var i=0,clip;clip=channels[i++];){if(clip.paused||clip.ended){if(clip.ended){clip.currentTime=0;}
  80. return clip;}}
  81. channels[0].pause();channels[0].currentTime=0;return channels[0];}});ig.Music=ig.Class.extend({tracks:[],namedTracks:{},currentTrack:null,currentIndex:0,random:false,_volume:1,_loop:false,_fadeInterval:0,_fadeTimer:null,_endedCallbackBound:null,init:function(){this._endedCallbackBound=this._endedCallback.bind(this);Object.defineProperty(this,"volume",{get:this.getVolume.bind(this),set:this.setVolume.bind(this)});Object.defineProperty(this,"loop",{get:this.getLooping.bind(this),set:this.setLooping.bind(this)});},add:function(music,name){if(!ig.Sound.enabled){return;}
  82. var path=music instanceof ig.Sound?music.path:music;var track=ig.soundManager.load(path,false);if(track instanceof ig.Sound.WebAudioSource){ig.system.stopRunLoop();throw("Sound '"+path+"' loaded as Multichannel but used for Music. "+"Set the multiChannel param to false when loading, e.g.: new ig.Sound(path, false)");}
  83. track.loop=this._loop;track.volume=this._volume;track.addEventListener('ended',this._endedCallbackBound,false);this.tracks.push(track);if(name){this.namedTracks[name]=track;}
  84. if(!this.currentTrack){this.currentTrack=track;}},next:function(){if(!this.tracks.length){return;}
  85. this.stop();this.currentIndex=this.random?Math.floor(Math.random()*this.tracks.length):(this.currentIndex+1)%this.tracks.length;this.currentTrack=this.tracks[this.currentIndex];this.play();},pause:function(){if(!this.currentTrack){return;}
  86. this.currentTrack.pause();},stop:function(){if(!this.currentTrack){return;}
  87. this.currentTrack.pause();this.currentTrack.currentTime=0;},play:function(name){if(name&&this.namedTracks[name]){var newTrack=this.namedTracks[name];if(newTrack!=this.currentTrack){this.stop();this.currentTrack=newTrack;}}
  88. else if(!this.currentTrack){return;}
  89. this.currentTrack.play();},getLooping:function(){return this._loop;},setLooping:function(l){this._loop=l;for(var i in this.tracks){this.tracks[i].loop=l;}},getVolume:function(){return this._volume;},setVolume:function(v){this._volume=v.limit(0,1);for(var i in this.tracks){this.tracks[i].volume=this._volume;}},fadeOut:function(time){if(!this.currentTrack){return;}
  90. clearInterval(this._fadeInterval);this.fadeTimer=new ig.Timer(time);this._fadeInterval=setInterval(this._fadeStep.bind(this),50);},_fadeStep:function(){var v=this.fadeTimer.delta().map(-this.fadeTimer.target,0,1,0).limit(0,1)*this._volume;if(v<=0.01){this.stop();this.currentTrack.volume=this._volume;clearInterval(this._fadeInterval);}
  91. else{this.currentTrack.volume=v;}},_endedCallback:function(){if(this._loop){this.play();}
  92. else{this.next();}}});ig.Sound=ig.Class.extend({path:'',volume:1,currentClip:null,multiChannel:true,_loop:false,init:function(path,multiChannel){this.path=path;this.multiChannel=(multiChannel!==false);Object.defineProperty(this,"loop",{get:this.getLooping.bind(this),set:this.setLooping.bind(this)});this.load();},getLooping:function(){return this._loop;},setLooping:function(loop){this._loop=loop;if(this.currentClip){this.currentClip.loop=loop;}},load:function(loadCallback){if(!ig.Sound.enabled){if(loadCallback){loadCallback(this.path,true);}
  93. return;}
  94. if(ig.ready){ig.soundManager.load(this.path,this.multiChannel,loadCallback);}
  95. else{ig.addResource(this);}},play:function(){if(!ig.Sound.enabled){return;}
  96. this.currentClip=ig.soundManager.get(this.path);this.currentClip.loop=this._loop;this.currentClip.volume=ig.soundManager.volume*this.volume;this.currentClip.play();},stop:function(){if(this.currentClip){this.currentClip.pause();this.currentClip.currentTime=0;}}});ig.Sound.WebAudioSource=ig.Class.extend({sources:[],gain:null,buffer:null,_loop:false,init:function(){this.gain=ig.soundManager.audioContext.createGain();this.gain.connect(ig.soundManager.audioContext.destination);Object.defineProperty(this,"loop",{get:this.getLooping.bind(this),set:this.setLooping.bind(this)});Object.defineProperty(this,"volume",{get:this.getVolume.bind(this),set:this.setVolume.bind(this)});},play:function(){if(!this.buffer){return;}
  97. var source=ig.soundManager.audioContext.createBufferSource();source.buffer=this.buffer;source.connect(this.gain);source.loop=this._loop;var that=this;this.sources.push(source);source.onended=function(){that.sources.erase(source);}
  98. source.start(0);},pause:function(){for(var i=0;i<this.sources.length;i++){try{this.sources[i].stop();}catch(err){}}},getLooping:function(){return this._loop;},setLooping:function(loop){this._loop=loop;for(var i=0;i<this.sources.length;i++){this.sources[i].loop=loop;}},getVolume:function(){return this.gain.gain.value;},setVolume:function(volume){this.gain.gain.value=volume;}});ig.Sound.FORMAT={MP3:{ext:'mp3',mime:'audio/mpeg'},M4A:{ext:'m4a',mime:'audio/mp4; codecs=mp4a'},OGG:{ext:'ogg',mime:'audio/ogg; codecs=vorbis'},WEBM:{ext:'webm',mime:'audio/webm; codecs=vorbis'},CAF:{ext:'caf',mime:'audio/x-caf'}};ig.Sound.use=[ig.Sound.FORMAT.OGG,ig.Sound.FORMAT.MP3];ig.Sound.channels=4;ig.Sound.enabled=true;ig.normalizeVendorAttribute(window,'AudioContext');ig.Sound.useWebAudio=!!window.AudioContext;});
  99. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/loader.js
  100. ig.baked=true;ig.module('impact.loader').requires('impact.image','impact.font','impact.sound').defines(function(){"use strict";ig.Loader=ig.Class.extend({resources:[],gameClass:null,status:0,done:false,_unloaded:[],_drawStatus:0,_intervalId:0,_loadCallbackBound:null,init:function(gameClass,resources){this.gameClass=gameClass;this.resources=resources;this._loadCallbackBound=this._loadCallback.bind(this);for(var i=0;i<this.resources.length;i++){this._unloaded.push(this.resources[i].path);}},load:function(){ig.system.clear('#000');if(!this.resources.length){this.end();return;}
  101. for(var i=0;i<this.resources.length;i++){this.loadResource(this.resources[i]);}
  102. this._intervalId=setInterval(this.draw.bind(this),16);},loadResource:function(res){res.load(this._loadCallbackBound);},end:function(){if(this.done){return;}
  103. this.done=true;clearInterval(this._intervalId);ig.system.setGame(this.gameClass);},draw:function(){this._drawStatus+=(this.status-this._drawStatus)/5;var s=ig.system.scale;var w=ig.system.width*0.6;var h=ig.system.height*0.1;var x=ig.system.width*0.5-w/2;var y=ig.system.height*0.5-h/2;ig.system.context.fillStyle='#000';ig.system.context.fillRect(0,0,480,320);ig.system.context.fillStyle='#fff';ig.system.context.fillRect(x*s,y*s,w*s,h*s);ig.system.context.fillStyle='#000';ig.system.context.fillRect(x*s+s,y*s+s,w*s-s-s,h*s-s-s);ig.system.context.fillStyle='#fff';ig.system.context.fillRect(x*s,y*s,w*s*this._drawStatus,h*s);},_loadCallback:function(path,status){if(status){this._unloaded.erase(path);}
  104. else{throw('Failed to load resource: '+path);}
  105. this.status=1-(this._unloaded.length/this.resources.length);if(this._unloaded.length==0){setTimeout(this.end.bind(this),250);}}});});
  106. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/timer.js
  107. ig.baked=true;ig.module('impact.timer').defines(function(){"use strict";ig.Timer=ig.Class.extend({target:0,base:0,last:0,pausedAt:0,init:function(seconds){this.base=ig.Timer.time;this.last=ig.Timer.time;this.target=seconds||0;},set:function(seconds){this.target=seconds||0;this.base=ig.Timer.time;this.pausedAt=0;},reset:function(){this.base=ig.Timer.time;this.pausedAt=0;},tick:function(){var delta=ig.Timer.time-this.last;this.last=ig.Timer.time;return(this.pausedAt?0:delta);},delta:function(){return(this.pausedAt||ig.Timer.time)-this.base-this.target;},pause:function(){if(!this.pausedAt){this.pausedAt=ig.Timer.time;}},unpause:function(){if(this.pausedAt){this.base+=ig.Timer.time-this.pausedAt;this.pausedAt=0;}}});ig.Timer._last=0;ig.Timer.time=Number.MIN_VALUE;ig.Timer.timeScale=1;ig.Timer.maxStep=0.05;ig.Timer.step=function(){var current=Date.now();var delta=(current-ig.Timer._last)/1000;ig.Timer.time+=Math.min(delta,ig.Timer.maxStep)*ig.Timer.timeScale;ig.Timer._last=current;};});
  108. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/system.js
  109. ig.baked=true;ig.module('impact.system').requires('impact.timer','impact.image').defines(function(){"use strict";ig.System=ig.Class.extend({fps:30,width:320,height:240,realWidth:320,realHeight:240,scale:1,tick:0,animationId:0,newGameClass:null,running:false,delegate:null,clock:null,canvas:null,context:null,init:function(canvasId,fps,width,height,scale){this.fps=fps;this.clock=new ig.Timer();this.canvas=ig.$(canvasId);this.resize(width,height,scale);this.context=this.canvas.getContext('2d');this.getDrawPos=ig.System.drawMode;if(this.scale!=1){ig.System.scaleMode=ig.System.SCALE.CRISP;}
  110. ig.System.scaleMode(this.canvas,this.context);},resize:function(width,height,scale){this.width=width;this.height=height;this.scale=scale||this.scale;this.realWidth=this.width*this.scale;this.realHeight=this.height*this.scale;this.canvas.width=this.realWidth;this.canvas.height=this.realHeight;},setGame:function(gameClass){if(this.running){this.newGameClass=gameClass;}
  111. else{this.setGameNow(gameClass);}},setGameNow:function(gameClass){ig.game=new(gameClass)();ig.system.setDelegate(ig.game);},setDelegate:function(object){if(typeof(object.run)=='function'){this.delegate=object;this.startRunLoop();}else{throw('System.setDelegate: No run() function in object');}},stopRunLoop:function(){ig.clearAnimation(this.animationId);this.running=false;},startRunLoop:function(){this.stopRunLoop();this.animationId=ig.setAnimation(this.run.bind(this),this.canvas);this.running=true;},clear:function(color){this.context.fillStyle=color;this.context.fillRect(0,0,this.realWidth,this.realHeight);},run:function(){ig.Timer.step();this.tick=this.clock.tick();this.delegate.run();ig.input.clearPressed();if(this.newGameClass){this.setGameNow(this.newGameClass);this.newGameClass=null;}},getDrawPos:null});ig.System.DRAW={AUTHENTIC:function(p){return Math.round(p)*this.scale;},SMOOTH:function(p){return Math.round(p*this.scale);},SUBPIXEL:function(p){return p*this.scale;}};ig.System.drawMode=ig.System.DRAW.SMOOTH;ig.System.SCALE={CRISP:function(canvas,context){ig.setVendorAttribute(context,'imageSmoothingEnabled',false);canvas.style.imageRendering='-moz-crisp-edges';canvas.style.imageRendering='-o-crisp-edges';canvas.style.imageRendering='-webkit-optimize-contrast';canvas.style.imageRendering='crisp-edges';canvas.style.msInterpolationMode='nearest-neighbor';},SMOOTH:function(canvas,context){ig.setVendorAttribute(context,'imageSmoothingEnabled',true);canvas.style.imageRendering='';canvas.style.msInterpolationMode='';}};ig.System.scaleMode=ig.System.SCALE.SMOOTH;});
  112. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/input.js
  113. ig.baked=true;ig.module('impact.input').defines(function(){"use strict";ig.KEY={'MOUSE1':-1,'MOUSE2':-3,'MWHEEL_UP':-4,'MWHEEL_DOWN':-5,'BACKSPACE':8,'TAB':9,'ENTER':13,'PAUSE':19,'CAPS':20,'ESC':27,'SPACE':32,'PAGE_UP':33,'PAGE_DOWN':34,'END':35,'HOME':36,'LEFT_ARROW':37,'UP_ARROW':38,'RIGHT_ARROW':39,'DOWN_ARROW':40,'INSERT':45,'DELETE':46,'_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,'NUMPAD_0':96,'NUMPAD_1':97,'NUMPAD_2':98,'NUMPAD_3':99,'NUMPAD_4':100,'NUMPAD_5':101,'NUMPAD_6':102,'NUMPAD_7':103,'NUMPAD_8':104,'NUMPAD_9':105,'MULTIPLY':106,'ADD':107,'SUBSTRACT':109,'DECIMAL':110,'DIVIDE':111,'F1':112,'F2':113,'F3':114,'F4':115,'F5':116,'F6':117,'F7':118,'F8':119,'F9':120,'F10':121,'F11':122,'F12':123,'SHIFT':16,'CTRL':17,'ALT':18,'PLUS':187,'COMMA':188,'MINUS':189,'PERIOD':190};ig.Input=ig.Class.extend({bindings:{},actions:{},presses:{},locks:{},delayedKeyup:{},isUsingMouse:false,isUsingKeyboard:false,isUsingAccelerometer:false,mouse:{x:0,y:0},accel:{x:0,y:0,z:0},initMouse:function(){if(this.isUsingMouse){return;}
  114. this.isUsingMouse=true;var mouseWheelBound=this.mousewheel.bind(this);ig.system.canvas.addEventListener('mousewheel',mouseWheelBound,false);ig.system.canvas.addEventListener('DOMMouseScroll',mouseWheelBound,false);ig.system.canvas.addEventListener('contextmenu',this.contextmenu.bind(this),false);ig.system.canvas.addEventListener('mousedown',this.keydown.bind(this),false);ig.system.canvas.addEventListener('mouseup',this.keyup.bind(this),false);ig.system.canvas.addEventListener('mousemove',this.mousemove.bind(this),false);if(ig.ua.touchDevice){ig.system.canvas.addEventListener('touchstart',this.keydown.bind(this),false);ig.system.canvas.addEventListener('touchend',this.keyup.bind(this),false);ig.system.canvas.addEventListener('touchmove',this.mousemove.bind(this),false);ig.system.canvas.addEventListener('MSPointerDown',this.keydown.bind(this),false);ig.system.canvas.addEventListener('MSPointerUp',this.keyup.bind(this),false);ig.system.canvas.addEventListener('MSPointerMove',this.mousemove.bind(this),false);ig.system.canvas.style.msTouchAction='none';}},initKeyboard:function(){if(this.isUsingKeyboard){return;}
  115. this.isUsingKeyboard=true;window.addEventListener('keydown',this.keydown.bind(this),false);window.addEventListener('keyup',this.keyup.bind(this),false);},initAccelerometer:function(){if(this.isUsingAccelerometer){return;}
  116. this.isUsingAccelerometer=true;window.addEventListener('devicemotion',this.devicemotion.bind(this),false);},mousewheel:function(event){var delta=event.wheelDelta?event.wheelDelta:(event.detail*-1);var code=delta>0?ig.KEY.MWHEEL_UP:ig.KEY.MWHEEL_DOWN;var action=this.bindings[code];if(action){this.actions[action]=true;this.presses[action]=true;this.delayedKeyup[action]=true;event.stopPropagation();event.preventDefault();}},mousemove:function(event){var internalWidth=parseInt(ig.system.canvas.offsetWidth)||ig.system.realWidth;var scale=ig.system.scale*(internalWidth/ig.system.realWidth);var pos={left:0,top:0};if(ig.system.canvas.getBoundingClientRect){pos=ig.system.canvas.getBoundingClientRect();}
  117. var ev=event.touches?event.touches[0]:event;this.mouse.x=(ev.clientX-pos.left)/scale;this.mouse.y=(ev.clientY-pos.top)/scale;},contextmenu:function(event){if(this.bindings[ig.KEY.MOUSE2]){event.stopPropagation();event.preventDefault();}},keydown:function(event){var tag=event.target.tagName;if(tag=='INPUT'||tag=='TEXTAREA'){return;}
  118. var code=event.type=='keydown'?event.keyCode:(event.button==2?ig.KEY.MOUSE2:ig.KEY.MOUSE1);if(event.type=='touchstart'||event.type=='mousedown'){this.mousemove(event);}
  119. var action=this.bindings[code];if(action){this.actions[action]=true;if(!this.locks[action]){this.presses[action]=true;this.locks[action]=true;}
  120. event.stopPropagation();event.preventDefault();}},keyup:function(event){var tag=event.target.tagName;if(tag=='INPUT'||tag=='TEXTAREA'){return;}
  121. var code=event.type=='keyup'?event.keyCode:(event.button==2?ig.KEY.MOUSE2:ig.KEY.MOUSE1);var action=this.bindings[code];if(action){this.delayedKeyup[action]=true;event.stopPropagation();event.preventDefault();}},devicemotion:function(event){this.accel=event.accelerationIncludingGravity;},bind:function(key,action){if(key<0){this.initMouse();}
  122. else if(key>0){this.initKeyboard();}
  123. this.bindings[key]=action;},bindTouch:function(selector,action){var element=ig.$(selector);var that=this;element.addEventListener('touchstart',function(ev){that.touchStart(ev,action);},false);element.addEventListener('touchend',function(ev){that.touchEnd(ev,action);},false);element.addEventListener('MSPointerDown',function(ev){that.touchStart(ev,action);},false);element.addEventListener('MSPointerUp',function(ev){that.touchEnd(ev,action);},false);},unbind:function(key){var action=this.bindings[key];this.delayedKeyup[action]=true;this.bindings[key]=null;},unbindAll:function(){this.bindings={};this.actions={};this.presses={};this.locks={};this.delayedKeyup={};},state:function(action){return this.actions[action];},pressed:function(action){return this.presses[action];},released:function(action){return!!this.delayedKeyup[action];},clearPressed:function(){for(var action in this.delayedKeyup){this.actions[action]=false;this.locks[action]=false;}
  124. this.delayedKeyup={};this.presses={};},touchStart:function(event,action){this.actions[action]=true;this.presses[action]=true;event.stopPropagation();event.preventDefault();return false;},touchEnd:function(event,action){this.delayedKeyup[action]=true;event.stopPropagation();event.preventDefault();return false;}});});
  125. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/impact.js
  126. ig.baked=true;ig.module('impact.impact').requires('dom.ready','impact.loader','impact.system','impact.input','impact.sound').defines(function(){"use strict";ig.main=function(canvasId,gameClass,fps,width,height,scale,loaderClass){ig.system=new ig.System(canvasId,fps,width,height,scale||1);ig.input=new ig.Input();ig.soundManager=new ig.SoundManager();ig.music=new ig.Music();ig.ready=true;var loader=new(loaderClass||ig.Loader)(gameClass,ig.resources);loader.load();};});
  127. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/animation.js
  128. ig.baked=true;ig.module('impact.animation').requires('impact.timer','impact.image').defines(function(){"use strict";ig.AnimationSheet=ig.Class.extend({width:8,height:8,image:null,init:function(path,width,height){this.width=width;this.height=height;this.image=new ig.Image(path);}});ig.Animation=ig.Class.extend({sheet:null,timer:null,sequence:[],flip:{x:false,y:false},pivot:{x:0,y:0},frame:0,tile:0,loopCount:0,alpha:1,angle:0,init:function(sheet,frameTime,sequence,stop){this.sheet=sheet;this.pivot={x:sheet.width/2,y:sheet.height/2};this.timer=new ig.Timer();this.frameTime=frameTime;this.sequence=sequence;this.stop=!!stop;this.tile=this.sequence[0];},rewind:function(){this.timer.set();this.loopCount=0;this.frame=0;this.tile=this.sequence[0];return this;},gotoFrame:function(f){this.timer.set(this.frameTime*-f-0.0001);this.update();},gotoRandomFrame:function(){this.gotoFrame(Math.floor(Math.random()*this.sequence.length))},update:function(){var frameTotal=Math.floor(this.timer.delta()/this.frameTime);this.loopCount=Math.floor(frameTotal/this.sequence.length);if(this.stop&&this.loopCount>0){this.frame=this.sequence.length-1;}
  129. else{this.frame=frameTotal%this.sequence.length;}
  130. this.tile=this.sequence[this.frame];},draw:function(targetX,targetY){var bbsize=Math.max(this.sheet.width,this.sheet.height);if(targetX>ig.system.width||targetY>ig.system.height||targetX+bbsize<0||targetY+bbsize<0){return;}
  131. if(this.alpha!=1){ig.system.context.globalAlpha=this.alpha;}
  132. if(this.angle==0){this.sheet.image.drawTile(targetX,targetY,this.tile,this.sheet.width,this.sheet.height,this.flip.x,this.flip.y);}
  133. else{ig.system.context.save();ig.system.context.translate(ig.system.getDrawPos(targetX+this.pivot.x),ig.system.getDrawPos(targetY+this.pivot.y));ig.system.context.rotate(this.angle);this.sheet.image.drawTile(-this.pivot.x,-this.pivot.y,this.tile,this.sheet.width,this.sheet.height,this.flip.x,this.flip.y);ig.system.context.restore();}
  134. if(this.alpha!=1){ig.system.context.globalAlpha=1;}}});});
  135. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/entity.js
  136. ig.baked=true;ig.module('impact.entity').requires('impact.animation','impact.impact').defines(function(){"use strict";ig.Entity=ig.Class.extend({id:0,settings:{},size:{x:16,y:16},offset:{x:0,y:0},pos:{x:0,y:0},last:{x:0,y:0},vel:{x:0,y:0},accel:{x:0,y:0},friction:{x:0,y:0},maxVel:{x:100,y:100},zIndex:0,gravityFactor:1,standing:false,bounciness:0,minBounceVelocity:40,anims:{},animSheet:null,currentAnim:null,health:10,type:0,checkAgainst:0,collides:0,_killed:false,slopeStanding:{min:(44).toRad(),max:(136).toRad()},init:function(x,y,settings){this.id=++ig.Entity._lastId;this.pos.x=this.last.x=x;this.pos.y=this.last.y=y;ig.merge(this,settings);},reset:function(x,y,settings){var proto=this.constructor.prototype;this.pos.x=x;this.pos.y=y;this.last.x=x;this.last.y=y;this.vel.x=proto.vel.x;this.vel.y=proto.vel.y;this.accel.x=proto.accel.x;this.accel.y=proto.accel.y;this.health=proto.health;this._killed=proto._killed;this.standing=proto.standing;this.type=proto.type;this.checkAgainst=proto.checkAgainst;this.collides=proto.collides;ig.merge(this,settings);},addAnim:function(name,frameTime,sequence,stop){if(!this.animSheet){throw('No animSheet to add the animation '+name+' to.');}
  137. var a=new ig.Animation(this.animSheet,frameTime,sequence,stop);this.anims[name]=a;if(!this.currentAnim){this.currentAnim=a;}
  138. return a;},update:function(){this.last.x=this.pos.x;this.last.y=this.pos.y;this.vel.y+=ig.game.gravity*ig.system.tick*this.gravityFactor;this.vel.x=this.getNewVelocity(this.vel.x,this.accel.x,this.friction.x,this.maxVel.x);this.vel.y=this.getNewVelocity(this.vel.y,this.accel.y,this.friction.y,this.maxVel.y);var mx=this.vel.x*ig.system.tick;var my=this.vel.y*ig.system.tick;var res=ig.game.collisionMap.trace(this.pos.x,this.pos.y,mx,my,this.size.x,this.size.y);this.handleMovementTrace(res);if(this.currentAnim){this.currentAnim.update();}},getNewVelocity:function(vel,accel,friction,max){if(accel){return(vel+accel*ig.system.tick).limit(-max,max);}
  139. else if(friction){var delta=friction*ig.system.tick;if(vel-delta>0){return vel-delta;}
  140. else if(vel+delta<0){return vel+delta;}
  141. else{return 0;}}
  142. return vel.limit(-max,max);},handleMovementTrace:function(res){this.standing=false;if(res.collision.y){if(this.bounciness>0&&Math.abs(this.vel.y)>this.minBounceVelocity){this.vel.y*=-this.bounciness;}
  143. else{if(this.vel.y>0){this.standing=true;}
  144. this.vel.y=0;}}
  145. if(res.collision.x){if(this.bounciness>0&&Math.abs(this.vel.x)>this.minBounceVelocity){this.vel.x*=-this.bounciness;}
  146. else{this.vel.x=0;}}
  147. if(res.collision.slope){var s=res.collision.slope;if(this.bounciness>0){var proj=this.vel.x*s.nx+this.vel.y*s.ny;this.vel.x=(this.vel.x-s.nx*proj*2)*this.bounciness;this.vel.y=(this.vel.y-s.ny*proj*2)*this.bounciness;}
  148. else{var lengthSquared=s.x*s.x+s.y*s.y;var dot=(this.vel.x*s.x+this.vel.y*s.y)/lengthSquared;this.vel.x=s.x*dot;this.vel.y=s.y*dot;var angle=Math.atan2(s.x,s.y);if(angle>this.slopeStanding.min&&angle<this.slopeStanding.max){this.standing=true;}}}
  149. this.pos=res.pos;},draw:function(){if(this.currentAnim){this.currentAnim.draw(this.pos.x-this.offset.x-ig.game._rscreen.x,this.pos.y-this.offset.y-ig.game._rscreen.y);}},kill:function(){ig.game.removeEntity(this);},receiveDamage:function(amount,from){this.health-=amount;if(this.health<=0){this.kill();}},touches:function(other){return!(this.pos.x>=other.pos.x+other.size.x||this.pos.x+this.size.x<=other.pos.x||this.pos.y>=other.pos.y+other.size.y||this.pos.y+this.size.y<=other.pos.y);},distanceTo:function(other){var xd=(this.pos.x+this.size.x/2)-(other.pos.x+other.size.x/2);var yd=(this.pos.y+this.size.y/2)-(other.pos.y+other.size.y/2);return Math.sqrt(xd*xd+yd*yd);},angleTo:function(other){return Math.atan2((other.pos.y+other.size.y/2)-(this.pos.y+this.size.y/2),(other.pos.x+other.size.x/2)-(this.pos.x+this.size.x/2));},check:function(other){},collideWith:function(other,axis){},ready:function(){},erase:function(){}});ig.Entity._lastId=0;ig.Entity.COLLIDES={NEVER:0,LITE:1,PASSIVE:2,ACTIVE:4,FIXED:8};ig.Entity.TYPE={NONE:0,A:1,B:2,BOTH:3};ig.Entity.checkPair=function(a,b){if(a.checkAgainst&b.type){a.check(b);}
  150. if(b.checkAgainst&a.type){b.check(a);}
  151. if(a.collides&&b.collides&&a.collides+b.collides>ig.Entity.COLLIDES.ACTIVE){ig.Entity.solveCollision(a,b);}};ig.Entity.solveCollision=function(a,b){var weak=null;if(a.collides==ig.Entity.COLLIDES.LITE||b.collides==ig.Entity.COLLIDES.FIXED){weak=a;}
  152. else if(b.collides==ig.Entity.COLLIDES.LITE||a.collides==ig.Entity.COLLIDES.FIXED){weak=b;}
  153. if(a.last.x+a.size.x>b.last.x&&a.last.x<b.last.x+b.size.x){if(a.last.y<b.last.y){ig.Entity.seperateOnYAxis(a,b,weak);}
  154. else{ig.Entity.seperateOnYAxis(b,a,weak);}
  155. a.collideWith(b,'y');b.collideWith(a,'y');}
  156. else if(a.last.y+a.size.y>b.last.y&&a.last.y<b.last.y+b.size.y){if(a.last.x<b.last.x){ig.Entity.seperateOnXAxis(a,b,weak);}
  157. else{ig.Entity.seperateOnXAxis(b,a,weak);}
  158. a.collideWith(b,'x');b.collideWith(a,'x');}};ig.Entity.seperateOnXAxis=function(left,right,weak){var nudge=(left.pos.x+left.size.x-right.pos.x);if(weak){var strong=left===weak?right:left;weak.vel.x=-weak.vel.x*weak.bounciness+strong.vel.x;var resWeak=ig.game.collisionMap.trace(weak.pos.x,weak.pos.y,weak==left?-nudge:nudge,0,weak.size.x,weak.size.y);weak.pos.x=resWeak.pos.x;}
  159. else{var v2=(left.vel.x-right.vel.x)/2;left.vel.x=-v2;right.vel.x=v2;var resLeft=ig.game.collisionMap.trace(left.pos.x,left.pos.y,-nudge/2,0,left.size.x,left.size.y);left.pos.x=Math.floor(resLeft.pos.x);var resRight=ig.game.collisionMap.trace(right.pos.x,right.pos.y,nudge/2,0,right.size.x,right.size.y);right.pos.x=Math.ceil(resRight.pos.x);}};ig.Entity.seperateOnYAxis=function(top,bottom,weak){var nudge=(top.pos.y+top.size.y-bottom.pos.y);if(weak){var strong=top===weak?bottom:top;weak.vel.y=-weak.vel.y*weak.bounciness+strong.vel.y;var nudgeX=0;if(weak==top&&Math.abs(weak.vel.y-strong.vel.y)<weak.minBounceVelocity){weak.standing=true;nudgeX=strong.vel.x*ig.system.tick;}
  160. var resWeak=ig.game.collisionMap.trace(weak.pos.x,weak.pos.y,nudgeX,weak==top?-nudge:nudge,weak.size.x,weak.size.y);weak.pos.y=resWeak.pos.y;weak.pos.x=resWeak.pos.x;}
  161. else if(ig.game.gravity&&(bottom.standing||top.vel.y>0)){var resTop=ig.game.collisionMap.trace(top.pos.x,top.pos.y,0,-(top.pos.y+top.size.y-bottom.pos.y),top.size.x,top.size.y);top.pos.y=resTop.pos.y;if(top.bounciness>0&&top.vel.y>top.minBounceVelocity){top.vel.y*=-top.bounciness;}
  162. else{top.standing=true;top.vel.y=0;}}
  163. else{var v2=(top.vel.y-bottom.vel.y)/2;top.vel.y=-v2;bottom.vel.y=v2;var nudgeX=bottom.vel.x*ig.system.tick;var resTop=ig.game.collisionMap.trace(top.pos.x,top.pos.y,nudgeX,-nudge/2,top.size.x,top.size.y);top.pos.y=resTop.pos.y;var resBottom=ig.game.collisionMap.trace(bottom.pos.x,bottom.pos.y,0,nudge/2,bottom.size.x,bottom.size.y);bottom.pos.y=resBottom.pos.y;}};});
  164. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/map.js
  165. ig.baked=true;ig.module('impact.map').defines(function(){"use strict";ig.Map=ig.Class.extend({tilesize:8,width:1,height:1,data:[[]],name:null,init:function(tilesize,data){this.tilesize=tilesize;this.data=data;this.height=data.length;this.width=data[0].length;this.pxWidth=this.width*this.tilesize;this.pxHeight=this.height*this.tilesize;},getTile:function(x,y){var tx=Math.floor(x/this.tilesize);var ty=Math.floor(y/this.tilesize);if((tx>=0&&tx<this.width)&&(ty>=0&&ty<this.height)){return this.data[ty][tx];}
  166. else{return 0;}},setTile:function(x,y,tile){var tx=Math.floor(x/this.tilesize);var ty=Math.floor(y/this.tilesize);if((tx>=0&&tx<this.width)&&(ty>=0&&ty<this.height)){this.data[ty][tx]=tile;}}});});
  167. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/collision-map.js
  168. ig.baked=true;ig.module('impact.collision-map').requires('impact.map').defines(function(){"use strict";ig.CollisionMap=ig.Map.extend({lastSlope:1,tiledef:null,init:function(tilesize,data,tiledef){this.parent(tilesize,data);this.tiledef=tiledef||ig.CollisionMap.defaultTileDef;for(var t in this.tiledef){if(t|0>this.lastSlope){this.lastSlope=t|0;}}},trace:function(x,y,vx,vy,objectWidth,objectHeight){var res={collision:{x:false,y:false,slope:false},pos:{x:x,y:y},tile:{x:0,y:0}};var steps=Math.ceil(Math.max(Math.abs(vx),Math.abs(vy))/this.tilesize);if(steps>1){var sx=vx/steps;var sy=vy/steps;for(var i=0;i<steps&&(sx||sy);i++){this._traceStep(res,x,y,sx,sy,objectWidth,objectHeight,vx,vy,i);x=res.pos.x;y=res.pos.y;if(res.collision.x){sx=0;vx=0;}
  169. if(res.collision.y){sy=0;vy=0;}
  170. if(res.collision.slope){break;}}}
  171. else{this._traceStep(res,x,y,vx,vy,objectWidth,objectHeight,vx,vy,0);}
  172. return res;},_traceStep:function(res,x,y,vx,vy,width,height,rvx,rvy,step){res.pos.x+=vx;res.pos.y+=vy;var t=0;if(vx){var pxOffsetX=(vx>0?width:0);var tileOffsetX=(vx<0?this.tilesize:0);var firstTileY=Math.max(Math.floor(y/this.tilesize),0);var lastTileY=Math.min(Math.ceil((y+height)/this.tilesize),this.height);var tileX=Math.floor((res.pos.x+pxOffsetX)/this.tilesize);var prevTileX=Math.floor((x+pxOffsetX)/this.tilesize);if(step>0||tileX==prevTileX||prevTileX<0||prevTileX>=this.width){prevTileX=-1;}
  173. if(tileX>=0&&tileX<this.width){for(var tileY=firstTileY;tileY<lastTileY;tileY++){if(prevTileX!=-1){t=this.data[tileY][prevTileX];if(t>1&&t<=this.lastSlope&&this._checkTileDef(res,t,x,y,rvx,rvy,width,height,prevTileX,tileY)){break;}}
  174. t=this.data[tileY][tileX];if(t==1||t>this.lastSlope||(t>1&&this._checkTileDef(res,t,x,y,rvx,rvy,width,height,tileX,tileY))){if(t>1&&t<=this.lastSlope&&res.collision.slope){break;}
  175. res.collision.x=true;res.tile.x=t;x=res.pos.x=tileX*this.tilesize-pxOffsetX+tileOffsetX;rvx=0;break;}}}}
  176. if(vy){var pxOffsetY=(vy>0?height:0);var tileOffsetY=(vy<0?this.tilesize:0);var firstTileX=Math.max(Math.floor(res.pos.x/this.tilesize),0);var lastTileX=Math.min(Math.ceil((res.pos.x+width)/this.tilesize),this.width);var tileY=Math.floor((res.pos.y+pxOffsetY)/this.tilesize);var prevTileY=Math.floor((y+pxOffsetY)/this.tilesize);if(step>0||tileY==prevTileY||prevTileY<0||prevTileY>=this.height){prevTileY=-1;}
  177. if(tileY>=0&&tileY<this.height){for(var tileX=firstTileX;tileX<lastTileX;tileX++){if(prevTileY!=-1){t=this.data[prevTileY][tileX];if(t>1&&t<=this.lastSlope&&this._checkTileDef(res,t,x,y,rvx,rvy,width,height,tileX,prevTileY)){break;}}
  178. t=this.data[tileY][tileX];if(t==1||t>this.lastSlope||(t>1&&this._checkTileDef(res,t,x,y,rvx,rvy,width,height,tileX,tileY))){if(t>1&&t<=this.lastSlope&&res.collision.slope){break;}
  179. res.collision.y=true;res.tile.y=t;res.pos.y=tileY*this.tilesize-pxOffsetY+tileOffsetY;break;}}}}},_checkTileDef:function(res,t,x,y,vx,vy,width,height,tileX,tileY){var def=this.tiledef[t];if(!def){return false;}
  180. var lx=(tileX+def[0])*this.tilesize,ly=(tileY+def[1])*this.tilesize,lvx=(def[2]-def[0])*this.tilesize,lvy=(def[3]-def[1])*this.tilesize,solid=def[4];var tx=x+vx+(lvy<0?width:0)-lx,ty=y+vy+(lvx>0?height:0)-ly;if(lvx*ty-lvy*tx>0){if(vx*-lvy+vy*lvx<0){return solid;}
  181. var length=Math.sqrt(lvx*lvx+lvy*lvy);var nx=lvy/length,ny=-lvx/length;var proj=tx*nx+ty*ny;var px=nx*proj,py=ny*proj;if(px*px+py*py>=vx*vx+vy*vy){return solid||(lvx*(ty-vy)-lvy*(tx-vx)<0.5);}
  182. res.pos.x=x+vx-px;res.pos.y=y+vy-py;res.collision.slope={x:lvx,y:lvy,nx:nx,ny:ny};return true;}
  183. return false;}});var H=1/2,N=1/3,M=2/3,SOLID=true,NON_SOLID=false;ig.CollisionMap.defaultTileDef={5:[0,1,1,M,SOLID],6:[0,M,1,N,SOLID],7:[0,N,1,0,SOLID],3:[0,1,1,H,SOLID],4:[0,H,1,0,SOLID],2:[0,1,1,0,SOLID],10:[H,1,1,0,SOLID],21:[0,1,H,0,SOLID],32:[M,1,1,0,SOLID],43:[N,1,M,0,SOLID],54:[0,1,N,0,SOLID],27:[0,0,1,N,SOLID],28:[0,N,1,M,SOLID],29:[0,M,1,1,SOLID],25:[0,0,1,H,SOLID],26:[0,H,1,1,SOLID],24:[0,0,1,1,SOLID],11:[0,0,H,1,SOLID],22:[H,0,1,1,SOLID],33:[0,0,N,1,SOLID],44:[N,0,M,1,SOLID],55:[M,0,1,1,SOLID],16:[1,N,0,0,SOLID],17:[1,M,0,N,SOLID],18:[1,1,0,M,SOLID],14:[1,H,0,0,SOLID],15:[1,1,0,H,SOLID],13:[1,1,0,0,SOLID],8:[H,1,0,0,SOLID],19:[1,1,H,0,SOLID],30:[N,1,0,0,SOLID],41:[M,1,N,0,SOLID],52:[1,1,M,0,SOLID],38:[1,M,0,1,SOLID],39:[1,N,0,M,SOLID],40:[1,0,0,N,SOLID],36:[1,H,0,1,SOLID],37:[1,0,0,H,SOLID],35:[1,0,0,1,SOLID],9:[1,0,H,1,SOLID],20:[H,0,0,1,SOLID],31:[1,0,M,1,SOLID],42:[M,0,N,1,SOLID],53:[N,0,0,1,SOLID],12:[0,0,1,0,NON_SOLID],23:[1,1,0,1,NON_SOLID],34:[1,0,1,1,NON_SOLID],45:[0,1,0,0,NON_SOLID]};ig.CollisionMap.staticNoCollision={trace:function(x,y,vx,vy){return{collision:{x:false,y:false,slope:false},pos:{x:x+vx,y:y+vy},tile:{x:0,y:0}};}};});
  184. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/background-map.js
  185. ig.baked=true;ig.module('impact.background-map').requires('impact.map','impact.image').defines(function(){"use strict";ig.BackgroundMap=ig.Map.extend({tiles:null,scroll:{x:0,y:0},distance:1,repeat:false,tilesetName:'',foreground:false,enabled:true,preRender:false,preRenderedChunks:null,chunkSize:512,debugChunks:false,anims:{},init:function(tilesize,data,tileset){this.parent(tilesize,data);this.setTileset(tileset);},setTileset:function(tileset){this.tilesetName=tileset instanceof ig.Image?tileset.path:tileset;this.tiles=new ig.Image(this.tilesetName);this.preRenderedChunks=null;},setScreenPos:function(x,y){this.scroll.x=x/this.distance;this.scroll.y=y/this.distance;},preRenderMapToChunks:function(){var totalWidth=this.width*this.tilesize*ig.system.scale,totalHeight=this.height*this.tilesize*ig.system.scale;this.chunkSize=Math.min(Math.max(totalWidth,totalHeight),this.chunkSize);var chunkCols=Math.ceil(totalWidth/this.chunkSize),chunkRows=Math.ceil(totalHeight/this.chunkSize);this.preRenderedChunks=[];for(var y=0;y<chunkRows;y++){this.preRenderedChunks[y]=[];for(var x=0;x<chunkCols;x++){var chunkWidth=(x==chunkCols-1)?totalWidth-x*this.chunkSize:this.chunkSize;var chunkHeight=(y==chunkRows-1)?totalHeight-y*this.chunkSize:this.chunkSize;this.preRenderedChunks[y][x]=this.preRenderChunk(x,y,chunkWidth,chunkHeight);}}},preRenderChunk:function(cx,cy,w,h){var tw=w/this.tilesize/ig.system.scale+1,th=h/this.tilesize/ig.system.scale+1;var nx=(cx*this.chunkSize/ig.system.scale)%this.tilesize,ny=(cy*this.chunkSize/ig.system.scale)%this.tilesize;var tx=Math.floor(cx*this.chunkSize/this.tilesize/ig.system.scale),ty=Math.floor(cy*this.chunkSize/this.tilesize/ig.system.scale);var chunk=ig.$new('canvas');chunk.width=w;chunk.height=h;chunk.retinaResolutionEnabled=false;var chunkContext=chunk.getContext('2d');ig.System.scaleMode(chunk,chunkContext);var screenContext=ig.system.context;ig.system.context=chunkContext;for(var x=0;x<tw;x++){for(var y=0;y<th;y++){if(x+tx<this.width&&y+ty<this.height){var tile=this.data[y+ty][x+tx];if(tile){this.tiles.drawTile(x*this.tilesize-nx,y*this.tilesize-ny,tile-1,this.tilesize);}}}}
  186. ig.system.context=screenContext;return chunk;},draw:function(){if(!this.tiles.loaded||!this.enabled){return;}
  187. if(this.preRender){this.drawPreRendered();}
  188. else{this.drawTiled();}},drawPreRendered:function(){if(!this.preRenderedChunks){this.preRenderMapToChunks();}
  189. var dx=ig.system.getDrawPos(this.scroll.x),dy=ig.system.getDrawPos(this.scroll.y);if(this.repeat){var w=this.width*this.tilesize*ig.system.scale;dx=(dx%w+w)%w;var h=this.height*this.tilesize*ig.system.scale;dy=(dy%h+h)%h;}
  190. var minChunkX=Math.max(Math.floor(dx/this.chunkSize),0),minChunkY=Math.max(Math.floor(dy/this.chunkSize),0),maxChunkX=Math.ceil((dx+ig.system.realWidth)/this.chunkSize),maxChunkY=Math.ceil((dy+ig.system.realHeight)/this.chunkSize),maxRealChunkX=this.preRenderedChunks[0].length,maxRealChunkY=this.preRenderedChunks.length;if(!this.repeat){maxChunkX=Math.min(maxChunkX,maxRealChunkX);maxChunkY=Math.min(maxChunkY,maxRealChunkY);}
  191. var nudgeY=0;for(var cy=minChunkY;cy<maxChunkY;cy++){var nudgeX=0;for(var cx=minChunkX;cx<maxChunkX;cx++){var chunk=this.preRenderedChunks[cy%maxRealChunkY][cx%maxRealChunkX];var x=-dx+cx*this.chunkSize-nudgeX;var y=-dy+cy*this.chunkSize-nudgeY;ig.system.context.drawImage(chunk,x,y);ig.Image.drawCount++;if(this.debugChunks){ig.system.context.strokeStyle='#f0f';ig.system.context.strokeRect(x,y,this.chunkSize,this.chunkSize);}
  192. if(this.repeat&&chunk.width<this.chunkSize&&x+chunk.width<ig.system.realWidth){nudgeX+=this.chunkSize-chunk.width;maxChunkX++;}}
  193. if(this.repeat&&chunk.height<this.chunkSize&&y+chunk.height<ig.system.realHeight){nudgeY+=this.chunkSize-chunk.height;maxChunkY++;}}},drawTiled:function(){var tile=0,anim=null,tileOffsetX=(this.scroll.x/this.tilesize).toInt(),tileOffsetY=(this.scroll.y/this.tilesize).toInt(),pxOffsetX=this.scroll.x%this.tilesize,pxOffsetY=this.scroll.y%this.tilesize,pxMinX=-pxOffsetX-this.tilesize,pxMinY=-pxOffsetY-this.tilesize,pxMaxX=ig.system.width+this.tilesize-pxOffsetX,pxMaxY=ig.system.height+this.tilesize-pxOffsetY;for(var mapY=-1,pxY=pxMinY;pxY<pxMaxY;mapY++,pxY+=this.tilesize){var tileY=mapY+tileOffsetY;if(tileY>=this.height||tileY<0){if(!this.repeat){continue;}
  194. tileY=(tileY%this.height+this.height)%this.height;}
  195. for(var mapX=-1,pxX=pxMinX;pxX<pxMaxX;mapX++,pxX+=this.tilesize){var tileX=mapX+tileOffsetX;if(tileX>=this.width||tileX<0){if(!this.repeat){continue;}
  196. tileX=(tileX%this.width+this.width)%this.width;}
  197. if((tile=this.data[tileY][tileX])){if((anim=this.anims[tile-1])){anim.draw(pxX,pxY);}
  198. else{this.tiles.drawTile(pxX,pxY,tile-1,this.tilesize);}}}}}});});
  199. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/impact/game.js
  200. ig.baked=true;ig.module('impact.game').requires('impact.impact','impact.entity','impact.collision-map','impact.background-map').defines(function(){"use strict";ig.Game=ig.Class.extend({clearColor:'#000000',gravity:0,screen:{x:0,y:0},_rscreen:{x:0,y:0},entities:[],namedEntities:{},collisionMap:ig.CollisionMap.staticNoCollision,backgroundMaps:[],backgroundAnims:{},autoSort:false,sortBy:null,cellSize:64,_deferredKill:[],_levelToLoad:null,_doSortEntities:false,staticInstantiate:function(){this.sortBy=this.sortBy||ig.Game.SORT.Z_INDEX;ig.game=this;return null;},loadLevel:function(data){this.screen={x:0,y:0};this.entities=[];this.namedEntities={};for(var i=0;i<data.entities.length;i++){var ent=data.entities[i];this.spawnEntity(ent.type,ent.x,ent.y,ent.settings);}
  201. this.sortEntities();this.collisionMap=ig.CollisionMap.staticNoCollision;this.backgroundMaps=[];for(var i=0;i<data.layer.length;i++){var ld=data.layer[i];if(ld.name=='collision'){this.collisionMap=new ig.CollisionMap(ld.tilesize,ld.data);}
  202. else{var newMap=new ig.BackgroundMap(ld.tilesize,ld.data,ld.tilesetName);newMap.anims=this.backgroundAnims[ld.tilesetName]||{};newMap.repeat=ld.repeat;newMap.distance=ld.distance;newMap.foreground=!!ld.foreground;newMap.preRender=!!ld.preRender;newMap.name=ld.name;this.backgroundMaps.push(newMap);}}
  203. for(var i=0;i<this.entities.length;i++){this.entities[i].ready();}},loadLevelDeferred:function(data){this._levelToLoad=data;},getMapByName:function(name){if(name=='collision'){return this.collisionMap;}
  204. for(var i=0;i<this.backgroundMaps.length;i++){if(this.backgroundMaps[i].name==name){return this.backgroundMaps[i];}}
  205. return null;},getEntityByName:function(name){return this.namedEntities[name];},getEntitiesByType:function(type){var entityClass=typeof(type)==='string'?ig.global[type]:type;var a=[];for(var i=0;i<this.entities.length;i++){var ent=this.entities[i];if(ent instanceof entityClass&&!ent._killed){a.push(ent);}}
  206. return a;},spawnEntity:function(type,x,y,settings){var entityClass=typeof(type)==='string'?ig.global[type]:type;if(!entityClass){throw("Can't spawn entity of type "+type);}
  207. var ent=new(entityClass)(x,y,settings||{});this.entities.push(ent);if(ent.name){this.namedEntities[ent.name]=ent;}
  208. return ent;},sortEntities:function(){this.entities.sort(this.sortBy);},sortEntitiesDeferred:function(){this._doSortEntities=true;},removeEntity:function(ent){if(ent.name){delete this.namedEntities[ent.name];}
  209. ent._killed=true;ent.type=ig.Entity.TYPE.NONE;ent.checkAgainst=ig.Entity.TYPE.NONE;ent.collides=ig.Entity.COLLIDES.NEVER;this._deferredKill.push(ent);},run:function(){this.update();this.draw();},update:function(){if(this._levelToLoad){this.loadLevel(this._levelToLoad);this._levelToLoad=null;}
  210. this.updateEntities();this.checkEntities();for(var i=0;i<this._deferredKill.length;i++){this._deferredKill[i].erase();this.entities.erase(this._deferredKill[i]);}
  211. this._deferredKill=[];if(this._doSortEntities||this.autoSort){this.sortEntities();this._doSortEntities=false;}
  212. for(var tileset in this.backgroundAnims){var anims=this.backgroundAnims[tileset];for(var a in anims){anims[a].update();}}},updateEntities:function(){for(var i=0;i<this.entities.length;i++){var ent=this.entities[i];if(!ent._killed){ent.update();}}},draw:function(){if(this.clearColor){ig.system.clear(this.clearColor);}
  213. this._rscreen.x=ig.system.getDrawPos(this.screen.x)/ig.system.scale;this._rscreen.y=ig.system.getDrawPos(this.screen.y)/ig.system.scale;var mapIndex;for(mapIndex=0;mapIndex<this.backgroundMaps.length;mapIndex++){var map=this.backgroundMaps[mapIndex];if(map.foreground){break;}
  214. map.setScreenPos(this.screen.x,this.screen.y);map.draw();}
  215. this.drawEntities();for(mapIndex;mapIndex<this.backgroundMaps.length;mapIndex++){var map=this.backgroundMaps[mapIndex];map.setScreenPos(this.screen.x,this.screen.y);map.draw();}},drawEntities:function(){for(var i=0;i<this.entities.length;i++){this.entities[i].draw();}},checkEntities:function(){var hash={};for(var e=0;e<this.entities.length;e++){var entity=this.entities[e];if(entity.type==ig.Entity.TYPE.NONE&&entity.checkAgainst==ig.Entity.TYPE.NONE&&entity.collides==ig.Entity.COLLIDES.NEVER){continue;}
  216. var checked={},xmin=Math.floor(entity.pos.x/this.cellSize),ymin=Math.floor(entity.pos.y/this.cellSize),xmax=Math.floor((entity.pos.x+entity.size.x)/this.cellSize)+1,ymax=Math.floor((entity.pos.y+entity.size.y)/this.cellSize)+1;for(var x=xmin;x<xmax;x++){for(var y=ymin;y<ymax;y++){if(!hash[x]){hash[x]={};hash[x][y]=[entity];}
  217. else if(!hash[x][y]){hash[x][y]=[entity];}
  218. else{var cell=hash[x][y];for(var c=0;c<cell.length;c++){if(entity.touches(cell[c])&&!checked[cell[c].id]){checked[cell[c].id]=true;ig.Entity.checkPair(entity,cell[c]);}}
  219. cell.push(entity);}}}}}});ig.Game.SORT={Z_INDEX:function(a,b){return a.zIndex-b.zIndex;},POS_X:function(a,b){return(a.pos.x+a.size.x)-(b.pos.x+b.size.x);},POS_Y:function(a,b){return(a.pos.y+a.size.y)-(b.pos.y+b.size.y);}};});
  220. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/draw.js
  221. ig.baked=true;ig.module('plugins.midas.draw').requires('impact.impact').defines(function(){Color=function(r,g,b,a){this.red=r;this.green=g;this.blue=b;this.alpha=a;var colorString="";this.toString=function(){if(colorString==""){colorString="rgba("+this.red+","+this.green+","+this.blue+","+this.alpha+")";}
  222. return colorString;};};PluginDraw=function(){var strokeColor="#000000",lineWidth=1,fillColor=null,lineCap=null,strokeDirty=false,fillDirty=false,lineCapDirty=false;this.hexToRgb=function(hex){var shorthandRegex=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;hex=hex.replace(shorthandRegex,function(m,r,g,b){return r+r+g+g+b+b;});var result=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);if(result){var red=parseInt(result[1],16);var green=parseInt(result[2],16);var blue=parseInt(result[3],16);var color=new Color(red,green,blue,1);return color;}};this.setLineWidth=function(newLineWidth){lineWidth=newLineWidth;};this.setStroke=function(newStrokeColor){if(strokeColor!=newStrokeColor){strokeDirty=true;}
  223. strokeColor=newStrokeColor;};this.setFill=function(newFillColor){if(fillColor!=newFillColor){fillDirty=true;}
  224. fillColor=newFillColor;};this.setLineCap=function(newLineCap){if(lineCap!=newLineCap){lineCapDirty=true;}
  225. lineCap=newLineCap;};this.getContext=function(){return ig.system.context;};this.rect=function(x,y,width,height){var context=this.getContext();var scale=ig.system.scale;var scaledOffsetRect={x:scale*x-scale*ig.game.screen.x,y:scale*y-scale*ig.game.screen.y,width:scale*width,height:scale*height};context.beginPath();context.rect(scaledOffsetRect.x,scaledOffsetRect.y,scaledOffsetRect.width,scaledOffsetRect.height);if(fillColor){if(fillDirty){context.fillStyle=fillColor;fillDirty=false;}
  226. context.fill();}
  227. if(strokeColor){if(strokeDirty){context.strokeStyle=strokeColor;strokeDirty=false;}
  228. context.lineWidth=lineWidth;context.stroke();}
  229. this.reset();};this.line=function(x1,y1,x2,y2){var context=this.getContext();var scale=ig.system.scale;var startingVector={x:scale*x1-scale*ig.game.screen.x,y:scale*y1-scale*ig.game.screen.y};var endingVector={x:scale*x2-scale*ig.game.screen.x,y:scale*y2-scale*ig.game.screen.y};context.beginPath();context.moveTo(startingVector.x,startingVector.y);context.lineTo(endingVector.x,endingVector.y);context.strokeStyle=strokeColor;context.lineWidth=lineWidth;if(lineCapDirty){context.lineCap=lineCap;lineCapDirty=false;}
  230. context.stroke();};this.point=function(x,y){this.line(x,y,x+1,y+1);};this.reset=function(){var context=this.getContext();this.strokeColor="#000000";this.lineWidth=1;this.fillColor=null;context.strokeStyle=strokeColor;context.fillStyle=fillColor;context.lineWidth=lineWidth;};this.circle=function(centerX,centerY,radius){var context=this.getContext();var scale=ig.system.scale;if(fillColor){context.beginPath();context.arc(centerX+ig.game.screen.x,centerY+ig.game.screen.y,scale*radius,0,2*Math.PI,false);context.closePath();if(fillDirty){context.fillStyle=fillColor;fillDirty=false;}
  231. context.fill();}
  232. if(strokeColor){var strokeRadius=(radius-(lineWidth/2));context.beginPath();context.arc(centerX+ig.game.screen.x,centerY+ig.game.screen.y,scale*strokeRadius,0,2*Math.PI,false);context.closePath();if(strokeDirty){context.strokeStyle=strokeColor;strokeDirty=false;}
  233. context.lineWidth=lineWidth;context.stroke();}};this.poly=function(points){var context=this.getContext();context.beginPath();context.moveTo(points[0][0],points[0][1]);for(var i=1;i<points.length;i++){context.lineTo(points[i][0],points[i][1]);}
  234. context.closePath();if(fillColor){if(fillDirty){context.fillStyle=fillColor;fillDirty=false;}
  235. context.fill();}
  236. if(strokeColor){if(strokeDirty){context.strokeStyle=strokeColor;strokeDirty=false;}
  237. context.lineWidth=lineWidth;context.stroke();}};};ig.draw=new PluginDraw();});
  238. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/launcher/ui/lifepip.js
  239. ig.baked=true;ig.module('launcher.ui.lifepip').requires('impact.impact','plugins.midas.draw').defines(function(){LifePip=ig.Class.extend({activeColor:pmGameData.backgroundColor,disabledColor:pmGameData.backgroundHighlightColor,activeCircleColor:"white",disabledCircleColor:"rgba(255, 255, 255, 0.5)",drawActive:function(x,y){ig.draw.reset();ig.draw.setFill(this.activeColor);ig.draw.setStroke(null);ig.draw.circle(x,y,12);ig.draw.setFill(this.activeCircleColor);ig.draw.circle(x,y,9);ig.draw.setFill(this.activeColor);ig.draw.circle(x,y,7);},drawDisabled:function(x,y){ig.draw.reset();ig.draw.setFill(this.disabledColor);ig.draw.setStroke(null);ig.draw.circle(x,y,12);ig.draw.setFill(this.disabledCircleColor);ig.draw.circle(x,y,9);}});});
  240. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/clocks.js
  241. ig.baked=true;ig.module('plugins.midas.clocks').requires('impact.impact').defines(function(){TrueClock=ig.Class.extend({getMilliseconds:function(){var date=new Date();return date.getTime();}});TrueStopwatch=ig.Class.extend({clock:new TrueClock(),base:0,target:0,pauseTime:0,running:false,init:function(){var milliseconds=this.clock.getMilliseconds();this.base=milliseconds;this.target=milliseconds;this.pauseTime=milliseconds;},start:function(){if(!this.running){this.base=this.clock.getMilliseconds();this.running=true;}},get:function(){if(this.running){return this.clock.getMilliseconds()-this.base;}
  242. return this.target-this.base;},pause:function(){if(this.running){var milliseconds=this.clock.getMilliseconds();this.pauseTime=milliseconds;this.target=milliseconds;this.running=false;}},unpause:function(){if(!this.running){var milliseconds=this.clock.getMilliseconds();this.base+=milliseconds-this.pauseTime;this.pauseTime=milliseconds;this.running=true;}},stop:function(){if(this.running){this.target=this.clock.getMilliseconds();this.running=false;}},reset:function(){this.base=this.clock.getMilliseconds();this.target=this.base;this.running=false;}});TrueTimer=ig.Class.extend({clock:new TrueClock(),base:0,target:0,running:false,timerCallback:function(){},init:function(){var milliseconds=this.clock.getMilliseconds();this.base=milliseconds;this.target=milliseconds;},start:function(milliseconds){if(!this.running){this.base=this.clock.getMilliseconds();this.target=this.base+milliseconds;this.running=true;}},get:function(){var remaining=this.target-this.clock.getMilliseconds();if(this.running){if(remaining<=0){this.running=false;remaining=0;this.timerCallback();}}else{remaining=this.target-this.base;}
  243. return remaining;},stop:function(){if(this.running){this.base=this.clock.getMilliseconds();this.running=false;}},reset:function(){this.base=this.clock.getMilliseconds();this.target=this.base;},setTimerCallback:function(callback){this.timerCallback=callback;}});});
  244. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/launcher/ui/header.js
  245. ig.baked=true;ig.module('launcher.ui.header').requires('impact.game','impact.timer','launcher.ui.lifepip','plugins.midas.draw','plugins.midas.clocks').defines(function(){HeaderUI=ig.Class.extend({size:{x:800,y:50},clearColor:pmGameData.complementColor,numberFont:new ig.Font(pmGameData.assetPath+'common/proxima-semibold-24-white.font.png'),labelFont:new ig.Font(pmGameData.assetPath+'common/proxima-extrabold-12-white.font.png'),timerImage:new ig.Image(pmGameData.assetPath+'common/gameclock.png'),activePips:0,disabledPips:0,timerStart:false,stopwatch:new TrueStopwatch(),timer:new TrueTimer(),stopwatchEnabled:false,timerEnabled:false,lifeEnabled:false,scoreEnabled:false,totalPips:0,trueLifePip:null,init:function(){this.trueLifePip=new LifePip();},update:function(){this.displayTime=this.formatForMilliseconds(this.stopwatch.get());},formatForMilliseconds:function(delta){var displayTime="0:00";var seconds=Math.floor(delta/1000);var milliseconds=Math.floor(delta-seconds*1000);if(seconds/60>=1){displayTime=this.formatForMinutes(seconds);}else{displayTime=this.formatForSeconds(seconds);}
  246. displayTime+=":";if(milliseconds<100){displayTime+="0";}
  247. displayTime+=Math.floor(milliseconds/10);return displayTime;},formatForSeconds:function(seconds){var displayTime="00";if(seconds<10){displayTime="0"+seconds;}else if(seconds>=10){displayTime=""+seconds;}
  248. return displayTime;},formatForMinutes:function(seconds){var displayTime="0:00";if(seconds>=60){displayTime=Math.floor(seconds/60)+":";if(seconds%60<10){displayTime+="0";}
  249. displayTime+=seconds%60;}else{displayTime="0:"+this.formatForSeconds(delta);}
  250. return displayTime;},draw:function(){ig.draw.reset();ig.draw.setFill(this.clearColor);ig.draw.setStroke(null);ig.draw.rect(0,0,this.size.x,this.size.y);if(this.stopwatchEnabled||this.timerEnabled){this.timerImage.draw(10,10);this.numberFont.draw(this.displayTime,50,12,ig.Font.ALIGN.LEFT);}
  251. if(this.lifeEnabled){var lastPipDrawn=620;for(var i=Math.min(this.totalPips-1,this.activePips-1);i>=0;i--){this.trueLifePip.drawActive(lastPipDrawn-i*30,25);}
  252. lastPipDrawn-=this.activePips*30;for(var i=0;i<this.disabledPips;i++){this.trueLifePip.drawDisabled(lastPipDrawn-i*30,25);}}
  253. if(this.scoreEnabled){this.numberFont.draw(""+this.prettyPrintScore(ig.global['score']),790,12,ig.Font.ALIGN.RIGHT);}},setPips:function(activated,deactivated){this.totalPips=activated+deactivated;this.activePips=activated;this.disabledPips=deactivated;},addActivePip:function(){this.activePips++;this.totalPips++;},addDisabledPip:function(){this.disabledPips++;this.totalPips++;},activateNextPip:function(){this.activePips++;this.disabledPips--;},deactivateNextPip:function(){this.activePips--;this.disabledPips++;},startStopwatch:function(){this.stopwatch.start();},pauseStopwatch:function(){this.stopwatch.pause();},unpauseStopwatch:function(){this.stopwatch.unpause();},clearStopwatch:function(){this.stopwatch.reset();},getClock:function(){return this.stopwatch.get();},enableStopwatch:function(){this.stopwatchEnabled=true;},enableLife:function(){this.lifeEnabled=true;},enableScore:function(){this.scoreEnabled=true;},prettyPrintScore:function(rawScore){var scoreString=Math.floor(rawScore).toLocaleString();return scoreString;}});});
  254. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/button.js
  255. ig.baked=true;ig.module('plugins.midas.button').requires('impact.entity').defines(function(){EntityButton=ig.Entity.extend({size:{x:80,y:40},animSheet:null,state:'idle',wasPreviouslyPressed:false,wasPreviouslyHovered:false,init:function(x,y,settings){this.parent(x,y,settings);this.addAnim('idle',1,[0]);this.addAnim('active',1,[1]);this.addAnim('hover',1,[2]);},update:function(){if(this.state!=='hidden'){var isClicked=ig.input.state('click');if(this.mouseWithinButton()){this.wasPreviouslyHovered=true;document.body.style.cursor="pointer";if(isClicked){this.setState('active');if(this.wasPreviouslyPressed){this.pressed();}else{this.onPress();}
  256. this.wasPreviouslyPressed=true;}else{this.setState('hover');if(this.wasPreviouslyPressed){document.body.style.cursor="default";this.onRelease();}
  257. this.wasPreviouslyPressed=false;}}else{if(this.wasPreviouslyHovered){document.body.style.cursor="default";this.setState('idle');this.wasPreviouslyPressed=false;this.wasPreviouslyHovered=false;}}}},draw:function(){if(this.state!=='hidden'){this.parent();}},setState:function(s){this.state=s;if(this.state!=='hidden'){this.currentAnim=this.anims[this.state];}},onPress:function(){},pressed:function(){},onRelease:function(){},mouseWithinButton:function(){return ig.input.mouse.x+ig.game.screen.x>this.pos.x&&ig.input.mouse.x+ig.game.screen.x<this.pos.x+this.size.x&&ig.input.mouse.y+ig.game.screen.y>this.pos.y&&ig.input.mouse.y+ig.game.screen.y<this.pos.y+this.size.y;}});});
  258. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/launcher/ui/credits.js
  259. ig.baked=true;ig.module('launcher.ui.credits').requires('impact.game','impact.entity','plugins.midas.draw','plugins.midas.button').defines(function(){CreditsButton=EntityButton.extend({isDoingFade:false,fadeDirection:0.1,init:function(x,y,settings){this.parent(x,y,settings);this.anims.idle.alpha=0;},update:function(){if(this.mouseWithinButton()){if(!this.isDoingFade&&this.currentAnim.alpha!=1){this.anims.idle.alpha=0;this.anims.hover.alpha=0;this.fadeDirection=0.1;this.isDoingFade=true;}}else{if(!this.isDoingFade&&this.currentAnim.alpha!=0){this.anims.hover.alpha=0;this.anims.idle.alpha=1;this.fadeDirection=-0.1;this.isDoingFade=true;}}
  260. if(this.isDoingFade){this.currentAnim.alpha+=this.fadeDirection;if(this.currentAnim.alpha>=1){this.currentAnim.alpha=1;this.isDoingFade=false;}
  261. if(this.currentAnim.alpha<=0){this.currentAnim.alpha=0;this.isDoingFade=false;}}
  262. this.parent();},draw:function(){this.parent();}});Credits=ig.Game.extend({clearColor:"#000000",font:new ig.Font('common/proxima-extrabold-30-white.font.png'),scrollPos:0,creditsText:"Credits\n\n\nProgramming and Game Design:\nJustin Gilman\n\n\nArt and UI Design:\nJason Calleiro\n\n\nServer API:\nScott Shervington",loopCredits:false,endCredits:true,buttonClick:new ig.Sound(pmGameData.assetPath+'common/button-click.*'),init:function(){ig.game.spawnEntity(EntityButton,650,450,{size:{x:128,y:128},animSheet:new ig.AnimationSheet('common/backbutton.png',128,128),onRelease:function(){ig.game.buttonClick.play();ig.system.setGame(MainMenu);}});if(this.font.heightForString(this.creditsText)>ig.system.height){this.loopCredits=true;}},update:function(){if(this.loopCredits){if(this.scrollPos+ig.system.height>-100-this.font.heightForString(this.creditsText)){this.scrollPos--;}else{if(this.endCredits){ig.system.setGame(MainMenu);}else{this.scrollPos=0;}}}else{if(this.scrollPos+ig.system.height>(ig.system.height-this.font.heightForString(this.creditsText))/2){this.scrollPos--;}}
  263. this.parent();},draw:function(){this.parent();this.font.draw(this.creditsText,ig.system.width/2,this.scrollPos+ig.system.height,ig.Font.ALIGN.CENTER);}});});
  264. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/browserinfo.js
  265. ig.baked=true;ig.module('plugins.midas.browserinfo').requires('impact.impact').defines(function(){PluginBrowserInfo=function(){this.getName=function(){var name=navigator.appName;var userAgent=navigator.userAgent;var nameMatch=userAgent.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);if(nameMatch){name=nameMatch[1];}
  266. return name;};this.getVersion=function(){var version=navigator.appVersion;var userAgent=navigator.userAgent;var versionMatch=userAgent.match(/version\/([\.\d]+)/i);var nameMatch=userAgent.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);if(nameMatch){version=nameMatch[2];if(versionMatch!=null){version=versionMatch[1];}}
  267. return version;};this.getMajorVersion=function(){return this.getVersion().split('.')[0];};this.getMinorVersion=function(){return this.getVersion().split('.')[1];};this.shouldBlock=function(browserFilter){for(var i=0;i<browserFilter.length;i++){var browserRule=browserFilter[i];if(browserRule.name.toLowerCase()==this.getName().toLowerCase()&&this.getMajorVersion()<=browserRule.version){return true;}}
  268. return false;};};ig.browserInfo=new PluginBrowserInfo();});
  269. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/arrayutils.js
  270. ig.baked=true;ig.module('plugins.midas.arrayutils').requires('impact.impact').defines(function(){PluginArrayUtils=function(){var populateDiffArray=function(array1,diffData){var match=false;for(var j=0;j<array1.length;j++){match=false;for(var i=0;i<diffData.length;i++){if(ig.arrayUtils.compare(array1[j],diffData[i].item)){diffData[i].count++;match=true;}}
  271. if(!match){diffData.push({item:array1[j],count:1});}}
  272. return diffData;};this.shuffle=function(obj){var rand;var index=0;var shuffled=[];this.each(obj,function(value){rand=Math.floor(Math.random()*index);shuffled[index]=shuffled[rand];index++;shuffled[rand]=value;});return shuffled;};this.each=function(obj,iterator,context){if(obj==null)return;for(var key in obj){if(this.has(obj,key)){if(iterator.call(context,obj[key],key,obj)==={})return;}}};this.has=function(obj,key){return obj.hasOwnProperty(key);};this.contains=function(needle,haystack){for(var i=0;i<haystack.length;i++){if(haystack[i]===needle){return true;}}
  273. return false;};this.removeDuplicates=function(dirtyArray){var cleaned=[];var found=null;for(var j=0;j<dirtyArray.length;j++){var value=dirtyArray[j];found=value;for(var i=0;i<cleaned.length;i++){if(this.compare(cleaned[i],value)){found=null;}}
  274. if(found){cleaned.push(found);}}
  275. return cleaned;};this.compare=function(array1,array2){if(!array1||!array2){return false;}
  276. if(array1.length!=array2.length){return false;}
  277. for(var i=0;i<array1.length;i++){if(this[i]instanceof Array&&array2[i]instanceof Array){if(!this.compare(array1[i],array2[i])){return false;}}
  278. else if(array1[i]!=array2[i]){return false;}}
  279. return true;};this.diff=function(array1,array2){var diffData=[];diffData=populateDiffArray(array1,diffData);diffData=populateDiffArray(array2,diffData);var diffResult=[];for(var i=0;i<diffData.length;i++){if(diffData[i].count<=1){diffResult.push(diffData[i].item);}}
  280. return diffResult;};};ig.arrayUtils=new PluginArrayUtils();});
  281. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/ajaxpromise.js
  282. ig.baked=true;ig.module('plugins.midas.ajaxpromise').requires('impact.impact','plugins.midas.arrayutils').defines(function(){PluginAjaxPromise=ig.Class.extend({doneCallbacks:[],failureCallbacks:[],alwaysCallbacks:[],result:null,state:0,setResult:function(result){this.result=result;},resolve:function(){this.state=PluginAjaxPromise.STATE.FULFILLED;this.isDone();this.isAlways();},reject:function(){this.state=PluginAjaxPromise.STATE.FAILED;this.isFailure();this.isAlways();},operateOnDelegates:function(callbackCollection){ig.arrayUtils.each(callbackCollection,function(value){value(this.result);},this);},isDone:function(){this.operateOnDelegates(this.doneCallbacks);},isFailure:function(){this.operateOnDelegates(this.failureCallbacks);},isAlways:function(){this.operateOnDelegates(this.alwaysCallbacks);},done:function(newDoneCallback){if(this.state==PluginAjaxPromise.STATE.FULFILLED){newDoneCallback(this.result);}else{this.doneCallbacks.push(newDoneCallback);}},fail:function(newFailCallback){if(this.state==PluginAjaxPromise.STATE.FAILED){newFailCallback(this.result);}else{this.failureCallbacks.push(newFailCallback);}},always:function(newAlwaysCallback){if(this.state==PluginAjaxPromise.STATE.UNFULFILLED){this.alwaysCallbacks.push(newAlwaysCallback);}else{newAlwaysCallback(this.result);}}});PluginAjaxPromise.STATE={UNFULFILLED:0,FULFILLED:1,FAILED:2};});
  283. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/ajax.js
  284. ig.baked=true;ig.module('plugins.midas.ajax').requires('impact.impact','plugins.midas.ajaxpromise').defines(function(){PluginAjax=ig.Class.extend({get:function(url){var promise=new PluginAjaxPromise();var request=null;if(window.XMLHttpRequest){request=new XMLHttpRequest();}else{request=new ActiveXObject("Microsoft.XMLHTTP");}
  285. request.onreadystatechange=function(){if(request.readyState==4){if(request.status==200){promise.setResult(request);promise.resolve();}else{promise.reject();}}};request.open('GET',url,true);request.send();return promise;},getJson:function(url){var promise=new PluginAjaxPromise();var request=null;if(window.XMLHttpRequest){request=new XMLHttpRequest();}else{request=new ActiveXObject("Microsoft.XMLHTTP");}
  286. request.onreadystatechange=function(){if(request.readyState==4){if(request.status==200){promise.setResult(JSON.parse(request.response));promise.resolve();}else{promise.setResult({});promise.reject();}}};request.open('GET',url,true);request.send();return promise;},post:function(url,data){var promise=new PluginAjaxPromise();var request=null;if(window.XMLHttpRequest){request=new XMLHttpRequest();}else{request=new ActiveXObject("Microsoft.XMLHTTP");}
  287. request.onreadystatechange=function(){if(request.readyState==4){if(request.status==200){promise.setResult(request);promise.resolve();}else{promise.reject();}}};request.open('POST',url,true);request.send(this.dataToParams(data));return promise;},postJson:function(url,data){var promise=new PluginAjaxPromise();var request=null;if(window.XMLHttpRequest){request=new XMLHttpRequest();}else{request=new ActiveXObject("Microsoft.XMLHTTP");}
  288. request.onreadystatechange=function(){if(request.readyState==4){if(request.status==200){promise.setResult(JSON.parse(request.response));promise.resolve();}else{promise.reject();}}};request.open('POST',url,true);request.send(this.dataToParams(data));return promise;},dataToParams:function(data){var paramArray=[];for(var key in data){if(data.hasOwnProperty(key)){var value=data[key];if(typeof value==='object'){value=JSON.stringify(value);}
  289. paramArray.push(key+"="+value);}}
  290. return paramArray.join("&");}});ig.ajax=new PluginAjax();});
  291. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/launcher/ui/nextgameinfopanel.js
  292. ig.baked=true;ig.module('launcher.ui.nextgameinfopanel').requires('impact.entity','plugins.midas.draw').defines(function(){NextGameInfoPanel=ig.Entity.extend({size:{x:600,y:400},headerFont:new ig.Font(pmGameData.assetPath+'common/opensans-48-800-gray.font.png'),scoreFont:new ig.Font(pmGameData.assetPath+'common/opensans-60-gray.font.png'),scoreLabelFont:new ig.Font(pmGameData.assetPath+'common/opensans-24-lightgray.font.png'),labelFont:new ig.Font(pmGameData.assetPath+'common/opensans-24-600-gray.font.png'),gameIcon:new ig.AnimationSheet(pmGameData.gameIcon,108,108),gameIconAnimation:null,init:function(x,y,settings){this.parent(x,y,settings);this.gameIconAnimation=new ig.Animation(this.gameIcon,1,[ig.global['nextGame'].gameIconIndex]);},update:function(){},draw:function(){var x=this.pos.x+(this.size.x/2),y=this.pos.y+(this.size.y/2);ig.draw.setStroke(null);ig.draw.setFill("#F9F9F9");ig.draw.rect(this.pos.x,this.pos.y,this.size.x,this.size.y);ig.draw.setFill(null);ig.draw.setStroke(pmGameData.backgroundColor);ig.draw.setLineWidth(4);ig.draw.rect(this.pos.x+10,this.pos.y+10,this.size.x-20,this.size.y-20);ig.draw.setStroke("#D3D3D3");ig.draw.line(this.pos.x+50,this.pos.y+100,this.pos.x+this.size.x-50,this.pos.y+100);ig.draw.line(this.pos.x+50,this.pos.y+190,this.pos.x+this.size.x-50,this.pos.y+190);this.headerFont.draw('CONGRATULATIONS!',x,y-160,ig.Font.ALIGN.CENTER);this.scoreLabelFont.draw('YOUR\nSCORE',x-30,y-80,ig.Font.ALIGN.RIGHT);this.scoreFont.draw(ig.global['headerui'].prettyPrintScore(ig.global['score']),x-20,y-100,ig.Font.ALIGN.LEFT);this.labelFont.draw("NEXT UP: "+ig.global['nextGame'].name,x,y,ig.Font.ALIGN.CENTER);this.gameIconAnimation.draw(x-54,y-54+90);this.parent();}});});
  293. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/launcher/ui/playagaininfopanel.js
  294. ig.baked=true;ig.module('launcher.ui.playagaininfopanel').requires('impact.entity','plugins.midas.draw').defines(function(){PlayAgainInfoPanel=ig.Entity.extend({size:{x:600,y:400},headerFont:new ig.Font(pmGameData.assetPath+'common/opensans-48-800-gray.font.png'),scoreFont:new ig.Font(pmGameData.assetPath+'common/opensans-60-gray.font.png'),scoreLabelFont:new ig.Font(pmGameData.assetPath+'common/opensans-24-lightgray.font.png'),labelFont:new ig.Font(pmGameData.assetPath+'common/opensans-24-600-gray.font.png'),gameIcon:new ig.AnimationSheet(pmGameData.gameIcon,108,108),gameIconAnimation:null,init:function(x,y,settings){this.parent(x,y,settings);this.gameIconAnimation=new ig.Animation(this.gameIcon,1,[ig.global['nextGame'].gameIconIndex]);},update:function(){},draw:function(){var x=this.pos.x+(this.size.x/2),y=this.pos.y+(this.size.y/2);ig.draw.setStroke(null);ig.draw.setFill("#F9F9F9");ig.draw.rect(this.pos.x,this.pos.y,this.size.x,this.size.y);ig.draw.setFill(null);ig.draw.setStroke(pmGameData.backgroundColor);ig.draw.setLineWidth(4);ig.draw.rect(this.pos.x+10,this.pos.y+10,this.size.x-20,this.size.y-20);ig.draw.setStroke("#D3D3D3");ig.draw.line(this.pos.x+50,this.pos.y+100,this.pos.x+this.size.x-50,this.pos.y+100);ig.draw.line(this.pos.x+50,this.pos.y+190,this.pos.x+this.size.x-50,this.pos.y+190);this.headerFont.draw('CONGRATULATIONS!',x,y-160,ig.Font.ALIGN.CENTER);this.scoreLabelFont.draw('YOUR\nSCORE',x-30,y-80,ig.Font.ALIGN.RIGHT);this.scoreFont.draw(ig.global['headerui'].prettyPrintScore(ig.global['score']),x-20,y-100,ig.Font.ALIGN.LEFT);this.labelFont.draw("Currently playing:",x,y-5,ig.Font.ALIGN.CENTER);this.gameIconAnimation.draw(x-54,y-54+80);this.labelFont.draw(pmGameData.displayName,x,y+135,ig.Font.ALIGN.CENTER);this.parent();}});});
  295. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/launcher/ui/lessoncompleteinfopanel.js
  296. ig.baked=true;ig.module('launcher.ui.lessoncompleteinfopanel').requires('impact.entity','plugins.midas.draw').defines(function(){LessonCompleteInfoPanel=ig.Entity.extend({size:{x:600,y:400},headerFont:new ig.Font(pmGameData.assetPath+'common/opensans-48-800-gray.font.png'),scoreFont:new ig.Font(pmGameData.assetPath+'common/opensans-60-gray.font.png'),scoreLabelFont:new ig.Font(pmGameData.assetPath+'common/opensans-24-lightgray.font.png'),labelFont:new ig.Font(pmGameData.assetPath+'common/opensans-24-600-gray.font.png'),init:function(x,y,settings){this.parent(x,y,settings);},update:function(){},draw:function(){var x=this.pos.x+(this.size.x/2),y=this.pos.y+(this.size.y/2);ig.draw.setStroke(null);ig.draw.setFill("#F9F9F9");ig.draw.rect(this.pos.x,this.pos.y,this.size.x,this.size.y);ig.draw.setFill(null);ig.draw.setStroke(pmGameData.backgroundColor);ig.draw.setLineWidth(4);ig.draw.rect(this.pos.x+10,this.pos.y+10,this.size.x-20,this.size.y-20);ig.draw.setStroke("#D3D3D3");ig.draw.line(this.pos.x+50,this.pos.y+100,this.pos.x+this.size.x-50,this.pos.y+100);ig.draw.line(this.pos.x+50,this.pos.y+190,this.pos.x+this.size.x-50,this.pos.y+190);this.headerFont.draw('CONGRATULATIONS!',x,y-160,ig.Font.ALIGN.CENTER);this.scoreLabelFont.draw('You\'ve finished '+ig.global['nextGame'].currentName+'!',x,y-65,ig.Font.ALIGN.CENTER);this.labelFont.draw('START '+ig.global['nextGame'].nextName,x,y+20,ig.Font.ALIGN.CENTER);this.parent();}});});
  297. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/launcher/ui/trainingcompleteinfopanel.js
  298. ig.baked=true;ig.module('launcher.ui.trainingcompleteinfopanel').requires('impact.entity','plugins.midas.draw').defines(function(){TrainingCompleteInfoPanel=ig.Entity.extend({size:{x:600,y:400},headerFont:new ig.Font(pmGameData.assetPath+'common/opensans-48-800-gray.font.png'),scoreFont:new ig.Font(pmGameData.assetPath+'common/opensans-60-gray.font.png'),scoreLabelFont:new ig.Font(pmGameData.assetPath+'common/opensans-24-lightgray.font.png'),labelFont:new ig.Font(pmGameData.assetPath+'common/opensans-24-600-gray.font.png'),brainSpritesheet:new ig.AnimationSheet(pmGameData.assetPath+'common/brains.png',123,108),brains:{},init:function(x,y,settings){this.parent(x,y,settings);this.brains['gold']=new ig.Animation(this.brainSpritesheet,1,[0]);this.brains['silver']=new ig.Animation(this.brainSpritesheet,1,[1]);this.brains['bronze']=new ig.Animation(this.brainSpritesheet,1,[2]);},update:function(){this.brains[ig.global['nextGame'].currentBrain.toLowerCase()].update();},draw:function(){var x=this.pos.x+(this.size.x/2),y=this.pos.y+(this.size.y/2);ig.draw.setStroke(null);ig.draw.setFill("#F9F9F9");ig.draw.rect(this.pos.x,this.pos.y,this.size.x,this.size.y);ig.draw.setFill(null);ig.draw.setStroke(pmGameData.backgroundColor);ig.draw.setLineWidth(4);ig.draw.rect(this.pos.x+10,this.pos.y+10,this.size.x-20,this.size.y-20);ig.draw.setStroke("#D3D3D3");ig.draw.line(this.pos.x+50,this.pos.y+100,this.pos.x+this.size.x-50,this.pos.y+100);ig.draw.line(this.pos.x+50,this.pos.y+300,this.pos.x+this.size.x-50,this.pos.y+300);this.headerFont.draw('CONGRATULATIONS!',x,y-160,ig.Font.ALIGN.CENTER);this.scoreLabelFont.draw('You\'ve completed '+ig.global['nextGame'].name+'!',x,y-85,ig.Font.ALIGN.CENTER);this.labelFont.draw('TOTAL POINTS: '+ig.global['nextGame'].totalPoints+'!',x,y-55,ig.Font.ALIGN.CENTER);this.labelFont.draw('CURRENT BRAIN: '+ig.global['nextGame'].currentBrain,x,y+120,ig.Font.ALIGN.CENTER);this.brains[ig.global['nextGame'].currentBrain.toLowerCase()].draw(x-60,y-25);this.parent();}});});
  299. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/drawnbutton.js
  300. ig.baked=true;ig.module('plugins.midas.drawnbutton').requires('impact.entity','plugins.midas.draw').defines(function(){EntityDrawnButton=ig.Entity.extend({size:{x:80,y:40},state:'idle',wasPreviouslyPressed:false,wasPreviouslyHovered:false,text:"Submit",font:null,fillColors:{idle:"#FF0000",hover:"#FF8888",active:"#FF8888"},strokeColors:{idle:null,hover:null,active:null},buttonFillColor:"#FF0000",buttonStrokeColor:null,init:function(x,y,settings){this.parent(x,y,settings);},update:function(){if(this.state=='hidden'){return;}
  301. if(this.font!=null){this.font.alpha=1;if(this.size.x<this.font.widthForString(this.text)){this.size.x=this.font.widthForString(this.text);}
  302. if(this.size.y<this.font.heightForString(this.text)){this.size.y=this.font.heightForString(this.text);}}
  303. var isClicked=ig.input.state('click');if(this.mouseWithinButton()){this.wasPreviouslyHovered=true;document.body.style.cursor="pointer";if(isClicked){this.setState('active');if(this.wasPreviouslyPressed){this.pressed();}else{this.onPress();}
  304. this.wasPreviouslyPressed=true;}else{this.setState('hover');if(this.wasPreviouslyPressed){document.body.style.cursor="default";this.onRelease();}
  305. this.wasPreviouslyPressed=false;}}else{if(this.wasPreviouslyHovered){document.body.style.cursor="default";this.setState('idle');this.wasPreviouslyPressed=false;}}},draw:function(){if(this.state=='hidden'){return;}
  306. ig.draw.setStroke(this.strokeColors[this.state]);ig.draw.setFill(this.fillColors[this.state]);ig.draw.rect(this.pos.x,this.pos.y,this.size.x,this.size.y);if(this.font!=null){this.font.draw(this.text,this.pos.x+this.size.x/2,this.pos.y+this.size.y/2-this.font.heightForString(this.text)/2,ig.Font.ALIGN.CENTER);}
  307. this.parent();},setState:function(s){this.state=s;},onPress:function(){},pressed:function(){},onRelease:function(){},mouseWithinButton:function(){return ig.input.mouse.x+ig.game.screen.x>this.pos.x&&ig.input.mouse.x+ig.game.screen.x<this.pos.x+this.size.x&&ig.input.mouse.y+ig.game.screen.y>this.pos.y&&ig.input.mouse.y+ig.game.screen.y<this.pos.y+this.size.y;}});});
  308. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/launcher/endgame.js
  309. ig.baked=true;ig.module('launcher.endgame').requires('impact.game','impact.font','launcher.ui.nextgameinfopanel','launcher.ui.playagaininfopanel','launcher.ui.lessoncompleteinfopanel','launcher.ui.trainingcompleteinfopanel','plugins.midas.button','plugins.midas.drawnbutton','plugins.midas.draw').defines(function(){EndGame=ig.Game.extend({clearColor:pmGameData.backgroundColor,headerFont:new ig.Font(pmGameData.assetPath+'common/opensans-48-gray.font.png'),scoreFont:new ig.Font(pmGameData.assetPath+'common/opensans-60-gray.font.png'),labelFont:new ig.Font(pmGameData.assetPath+'common/opensans-24-lightgray.font.png'),buttonClick:new ig.Sound(pmGameData.assetPath+'common/button-click.*'),init:function(){document.body.style.cursor="default";ig.input.bind(ig.KEY.MOUSE1,'click');if(ig.global['nextGame'].type=="nextGame"){this.nextGame();}else if(ig.global['nextGame'].type=="nextLesson"){this.lessonComplete();}else if(ig.global['nextGame'].type=="trainingComplete"){this.trainingComplete();}else if(ig.global['nextGame'].type=="playAgain"){this.playAgain();}},nextGame:function(){var x=ig.system.width/2,y=ig.system.height/2;ig.game.spawnEntity(NextGameInfoPanel,100,100,{});ig.game.spawnEntity(EntityDrawnButton,x-125,y+165,{font:new ig.Font(pmGameData.assetPath+'common/dosis-30-white.font.png'),size:{x:250,y:60},text:"PLAY NOW!",fillColors:{idle:pmGameData.complementColor,hover:pmGameData.complementHighlightColor,active:pmGameData.complementHighlightColor},strokeColors:{idle:null,hover:null,active:null},onRelease:function(){ig.game.buttonClick.play();var url=ig.global['nextGame'].url;if(url!=""&&url!=null){document.location.href=url;}else{ig.global["wrapperState"]="starting";ig.system.setGame(GameWrapper);}}});},playAgain:function(){pmGameData.id=ig.global['nextGame'].id;var x=ig.system.width/2,y=ig.system.height/2;ig.game.spawnEntity(PlayAgainInfoPanel,100,100,{});ig.game.spawnEntity(EntityDrawnButton,x-125,y+165,{font:new ig.Font(pmGameData.assetPath+'common/dosis-30-white.font.png'),size:{x:250,y:60},text:"PLAY AGAIN?",fillColors:{idle:pmGameData.complementColor,hover:pmGameData.complementHighlightColor,active:pmGameData.complementHighlightColor},strokeColors:{idle:null,hover:null,active:null},onRelease:function(){ig.game.buttonClick.play();var url=ig.global['nextGame'].url;if(ig.global['nextGame'].type=="playAgain"||url==""||url==null){ig.global["wrapperState"]="starting";ig.system.setGame(GameWrapper);}else{document.location.href=url;}}});},lessonComplete:function(){var x=ig.system.width/2,y=ig.system.height/2;ig.game.spawnEntity(LessonCompleteInfoPanel,100,100,{});ig.game.spawnEntity(EntityDrawnButton,x-125,y+85,{font:new ig.Font(pmGameData.assetPath+'common/dosis-30-white.font.png'),size:{x:250,y:60},text:"NEXT WORKOUT!",fillColors:{idle:pmGameData.complementColor,hover:pmGameData.complementHighlightColor,active:pmGameData.complementHighlightColor},strokeColors:{idle:null,hover:null,active:null},onRelease:function(){ig.game.buttonClick.play();var url=ig.global['nextGame'].url;if(url!=""&&url!=null){document.location.href=url;}else{ig.global["wrapperState"]="starting";ig.system.setGame(GameWrapper);}}});},trainingComplete:function(){var x=ig.system.width/2,y=ig.system.height/2;ig.game.spawnEntity(TrainingCompleteInfoPanel,100,100,{});ig.game.spawnEntity(EntityDrawnButton,x-125,y+165,{font:new ig.Font(pmGameData.assetPath+'common/dosis-30-white.font.png'),size:{x:250,y:60},text:"MORE TRAINING!",fillColors:{idle:pmGameData.complementColor,hover:pmGameData.complementHighlightColor,active:pmGameData.complementHighlightColor},strokeColors:{idle:null,hover:null,active:null},onRelease:function(){ig.game.buttonClick.play();var url=ig.global['nextGame'].url;if(url!=""&&url!=null){document.location.href=url;}else{ig.global["wrapperState"]="starting";ig.system.setGame(GameWrapper);}}});},update:function(){this.parent();ig.global['headerui'].update();},draw:function(){this.parent();ig.global['headerui'].draw();}});});
  310. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/com/purelymental/missingpiece/entities/piece.js
  311. ig.baked=true;ig.module('com.purelymental.missingpiece.entities.piece').requires('impact.entity','plugins.midas.draw').defines(function(){EntityPiece=ig.Entity.extend({size:{x:150,y:150},backgroundTile:0,shakeCount:0,shakeOffset:{x:0,y:0},shakeTimer:new ig.Timer(),piecePosition:{x:0,y:0},holes:new ig.Image('missingpiece/holes.png'),isCorrect:false,init:function(x,y,settings){this.parent(x,y,settings);},update:function(){if(this.mouseOver()){this.hover=true;document.body.style.cursor="pointer";}else{this.hover=false;}
  312. if(ig.input.state('click')){if(this.hover&&!this.pressed){this.pressed=true;this.onPress();}else if(this.hover&&this.pressed){}}else{if(this.hover&&this.pressed){this.onRelease();}
  313. this.pressed=false;}
  314. if(this.shakeCount>0&&this.shakeTimer.delta()>=0.05){if(this.shakeCount%2==0){this.shakeOffset.x=-3;}else{this.shakeOffset.x=3;}
  315. this.shakeCount--;this.shakeTimer.set(0);}
  316. if(this.shakeCount==0){this.shakeOffset.x=0;}
  317. this.parent();},draw:function(){this.parent();ig.system.context.drawImage(ig.game.background.backgroundCanvas,this.piecePosition.x*50,this.piecePosition.y*50,150,150,this.pos.x+this.shakeOffset.x,this.pos.y+this.shakeOffset.y,150,150);this.holes.drawTile(this.pos.x+this.shakeOffset.x,this.pos.y+this.shakeOffset.y,ig.global['paramData'].shapes[0]+1,150,150);if(this.isCorrect){var holePos={x:ig.game.correctPosition.x*50,y:ig.game.correctPosition.y*50};if(!ig.game.correctOneClicked){this.holes.drawTile(holePos.x,holePos.y+50,ig.global['paramData'].shapes[0],150,150);}}},mouseOver:function(){return ig.input.mouse.x+ig.game.screen.x>this.pos.x&&ig.input.mouse.x+ig.game.screen.x<this.pos.x+this.size.x&&ig.input.mouse.y+ig.game.screen.y>this.pos.y&&ig.input.mouse.y+ig.game.screen.y<this.pos.y+this.size.y;},onPress:function(){},onRelease:function(){if(ig.game.pieceClicked(this.piecePosition)){this.kill();}else{this.shakeCount=6;this.shakeTimer.set(0);}}});});
  318. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/com/purelymental/missingpiece/entities/particle.js
  319. ig.baked=true;ig.module('com.purelymental.missingpiece.entities.particle').requires('impact.entity','impact.timer','plugins.midas.draw').defines(function(){EntityParticle=ig.Entity.extend({animSheet:new ig.AnimationSheet('missingpiece/particles.png',50,50),maxVel:{x:1000,y:1000},isDead:false,collides:ig.Entity.COLLIDES.NEVER,init:function(x,y,settings){this.timer=new ig.Timer();this.timer.set(Math.random()*2);var colors=['white','yellow','blue','red'];this.addAnim(colors[0],0.05,[0,1,2]);this.addAnim(colors[1],0.05,[3,4,5]);this.addAnim(colors[2],0.05,[6,7,8]);this.addAnim(colors[3],0.05,[9,10,11]);var colorPicker=Math.floor(Math.random()*2);this.currentAnim=this.anims[colors[colorPicker]].rewind();this.parent(x,y,settings);this.vel.x=(Math.random()*200)-100;this.vel.y=-((Math.random()*150)+50);this.accel.y=200;},update:function(){this.parent();if(this.timer.delta()>0){this.isDead=true;this.kill();}},draw:function(){this.parent();}});});
  320. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/com/purelymental/missingpiece/entities/particleemitter.js
  321. ig.baked=true;ig.module('com.purelymental.missingpiece.entities.particleemitter').requires('impact.entity','impact.timer','com.purelymental.missingpiece.entities.particle','plugins.midas.draw').defines(function(){EntityParticleemitter=ig.Entity.extend({size:{x:50,y:50},gravityFactor:0,camera:null,particles:[],init:function(x,y,settings){this.timer=new ig.Timer();this.timer.set(0.2);this.parent(x,y,settings);},update:function(){this.parent();for(var i=this.particles.length-1;i>=0;i--){if(this.particles[i].isDead){this.particles.splice(i,1);}}},spawn:function(amount){if(this.particles.length+amount<100){for(var i=0;i<amount;i++){this.spawnSingle();}}else{for(var i=0;i<Math.max(0,amount-this.particles.length);i++){this.spawnSingle();}}},spawnSingle:function(){var particlePos={x:Math.floor(Math.random()*this.size.x)+this.pos.x,y:Math.floor(Math.random()*this.size.y)+this.pos.y};this.particles.push(ig.game.spawnEntity(EntityParticle,particlePos.x,particlePos.y));},draw:function(){this.parent();}});});
  322. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/imageasset.js
  323. ig.baked=true;ig.module('plugins.midas.imageasset').requires('impact.image').defines(function(){ImageAsset=ig.Image.extend({asyncLoaded:false,init:function(asyncImage){if(asyncImage){this.data=asyncImage;this.width=asyncImage.width;this.height=asyncImage.height;this.loaded=true;this.asyncLoaded=true;if(ig.system.scale!=1){this.resize(ig.system.scale);}}}});});
  324. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/plugins/midas/imageloader.js
  325. ig.baked=true;ig.module('plugins.midas.imageloader').requires('impact.impact','plugins.midas.imageasset','plugins.midas.ajaxpromise').defines(function(){PluginImageLoader=ig.Class.extend({getImage:function(path){var promise=new PluginAjaxPromise();if(path==null||path==""){promise.reject();return promise;}
  326. var asyncImage=new Image();asyncImage.onload=function(event){promise.setResult(asyncImage);promise.resolve();};asyncImage.onerror=function(event){promise.setResult(asyncImage);promise.reject();};asyncImage.src=path;return promise;},loadImage:function(path,imageAsset){var promise=this.getImage(path);promise.done(function(result){imageAsset.init(result);});return promise;}});});
  327. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/com/purelymental/missingpiece/entities/background.js
  328. ig.baked=true;ig.module('com.purelymental.missingpiece.entities.background').requires('impact.entity','plugins.midas.draw','plugins.midas.ajax','plugins.midas.imageloader').defines(function(){EntityBackground=ig.Entity.extend({pos:{x:0,y:0},size:{x:800,y:400},backgroundCanvas:null,init:function(x,y,settings){this.parent(x,y,settings);this.backgroundCanvas=ig.global['backgroundBuilder'].getRandomBackground();},update:function(){this.parent();},draw:function(){ig.system.context.drawImage(this.backgroundCanvas,0,0,this.size.x,this.size.y,0,50,this.size.x,this.size.y);this.parent();}});});
  329. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/com/purelymental/missingpiece/game.js
  330. ig.baked=true;ig.module('com.purelymental.missingpiece.game').requires('impact.game','impact.sound','com.purelymental.missingpiece.entities.piece','com.purelymental.missingpiece.entities.particleemitter','com.purelymental.missingpiece.entities.background','plugins.midas.draw','plugins.midas.arrayutils','plugins.midas.imageloader').defines(function(){MissingPiece=ig.Game.extend({background:null,correctPosition:{x:0,y:0},correctOneClicked:false,correctTimer:new ig.Timer(),particleEmitter:null,clearColor:"#000000",friendImages:[],incorrectCount:0,correctSound:new ig.Sound(pmGameData.assetPath+"common/correct.*"),incorrectSound:new ig.Sound(pmGameData.assetPath+"common/incorrect.*"),init:function(x,y,settings){this.background=ig.game.spawnEntity(EntityBackground);ig.input.bind(ig.KEY.MOUSE1,'click');var centerX=ig.system.width/2;var piecePositions=[{x:centerX-75,y:450},{x:centerX-275,y:450},{x:centerX+125,y:450}];this.correctPosition=this.getRandomLegitPosition();var correctSet=false;for(var i=0;i<3;i++){var newPosition=piecePositions.splice(Math.floor(Math.random()*piecePositions.length),1)[0];if(!correctSet){this.spawnEntity(EntityPiece,newPosition.x,newPosition.y,{piecePosition:this.correctPosition,isCorrect:true});correctSet=true;}else{var randomTilePosition=null;var randomPosition=null;while(randomTilePosition==null||randomTilePosition==this.getTileFromPosition(this.correctPosition)){randomPosition=this.getRandomLegitPosition();randomTilePosition=this.getTileFromPosition(randomPosition);}
  331. this.spawnEntity(EntityPiece,newPosition.x,newPosition.y,{piecePosition:randomPosition,isCorrect:false});}}
  332. this.particleEmitter=this.spawnEntity(EntityParticleemitter,this.correctPosition.x*50+50,this.correctPosition.y*50+100,{});ig.global['headerui'].startStopwatch();},update:function(){ig.global['headerui'].update();document.body.style.cursor="default";this.parent();if(this.correctOneClicked){ig.global['headerui'].pauseStopwatch();if(this.correctTimer.delta()>0.1){if(this.getEntitiesByType(EntityParticle)<=0){ig.global['headerui'].activateNextPip();ig.global['gameData'].rounds.push({incorrect:this.incorrectCount,duration:ig.global['headerui'].getClock()});if(ig.global['paramData'].screens.length==0){ig.global["wrapperState"]="ending";ig.system.setGame(GameWrapper);}else{ig.system.setGame(MissingPiece);}}}else{this.particleEmitter.spawn(3);}}},draw:function(){this.parent();ig.global['headerui'].draw();},getRandomLegitPosition:function(){var randomPos={x:0,y:0};randomPos.x=Math.floor(Math.random()*13);randomPos.y=Math.floor(Math.random()*6);return randomPos;},getTileFromPosition:function(position){return(position.y*16)+position.x;},pieceClicked:function(position){if(position.x==this.correctPosition.x&&position.y==this.correctPosition.y){this.correctOneClicked=true;this.correctTimer.set(0);this.correctSound.play();return true;}
  333. this.incorrectCount++;this.incorrectSound.play();return false;}});});
  334. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/com/purelymental/missingpiece/backgroundbuilder.js
  335. ig.baked=true;ig.module('com.purelymental.missingpiece.backgroundbuilder').requires('impact.entity','plugins.midas.draw','plugins.midas.arrayutils').defines(function(){BackgroundBuilder=ig.Class.extend({imagesRequested:30,friendImages:[],customCanvas:null,customContext:null,imagesLoaded:0,backgrounds:[new ig.Image('missingpiece/image1.png'),new ig.Image('missingpiece/image2.png'),new ig.Image('missingpiece/image3.png'),new ig.Image('missingpiece/image4.png'),new ig.Image('missingpiece/image5.png'),new ig.Image('missingpiece/image6.png'),new ig.Image('missingpiece/image7.png'),new ig.Image('missingpiece/image8.png'),new ig.Image('missingpiece/image9.png'),new ig.Image('missingpiece/image10.png'),new ig.Image('missingpiece/image11.png')],beginLoading:function(){this.friendImages=[];var self=this;var imageLoader=new PluginImageLoader();var picturePromise=ig.ajax.getJson('/api/facebook/friendphotos/'+this.imagesRequested);picturePromise.done(function(result){self.imagesLoaded=0;var iconsData=result.icons;if(iconsData.length>0){for(var i=0;i<iconsData.length;i++){var friendData=iconsData[i];var currentImageData={image:new ImageAsset(),pos:{x:0,y:0}};self.friendImages.push(currentImageData);imageLoader.loadImage(friendData.icon,currentImageData.image);}}});},getLoadedFriendImages:function(){var loadedFriendImages=[];for(var i=0;i<this.friendImages.length;i++){if(this.friendImages[i].image.asyncLoaded){loadedFriendImages.push(this.friendImages[i]);}}
  336. return loadedFriendImages;},getRandomBackground:function(){var screenToShow=ig.global['paramData'].screens.shift();this.customCanvas=ig.$new('canvas');this.customCanvas.width=ig.system.width;this.customCanvas.height=ig.system.height;this.customContext=this.customCanvas.getContext('2d');var loadedFriendImages=this.getLoadedFriendImages();if(loadedFriendImages.length>=20){this.buildMasonImages(loadedFriendImages,this.customContext);}else{var backgroundImage=this.backgrounds[screenToShow];this.customContext.drawImage(backgroundImage.data,0,0);}
  337. return this.customCanvas;},buildMasonImages:function(images,context){var colWidth=180;var columnPointer=0;var boardHeight=800;var curColumn=[];images=ig.arrayUtils.shuffle(images);images=images.slice(images.length-20);for(var i=0;i<images.length;i++){var friendImage=images[i];var columnHeight=this.getColumnHeight(curColumn);if(columnHeight+friendImage.image.height<=boardHeight){friendImage.pos.y=columnHeight;friendImage.pos.x=columnPointer;curColumn.push(friendImage);}else{curColumn=[];columnPointer+=colWidth;friendImage.pos.y=0;friendImage.pos.x=columnPointer;curColumn.push(friendImage);}}
  338. for(var i=0;i<images.length;i++){var friendImage=images[i];context.drawImage(friendImage.image.data,friendImage.pos.x,friendImage.pos.y);}},getColumnHeight:function(columnArray){var columnHeight=0;for(var j=0;j<columnArray.length;j++){columnHeight+=columnArray[j].image.height;}
  339. return columnHeight;}});});
  340. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/com/purelymental/missingpiece/gamewrapper.js
  341. ig.baked=true;ig.module('com.purelymental.missingpiece.gamewrapper').requires('impact.game','plugins.midas.ajax','launcher.endgame','com.purelymental.missingpiece.game','com.purelymental.missingpiece.backgroundbuilder').defines(function(){GameWrapper=ig.Game.extend({clearColor:pmGameData.backgroundColor,init:function(){if(ig.global["wrapperState"]=="starting"){this.start();ig.global["wrapperState"]="started";}
  342. if(ig.global["wrapperState"]=="ending"){this.end();ig.global["wrapperState"]="ended";}
  343. ig.global['backgroundBuilder']=new BackgroundBuilder();},update:function(){this.parent();},draw:function(){this.parent();},start:function(){ig.global['gameData']={};var gameDataPromise=ig.ajax.postJson("/api/games/"+pmGameData.id+"/start.json",{});gameDataPromise.done(function(result){ig.global['paramData']=result.paramData;});gameDataPromise.fail(function(){ig.global['paramData']={screens:[4,5,6,7],shapes:[0]};});gameDataPromise.always(function(){ig.global['gameData'].rounds=[];ig.global['headerui'].enableLife();ig.global['headerui'].setPips(0,ig.global['paramData'].screens.length);ig.global['headerui'].enableStopwatch();ig.global['backgroundBuilder'].beginLoading();ig.system.setGame(MissingPiece);pmGameData.start();});},end:function(){var gameFinishPromise=ig.ajax.postJson("/api/games/"+pmGameData.id+"/finish.json",ig.global['gameData']);gameFinishPromise.done(function(result){ig.global['score']=result.score;ig.global['nextGame']=result.nextScreenData;});gameFinishPromise.fail(function(){ig.global['score']=1337;ig.global['nextGame']={type:"playAgain",url:null,gameIconIndex:pmGameData.gameIconIndex,id:pmGameData.id};});gameFinishPromise.always(function(){ig.system.setGame(EndGame);pmGameData.finish();});}});});
  344. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/com/purelymental/missingpiece/howtoplay.js
  345. ig.baked=true;ig.module('com.purelymental.missingpiece.howtoplay').requires('impact.game','impact.font','impact.sound','plugins.midas.button').defines(function(){HowToPlay=ig.Game.extend({font:new ig.Font(pmGameData.assetPath+'common/proxima-extrabold-30-white.font.png'),clearColor:pmGameData.backgroundColor,buttonClick:new ig.Sound(pmGameData.assetPath+'common/button-click.*'),init:function(){ig.game.spawnEntity(EntityButton,650,450,{size:{x:128,y:128},animSheet:new ig.AnimationSheet(pmGameData.assetPath+'common/backbutton.png',128,128),onRelease:function(){ig.game.buttonClick.play();ig.system.setGame(MainMenu);}});},update:function(){this.parent();},draw:function(){this.parent();this.font.draw("Missing Piece is a game of\nquick pattern recognition.\n\nThe picture up top will have a piece removed.\nClick the piece down below that would\ncorrectly complete the picture.\n\nFinish all of the pictures to complete the game!",50,50,ig.Font.ALIGN.LEFT);}});});
  346. // /home/jgilman/git/purelymental-games/tools/../launcher/lib/launcher/mainmenu.js
  347. ig.baked=true;ig.module('launcher.mainmenu').requires('impact.game','impact.font','impact.sound','launcher.ui.header','launcher.ui.credits','plugins.midas.button','plugins.midas.browserinfo','com.purelymental.'+pmGameData.includePath+'.gamewrapper','com.purelymental.'+pmGameData.includePath+'.howtoplay').defines(function(){MainMenu=ig.Game.extend({font:new ig.Font(pmGameData.assetPath+'common/proxima-extrabold-30-white.font.png'),gameIcon:new ig.AnimationSheet(pmGameData.gameIcon,108,108),clearColor:pmGameData.backgroundColor,gameIconAnimation:null,buttonClick:new ig.Sound(pmGameData.assetPath+'common/button-click.*'),init:function(){this.gameIconAnimation=new ig.Animation(this.gameIcon,1,[pmGameData.gameIconIndex]);ig.global['score']=0;ig.global['gameData']={};document.body.style.cursor="default";ig.global['headerui']=new HeaderUI();ig.input.bind(ig.KEY.MOUSE1,'click');var x=ig.system.width/2,y=ig.system.height/2;ig.game.spawnEntity(EntityButton,x+24,y+150,{size:{x:190,y:48},animSheet:new ig.AnimationSheet(pmGameData.assetPath+'common/btnstartgame.png',190,48),onRelease:function(){ig.game.buttonClick.play();ig.global["wrapperState"]="starting";ig.system.setGame(GameWrapper);}});ig.game.spawnEntity(EntityButton,x-214,y+150,{size:{x:190,y:48},animSheet:new ig.AnimationSheet(pmGameData.assetPath+'common/btnhowtoplay.png',190,48),onRelease:function(){ig.game.buttonClick.play();ig.system.setGame(HowToPlay);}});ig.game.spawnEntity(CreditsButton,4,580,{size:{x:16,y:16},animSheet:new ig.AnimationSheet('common/credits.png',16,16),onRelease:function(){ig.game.buttonClick.play();ig.system.setGame(Credits);}});},update:function(){this.parent();ig.global['headerui'].update();},draw:function(){this.parent();var x=ig.system.width/2,y=ig.system.height/2;this.gameIconAnimation.draw(x-54,y-54);this.font.draw(pmGameData.displayName,x,y-150,ig.Font.ALIGN.CENTER);ig.global['headerui'].draw();}});var browsers=[{name:"Safari",version:6}];ig.ua.safari=/safari/i.test(navigator.userAgent);if(ig.ua.mobile||ig.browserInfo.shouldBlock(browsers)){ig.Sound.enabled=false;}
  348. ig.main('#canvas',MainMenu,60,800,600);});