-
Notifications
You must be signed in to change notification settings - Fork 1
/
js13.js
53 lines (53 loc) · 25.9 KB
/
js13.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(function(){function Gb(){if(0!=Za.length){var a=Za.shift(),b=a[0],c=a[1];sb=0==Za.length?100:sb+c;J.getElementById("text").textContent=b;J.getElementById("pbar-in").style.width=2*sb+"px";setTimeout(function(){a[2]();setTimeout(Gb,0)})}}function Hb(a){var b=R(3.5,(a-xa)/32);xa=a;a-tb<ub?M=vb+(Ib-vb)*(a-tb)/ub:(tb=a,vb=M,Ib=.3>S()?w(-2,2)+w(-2,2)+w(-1,1):M,ub=5E3*(w(2,4)+T(2)+T(2)));var c=(ia/3|0)%Ka;if($a)if(0>=d.F)wb();else{var f=isUpPressed()?1.65:.6;d.V=d.e>ya/2||d.e<-ya/2;isLeftPressed()?(d.b.x=
da(-10,d.b.x-f),d.K&&(d.V=!0)):isRightPressed()&&(d.b.x=R(10,d.b.x+f),d.K&&(d.V=!1));!d.K&&d.ia&&(d.b.x+=Jb(M,d.b.x,.02));ea.B=!d.U&&isUpPressed();f=d.a.y<G;d.b.scale(f?.99:.76);d.b.y=U(-10,20,d.b.y+(ea.B?-.25:d.K?.8:.5));var k=d.b;d.a.add(q(k.x*b,k.y*b));d.e=Math.atan2(E+Kb-d.a.y+.72*n,D+Lb-d.a.x);var k=Math.cos(d.e)*e*50,x=F(d.e)*e*50;d.P=.9*d.P+.1*x;d.J=.9*d.J+.1*k;d.a.y>G&&(f&&splashAt(l/2-d.J,d.b.y,d.a.x,d.a.y+n-2*e),d.a.y>G+.5*m&&(d.a.y=0));d.a.x>fa+l&&(d.a.x=-l);d.a.x<-l&&(d.a.x=fa+l);a:{var f=
za(d.a.x/e|0,(d.a.y-.4*n)/e|0),g=x=k=!1,s=0,t=0;d.ia=f==V||f==Aa||1==f;0<d.b.x&&(s=n/4,t=-d.a.x%e);0>d.b.x&&(s=n/-4,t=-d.a.x%e+e);Ba(d.a.x+s,d.a.y-.8*n)&&(x=!0,Ba(d.a.x+s,d.a.y-.6*n)&&(k=!0));Ba(d.a.x+s,d.a.y+2*e)&&(g=!0,Ba(d.a.x+s,d.a.y)&&(k=!0));if(g||x)if(k&&(d.b.x*=-.3,d.a.x+=t),.2>A(d.b.y)?d.b.y=0:d.b.y*=0<d.b.y&&g||0>d.b.y&&x?-.3:.3,x&&(d.a.y+=e-d.a.y%e,k||(d.a.y+=e),d.b.x*=.2),g){d.a.y-=d.a.y%e;k&&(d.a.y-=e);d.K=!0;Mb=0;break a}6<Mb++&&(d.K=!1)}d.K?.3>A(d.b.x)?d.b.x=0:d.b.x*=.8:d.a.y<-20*e&&
(d.U=20);0<d.U&&d.U--;La&&4>d.q?(ab.e=360*d.e/B,ab.d(d.a.x,d.a.y-.72*n),d.q++,4<=d.q&&(d.q+=5)):4<=d.q&&(d.q--,4>d.q&&(d.q=0))}f=d.a.y<mc;0<d.F&&(E=d.a.y-m/2+d.P|0,D=d.a.x-l/2+d.J|0);v.setTransform(1,0,0,1,-D,-E);C.setTransform(1,0,0,1,-D,-E);f&&(bb.setTransform(1,0,0,1,-D,-E),cb.position.x=d.a.x-20*M*e);$a&&(G>db-200*e&&(G-=.005*b),ea.position.x=d.a.x-(d.V?-5:5),ea.position.y=d.a.y-15,nc(b),ab.update(b),updateAliens(b),ja.update(b),ea.update(b),eb.update(b),W.update(b),N.update(b),f&&(cb.B=22<qa,
cb.update(b),ka.update(b)),C.clearRect(D,E,l,m),bb.clearRect(D,E,l,m),v.clearRect(D,E,l,m),v.save(),v.globalCompositeOperation="lighter",ea.u(v),ja.u(v),v.restore(),eb.u(v),v.beginPath(),ab.u(v),v.strokeStyle=ra([250,60,60,.4]),v.lineWidth=7,v.stroke(),v.lineWidth=2,v.strokeStyle=ra([255,190,190,.9]),v.stroke(),N.u(v),renderAliens(v),f&&(cb.u(bb),ka.u(bb)),fb&&(f=d.a,k=d.e,x=fb,v.save(),v.translate(f.x-n/2,f.y-n),d.V&&(v.translate(n,0),v.scale(-1,1),k=ya-k),v.drawImage(x,0,0,n,n,0,0,n,n),v.translate(n/
3+n/9,n/3),v.rotate(k),v.drawImage(x,n,0,n,n,-n/3,-n/3,n,n),v.restore()));C.save();W.u(C);C.restore();E>G-m&&(Nb!=c&&(C.fillStyle=Ma[c],Nb=c),oc());sa.save();c=-.3*D;f=U(-1,0,-1.1*E/db)*m;sa.translate(c,f);sa.fillRect(-c,-f,l,m);sa.restore();var g=D+l/2,p=E+m/2,g=g-$/2,p=p-aa/2,s=Na[ta],c=g-Ca,f=p-Da,k=A(c),x=A(f);if(k||x){if(k>$||x>aa)Ca=g,Da=p,Ea(s,g,p,0,0,$,aa);else if(200<k||200<x){Ca=g;Da=p;var O,h,xb,r,s=0;0>c?(O=k,h=0):(O=0,h=k);0>f?(xb=x,r=0):(r=x,xb=0);var u=$-k,y=aa-x,t=1-ta,z=Na[t];z.clearRect(0,
0,$,aa);z.drawImage(yb[ta],h,r,u,y,O,xb,u,y);0>f?(Ea(z,g,p,0,0,$,x),s=x,p+=x):Ea(z,g,p+aa-x,0,aa-x,$,x);0>c?Ea(z,g,p,0,s,k,aa-x):(g+=$-k,Ea(z,g,p,$-k,s,k,aa-x));ta=t;c=f=0}la.clearRect(0,0,l,m);la.drawImage(yb[ta],200+c,200+f,l,m,0,0,l,m)}Ob();gb(Hb);ia++;c="Health: "+d.F+" Wind: "+M.toFixed(1);1E3<a-Pb&&(Pb=a,qa=ia-Qb,Qb=ia);X.clearRect(0,0,l,m);X.fillText(c,l/2,50);0<Fa&&ga?(Fa-=b,X.fillText(ga,l/2-d.J,m/2-d.P-100)):d.U&&X.fillText("Engine FROZEN!",l/2-d.J,m/2-d.P-100)}function Rb(a){var b=a.position.x;
N.d(b,a.position.y);if(a=u[u.length*(1-(b-D)/l)|0+y(-1,2)])a.j+=1}function Jb(a,b,c){a-=b;return U(-10,10,A(a)*a*c)}function hb(){return M}function Sb(){return d.ia?M:0}function pc(a){return ib(l,m,function(b){var c=new Int8Array(l*m),f=new Int8Array(l*m),k=0;ma(l,m,function(b,g){c[k]=Ga(5*(b-l/2)/(3*g/m+.6)+5*F(a+B*(b+2*g)/l)+3*F(a+2*B*(b+g)/l));f[k]=Ga(5*(2*g/m+.6)*F(a+4*B*(b+g/2)/l)*F(a+3.5*B*(b+g)/l));k++});qc(c,f,ba,b,l,m)})}function ua(){if(Ma.length<Ka){if(!ba){ba=[];for(var a=0,b=0;b<m;b++)for(var c=
y(5,25),f=y(10,35),k=y(20,40),d=0;d<l;d++){var g=y(25,50),s=y(30,65),e=y(70,120);ba[a++]=20+(g+c>>1)+Ga(5*F(b*B/10));ba[a++]=25+(s+f>>1)+Ga(5*F(b*B/12));ba[a++]=30+(e+k>>1)+Ga(8*F(b*B/13));ba[a++]=255;c=g;f=s;k=e}a=[];Tb({data:ba,width:l,height:m},a,[.1,.1,.1,.1,.2,.1,.1,.1,.1]);ba=a}Ma.push(C.createPattern(pc(Ma.length*B/Ka),"repeat"))}}function oc(){C.translate(D,0);C.beginPath();C.moveTo(l,E+m);C.lineTo(0,E+m);var a=0;K(u,function(b){C.lineTo(a,b.height+3*F((a-3.5*ia*M)/322*B+4*F((a-2*ia*M)/511*
B)+4*F((a-ia*M)/733*B)));a+=Ub});C.closePath();C.fill();C.stroke()}function nc(a){var b=0;K(u,function(c){c.j+=a*(-.04*(c.height-G)-.025*c.j);c.height+=c.j*a;b=da(b,A(c.j))});if(1<b){var c=[],f=[];z(Vb,function(){for(var a=0;a<u.length;a++)0<a&&(c[a]=.25*(u[a].height-u[a-1].height),u[a-1].j+=c[a]),a<u.length-1&&(f[a]=.25*(u[a].height-u[a+1].height),u[a+1].j+=f[a]);for(a=0;a<u.length;a++)0<a&&(u[a-1].height+=c[a]),a<u.length-1&&(u[a+1].height+=f[a])})}}function Ba(a,b){return Oa[za(a/e|0,b/e|0)]}function Wb(a,
b){var c=Xb[za(a,b)];return void 0===c?jb:c}function za(a,b){return 0>b?V:0>a?b>=1E3-.4*a?kb:V:2048<=a?b>=1E3+.4*(a-2048)?kb:V:1E3<=b?kb:Ha[2048*b+a]}function zb(a,b,c){for(var f=c*c,k={},d=0;d<c;d++){var g=Ab(f-d*d),s=b+g-R(.4*g,4*e);Yb(a+d,a-d,b-g,s,lb,k);Yb(a+d,a-d,s,b+g,jb,k)}c+=2*e;P=R(P,a-c);Y=R(Y,b-c);na=da(na,a+c);oa=da(oa,b+c)}function Yb(a,b,c,f,k,d){for(;c<f;c+=e)for(var g=2048*(c/e|0),g=[g+(a/e|0),g+(b/e|0)],s=0;2>s;s++){var t=g[s];if(!d[t]){d[t]=1;var p=Ha[t];p!=kb&&p!=V&&p!=k&&(k==jb&&
p!=Bb&&(k=lb),k==lb&&p!=Bb&&p!=lb&&p!=jb&&(k=V),Ha[t]=k)}}}function Ob(){1E7>P&&(Na[ta].clearRect(P-Ca,Y-Da,na-P-3,oa-Y-3),Ea(Na[ta],P,Y,P-Ca-1,Y-Da-1,na-P+1,oa-Y+1),P=Y=1E7,na=oa=-1E7)}function mb(a,b,c){Ha[2048*b+a]=c;a*=e;b*=e;c=2*e;var f=R(P,a-c);minDirtyY2=R(Y,b-c);maxDirtyX2=da(na,a+c);maxDirtyY2=da(oa,b+c);maxDirtyY2-minDirtyY2>50*c||maxDirtyX2-f>50*c?(Ob(),P=a-c,Y=b-c,na=a+c,oa=b+c):(P=f,Y=minDirtyY2,na=maxDirtyX2,oa=maxDirtyY2)}function Ea(a,b,c,f,k,d,g){var s=d/e|0,t=g/e|0,p=b/e|0;b=c/e|
0;var O=Ca;c=Da;a.save();a.translate(-O,-c);a.rect(O+f,c+k,d,g);a.clip();f-=e;f-=f%e;k-=e;k-=k%e;for(var s=s+4,t=t+2,O=O+f,l=c+k,h=b;h<b+t;h++){var n=Wb(p,h),m=0;z(s,function(b){var c=Wb(p+b,h);if(c!=n||b>=s-1){if(n){a.fillStyle=n;a.beginPath();a.moveTo(O+m*e+ha[A(11*m+3*h)%80],l+ha[A(9*m+7*h)%80]);for(var f=m+1;f<=b;f++)a.lineTo(O+f*e+ha[A(11*f+3*h)%80],l+ha[A(9*f+7*h)%80]);f--;for(a.lineTo(O+f*e+ha[A(11*f+3*(h+1))%80],1+l+e+ha[A(9*f+7*(h+1))%80]);f>=m;f--)a.lineTo(O+f*e+ha[A(11*f+3*(h+1))%80],1+
l+e+ha[A(9*f+7*(h+1))%80]);a.closePath();a.fill()}m=b}n=c});l+=e}a.restore()}function Pa(a,b,c){return ib(r,r,function(f){var k=0;ma(r,r,function(d,g){f[k++]=a(d,g);f[k++]=b(d,g);f[k++]=c(d,g);f[k++]=255})})}function rc(){return function(a){var b=R(a.l,.4);return Qa((b+.08)/2,(a.M+.31)/2,(a.b+.16)/2)}}function wb(a){d.F=0;$a=!1;nb.innerHTML=(a?"<h1>You WIN!</h1>Awesome!!!":"<h1>Game Over</h1>Better luck next time.")+"<br><br>Press Refresh (F5) to start over.";nb.style.display="block"}function pa(a,
b){var c={t:0,A:0,f:.3,N:function(){},ba:function(a,b){var c=b.size,g=c>>1,d=b.position.x|0,e=b.position.y|0,p=a.createRadialGradient(d,e,b.la,d,e,g);p.addColorStop(0,b.ra);p.addColorStop(1,b.sa);a.fillStyle=p;a.fillRect(d-g,e-g,c,c)},ua:function(a,b){this.Q({W:a,L:[],ga:[],B:!1,s:q(0,0),n:q(0,.3),elapsedTime:0,duration:-1,o:0,D:0,aa:0,C:0,v:0,w:0,G:0,D:0});this.Q(b||{})},Q:function(a){for(var b in a)this[b]=a[b];this.i||(this.i=this.size);this.o||(this.o=this.W/this.r);this.t&&(this.t=ra(this.t))},
d:function(a,b){if(this.L.length>=this.W)return null;var c=this.ga.shift()||{position:q()};this.va(c,a||this.position.x,b||this.position.y);this.L.push(c);return c},va:function(a,b,c){a.position.x=b+this.s.x*w(-1,1);a.position.y=c+this.s.y*w(-1,1);b=(this.e+this.C*w(-1,1))*(ya/180);b=q(Math.cos(b),F(b));c=this.speed+this.w*w(-1,1);a.direction=q(b.x*c,b.y*c);a.size=this.size+this.v*w(-1,1);a.size=1>=a.size?1:a.size|0;a.i=this.i+this.v*w(-1,1);a.f=this.f;a.c=this.r+this.aa*w(-1,1);a.g=this.g+this.G*
w(-1,1);a.g=100<a.g?100:0>a.g?0:a.g;a.la=a.size/200*a.g|0;if(this.h){var g=[this.h[0],this.h[1],this.h[2],this.h[3]];if(this.H){var d=this;z(4,function(a){g[a]+=d.H[a]*w(-1,1)})}this.k&&(b=[this.k[0]+this.p[0]*w(-1,1),this.k[1]+this.p[1]*w(-1,1),this.k[2]+this.p[2]*w(-1,1),this.k[3]+this.p[3]*w(-1,1)],a.O=[(b[0]-g[0])/a.c,(b[1]-g[1])/a.c,(b[2]-g[2])/a.c,(b[3]-g[3])/a.c]);a.color=g}a.da=(a.i-a.size)/a.c},update:function(a){a/=31;if(this.B&&0<this.o){var b=1/this.o;for(this.D+=a;this.L.length<this.W&&
this.D>b;)this.d(),this.D-=b;-1!=this.duration&&(this.elapsedTime+=a,this.duration<this.elapsedTime&&this.xa())}var c=this;K(this.L,function(b,d){if(0<b.c){if(c.n){var k=b.direction,e=c.n;b.direction=q(k.x+e.x,k.y+e.y)}c.A&&(b.direction.x+=Jb(c.A(b),b.direction.x,b.f));b.position.add(b.direction);b.c-=a;c.N(b,d)}0<b.c?(b.size+=b.da*a,b.la=b.size/200*b.g|0,b.O&&(b.color[0]+=b.O[0]*a,b.color[1]+=b.O[1]*a,b.color[2]+=b.O[2]*a,b.color[3]+=b.O[3]*a),b.color&&(b.sa=c.t||ra(b.color,0),b.ra=ra(b.color))):
(c.L.splice(d,1),c.ga.push(b))})},xa:function(){this.B=!1;this.D=this.elapsedTime=0},u:function(a){var b=this;K(this.L,function(c){b.ba(a,c)})}};c.ua(a,b);return c}function ra(a,b){return"rgba("+[U(0,255,a[0]|0),U(0,255,a[1]|0),U(0,255,a[2]|0),U(0,1,void 0!=b?b:a[3].toFixed(2))].join()+")"}function sc(a,b){return q(a.x-b.x,a.y-b.y)}function q(a,b){return{x:a||0,y:b||0,scale:function(a){this.x*=a;this.y*=a},add:function(a){this.x+=a.x;this.y+=a.y},sub:function(a){this.x-=a.x;this.y-=a.y}}}function Zb(a,
b,c,f){return ib(b,c,function(d){for(var e=0,g=0;g<c*b;){for(var s=a[e++],t=0;16>t;t++){var p=255*(s&3)/3|0,h=4*(g+15-t),s=s>>2;d[h++]=~f&1?p/2:p;d[h++]=~f&2?p/2:p;d[h++]=~f&4?p/2:p;d[h++]=0==p?0:255}g+=16}})}function Cb(a,b){var c=a.canvas.width,f=a.canvas.height,d=ca(c,f),e=Db(a,H(d),[-1,0,0,0,0,0,-2,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0]),g=ca(c,f),s=Db(a,H(g),[0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,-2,0,0,0,0,0,-1]),t=0,e=b?e:s,p=e.data,s=d,h=g;z(c*f,function(){z(3,function(){p[t]=255-p[t];t++});t++});
b&&(s=g,h=d);H(h).putImageData(e,0,0);a.globalCompositeOperation="darken";a.drawImage(h,0,0,c,f);a.globalCompositeOperation="lighter";a.drawImage(s,0,0,c,f)}function Db(a,b,c){var f=Eb(a);a=(b||a).createImageData(f.width,f.height);Tb(f,a.data,c);b&&b.putImageData(a,0,0);return a}function Tb(a,b,c){var f=Ga(Ab(c.length)),d=f/2|0,e=a.data,g=a.width,s=a.height,h=0;ma(g,s,function(a,l){var n=0,m=0,r=0,q=e[4*(l*g+a)+3];ma(f,f,function(b,h){var t=l+h-d,q=a+b-d,t=t+10*s,t=t%s,q=q+10*g,q=q%g,t=4*(t*g+q),
q=c[h*f+b];n+=e[t]*q;m+=e[t+1]*q;r+=e[t+2]*q});b[h++]=n;b[h++]=m;b[h++]=r;b[h++]=q})}function qc(a,b,c,d,k,e){var g=0,s=0,h=20*k,p=20*e;ma(k,e,function(l,n){var m=a[s],q=b[s];s++;m=4*((l-m+h)%k+(n-q+p)%e*k);d[g++]=c[m++];d[g++]=c[m++];d[g++]=c[m++];d[g++]=c[m]})}function Ra(a,b){var c=Eb(a),d=c.data,k=0;z(c.width*c.height,function(){var a=d[k],c=d[k+1],e=d[k+2],a=a/255,c=c/255,e=e/255,h,p,l,m=Math.max(a,c,e),n=m-Math.min(a,c,e);0==n?a=l=0:(l=n/m,h=(m-a)/6/n+.5,p=(m-c)/6/n+.5,e=(m-e)/6/n+.5,a=a===
m?e-p:c===m?1/3+h-e:2/3+p-h,0>a?a++:1<a&&a--);l=b({l:a,M:l,b:m});d[k++]=l.wa;d[k++]=l.ta;d[k++]=l.oa;k++});a.putImageData(c,0,0)}function Qa(a,b,c){void 0===b&&(b=a.M,c=a.b,a=a.l);var d=6*a|0,k=6*a-d;a=c*(1-b);var e=c*(1-k*b);b=c*(1-(1-k)*b);var g,h,l;switch(d%6){case 0:g=c;h=b;l=a;break;case 1:g=e;h=c;l=a;break;case 2:g=a;h=c;l=b;break;case 3:g=a;h=e;l=c;break;case 4:g=b;h=a;l=c;break;case 5:g=c,h=a,l=e}return{wa:255*g|0,ta:255*h|0,oa:255*l|0}}function I(a,b,c,d,e,h,g,l,m,p){function n(r,v){var u=
v*a+r;try{return q[u]?q[u]:q[u]=T(p)|0?U(0,255,(T(m)|0)+n((a+r-y(e,h))%a,(b+v-y(g,l))%b)):y(c,d)}catch(w){return q[u]=y(c,d)}}var q=[];return n}function Q(a,b,c){Za.push([a,b,c])}function ib(a,b,c){a=ca(a,b);b=H(a);var d=Eb(b);c(d.data,b,a);b.putImageData(d,0,0);return a}function Eb(a){return a.getImageData(0,0,a.canvas.width,a.canvas.height)}function y(a,b){return w(a,b)|0}function w(a,b){return a+T(b-a)}function T(a){return S()*a}function Fb(a){return a*a}function H(a){return a.getContext("2d")}
function ca(a,b){var c=J.createElement("canvas");c.width=a||l;c.height=b||m;return c}function ma(a,b,c){for(var d=0;d<b;d++)for(var e=0;e<a;e++)c(e,d)}function U(a,b,c){return R(b,da(a,c))}function K(a,b){for(var c=a.length-1;0<=c&&!b(a[c],c);c--);}function tc(a){for(var b=0;2>b&&!a(b);b++);}function z(a,b){for(var c=0;c<a;c++)b(c)}function S(){var a=2091639*L.Z+L.R*L.S;L.Z=L.$;L.$=L.T;L.R=a|0;L.T=a-L.R;return L.T}var Sa=250,$b=400,Ka=10,Vb=8,ac=1,bc=450,e=7,l=1E7,m=0,h=1;/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&
(Sa=200,$b=300,Ka=5,Vb=4,ac=1,bc=300);for(;(m>innerHeight||l>innerWidth)&&3<e;)e--,h=e/7,l=1715*h|0,m=1400*h|0;var fa=2048*e,db=1E3*e,G=db-150,M=1.5,Ma=[],D=0,E=0,L={ka:function(a){a=1>a?1/a:a;this.Z=(a>>>0)*this.S;a=69069*a+1>>>0;this.$=a*this.S;this.T=(69069*a+1>>>0)*this.S;this.R=1;return this},Z:0,$:0,T:0,R:0,S:2.3283064365386963E-10};L.ka(5);var cc=[],va=[],J=document;J.getElementById("overlay").style.width=l+"px";J.getElementById("overlay").style.left=(-l>>1)+"px";var uc=J.getElementById("canvas_cont");
z(6,function(){var a=ca();a.style.left=(-l>>1)+"px";uc.appendChild(a);cc.push(a);va.push(H(a))});var sa=va[0],bb=va[1],la=va[2],v=va[3],C=va[4],X=va[5],A=Math.abs,R=Math.min,da=Math.max,F=Math.sin,Ga=Math.round,Ab=Math.sqrt,ya=Math.PI,B=2*ya,gb=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame;if(!gb)var dc=0,gb=function(a){var b=Date.now(),c=da(0,16-(b-dc));window.setTimeout(function(){a(b+c)},c);dc=b+c};var Za=[],d={a:q(50*e,900*e),b:q(),P:0,J:0,F:30,
q:0},fb=0,n=64*h|0;Q("Chasing Sprites",4,function(){var a=Zb([0,0,0,44016,0,0,176124,0,0,152917,0,0,177556,0,0,174826,0,1024,174680,5119,-2096,174752,1365,1431655764,175088,5467,-445688492,437244,86,-50380800,437247,6,-1124253696,1747967,1,-1359396864,437247,0,1788870656,1485823,0,444596224,1485823,0,83886080,1485567,0,0,1747711,0,0,1485804,0,0,48175,0,0,15407,0,0,11307,0,0,11304,0,0,11307,0,0,11051,0,0],48,24),b=ca(2*n,n),b=H(b);b.drawImage(a,0,0,2*n,n);Cb(b,!0);fb=ca(2*n,n);var a=H(fb),c=b.getImageData(0,
0,2*n,n).data,b=a.createImageData(2*n,n),d=b.data,e=0;ma(2*n,n,function(){d[e]=c[e];e++;d[e]=c[e];e++;d[e]=c[e]/2;e++;d[e]=c[e];e++});a.putImageData(b,0,0);ua()});var Mb=0;splashAt=function(a,b,c,d){0>a||a>l||(u[u.length*(1-a/l)|0].j=22*b,20<qa&&(W.B=!0,W.position.x=c,W.position.y=d,W.speed=.75*b,W.o=20*A(b)))};KEYS={};updateFromKeys=function(a){KEYS[a.keyCode]="keydown"==a.type;(32==a.keyCode||37<=a.keyCode&&40>=a.ya)&&a.preventDefault()};isLeftPressed=function(){return KEYS[37]||KEYS[65]||KEYS[83]};
isRightPressed=function(){return KEYS[39]||KEYS[68]||KEYS[70]};isUpPressed=function(){return KEYS[38]||KEYS[32]||KEYS[87]||KEYS[69]};J.onkeydown=updateFromKeys;J.onkeyup=updateFromKeys;var Lb=0,Kb=0,La=0;J.onmousemove=function(a){var b=cc[1].getBoundingClientRect();Lb=a.clientX-b.left;Kb=a.clientY-b.top};J.onmousedown=function(a){La|=1<<a.button};J.onmouseup=function(a){La&=~(1<<a.button)};var Ia=[[47,-67108864,42,-1442840576,170,-1442840576,170,-1442840576,11946,-1430781952,10922,-1431568384,9898,
-1431830528,785066,-1431314432,682666,-1431658496,956074,-1431916544,9278826,-1454001664,43423066,-1453932672,44734294,-1512658240,40539994,-1512658240,40539482,-1453938048,44737898,-1453675904,40544917,1521134208,39496277,1437160832,11183735,2006624768,9813,1436024832,9821,-577110016,632149,1448779776,693338,-1457868800,692377,1761976320,6963221,1442950784,111486608,93350592,127149712,94378560,23864896,26219968,10488192,6294016],[770048,1032192,704512,1024E3,688128,1024E3,698368,15376384,698880,
65699840,11776,48758784,10752,48758784,961194,-357924864,961194,-1431576576,961194,-1431642112,16411306,-1432950272,66737834,-1437159936,65689002,-1453937152,44727658,-1510560256,-22381142,-1443189848,-22369622,-1431655432,-1096111446,-1431655768,-1431655766,-1431660888,-1436898731,1437247144,-1458918787,2108318120,-1458918742,-1431678552,-1458918742,-1431662172,-1459191808,692644,1762033664,692564,-1794790828,-1788198312,67201636,1520762880,27300,1519648768,5476,-1789394944,10836,-1431830528],[682,
-1434451968,3071,-1414529024,16362,-1430519808,44760746,-1431655808,44739242,-1431655552,48933546,-1431654464,732605098,-1431655432,1051372202,-1431655430,984263338,-1431655686,715806378,-1433032006,715806058,-1454003542,715825002,-1443452246,715824986,-1510561110,715827882,-1431655766,1789569706,-1431655766,447326890,-1431741786,357935773,1990874452,1747613,1990890496,1747605,1454023936,22697386,-1432966848,27935066,-1543411136,27934746,-1543411136,22697301,1414899008,1742080,5936384,1485312,5936384,
1399040,5854208,349440,5586944]],Ta=[],wa=[],Ua=[],Va=[],Ja=0,ob=0,Z=0,ec=-1E7;updateAliens1=function(a){var b=!1;0<Ja?(Ja-=a,K(Va,function(b){b.y+=a*A(b.speed)/2;0>=Ja&&(ob=40,b.speed=U(-10*h,10*h,-1.1*b.speed))})):(ob-=a,K(Va,function(b){b.x+=b.speed*a}));K(wa,function(c){var d=Va[c.pa],k=20*c.ma+(20<qa?6*F(10*(c.ma+3*c.na)/B+5E-4*c.ca*xa):0);c.x=d.x+e*k;if(!(0>=c.I)){c.y=d.y+c.na*e*10;0<c.X&&(c.X-=a,c.x+=w(-e,e),c.y+=w(-e,e),20<qa&&(ja.Q(Ta[c.m]),ja.d(c.x,c.y)));if(c.x<-200*e||c.x>fa+200*e)b=!0;
za(c.x/e|0,c.y/e|0)!=V&&(b=!0,c.I--,zb(c.x,c.y,16))}});b&&0>=Ja&&0>=ob&&(Ja=20)};explode=function(a,b){ea.e=-90;N.speed*=3;var c=e*b;ja.Q(Ta[a.m]);z((20>qa?4:12)*b*b,function(){ea.d(a.x+y(-2*c,2*c),a.y+y(-3*c,c));N.d(a.x+y(-2*c,2*c),a.y+y(-2*c,c));ja.d(a.x+y(-2*c,2*c),a.y+y(-2*c,2*c))});ea.e=90;N.speed/=3};renderAliens=function(a){K(wa,function(b){a.drawImage(Ia[b.m],b.x-b.Y/2,b.y-b.l/2,b.Y,b.l)});K(Ua,function(b){a.fillStyle=ra(Ta[b.m].h);a.fillRect(b.x-5,b.y-5,10,10)})};updateAliens=function(a){xa>
ec+12E4&&startAlienWave();updateAliens1(a);K(wa,function(b,c){5>b.I&&.3>S()&&N.d(b.x,b.y);var f=d.a.x-b.x,k=d.a.y-n/2-b.y;!b.qa&&A(f)+A(k)<n&&(d.F--,Fa=50,ga="Ouch!",b.I=0,explode(b,2),b.qa=1);if(0>=b.I)b.b=R(3*e,(b.b||0)+.3),b.y+=b.b*a,.6>S()&&N.d(b.x,b.y),f=Ba(b.x,b.y),b.y>G+20*e&&(splashAt(b.x-D,12,b.x,b.y-20*e),f=!0),f&&(explode(b,2),wa.splice(c,1),0==wa.length&&10==Z&&0<d.F&&wb(!0),zb(b.x,b.y,6*e));else{b.y>G+5*e&&(wb(),E=b.y-m/2,D=b.x-m/2);var h=e*(22-b.ca+2*b.m),f=f+w(-h,h),k=k+w(-h,h),g=f*
f+k*k,h=h*h;S()<1E-4*(b.m+1+b.ca)*a*(g<40*h?3:1)&&Ua.length<50+25*Z&&(g>99*h?(f=0,k=1):(g=Ab(g),f/=g,k/=g),Ua.push({x:b.x,y:b.y,m:b.m,ea:e*f*w(1,1.1+b.m/3),fa:e*k*w(1,1.1+b.m/3)}))}});Oa[Aa]=1;K(Ua,function(b,c){tc(function(){b.x+=b.ea*a;b.y+=b.fa*a;var f=b.x>D-l&&b.x<D+l&&b.y>E-m&&b.y<E+m;f&&20<qa&&(ja.Q(Ta[b.m]),ja.d(b.x,b.y));var k=b.y<-10*e||b.x<-200*e||b.x>fa+200*e;b.y>G+5*e&&(splashAt(b.x-D,6,b.x,b.y-20*e),k=!0);A(b.x-d.a.x)+A(b.y-d.a.y+n/2)<n&&(d.F--,Fa=50,ga="Ouch!",d.a.x+=b.ea,d.a.y+=b.fa,
k=!0);Ba(b.x,b.y)&&(k=!0,zb(b.x,b.y,3*e));if(k)return Ua.splice(c,1),f&&explode(b,1),!0})});Oa[Aa]=0};startAlienWave=function(){ec=xa;if(!(10<=Z)){var a=20*e;Z++;ga="Wave #"+Z+" started! coming from the top ";0==Z%2?(a=fa-12*a,ga+="RIGHT!"):ga+="LEFT!";Fa=250;for(var b=0;6>b;b++){Va.push({x:a,y:e*(30+20*b),speed:(1.2*Z+1.5)*h});for(var c=b>>1,d=0;12>d;d++)wa.push({ma:d,na:b,m:c,pa:Va.length-1,Y:Ia[c].width*(1+Z/15),l:Ia[c].height*(1+Z/15),ca:Z,I:6+3*Z,X:0})}}};Q("Beaming Aliens",4,function(){z(3,
function(a){var b=Zb(Ia[a],32,Ia[a].length/2,1<<a),c=ca(64*h,2*b.height*h);H(c).drawImage(b,0,0,c.width,c.height);Ia[a]=c});z(3,function(a){var b={k:[40,40,40,.2],p:[10,10,10,0],h:[220,220,220,.9],H:[5,5,5,0]};b.k[a]=120;b.h[a]=250;Ta.push(b)});ua()});var fc,pb={};Q("Painting Sky",10,function(){fc=ib(Sa,2*m,function(a){var b=0;z(Sa,function(){a[b++]=40;a[b++]=50;a[b++]=80;a[b++]=255});var c=105/m,d=4*Sa;ma(Sa,2*m-1,function(){a[b]=(a[b-4]+a[b-d]+(T(2)|0)>>1)+(S()<c?T(2)|0:0);b++;a[b]=(a[b-4]+a[b-
d]+(T(2)|0)>>1)+(S()<c?T(2)|0:0);b++;a[b]=(a[b-4]+a[b-d]+(T(2)|0)>>1)+(S()<c?T(2)|0:0);b++;a[b++]=255})});sa.fillStyle=sa.createPattern(fc,"repeat-x");sa.fillRect(0,0,l,m);ua()});Q("Blowing Clouds",10,function(){for(var a=6;30>a;a++){pb[a]=[];for(var b=30+4*a,c=0;c<ac;c++){var d=ca(120,60),e=H(d);e.scale(2,1);for(var h=0;4>h;h++){var g=y(22.5,37.5),l=y(22.5,37.5),m=e.createRadialGradient(g,l,15,g,l,22.5),p=b+y(-10,10),n="rgba("+p+","+p+","+p+",0)";m.addColorStop(0,"rgba("+p+","+p+","+p+",.8)");m.addColorStop(1,
n);e.fillStyle=m;e.arc(g,l,30,0,B);e.fill()}pb[a].push(d)}}ua()});var r=$b,qb,gc,hc,Wa,rb,ic,jc,kc,lc,Xa;Q("Chiseling Rocks",10,function(){function a(a,b){return function(c,d){return da(b,a(c,d))}}qb=Pa(I(r,r,120,180,-3,3,-3,3,-1,200),I(r,r,70,130,-3,3,-3,3,-1,100),I(r,r,40,80,-3,3,-3,3,-2,100));var b=Pa(I(r,r,60,180,-1,2,1,3,-2,100),I(r,r,70,220,-1,2,1,3,-1,200),I(r,r,70,100,-1,2,1,3,-3,100)),c=Pa(a(I(r,r,60,110,1,3,-3,0,-4,100),20),a(I(r,r,80,160,1,3,-3,0,-2,500),30),a(I(r,r,20,40,1,3,-3,0,4,1E3),
80));gc=la.createPattern(b,"repeat");Ra(H(b),function(a){return Qa(a.l,a.M/4,.4*a.b)});hc=la.createPattern(b,"repeat");Ra(H(c),function(a){return Qa(a.l,.1*a.M,U(.75,1,1.1*a.b))});jc=la.createPattern(c,"repeat");rb=Pa(I(r+7,r+7,80,140,-2,4,-2,4,2,300),I(r+7,r+7,80,140,-2,4,-2,4,-1,300),I(r+7,r+7,40,80,-2,4,-2,4,-2,300))});Q("Chiseling Rocks",10,function(){var a=Pa(I(r,r,30,50,1,4,1,4,5,100),I(r,r,120,180,1,4,1,4,-2,200),I(r,r,150,220,1,4,1,4,-2,200));Wa=H(rb);Xa=H(qb);var b=H(a);Ra(b,function(a){return Qa(a.l,
.3*a.M,.5*a.b)});K([Wa,Xa,b],function(a){Db(a,a,[.1,.1,.1,.1,.2,.1,.1,.1,.1])});kc=la.createPattern(a,"repeat");ua()});Q("Chiseling Rocks",10,function(){Cb(Wa);Ra(Wa,function(a){return Qa(a.l,.3*a.M,.5*a.b)});Cb(Xa);Ra(Xa,rc());lc=la.createPattern(qb,"repeat");ic=la.createPattern(rb,"repeat");qb=rb=Wa=Xa=0});var Ha,$=l+400,aa=m+400,ha=[],ta=0,yb=[],Na=[];Q("Digging Caves",10,function(){L.ka(1);var a=ca(2048,1E3),b=H(a),a=ra([0,0,0,0]);b.fillStyle=a;b.fillRect(0,0,2048,1E3);b.shadowColor="#400000";
b.shadowBlur=0;b.shadowOffsetX=0;b.shadowOffsetY=-14;b.fillStyle="#600000";var c=[];c[2048]=0;(function(a,b,c){var d=a.length-1;c=Math.pow(2,-c);b*=c;var e=d/2;for(a[0]=a[d]=0;e;){for(var f=e;f<d;f+=2*e)a[f]=b*w(.2,1)+(a[f-e]+a[f+e])/2;b*=c;e>>=1}})(c,1500,.7);b.beginPath();b.lineTo(0,1E3);z(2048,function(a){c[a]+=400*Fb(F(2*B*a/2048))*Fb(F(ya+3*B*a/2048));c[a]*=1/(1+Fb(.001*(a-1024)));b.lineTo(a,1E3-c[a])});b.lineTo(2049,1E3);b.closePath();b.fill();b.clip();b.shadowOffsetY=3;b.lineWidth=22;b.shadowColor=
"#800000";b.beginPath();b.strokeStyle="#a00000";b.moveTo(0,600);b.lineTo(2048,900);b.moveTo(0,900);b.lineTo(2048,600);b.moveTo(204.8,0);b.lineTo(1433.6,810);b.moveTo(1843.2,0);b.lineTo(614.4,810);b.stroke();b.beginPath();b.fillStyle="#a00000";b.arc(204.8,750,30,0,B);b.arc(1843.2,750,30,0,B);b.fill();Ha=new Uint8Array(2048E3);var d=b.getImageData(0,0,2048,1E3).data,e=0,h=0;ma(2048,1E3,function(a,b){var l=d[e+=4]>>5,m=b/1E3;.4>m&&(l==Aa||l==Bb)&&b<1E3-c[a]+100*(.4-m)&&(l=Ya);Ha[h++]=l})});z(2,function(){var a=
ca($,aa);yb.push(a);Na.push(a.getContext("2d"))});z(80,function(){ha.push(y(-(e>>1),1+(e>>1)))});var Xb={},P=1E7,Y=1E7,na=-1E7,oa=-1E7,Oa={6:1,3:1,7:1},V=0,Aa=2,Bb=3,jb=4,lb=5,kb=6,Ya=7;Q("Digging Caves",10,function(){Xb=[0,hc,gc,ic,kc,lc,"#333",jc];ua()});var Ca=1E7,Da=0,ba;Q("Waving waves",10,function(){z(Ka-Ma.length,function(){ua()});ba=null});C.strokeStyle="rgba(200,200,250,0.3)";C.lineWidth=3;var Ub=10,u=[];z(l/Ub+1,function(){u.push({height:G,j:0})});C.globalAlpha=.9;var ia=0,Qb=ia,Pb=-1,Nb,
$a=!1,ga,Fa=0,ea=pa(350,{position:q(),e:90,C:10,duration:-1,k:[200,45,10,0],p:[40,40,40,0],n:q(0,.03),r:1,s:q(4,6),g:12,G:12,size:30*h|0,i:75*h|0,t:[40,20,10,0],v:5*h,speed:4*h,w:1*h,o:140,h:[220,188,88,1],H:[32,35,38,0],N:function(a){if(a.position.y>G)a.c=0,Rb(a);else{var b=(a.position.x/e|0)+1,c=(a.position.y/e|0)+1,d=za(b,c);d==Aa||d==Ya?(a.c=0,N.d(a.position.x,a.position.y),d==Ya?(W.speed=3*h,W.d(a.position.x,a.position.y),mb(b,c,V)):mb(b,c,.8>S()?1:V)):Oa[d]&&(a.position.sub(a.direction),a.direction.y*=
-1)}},A:Sb,f:.1}),ja=pa(450,{position:q(),e:90,C:10,duration:-1,n:0,r:1,s:q(3,3),g:22,G:12,size:30*h|0,i:15*h|0,v:5*h,speed:4*h,w:1*h,o:-1,f:.1}),eb=pa(250,{position:q(),e:0,C:360,duration:-1,k:[230,150,150,.1],p:[20,20,20,.1],n:q(0,.4),r:2.5,s:q(3,3),g:82,G:12,size:8*h|0,i:2*h|0,speed:5*h,w:1*h,h:[250,160,160,1],H:[5,5,5,0],A:Sb,f:.1}),ab=pa(100,{n:0,position:q(),h:[200,50,50,.8],speed:e,r:3,ba:function(a,b){a.moveTo(b.ja.x,b.ja.y);a.lineTo(b.position.x,b.position.y)},N:function(a){if(!(0>a.c)){a.ja=
sc(a.position,a.direction);for(var b=0;6>b&&a.c;b++){var c=a.position.x,d=a.position.y;d>G&&(a.c*=.8,Rb(a));K(wa,function(b){var e=b.x-b.Y/2,g=b.y-b.l/2;c>e&&c<e+b.Y&&d>g&&d<g+b.l&&(a.c=0,eb.d(c,d),b.I--,b.X=5)});var k=(c/e|0)+1,l=(d/e|0)+1,g=za(k,l);if(g==Aa||g==Ya)if(N.d(c,d),g==Ya)a.c*=.8,W.speed=3*h,W.d(c,d),mb(k,l,V);else{a.c=0;mb(k,l,.8>S()?1:V);continue}else if(Oa[g]){a.c=0;eb.d(c,d);continue}a.position.add(a.direction)}a.c||(a.position.sub(a.direction),a.c=1E-5)}}}),cb=pa(bc,{B:!0,position:q(d.a.x,
-60*e),e:90,C:180,duration:-1,k:[240,240,250,.1],p:[10,10,10,0],n:q(0,.02),r:25,s:q(.7*l,5*e),g:12,G:12,size:20*h|0,i:10*h|0,v:2*h,t:[40,40,40,0],speed:.2*h,w:.1,h:[220,220,230,1],H:[22,22,22,0],A:hb,N:function(a,b){a.position.x+=F(B*b/50+.001*xa);a.direction.y=R(a.direction.y,4*h)},f:.4}),ka=pa(350,{position:q(fa/2,-125*e),e:0,duration:-1,n:0,r:10,o:-1,s:q(fa/2,10*e),size:280*h|0,i:280*h|0,v:30,speed:.2*h,w:.1,A:hb,f:.3,N:function(a){a.c=1E3;a.position.x+=fa;a.position.x%=fa},ba:function(a,b){var c=
b.size|0,d=b.position.x|0,e=b.position.y|0;if(!b.ha){var h=100*b.f|0,h=U(6,29,h),g=pb[h].shift();pb[h].push(g);b.ha=g}a.drawImage(b.ha,d,e,2*c,c)}}),N=pa(250,{position:q(),e:-90,C:20,duration:10,k:[40,40,40,0],p:[10,10,10,0],n:q(0,-.25),r:.8,aa:.2,s:q(2,2),g:12,G:12,size:45*h|0,i:60*h|0,v:6*h,t:[0,0,0,0],speed:1.2*h,w:.1,h:[220,220,220,1],H:[22,22,22,0],A:hb,f:.8}),W=pa(250,{position:q(),e:-90,C:80,duration:.15,k:[40,70,140,.2],p:[10,10,10,0],t:[140,140,255,0],h:[60,80,120,.9],H:[12,12,12,0],n:q(0,
.5),r:1.2,aa:.2,s:q(16,4),g:72,G:12,size:14,i:8,v:1,o:100,speed:2*h,w:.5,N:function(a){a.position.y>G&&0<a.direction.y&&(a.c=0)},A:hb,f:.05}),vb=M,Ib=0,ub=0,tb=0,xa=0,qa=30,mc=.4*db+20*e,sb=0,nb;Q("Almost Ready...",10,function(){z(ka.W,function(){.22>S()&&(ka.position.y+=2,ka.f*=.98);var a=ka.d();a.i=a.size;a.da=0});X.font="20px Verdana";X.textAlign="center";X.fillStyle="#eec";X.shadowColor="#222";X.shadowBlur=4;X.shadowOffsetX=1;X.shadowOffsetY=1});Q("Ready!",2,function(){var a=J.getElementById("start");
a.value="Press to Start!";a.disabled=!1;nb=J.getElementById("overlay");gb(Hb);a.onclick=function(){$a=!0;nb.style.display="none"}});Gb()})();