From c09369e7a5b999f5b77c017743ddaa1658b922b2 Mon Sep 17 00:00:00 2001 From: Sky Date: Tue, 23 May 2023 15:26:59 -0400 Subject: [PATCH] bookmarklets --- bookmarklets.html | 4 + changelog.html | 2 +- js/katamari.js | 1 + js/kickass.js | 263 ---------------------------------------------- 4 files changed, 6 insertions(+), 264 deletions(-) create mode 100644 js/katamari.js delete mode 100644 js/kickass.js diff --git a/bookmarklets.html b/bookmarklets.html index f9bd50e5..f77316cb 100644 --- a/bookmarklets.html +++ b/bookmarklets.html @@ -37,6 +37,10 @@

Drag the link above to your bookmarks bar. This adds a piano to the page.

Developer Console

Drag the link above to your bookmarks bar. This adds all features of the developer console to whatever page your on.

+ Asteroids +

Drag the link above to your bookmarks bar. This allows you to play Asteroids on the website you are on, destroying everything.

+ Katamari +

Drag the link above to your bookmarks bar. This allows you to collect the words on the page into a ball. Fun game, I recommend playing it.

Tab Cloaks

The Ultimate Tab Cloak diff --git a/changelog.html b/changelog.html index e3ac89ef..2a71f285 100644 --- a/changelog.html +++ b/changelog.html @@ -20,7 +20,7 @@

e-gamepass

v. 2023.05.22

-

Major update?!
Added saves
Complete backend remake
Fixed flash pages to make them full screen automatically
Added 2 games (game1 and game2)

+

Major update?!
Added saves
Complete backend remake
Fixed flash pages to make them full screen automatically
Added 2 games (Cell Machine and Death Run 3D)
Added more bookmarklets
Tetris Update!

diff --git a/js/katamari.js b/js/katamari.js new file mode 100644 index 00000000..24d85054 --- /dev/null +++ b/js/katamari.js @@ -0,0 +1 @@ +var BORDER_STYLE="1px solid #bbb",CSS_TRANSFORM=null,CSS_TRANSFORM_ORIGIN=null,POSSIBLE_TRANSFORM_PREFIXES=["-webkit-","-moz-","-o-","-ms-",""],khFirst=!1;function getCssTransform(){var t,e,o=document.createElement("div");for(t=0;t0){e.push(o);return}if(o.childNodes&&!o.khIgnore)for(l=0,n=i(o),r=o.childNodes.length;l0&&0===s[0].length&&s.shift(),o=0;o0&&((i=document.createElement("span")).innerHTML=r[o],l.insertBefore(i,e),n(i)),o0&&(i=document.createTextNode(s[o]),l.insertBefore(i,e));l.removeChild(e)})},this.addTagNames=function(t,e){var o,i,l,r,s=t.tagName&&t.tagName.toLowerCase();if(!t.khIgnore){if(-1!==e.indexOf(s)&&n(t),t.getElementsByTagName)for(o=0;oT())&&(l=(o=getClosestPoint(s,a,e=t))[0]-s,c=Math.sqrt(l*l+(r=o[1]-a)*r),d=0-S,f=o[0]-e.left,h=o[1]-e.top,g=c*Math.cos(p=Math.atan2(r,l)-S),_=c*Math.sin(p),b=e.el.cloneNode(!0),m=jQuery(e.el),y={el:b,attX:g,attY:_,attT:"translate("+Math.round(g)+"px,"+Math.round(_)+"px) rotate("+d+"rad)",r:c,offTh:p,offPhi:0-x,diag:e.diag,removeR:c+e.diag,visible:!1,display:m.css("display")},u.push(y),E=e,$=Math.pow(3*(T()+gridObjVol(E)*v)/(4*Math.PI),1/3),b.style.position="absolute",b.style.left=-f+"px",b.style.top=-h+"px",b.style.setProperty(CSS_TRANSFORM_ORIGIN,f+"px "+h+"px",null),b.style.display="none",b.style.color=m.css("color"),b.style.textDecoration=m.css("text-decoration"),b.style.fontSize=m.css("font-size"),b.style.fontWeight=m.css("font-weight"),b.khIgnore=!0,i.appendChild(b),n&&n.play_pop(),!0)}function I(t){var e=S+t.offTh,o=x+t.offPhi,n=t.r*Math.cos(e),i=t.r*Math.sin(e),l=t.r*Math.cos(S-t.offTh+Math.PI)-n,r=t.r*Math.sin(S-t.offTh+Math.PI)-i,c=(-Math.cos(o)+1)/2,d=n+c*l,f=i+c*r,h=t.r*Math.sin(o);return h<0&&Math.sqrt(d*d+f*f)+t.diag<$?(t.visible&&(t.visible=!1,t.el.style.display="none"),!1):(t.visible||(t.visible=!0,t.el.style.display=t.display),t.el.style.zIndex=h>0?501:499,t.el.style.setProperty(CSS_TRANSFORM,"translate("+s+"px,"+a+"px) rotate("+S+"rad) scaleX("+Math.cos(o)+") "+t.attT,null),!0)}function P(t){i.removeChild(t.el),delete t.el}this.init=function(){(l=document.createElement("canvas")).width=2*$,l.height=2*$,l.style.cssText="position: absolute; z-index: 500;",t.appendChild(l),r=l.getContext("2d"),i=document.createElement("div"),t.appendChild(i)},this.setRadius=function(t){$=t},this.getState=function(){return{x:s,y:a,vx:c,vy:d,radius:$,th:S,phi:x}},this.setState=function(t){s=t.x,a=t.y,c=t.vx,d=t.vy,$=t.radius,S=t.th,x=t.phi},this.setXY=function(t,e){s=t,a=e},this.setTh=function(t){S=t},this.setPhi=function(t){x=t},this.setColor=function(t){g=t},this.setDocSize=function(t,e){h=t,p=e},this.setAccel=function(t){m=t},this.setAccelTarget=function(t,e){_=t,b=e},this.updatePhysics=function(){var t,o,i,l=s,r=a,f=!1;m?(c+=.5*Math.cos(i=Math.atan2(b-a,_-s)),d+=.5*Math.sin(i)):(c*=.95,d*=.95),s+=c,a+=d,s-$<0?(f=!0,s=$+1,c=-c):s+$>h&&(f=!0,s=h-$-1,c=-c),a-$<0?(f=!0,a=$+1,d=-d):a+$>p&&(f=!0,a=p-$-1,d=-d),(0!==c||0!==d)&&(S=Math.atan2(d,c),x-=Math.sqrt((t=s-l)*t+(o=a-r)*o)/$),e.removeIntersecting(s,a,$,E),this.draw(),f&&n&&n.play_bounce()},this.draw=function(){var t,e,o=0;for(!function t(){var e,o,n,i,c,d,h,p,u,_,b;for(l.style.left=s-$+"px",l.style.top=a-$+"px",$!=f&&(l.width=2*$+1,l.height=2*$+1,f=$),r.clearRect(0,0,2*$,2*$),r.fillStyle="#fff",r.beginPath(),r.arc($,$,$-1,0,2*Math.PI,!0),r.fill(),r.strokeStyle=g,r.beginPath(),r.arc($,$,$-1,0,2*Math.PI,!0),r.stroke(),r.fillStyle=g,e=$+$*Math.cos(S+Math.PI/16),o=$+$*Math.sin(S+Math.PI/16),n=$+$*Math.cos(S-Math.PI/16),i=$+$*Math.sin(S-Math.PI/16),c=$+$*Math.cos(S+15*Math.PI/16)-e,d=$+$*Math.sin(S+15*Math.PI/16)-o,h=0;h<2*Math.PI;h+=Math.PI/7)p=(-Math.cos(x+h)+1)/2,u=(-Math.cos(x+h+Math.PI/32)+1)/2,_=Math.sin(x+h),b=Math.sin(x+h+Math.PI/32),_>0&&b>0&&(r.beginPath(),r.moveTo(e+p*c,o+p*d),r.lineTo(e+u*c,o+u*d),r.lineTo(n+u*c,i+u*d),r.lineTo(n+p*c,i+p*d),r.fill())}(),t=u.length;--t>=0;)if((e=u[t]).removeR<$)u.splice(t,1).map(P);else if(I(e)&&++o>y){u.splice(0,t).map(P);break}}}function preventDefault(t){return t.preventDefault(),t.returnValue=!1,!1}function Game(t,e,o){var e,n,i,l;function r(){n.setDocSize(jQuery(document).width()-5,jQuery(document).height()-5)}(n=new PlayerBall(t,e,o,!1)).init(),n.setXY(300,300),window.scrollTo(0,200),r(),document.addEventListener("touchstart",function(t){if(1===t.touches.length)return n.setAccel(!0),preventDefault(t)},!0),document.addEventListener("touchmove",function(t){n.setAccelTarget(t.touches[0].pageX,t.touches[0].pageY)},!0),document.addEventListener("touchend",function(t){if(0===t.touches.length)return n.setAccel(!1),preventDefault(t)},!0),-5!==o.MOUSEB&&(document.addEventListener("mousemove",function(t){n.setAccelTarget(t.pageX,t.pageY)},!0),document.addEventListener("mousedown",function(t){if(t.button===o.MOUSEB)return n.setAccel(!0),preventDefault(t)},!0),document.addEventListener("mouseup",function(t){if(t.button===o.MOUSEB)return n.setAccel(!1),preventDefault(t)},!0),0===o.MOUSEB?document.addEventListener("click",function(t){if(0===t.button)return preventDefault(t)},!0):2===o.MOUSEB&&document.addEventListener("contextmenu",preventDefault,!0)),i=setInterval(function(){n.updatePhysics()},25),l=setInterval(r,1e3)}function whenAllLoaded(t,e,o){o.finalize(jQuery(document).width(),jQuery(document).height()),jQuery("#loadingp").empty(),jQuery("").click(function(){var n,i,l;jQuery("#bgmusicc").attr("checked")&&((i=document.getElementById("khbgmusic"))||((i=document.createElement("audio")).id="khbgmusic",i.loop="loop",i.src="http://kathack.com/js/katamari.mp3",t.appendChild(i)),i.play()),l={color:jQuery("#khcolor").val(),VOL_MULT:parseFloat(jQuery("#vol_mult").val()),MAX_ATTACHED_VISIBLE:parseInt(jQuery("#maxAtt").val(),10),CHECK_VOLS:!!jQuery("#checkv").attr("checked"),MOUSEB:parseInt(jQuery("#mouseb").val(),10)},t.removeChild(e),n=new Game(t,o,l)}).appendTo("#loadingp")}function buildPopup(t){var e=document.createElement("div");return e.style.cssText="position: fixed;left: 50%;top: 50%;width: 400px;margin-left:-200px;margin-top:-150px;border:1px solid black;background-color:white;color:black;padding:20px;font-size:13px;text-align:left;z-index:501;",e.innerHTML='

Katamari!

Controls: Hold down to control the ball!




Loading!

',t.appendChild(e),e.getElementsByTagName("button")[0].addEventListener("click",function(){t.removeChild(e)},!0),e}function main(){var t,e,o;(t=document.createElement("div")).khIgnore=!0,document.body.appendChild(t),o=buildPopup(t),setTimeout(function(){var n,i,l;for(window.khNodes.addWords(document.body),n=0,i=document.body.childNodes.length;n Rootof Creations HB, rootof.com, kickassapp.com -*/(function(window) { -var JSONP=(function(){var counter=0,head,query,key,window=this;function load(url){var script=document.createElement('script'),done=false;script.src=url;script.async=true;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){done=true;script.onload=script.onreadystatechange=null;if(script&&script.parentNode){script.parentNode.removeChild(script);}}};if(!head){head=document.getElementsByTagName('head')[0];if(!head) -head=document.body;} -head.appendChild(script);} -function jsonp(url,params,callback){query="?";params=params||{};for(key in params){if(params.hasOwnProperty(key)){query+=encodeURIComponent(key)+"="+encodeURIComponent(params[key])+"&";}} -var jsonp="json"+(++counter);window[jsonp]=function(data){callback(data);try{delete window[jsonp];}catch(e){} -window[jsonp]=null;};load(url+query+"callback="+jsonp);return jsonp;} -return{get:jsonp};}());var CORS={request:function(url,params,callback){if(this.calledByExtension()){this._callbacks[this._callbackId++]=callback;window.postMessage(JSON.stringify({from:"kickassapp-page",url:url,type:"callApi",params:params}),"*");return;} -params=params||{};var query="?";for(key in params){if(params.hasOwnProperty(key)){query+=encodeURIComponent(key)+"="+encodeURIComponent(params[key])+"&";}} -var xhr=new XMLHttpRequest();xhr.onreadystatechange=function(){if(xhr.readyState==4){callback(JSON.parse(xhr.responseText));}} -xhr.open("GET",url+query);xhr.withCredentials=true;xhr.setRequestHeader("Content-Type","application/json");xhr.send();},calledByExtension:function(){return!!document.getElementById("kickass-has-been-initialized-yes-yes-yes");},_callbacks:{},_callbackId:0} -if(CORS.calledByExtension()){window.addEventListener("message",function(e){var messageData;try{messageData=JSON.parse(e.data);}catch(e){return;} -if(messageData.from==="kickassapp-extension"&&messageData.sanityCheck==="kickassapp-extension-version1"){var message=messageData.payload;if(message.type==="response"){CORS._callbacks[message.requestId](message.body);delete CORS._callbacks[message.requestId];}else if(message.type==="destroy"){window.KICKASSGAME.destroy();}}},false);}function getGlobalNamespace(){return window&&window.INSTALL_SCOPE?window.INSTALL_SCOPE:window;} -var Class=function(methods){var ret=function(){if(ret.$prototyping)return this;if(typeof this.initialize=='function') -return this.initialize.apply(this,arguments);};if(methods.Extends){ret.parent=methods.Extends;methods.Extends.$prototyping=true;ret.prototype=new methods.Extends;methods.Extends.$prototyping=false;} -for(var key in methods)if(methods.hasOwnProperty(key)) -ret.prototype[key]=methods[key];return ret;};if(typeof exports!='undefined')exports.Class=Class;var Vector=new Class({initialize:function(x,y){if(typeof x=='object'){this.x=x.x;this.y=x.y;}else{this.x=x;this.y=y;}},cp:function(){return new Vector(this.x,this.y);},mul:function(factor){this.x*=factor;this.y*=factor;return this;},mulNew:function(factor){return new Vector(this.x*factor,this.y*factor);},div:function(factor){this.x/=factor;this.y/=factor;return this;},divNew:function(factor){return new Vector(this.x/factor,this.y/factor);},add:function(vec){this.x+=vec.x;this.y+=vec.y;return this;},addNew:function(vec){return new Vector(this.x+vec.x,this.y+vec.y);},sub:function(vec){this.x-=vec.x;this.y-=vec.y;return this;},subNew:function(vec){return new Vector(this.x-vec.x,this.y-vec.y);},rotate:function(angle){var x=this.x,y=this.y;this.x=x*Math.cos(angle)-Math.sin(angle)*y;this.y=x*Math.sin(angle)+Math.cos(angle)*y;return this;},rotateNew:function(angle){return this.cp().rotate(angle);},setAngle:function(angle){var l=this.len();this.x=Math.cos(angle)*l;this.y=Math.sin(angle)*l;return this;},setAngleNew:function(angle){return this.cp().setAngle(angle);},setLength:function(length){var l=this.len();if(l)this.mul(length/l);else this.x=this.y=length;return this;},setLengthNew:function(length){return this.cp().setLength(length);},normalize:function(){var l=this.len();if(l==0) -return this;this.x/=l;this.y/=l;return this;},normalizeNew:function(){return this.cp().normalize();},angle:function(){return Math.atan2(this.y,this.x);},collidesWith:function(rect){return this.x>rect.x&&this.y>rect.y&&this.x-0.005)return 0;return l;},is:function(test){return typeof test=='object'&&this.x==test.x&&this.y==test.y;},dot:function(v2){return this.x*v2.x+this.y*v2.y;},inTriangle:function(a,b,c){var v0=c.subNew(a);var v1=b.subNew(a);var v2=p.subNew(a);var dot00=v0.dot(v0);var dot01=v0.dot(v1);var dot02=v0.dot(v2);var dot11=v1.dot(v1);var dot12=v1.dot(v2);var invDenom=1/(dot00*dot11-dot01*dot01);var u=(dot11*dot02-dot01*dot12)*invDenom;var v=(dot00*dot12-dot01*dot02)*invDenom;return(u>0)&&(v>0)&&(u+v<1);},distanceFrom:function(vec){return Math.sqrt(Math.pow((this.x-vec.x),2),Math.pow(this.y-vec.y,2));},toString:function(){return'[Vector('+this.x+', '+this.y+') angle: '+this.angle()+', length: '+this.len()+']';}});if(typeof exports!='undefined')exports.Vector=Vector; -var Rect=new Class({initialize:function(x,y,w,h){this.pos=new Vector(x,y);this.size={width:w,height:h};},hasPoint:function(point){return point.x>this.getLeft()&&point.xthis.getTop()&&point.ytween.duration){this.tweenFinished(tween,key);continue;} -var delta=tween.transition(tdelta/tween.duration);var changes=[];for(var i=0,t;t=tween.tweens[i];i++){var x=delta*(t[1]-t[0])+t[0];changes.push(x);} -this.fire(key,changes,delta);}},tweenStart:function(key,time){this.running[key]={startTime:time};var values=[];for(var i=0,tween;tween=this.tweens[key].tweens[i];i++) -values.push(tween[0]);this.fire(key,values,0);},tweenFinished:function(tween,key){var values=[];for(var i=0,t;t=tween.tweens[i];i++) -values.push(t[1]);this.fire(key,values,1);if(!tween.repeats){delete this.running[key];delete this.tweens[key];return;} -this.tweenStart(key,now());},fire:function(key,values,delta){for(var i=0,listener;listener=this.listeners[i];i++) -listener.set.call(listener,key,values,delta);}});var Tween={Linear:function(x){return x;},Quadratic:function(x){return x*x;},Quintic:function(x){return x*x*x;},Shake:function(x){return Math.sin(x);}}; -var GameGlobals={FPS:60,useAnimationFrame:false,boids:{flockRadius:400,size:100},path:function(){return"https://kickassapp.com/"+Array.prototype.slice.call(arguments).join("");},hasCanvas:(typeof document.createElement('canvas').getContext!=='undefined'),bulletColor:'black'};window.GameGlobals=GameGlobals; -if(!Array.prototype.indexOf){Array.prototype.indexOf=function(searchElement){if(this===void 0||this===null) -throw new TypeError();var t=Object(this);var len=t.length>>>0;if(len===0) -return-1;var n=0;if(arguments.length>0){n=Number(arguments[1]);if(n!==n) -n=0;else if(n!==0&&n!==(1/0)&&n!==-(1/0)) -n=(n>0||-1)*Math.floor(Math.abs(n));} -if(n>=len) -return-1;var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;k"+ship.name+"!!");} -for(var i=0,player;player=this.players[i];i++){player.setShip(ship);}},changeWeapon:function(weapon,isInitial){this.weaponClass=weapon.cannonClass;if(!isInitial){this.ui.showMessage("Changed to "+weapon.name.toUpperCase()+"!!!!");} -for(var i=0,player;player=this.players[i];i++){player.setCannons(weapon.cannonClass);}},changeWeaponById:function(id,isInitial){if(Weapons[id]){this.changeWeapon(Weapons[id],isInitial);}},flyOutPlayers:function(x,y){for(var i=0,player;player=this.players[i];i++){player.flyTo(x,-player.size.height);player.isBound=false;}},flyInPlayers:function(){for(var i=0,player;player=this.players[i];i++){player.flyTo(player.pos.x,100,function(){this.isBound=true;});}},newRank:function(rank){this.ui.showMessage("OMG. You leveled up to: "+rank+'!
Be sure to check what cool new stuff you get in the menu.');},fireBomb:function(){this.bombManager.blow();},destroy:function(){removeEvent(document,'keydown',this.keydownEvent);removeEvent(document,'keypress',this.keydownEvent);removeEvent(document,'keyup',this.keyupEvent);for(var i=0,player;player=this.players[i];i++){player.destroy();} -this.bulletManager.destroy();this.explosionManager.destroy();this.menuManager.destroy();if(!GameGlobals.useAnimationFrame){clearInterval(this.loopTimer);} -getGlobalNamespace().KICKASSGAME=false;if(this.isCampaign()){document.location.reload();}},isCampaign:function(){return getGlobalNamespace().IS_CLOUDFLARE_GAME;},isMySite:function(){return!!getGlobalNamespace().KICKASS_SITE_KEY;},shouldShowAd:function(){return!this.mySite&&!this.isCampaign();},shouldShowMenu:function(){return!this.mySite&&!this.isCampaign();},shouldShowHowToImage:function(){return this.mySite||this.isCampaign();}});window.KickAss=KickAss; -var StatisticsManager=new Class({initialize:function(game){this.game=game;this.data={};this.data.startedPlaying=now();this.data.elementsDestroyed=0;this.data.shotsFired=0;this.data.distanceFlownInPixels=0;this.data.totalPointsThisSession=0;this.data.usedThrusters=0;this.lastUpdate=0;},usedThrusters:function(){this.data.usedThrusters=1;},increaseDistanceWithPixels:function(px){this.data.distanceFlownInPixels+=px;},increasePointsGainedWithPoints:function(points){this.data.totalPointsThisSession+=points;},addShotFired:function(){this.data.shotsFired++;if(this.game.audioManager.shot){this.game.audioManager.shot.play();}},addElementsDestroyed:function(){this.data.elementsDestroyed++;},update:function(tdelta){this.lastUpdate+=tdelta;if(this.lastUpdate>0.25){this.syncWithServer();this.lastUpdate=0;}},syncWithServer:function(){var fragment=[];for(var key in this.data)if(this.data.hasOwnProperty(key)){fragment.push(key+':'+this.data[key]);} -this.game.menuManager.sendMessageToMenu("stats:!"+fragment.join('|'));}}); -var MySite=new Class({initialize:function(key){this.key=key;},load:function(callback){CORS.request(GameGlobals.path('mysite/api.json'),{site_key:this.key,url:document.location.toString()},bind(this,function(data){if(data&&data.embed){this.mySiteData=data.embed;callback(true);}else{callback(false);}}));},install:function(){},getShipId:function(){return this.mySiteData&&this.mySiteData.settings.ship;},getShipConfig:function(){return this.mySiteData&&this.mySiteData.settings.ship_config;},getShareURL:function(){return this.mySiteData&&this.mySiteData.settings.share_url;}}); -var Menu=new Class({initialize:function(game){this.game=game;this.size={height:300};},generate:function(parent){this.container=document.createElement('div');this.container.className='KICKASSELEMENT';this.container.id='kickass-profile-menu';parent.appendChild(this.container);var shipId=getGlobalNamespace().KICKASSSHIPID||"";this.url=GameGlobals.path('intermediate_postmessage.html?url='+ -encodeURIComponent(getGlobalNamespace().KICKASSURL||document.location.href)+"&origin="+encodeURIComponent(document.location.href)+"&preship="+(shipId)+"&is_campaign="+(this.game.isCampaign()?"true":"")+"&is_mysite="+(this.game.isMySite()?"true":""));this.isSocketReady=false;this.socketIframe=document.createElement("iframe");this.socketIframe.frameborder='0';this.socketIframe.className='KICKASSELEMENT';this.socketIframe.width='100%';this.socketIframe.height=this.size.height+'px';this.container.appendChild(this.socketIframe);this.menuOrigin="https://kickassapp.com/".replace(/\/$/,"");this.socketIframe.src=this.url;this.onMessage=bind(this,function(event){if(event.origin!==this.menuOrigin&&event.origin!==this.menuOrigin.replace("http://","https://")){console.log("ignoring event from",event.origin);return;} -var message=event.data;if(message==="ready"){this.onGameReady();return;} -var t=message.split(':!');if(t.length!==2){return;} -var type=t.shift().replace(/^./g,function(match){return match.charAt(0).toUpperCase();});if(typeof this['messageType'+type]==="function"){this['messageType'+type](t.join(":!"));}});window.addEventListener("message",this.onMessage,false);this.game.registerElement(this.container);},socketPostMessage:function(message){this.socketIframe.contentWindow.postMessage(message,this.menuOrigin);},onGameReady:function(){this.isSocketReady=true;this.game.registerElement(this.container.getElementsByTagName('iframe')[0]);this.socketPostMessage("url:!"+(getGlobalNamespace().KICKASSURL||document.location.href));if(this.game.statisticsManager){this.game.statisticsManager.syncWithServer();} -this.game.menuManager.onGameReady();},sendMessage:function(message){if(!this.isSocketReady){return;} -if(message!=this.lastMessage){try{this.socketPostMessage(message);}catch(e){} -this.lastMessage=message;}},messageTypeChangeShip:function(pieces){pieces=pieces.split(",");var shipId=pieces[0];var weaponId=pieces[1];var isInitial=pieces[2]==='initial';if(this.shipId===shipId){return;} -if(isInitial&&getGlobalNamespace().KICKASSSHIP){return;} -this.shipId=shipId;CORS.request(GameGlobals.path('designer/ship/'+shipId+'/construction.json'),{ship_id:shipId,is_initial:isInitial?'1':'0'},bind(this,function(data){this.game.updateShips(data.data,isInitial);try{window.focus();}catch(e){}}));if(!isInitial){this.parent.hideMenu();}},messageTypeChangeWeapon:function(weaponId,isInitial){this.game.changeWeaponById(weaponId,isInitial);},messageTypeSetMultiplier:function(mod){mod=parseInt(mod,10);if(isNaN(mod)||!mod){return;} -this.game.multiplier=mod;},messageTypeNewRank:function(rank){this.game.newRank(rank);},messageTypePlayerMessage:function(message){this.game.ui.showMessage(message);},destroy:function(){this.game.unregisterElement(this.container);this.game.unregisterElement(this.iframe);window.removeEventListener("message",this.onMessage,false);this.container.parentNode.removeChild(this.container);}}); -var MenuManager=new Class({initialize:function(game){this.game=game;this.numPoints=0;if(!getGlobalNamespace().KICKASS_INLINE_CSS){this.includeCSS(GameGlobals.path('css/menustyles.css'));}},generateDefaults:function(){for(var id in Weapons)if(Weapons.hasOwnProperty(id)){this.addWeapon(Weapons[id],id);} -this.hideBombMenu();},create:function(){this.container=document.createElement('div');this.container.className='KICKASSELEMENT KICKASShidden '+(this.game.shouldShowMenu()?"":"KICKASSNOMENU");this.container.id='kickass-menu';if(this.game.shouldShowMenu()){this.container.style.bottom='-250px';this.container.style.display='none';}else{removeClass(this.container,"KICKASShidden");} -getAppContainerElement().appendChild(this.container);var adHTML=this.game.shouldShowAd()?'':"";this.container.innerHTML='
'+'
'+ -adHTML+'
'+'
    '+'
'+'
'+''+'
'+'
'+ -this.numPoints+'
'+'
Press esc to quit
'+ -this.getShareHTML()+'
'+''+'
';this.pointsTab=document.getElementById('kickass-pointstab');this.pointsTabWrapper=document.getElementById('kickass-pointstab-wrapper');this.points=document.getElementById('kickass-points');this.escToQuit=document.getElementById('kickass-esctoquit');this.howToImage=document.getElementById('kickass-howto-image');this.weaponsMenu=document.getElementById('kickass-weapons-menu');this.weaponsList=document.getElementById('kickass-weapons-list');this.bombLink=document.getElementById('kickass-bomb-menu');this.submitScoreLink=document.getElementById('kickass-link-highscores');this.menuLink=document.getElementById('kickass-link-menu');this.switchShipLink=document.getElementById('kickass-link-ships');var all=this.container.getElementsByTagName('*');for(var i=0;i';}else{return'';}}else{var url='https://www.facebook.com/kickassapp';if(this.game.mySite){if(this.game.mySite.getShareURL()){url=this.game.mySite.getShareURL();}else{return"";}} -return'';}},onGameReady:function(){this.container.style.display='block';if(this.game.shouldShowHowToImage()){setTimeout(bind(this,function(){removeClass(this.howToImage,"kickass-howto-invisible");}),10);setTimeout(bind(this,function(){addClass(this.howToImage,"kickass-howto-invisible");}),4000);}},navigateTo:function(page,dontShowMenu){if(!dontShowMenu){this.showMenu();} -if(this.menu){this.menu.socketPostMessage('navigate:!'+page);}},toggleMenu:function(){if(this.game.shouldShowMenu()){if(hasClass(this.container,'KICKASShidden')){this.showMenu();}else{this.hideMenu();}}else{this.showMenu();}},toggleWeaponsMenu:function(){if(hasClass(this.weaponsMenu,'KICKASShidden')){this.showWeaponsMenu();}else{this.hideWeaponsMenu();}},hideWeaponsMenu:function(){this.weaponsMenu.style.width='';addClass(this.weaponsMenu,'KICKASShidden');},showWeaponsMenu:function(){var last=this.weaponsMenu.getElementsByTagName('li');last=last[last.length-1];this.weaponsMenu.style.width=(last.offsetLeft+last.offsetWidth-47)+'px';removeClass(this.weaponsMenu,'KICKASShidden');},showMenu:function(){if(this.game.shouldShowMenu()){this.container.style.bottom='';removeClass(this.container,'KICKASShidden');}},hideMenu:function(){this.container.style.bottom='';addClass(this.container,'KICKASShidden');},showBombMenu:function(){this.bombLink.style.width="";},hideBombMenu:function(){this.bombLink.style.width="0px";},getHeight:function(){return this.container.clientHeight;},isVisible:function(){return!hasClass(this.container,'KICKASShidden');},addPoints:function(killed,pos){var points=killed*this.game.multiplier;this.numPoints+=points;this.points.innerHTML=this.numPoints;if(this.game.statisticsManager){this.game.statisticsManager.increasePointsGainedWithPoints(points);} -this.game.ui.addPointsBubbleAt(pos,points);},includeCSS:function(file){var link=document.createElement('link');link.rel='stylesheet';link.type='text/css';link.href=file;(document.head||document.body).appendChild(link);},sendMessageToMenu:function(fragment){if(this.menu){this.menu.sendMessage(fragment);}},addWeapon:function(weapon,id){var li=document.createElement('li');li.className='KICKASSELEMENT kickass-weapon-item';li.weapon=weapon;li.style.backgroundImage='url('+GameGlobals.path('css/gfx/kickass/weap-'+weapon.id+'.png')+')';li.innerHTML=''+weapon.name+'';this.weaponsList.appendChild(li);addEvent(li,'click',bind(this,function(e){stopEvent(e);this.changeWeapon(weapon);this.sendMessageToMenu("changeWeapon:!"+id);}));},changeWeapon:function(weapon){this.game.changeWeapon(weapon);},destroy:function(){var all=this.container.getElementsByTagName('*');for(var i=0;i1000.0){this.isBroken=false;this.lineOffsets=[];this.randomPos();} -return;} -if(!this.tween){if(this.game.isKeyPressed('left')||this.game.isKeyPressed('right')){if(this.game.isKeyPressed('left')) -this.rotateLeft(tdelta);if(this.game.isKeyPressed('right')) -this.rotateRight(tdelta);}else{this.stopRotate();} -if(this.game.isKeyPressed('up')) -this.activateThrusters();else -this.stopThrusters();} -if(this.game.isKeyPressed(' ')){this.isShooting=true;if(!this.isBroken) -this.shootPressed();}else if(this.isShooting){this.isShooting=false;this.shootReleased();} -if(this.currentRotation) -this.dir.setAngle(this.dir.angle()+this.currentRotation*tdelta);var frictionedAcc=this.acc.mulNew(tdelta).sub(this.vel.mulNew(tdelta*this.friction));this.vel.add(frictionedAcc);if(this.vel.len()>this.terminalVelocity) -this.vel.setLength(this.terminalVelocity);var posDelta=this.vel.mulNew(tdelta);this.pos.add(posDelta);if(this.game.statisticsManager){this.game.statisticsManager.increaseDistanceWithPixels(posDelta.len());} -var showFlames=!this.acc.is({x:0,y:0});for(var i=0,thruster;thruster=this.thrusters[i];i++){thruster.setIsShown(showFlames);thruster.update(tdelta);} -if(this.isBound) -this.checkBounds();if(!this.lastPos.is(this.pos)||this.currentRotation||this.forceRedraw){this.forceRedraw=false;this.sheet.clear();this.sheet.setAngle(this.dir.angle()+Math.PI/2);this.sheet.setPosition(this.pos);if(showFlames){for(var i=0,thruster;thruster=this.thrusters[i];i++) -thruster.drawTo(this.sheet);} -this.sheet.drawPlayer(this.verts);this.lastPos=this.pos.cp();} -for(var i=0,cannon;cannon=this.cannons[i];i++){cannon.update(tdelta);}},randomPos:function(){var w=this.game.windowSize.width;var h=this.game.windowSize.height;this.pos=new Vector(random(0,w),random(0,h));},checkBounds:function(){if(this.tween) -return;var w=this.game.windowSize.width;var h=this.game.windowSize.height;var rightBound=this.pos.x+this.sheet.rect.size.width/2;var bottomBound=this.pos.y+this.sheet.rect.size.height/2;if(rightBound>w){window.scrollTo(this.game.scrollPos.x+50,this.game.scrollPos.y);this.pos.x=0;}else if(this.pos.x<0){window.scrollTo(this.game.scrollPos.x-50,this.game.scrollPos.y);this.pos.x=w-this.sheet.rect.size.width/2;} -if(bottomBound>h){window.scrollTo(this.game.scrollPos.x,this.game.scrollPos.y+h*0.75);this.pos.y=0;}else if(this.pos.y<0){window.scrollTo(this.game.scrollPos.x,this.game.scrollPos.y-h*0.75);this.pos.y=h-this.sheet.rect.size.height/2;}},inRect:function(rect){var ret=false;for(var i=0,vert;vert=this.verts[i];i++){if(rect.hasPoint(new Vector(vert.x+this.pos.x,vert.y+this.pos.y))) -ret=true;} -return ret;},hit:function(by){if(this.isBroken)return;this.isBroken=true;this.deadTime=now();},activateThrusters:function(){if(this.game.statisticsManager){this.game.statisticsManager.usedThrusters();} -this.acc=(new Vector(500,0)).setAngle(this.dir.angle());},stopThrusters:function(){this.acc=new Vector(0,0);},rotateLeft:function(tdelta){this.currentRotation=Math.max(-Math.PI*2,this.currentRotation-Math.PI*10*tdelta);},rotateRight:function(tdelta){this.currentRotation=Math.min(Math.PI*2,this.currentRotation+Math.PI*10*tdelta);},stopRotate:function(){this.currentRotation=0;},getSizeFromVertsAndObjects:function(){var largestDistance=0;for(var i=0,vert;vert=this.verts[i];i++) -largestDistance=Math.max(largestDistance,(new Vector(vert)).len());for(var i=0,obj;obj=this.thrusters[i];i++){var p1=(new Vector(obj.pos.x-obj.size.width/2,obj.pos.y-obj.size.height/2)).rotate(obj.angle);var p2=(new Vector(obj.pos.x+obj.size.width/2,obj.pos.y-obj.size.height/2)).rotate(obj.angle);var p3=(new Vector(obj.pos.x-obj.size.width/2,obj.pos.y+obj.size.height/2)).rotate(obj.angle);var p4=(new Vector(obj.pos.x+obj.size.width/2,obj.pos.y+obj.size.height/2)).rotate(obj.angle);largestDistance=Math.max(largestDistance,p1.len(),p2.len(),p3.len(),p4.len());} -return{width:largestDistance*2,height:largestDistance*2};},calculateBounds:function(){return{x:Math.max(this.size.width,this.size.height)*1,y:Math.max(this.size.height,this.size.width)*1};},shootPressed:function(){for(var i=0,cannon;cannon=this.cannons[i];i++) -cannon.shootPressed();},shootReleased:function(){for(var i=0,cannon;cannon=this.cannons[i];i++) -cannon.shootReleased();},flyTo:function(x,y,callback){this.tween={start:{pos:this.pos.cp(),dir:this.dir.cp()},to:new Vector(x,y),callback:callback||function(){}};this.tween.time=this.getTimeforTween();},destroy:function(){this.sheet.destroy();}});var Thruster=new Class({initialize:function(data,ship){this.pos=new Vector(data.p);this.size={width:data.s.w,height:data.s.h};this.angle=data.a||0;this.ship=ship;this.isShown=false;this.flameY=1;this.fx=new Fx();this.fx.addListener(this);this.flames={r:[],y:[]};this.lastFrameUpdate=0;this.generateFlames();},update:function(tdelta){this.fx.update();if(now()-this.lastFrameUpdate>1000/60) -this.generateFlames();},set:function(key,value){switch(key){case'flames':this.flameY=value;break;}},setIsShown:function(isShown){if(!this.isShown&&isShown){this.flameY=0.0;this.generateFlames();this.fx.add('flames',{start:this.flameY,end:1,duration:250,transition:Tween.Quintic});} -this.isShown=isShown;},drawTo:function(sheet){sheet.drawFlames(this.flames,this.angle);},generateFlames:function(){var redWidth=this.size.width,redIncrease=this.size.width*0.05,yellowWidth=this.size.width*0.8,yellowIncrease=yellowWidth*0.1,halfRed=redWidth/2,halfYellow=yellowWidth/2,offsetY=-this.size.height/2,metaY=0;var px=this.pos.x;var py=this.pos.y-this.size.height/2;function vec(x,y){return new Vector(x,y);} -this.flames.r=[vec(-halfRed+px,py)];this.flames.y=[vec(-halfYellow+px,py)];this.flames.self=this;for(var x=0;x(lower right corner or F)");}},blow:function(){var message=this.game.ui.showMessage("3...",5000);delay(1000,function(){message.innerHTML="2...";},this);delay(2000,function(){message.innerHTML="1...";},this);delay(3000,function(){message.innerHTML="boom";},this);delay(3000,this.blowStuffUp,this);this.nextBomb=this.bombShowDelay;},blowStuffUp:function(){this.game.bulletManager.updateEnemyIndex();var index=this.game.bulletManager.enemyIndex;for(var i=0,el;(el=index[i])&&i<10;i++){var rect=getRect(el);var center=new Vector(rect.left+rect.width/2,rect.top+rect.height/2);this.game.explosionManager.addExplosion(center,el,MegaParticleExplosion);el.parentNode.removeChild(el);} -this.game.menuManager.hideBombMenu();this.nextBomb=this.bombShowDelay;},isReady:function(){return this.nextBomb===-1;}});var ELEMENTSTHATARENOTTOBEINCLUDED=['BR','SCRIPT','STYLE','TITLE','META','HEAD','OPTION','OPTGROUP','LINK'];var ELEMENTSIZETHRESHOLD=5;var BulletManager=new Class({initialize:function(game){this.game=game;this.lastBlink=0;this.blinkActive=false;this.enemyIndex=[];this.updateDelay=2.5;this.nextUpdate=this.updateDelay;},update:function(tdelta){if(this.game.isKeyPressed('B')){this.blink();}else if(this.blinkActive){this.endBlink();} -this.nextUpdate-=tdelta;if(this.nextUpdate<0){this.updateEnemyIndex();}},blink:function(){if(now()-this.lastBlink>250){for(var i=0,el;el=this.enemyIndex[i];i++){if(!this.blinkActive) -el.style.outline='1px solid red';else -el.style.outline=el.KICKASSOLDBORDER;} -this.blinkActive=!this.blinkActive;this.lastBlink=now();if(!this.blinkActive){this.updateEnemyIndex();}}},endBlink:function(){for(var i=0,el;el=this.enemyIndex[i];i++) -el.style.outline=el.KICKASSOLDBORDER;this.lastBlink=0;this.blinkActive=false;},updateEnemyIndex:function(){var all=document.getElementsByTagName('*');this.enemyIndex=[];for(var i=0,el;el=all[i];i++){if(this.isDestroyable(el)){this.enemyIndex.push(el);el.KICKASSOLDBORDER=el.style.outline||(document.defaultView.getComputedStyle(el,null).outline);}} -this.nextUpdate=this.updateDelay;},isDestroyable:function(element,ignoreSize){if(this.shouldIgnoreElement(element,ignoreSize)) -return false;for(var i=0,child;child=element.childNodes[i];i++){if(child.nodeType===1&&ELEMENTSTHATARENOTTOBEINCLUDED.indexOf(child.tagName)===-1&&(child.offsetWidth>=ELEMENTSIZETHRESHOLD&&child.offsetHeight>=ELEMENTSIZETHRESHOLD)&&document.defaultView.getComputedStyle(child,null).visibility!=='hidden'){return false;}} -return true;},isDestroyableFromCollision:function(element){return this.isDestroyable(element,true);},shouldIgnoreElement:function(element,ignoreSize){if(element.nodeType!==1) -return true;if(element==document.documentElement||element==document.body) -return true;if(ELEMENTSTHATARENOTTOBEINCLUDED.indexOf(element.tagName)!==-1) -return true;if(element.style.visibility=='hidden'||element.style.display=='none') -return true;if(typeof element.className=="string"&&element.className.indexOf('KICKASSELEMENT')!=-1) -return true;if(!ignoreSize){if(element.offsetWidth=this.game.scrollSize.y) -return true;return false;},destroy:function(){for(var key in this.bullets)if(this.bullets.hasOwnProperty(key)) -for(var i=0,bullet;bullet=this.bullets[key][i];i++) -bullet.destroy();this.bullets={};}});var SessionManager=new Class({initialize:function(game){this.game=game;this.isPlaying=false;},update:function(tdelta){if(this.isPlaying&&this.game.bulletManager.enemyIndex.length==0){this.weHaveWon();}},weHaveWon:function(){this.isPlaying=false;this.game.ui.showMessage("You're done!");if(this.game.isCampaign()){this.game.menuManager.showMenu();this.game.menuManager.navigateTo('highscores');}else{this.game.menuManager.showMenu();} -this.game.menuManager.sendMessageToMenu("gameFinished:!");}}); -var ExplosionManager=new Class({initialize:function(game){this.game=game;this.explosions=[];},update:function(tdelta){var time=now();for(var i=0,explosion;explosion=this.explosions[i];i++){if(time-explosion.bornAt>(explosion.ttl||500)){explosion.destroy();this.explosions.splice(i,1);continue;} -explosion.update(tdelta);}},addExplosion:function(pos,forElement,explosionClass){explosionClass=explosionClass||ParticleExplosion;var explosion=new explosionClass(pos,forElement);explosion.game=this.game;explosion.checkBounds();this.explosions.push(explosion);if(this.game.audioManager.explosion){this.game.audioManager.explosion.play();}},destroy:function(){for(var i=0,explosion;explosion=this.explosions[i];i++) -explosion.destroy();this.explosions=[];}});var Cannon=new Class({initialize:function(player,game,x,y,angle){this.player=player;this.game=game;this.pos=new Vector(x,y);this.angle=angle||0;},shootPressed:function(){},shootReleased:function(){},checkCollisions:function(){},getExplosionClass:function(){return ParticleExplosion;},update:function(tdelta){this.game.hideAll();this.checkCollisions(tdelta);this.game.showAll();},checkCollision:function(bullet){var hit=bullet.checkCollision();if(!hit) -return false;this.game.explosionManager.addExplosion(bullet.pos,hit,this.getExplosionClass());this.game.menuManager.addPoints(Math.min(hit.getElementsByTagName('*').length+1,100),bullet.pos);if(!hit.isShot){hit.parentNode.removeChild(hit);} -if(this.game.statisticsManager){this.game.statisticsManager.addElementsDestroyed();} -return true;},createBullet:function(bulletClass){var pos=this.getABulletPos();var dir=this.getABulletDir();var bullet=new bulletClass(pos,dir);bullet.game=this.game;bullet.manager=this;bullet.initCanvas();bullet.vel.add(bullet.vel.cp().setLength(this.player.vel.len()));return bullet;},getABulletPos:function(){return this.player.pos.cp().add(this.pos.cp().rotate(this.player.dir.angle()+Math.PI/2));},getABulletDir:function(){return this.player.dir.cp().rotate(this.angle);},destroy:function(){}});var LaserCannon=new Class({Extends:Cannon,initialize:function(player,game,x,y,angle){Cannon.prototype.initialize.apply(this,arguments);this.lasers=[];},getExplosionClass:function(){return SplitExplosion;},update:function(tdelta){if(!this.lasers.length) -return;this.removeOld();Cannon.prototype.update.call(this,tdelta);},checkCollisions:function(tdelta){for(var i=0,laser;laser=this.lasers[i];i++){laser.update(tdelta);if(this.checkCollision(laser)){}}},removeOld:function(){for(var i=0,laser;laser=this.lasers[i];i++){if(laser.outOfBounds){laser.destroy();this.lasers.splice(i,1);}}},shootPressed:function(){if(this.lasers.length>5){return;} -if(now()-this.lastFired<500){return;} -this.lastFired=now();if(this.game.statisticsManager){this.game.statisticsManager.addShotFired();} -this.lasers.push(this.createBullet(LaserBullet));},destroy:function(){if(this.lasers.length){for(var i=0,laser;laser=this.lasers[i];i++){laser.destroy();} -this.lasers=[];}}});var BallCannon=new Class({Extends:Cannon,initialize:function(){Cannon.prototype.initialize.apply(this,arguments);this.lastFired=0;this.bullets=[];},getExplosionClass:function(){return ParticleExplosion;},update:function(tdelta){if(!this.bullets.length){return;} -this.removeOld();Cannon.prototype.update.call(this,tdelta);},removeOld:function(){var time=now();for(var i=0,bullet;bullet=this.bullets[i];i++){if(time-bullet.bornAt>2000){bullet.destroy();this.bullets.splice(i,1);}}},checkCollisions:function(tdelta){for(var i=0,bullet;bullet=this.bullets[i];i++){bullet.update(tdelta);if(this.checkCollision(bullet)){bullet.destroy();this.bullets.splice(i,1);}}},shootPressed:function(){if(now()-this.lastFired<200){return;} -this.lastFired=now();this.addBullet();if(this.game.statisticsManager){this.game.statisticsManager.addShotFired();}},addBullet:function(){if(this.bullets.length>7){this.bullets[0].destroy();this.bullets.shift();} -var bullet=this.createBullet(Bullet);this.bullets.push(bullet);},destroy:function(){for(var i=0,bullet;bullet=this.bullets[i];i++){bullet.destroy();} -this.bullets=[];}}); -var Bullet=new Class({initialize:function(pos,dir){this.pos=pos.cp();this.dir=dir;this.vel=new Vector(500,500);this.bornAt=now();},initCanvas:function(){this.sheet=new Sheet(new Rect(this.pos.x,this.pos.y,5,5));this.sheet.drawBullet();},draw:function(){this.sheet.setPosition(this.pos);},update:function(tdelta){this.pos.add(this.vel.setAngle(this.dir.angle()).mulNew(tdelta));this.checkBounds();this.draw();},checkCollision:function(){var element=document.elementFromPoint(this.pos.x,this.pos.y);if(element&&element.nodeType==3) -element=element.parentNode;var didFind=element&&this.game.bulletManager.isDestroyableFromCollision(element)?element:false;return didFind;},checkBounds:function(){var w=this.game.windowSize.width;var h=this.game.windowSize.height;var rightBound=this.pos.x+this.sheet.rect.size.width/2;var bottomBound=this.pos.y+this.sheet.rect.size.height/2;if(rightBound>w) -this.pos.x=0;else if(this.pos.x<0) -this.pos.x=w-this.sheet.rect.size.width/2;if(bottomBound>h) -this.pos.y=0;else if(this.pos.y<0) -this.pos.y=h-this.sheet.rect.size.height/2;},destroy:function(){this.sheet.destroy();}});var LaserBullet=new Class({Extends:Bullet,initialize:function(){Bullet.prototype.initialize.apply(this,arguments);this.vel=new Vector(750,750);this.lastDrawPos=this.pos.cp();},initCanvas:function(){var s=Math.max(GameGlobals.laserImage.width,GameGlobals.laserImage.height);this.sheet=new Sheet(new Rect(0,0,s,s));},update:function(tdelta){Bullet.prototype.update.apply(this,arguments);},draw:function(){this.sheet.drawLaser(this.pos,this.dir);this.lastDrawPos=this.pos.cp();},checkBounds:function(){var w=this.game.windowSize.width;var h=this.game.windowSize.height;var rightBound=this.pos.x+this.sheet.rect.size.width/2;var bottomBound=this.pos.y+this.sheet.rect.size.height/2;if(rightBound>w||this.pos.x<0) -this.outOfBounds=true;if(bottomBound>h||this.pos.y<0) -this.outOfBounds=true;},destroy:function(){this.sheet.destroy();}});GameGlobals.laserImage=document.createElement('img');GameGlobals.laserImage.src=GameGlobals.path('css/gfx/kickass/laser.png'); -var Explosion=new Class({initialize:function(pos,element){this.bornAt=now();this.pos=pos.cp();},update:function(tdelta){},checkBounds:function(){},destroy:function(){}}); -var ParticleExplosion=new Class({Extends:Explosion,initialize:function(pos,element){Explosion.prototype.initialize.apply(this,arguments);this.particleVel=new Vector(150,0);this.particles=[];this.generateParticles();this.sheet=new Sheet(new Rect(pos.x,pos.y,250,250));},update:function(tdelta){for(var i=0,particle;particle=this.particles[i];i++) -particle.pos.add(particle.vel.mulNew(tdelta).mul(random(0.5,1.0)).setAngle(particle.dir.angle()));this.sheet.clear();this.sheet.drawExplosion(this.particles);},generateParticles:function(){for(var i=0,j=!GameGlobals.hasCanvas?10:40;iw) -this.pos.x-=right-w;if(bottom>h) -this.pos.y-=bottom-h;this.sheet.setPosition(this.pos);},destroy:function(){this.sheet.destroy();}}); -var MegaParticleExplosion=new Class({Extends:ParticleExplosion,initialize:function(pos,element){Explosion.prototype.initialize.apply(this,arguments);this.particleVel=new Vector(200,0);this.particles=[];this.generateParticles();this.sheet=new Sheet(new Rect(pos.x,pos.y,500,500));this.ttl=2000;this.generationDelay=0.6;this.generationTimes=2;this.nextGenerate=this.generationDelay;},update:function(tdelta){this.nextGenerate-=tdelta;if(this.nextGenerate<=0&&this.generationTimes>0){this.nextGenerate=this.generationDelay;this.generateParticles();this.generationTimes--;} -ParticleExplosion.prototype.update.call(this,tdelta);}});var SplitExplosion=new Class({Extends:Explosion,initialize:function(pos,element){if(!element)return;Explosion.prototype.initialize.apply(this,arguments);this.element=element;this.fx=new Fx();this.fx.addListener(this);this.start();},update:function(tdelta){if(!this.element)return;this.fx.update();},set:function(key,value){if(key=='opacity'){}},start:function(){var pieces=this.createClones();var left=pieces[0],right=pieces[1];var lT='rotate(-'+random(30,50)+'deg) translate(-100px, 40px)';var rT='rotate('+random(30,50)+'deg) translate(100px, 40px)';setStyles(left,{'transform':lT});setStyles(right,{'transform':rT});this.left=left;this.right=right;this.fx.add('opacity',{start:1,end:0.5,duration:500});},createClones:function(){var coords=getRect(this.element);var leftContainer=this.createContainer(coords);var rightContainer=this.createContainer(coords);var left=cloneElement(this.element);var right=cloneElement(this.element);addClass(left,'KICKASSELEMENT');addClass(right,'KICKASSELEMENT');var styles={margin:0,overflow:'hidden'};setStyles(left,styles);setStyles(right,styles);leftContainer.appendChild(left);rightContainer.appendChild(right);rightContainer.style.left=coords.left+coords.width/2+'px';rightContainer.scrollLeft+=coords.width/2;this.element.style.opacity=0;this.element.style.visibility='hidden';this.element.style.display='none';return each([leftContainer,rightContainer],function(el){el.style.transition='transform 500ms ease-in';});},createContainer:function(coords){var ret=document.createElement('div');setStyles(ret,{position:'absolute',left:coords.left,top:coords.top,width:coords.width*0.5,height:coords.height,overflow:'hidden'});getAppContainerElement().appendChild(ret);return ret;},destroy:function(){try{this.left.parentNode.removeChild(this.left);this.right.parentNode.removeChild(this.right);this.element.parentNode.removeChild(this.element);}catch(e){}}});var Weapons={1:{name:'Cannon',id:'cannon',cannonClass:BallCannon},2:{name:'Laser',id:'laser',cannonClass:LaserCannon}};var WeaponMap={'cannon':Weapons[1],'laser':Weapons[2]}; -var SheetCanvas=new Class({initialize:function(rect){this.canvas=document.createElement('canvas');this.canvas.className='KICKASSELEMENT';with(this.canvas.style){position='absolute';zIndex='1000000';} -GameGlobals.kickass.registerElement(this.canvas);if(this.canvas.getContext) -this.ctx=this.canvas.getContext('2d');this.rect=rect;this.angle=0;this.updateCanvas();getAppContainerElement().appendChild(this.canvas);},tracePoly:function(verts){if(!verts[0])return;this.ctx.save();this.ctx.translate(this.rect.size.width/2,this.rect.size.height/2);this.ctx.rotate(this.angle);this.ctx.beginPath();this.ctx.moveTo(verts[0].x,verts[0].y);for(var i=0;i