-
Notifications
You must be signed in to change notification settings - Fork 1
/
esdf.html
241 lines (238 loc) · 47.7 KB
/
esdf.html
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FcR</title>
<style type="text/css">
body {
background: #1A1A1AFF;
/*background: black;*/
margin-top: 0px;
margin-left: 0px;
overflow: hidden;
cursor: crosshair;
}
canvas {
image-rendering: optimizeSpeed;
image-rendering: -moz-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: -o-crisp-edges;
image-rendering: pixelated;
-ms-interpolation-mode: nearest-neighbor;
padding: 0;
margin: auto;
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.stats {
position: relative;
padding: 0;
margin: 0;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
font-size: 16px;
margin: 2px;
z-index: 10;
}
.stats, .modal {
user-select: none;
color: #E1DCDCFF;
font: serif;
text-shadow: -1px 1px #C36278FF;
}
#scrapCount {
display: flex;
margin: 1px;
}
#life {
display: flex;
margin: 1px;
}
.label {
display: flex;
margin: 1px;
padding-left: 10px;
}
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 30px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color:
background-color:
}
.modal-content {
background-color: black;
background-color: rgba(0,0,0,0.8);
color: white;
margin: auto;
padding: 20px;
border: 1px solid #888;
max-width: 60vw;
}
#buildingCage {
/*display: none;*/
position: fixed;
font-size: 24px;
color: red;
padding-top: 46px;
top: 6px;
}
#levelMsg {
padding-top: 24px;
position: fixed;
font-size: 24px;
top: 6px;
}
#intro {
display: block;
}
#stats {
display: none;
}
</style>
</head>
<body oncontextmenu="return false;">
<span class="stats" id="stats">
<span class="label">SCRAPS:</span><span id="scrapCount">0</span>
<span class="label">LIFE:</span><span id="life"></span><span>%</span>
<span class="label">ENERGY:</span><span id="tinfoilHatEnergy">100</span><span>%</span>
</span>
<span class="stats">
<span id="buildingCage"></span>
<div id="levelMsg"></div>
</span>
<span id="intro" class="modal">
<div class="modal-content" style="text-align: left;">
<h3 style="text-align: center;">Faraday cage <span style="color: red;">Rampage</span></h3>
<p>Controls:</p>
<div>w, a, s, d to move,</div>
<div>Left Mouse Button or ← → ↑ ↓ to shoot</div>
<p>Destroy drones with the energy you accumulate on your Tin Foil Hat, collect 10 scraps to build faraday cages around each antenna and get 'em all offline!</p>
<p id="hermitPlace"></p>
<p>PRESS ANY KEY TO START</p>
</div>
</span>
<div id="board" class="modal">
<div class="modal-content">
<p id="boardHeader"></p>
<table>
<tr><td id="scrapPts" style="text-align: right;">100</td><td> pts</td><td id="scrapQtd" style="padding-left: 26px;">0</td><td>× scrap</td></tr>
<tr><td id="dronePts" style="text-align: right;">10000</td><td> pts</td><td id="droneQtd" style="padding-left: 26px;">0</td><td>× drone</td></tr>
<tr><td id="cagePts" style="text-align: right;">0</td><td> pts</td><td id="cageQtd" style="padding-left: 26px;">0</td><td>× cage</td></tr>
</table>
<br>
<p>
<span>TOTAL: </span><span id="totalPts">0</span><span> pts</span>
</p>
<p>
<span id="accScore"></span>
</p>
<br>
<br>
<div id="pressAnyKey"></div>
</div>
</div>
<script type="text/javascript">
function SfxrParams(){this.setSettings=function(a){for(var c=0;24>c;c++)this[String.fromCharCode(97+c)]=a[c]||0;.01>this.c&&(this.c=.01);a=this.b+this.c+this.e;.18>a&&(a=.18/a,this.b*=a,this.c*=a,this.e*=a)}}
function SfxrSynth(){this._params=new SfxrParams;var a,c,d,b,g,e,f,l,h,n,p,q;this.reset=function(){var a=this._params;b=100/(a.f*a.f+.001);g=100/(a.g*a.g+.001);e=1-a.h*a.h*a.h*.01;f=-a.i*a.i*a.i*1E-6;a.a||(p=.5-a.n/2,q=5E-5*-a.o);l=1+a.l*a.l*(0<a.l?-.9:10);h=0;n=1==a.m?0:(1-a.m)*(1-a.m)*2E4+32};this.totalReset=function(){this.reset();var b=this._params;a=b.b*b.b*1E5;c=b.c*b.c*1E5;d=b.e*b.e*1E5+12;return 3*((a+c+d)/3|0)};this.synthWave=function(v,B){var k=this._params,w=1!=k.s||k.v,t=k.v*k.v*.1,N=
1+3E-4*k.w,x=k.s*k.s*k.s*.1,W=1+1E-4*k.t,X=1!=k.s,Y=k.x*k.x,Z=k.g,O=k.q||k.r,ba=k.r*k.r*k.r*.2,P=k.q*k.q*(0>k.q?-1020:1020),Q=k.p?((1-k.p)*(1-k.p)*2E4|0)+32:0,ca=k.d,R=k.j/2,da=k.k*k.k*.01,J=k.a,K=a,ea=1/a,fa=1/c,ha=1/d;k=5/(1+k.u*k.u*20)*(.01+x);.8<k&&(k=.8);k=1-k;for(var L=!1,S=0,C=0,D=0,T=0,H=0,E,F=0,r,y=0,z,M=0,m,U=0,A,V=0,I=Array(1024),G=Array(32),u=I.length;u--;)I[u]=0;for(u=G.length;u--;)G[u]=2*Math.random()-1;for(u=0;u<B;u++){if(L)return u;Q&&++U>=Q&&(U=0,this.reset());n&&++h>=n&&(n=0,b*=
l);e+=f;b*=e;b>g&&(b=g,0<Z&&(L=!0));r=b;0<R&&(V+=da,r*=1+Math.sin(V)*R);r|=0;8>r&&(r=8);J||(p+=q,0>p?p=0:.5<p&&(p=.5));if(++C>K)switch(C=0,++S){case 1:K=c;break;case 2:K=d}switch(S){case 0:D=C*ea;break;case 1:D=1+2*(1-C*fa)*ca;break;case 2:D=1-C*ha;break;case 3:D=0,L=!0}O&&(P+=ba,z=P|0,0>z?z=-z:1023<z&&(z=1023));w&&N&&(t*=N,1E-5>t?t=1E-5:.1<t&&(t=.1));A=0;for(var ia=8;ia--;){y++;if(y>=r&&(y%=r,3==J))for(E=G.length;E--;)G[E]=2*Math.random()-1;switch(J){case 0:m=y/r<p?.5:-.5;break;case 1:m=1-y/r*2;
break;case 2:m=y/r;m=6.28318531*(.5<m?m-1:m);m=1.27323954*m+.405284735*m*m*(0>m?1:-1);m=.225*((0>m?-1:1)*m*m-m)+m;break;case 3:m=G[Math.abs(32*y/r|0)]}w&&(E=F,x*=W,0>x?x=0:.1<x&&(x=.1),X?(H+=(m-F)*x,H*=k):(F=m,H=0),F+=H,T+=F-E,m=T*=1-t);O&&(I[M%1024]=m,m+=I[(M-z+1024)%1024],M++);A+=m}A*=.125*D*Y;v[u]=1<=A?32767:-1>=A?-32768:32767*A|0}return B}}var synth=new SfxrSynth;
window.jsfxr=function(a){synth._params.setSettings(a);var c=synth.totalReset();a=new Uint8Array(4*((c+1)/2|0)+44);c=2*synth.synthWave(new Uint16Array(a.buffer,44),c);var d=new Uint32Array(a.buffer,0,44);d[0]=1179011410;d[1]=c+36;d[2]=1163280727;d[3]=544501094;d[4]=16;d[5]=65537;d[6]=44100;d[7]=88200;d[8]=1048578;d[9]=1635017060;d[10]=c;c+=44;d=0;for(var b="data:audio/wav;base64,";d<c;d+=3){var g=a[d]<<16|a[d+1]<<8|a[d+2];b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g>>18]+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g>>12&63]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g>>6&63]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g&63]}return b};function ArcadeAudio(){this.sounds={}}ArcadeAudio.prototype.add=function(a,c,d){this.sounds[a]=[];d.forEach(function(b,d){this.sounds[a].push({tick:0,count:c,pool:[]});for(var e=0;e<c;e++){var f=new Audio;f.src=jsfxr(b);this.sounds[a][d].pool.push(f)}},this)};
ArcadeAudio.prototype.play=function(a){a=this.sounds[a];a=1<a.length?a[Math.floor(Math.random()*a.length)]:a[0];a.pool[a.tick].play();a.tick<a.count-1?a.tick++:a.tick=0};var aa=new ArcadeAudio;aa.add("powerup",10,[[0,,.01,,.4384,.2,,.12,.28,1,.65,,,.0419,,,,,1,,,,,.3]]);aa.add("laser",5,[[1,,.2843,,.1411,.73,.53,-.5144,,,,-.18,,.5238,-.1934,,.1599,-.0999,.74,.3,,.1,,.5]]);aa.add("damage",3,[[3,,.0331,,.1935,.2152,,-.3201,,,,,,,,,,,1,,,,,.5]]);
aa.add("enemyDamage",3,[[3,,.0331,,.1935,.2152,,-.3201,,,,,,,,,,,1,,,,,.5]]);aa.add("explode",3,[[3,,.1573,.6834,.3784,.0896,,-.0374,,,,,,,,,.5521,-.2586,1,,,,,.5],[3,,.1263,.6704,.4849,.2342,,-.0711,,,,,,,,,.5514,-.1587,1,,,,,.5],[3,,.3588,.2999,.3115,.2253,,.027,,,,-.0804,.6019,,,,,,1,,,,,.5],[3,,.1571,.2424,.3945,.5088,,,,,,,,,,.3524,.3368,-.2398,1,,,,,.5]]);aa.add("unable",3,[[1,,.1678,,.1549,.2163,,,,,,,,,,,,,1,,,.1,,.5]]);
aa.add("caged",3,[[0,,.0926,.3748,.2258,.4546,,,,,,.2032,.6597,,,,,,1,,,,,.6],[1,,.1703,.2941,.5844,.5397,,.1259,-.4125,.5221,,-.0247,.9807,-.0471,,.3219,-.1941,.7949,.5184,.19,.4231,.5086,,.6],[3,.0444,.0123,.2714,.6115,.507,,6E-4,.239,.0587,-.0693,.0743,.9205,-.5129,-.0416,.3263,.2133,.8075,.9423,-.0767,,1E-4,-.3068,.6]]);aa.add("enemyShot",3,[[0,,.23,.1762,.3073,.58,.2,-.3263,-.14,,,-.18,,.5992,-.3439,,,,1,,,,,.25]]);aa.add("newLevel",3,[[1,,.1736,,.4041,.4702,,.3825,,,,,,,,.7227,,,1,,,,,.6]]);
var seed=Date.now();function random(){var a=1E4*Math.sin(.8765111159592828+seed++);return a-Math.floor(a)}random=Math.random;
for(var randomMinMax=function(a,c){return Math.floor(random()*(c-a+1))+a},mapKeys=function(a){return Object.keys(a).map(function(c){return a[c]})},groupBy=function(a,c){for(var d={},b=a.map(function(a){return a[c]}),g,e=0;e<b.length;e++)g=b[e],d[g]||(d[g]=a.filter(function(a){return a[c]===g}));return d},recycle=function(a){for(var c=a.length-1;0<=c;c--)if(a[c]._toRecycle)return a[c]._toRecycle=!1,a[c];return null},randomPick=function(a){return a[randomMinMax(0,a.length-1)]},byId=function(a){return document.getElementById(a)},
RECORD_INPUT=!1,RECORDED_INPUT=[],POOLS="playerBullets enemies enemyBullets shadows antennas scraps explosions cages".split(" "),POOLSize={antennas:10,cages:10,enemyBullets:1E3,playerBullets:1E3},THINGS_PAINT_ORDER="paths shadows decorativeWalls antennas cages scraps players playerBullets enemyBullets enemies explosions walls".split(" "),MAP_SIZE=20,PSIZE=2,TILESCALE=30,ORT_BORN_DIST=PSIZE*MAP_SIZE*4,spriteFactory=function(a,c){a=a||"BBBBBB BBBBBB BBBBBB BBBBBB BBBBBB BBBBBB".split(" ");c=c||{" ":"rgba(255,255,255,0)",
b:"black",B:"blue",R:"red",w:"white",g:"green",G:"#438043",1:"#438043"};var d=document.createElement("canvas");d.width=a[0].length*PSIZE;d.height=a.length*PSIZE;for(var b=d.getContext("2d",{alpha:!0}),g=0;g<a.length;g++)for(var e=a[g].split(""),f=0;f<e.length;f++)b.beginPath(),b.rect(f*PSIZE,g*PSIZE,PSIZE,PSIZE),b.fillStyle=c[e[f]],b.fill(),b.closePath();return d},mirrorCanvas=function(a){var c=document.createElement("canvas"),d=c.getContext("2d");d.height=a.height;d.width=a.width;d.drawImage(a,0,
0);d.clearRect(0,0,a.width,a.height);d.scale(-1,1);d.drawImage(a,0,0,-1*a.width,a.height);return c},buildIdleTileVersions=function(a,c,d){for(var b=[],g=0;g<a.length;g++){var e=d?a[g].map(d):a[g];e={idle:[spriteFactory(e,c)]};b.push(e)}return b},ShadowPalet={" ":"rgba(255,255,255,0)",x:"rgba(0,0,0,0.5)",y:"rgba(0,0,0,0.4)"},ShadowTemplate=[" xxxxxxxxxxx "," xxxxxxxxxxxxxxxxx ","xxxxxxxxxxxxxxxxxxxxx"," xxxxxxxxxxxxxxxxx "," xxxxxxxxxxx "],ShadowSprite=spriteFactory(ShadowTemplate,
ShadowPalet),ShadowTemplate2=["yxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","yxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","xyxxxxxxxxxxxxxxxxxxxxxxxxxxxx","yyxxxyxxxxxyyyxxxxxxxxyxxxxyxx"],ShadowSprite2=spriteFactory(ShadowTemplate2,ShadowPalet),ShadowTemplate3=[" xxxxxx "," xxxxxxxxxxxx ","xxxxxxxxxxxxxxxx"," xxxxxxxxxxxx "," xxxxxx "],ShadowSprite3=spriteFactory(ShadowTemplate3,ShadowPalet),worldFactory=function(a,c,d,b,g,e){a*=PSIZE;var f={count:0,buildingCage:!1,cagesToBuild:0,lost:!1,invalid:!1,scrapCount:0,
energy:100};f.w=a*c;f.h=a*d;f.thingsPaintOrder=THINGS_PAINT_ORDER;f.things={};for(var l=0;l<POOLS.length;l++){f.things[POOLS[l]]=[];for(var h=POOLSize[POOLS[l]]||100;1<=h;h--)f.things[POOLS[l]].push({x:null,y:null,w:null,h:null,speed:null,movex:null,color:null,_toRecycle:!0,xhit:0,yhit:0,whit:null,hhit:null})}f.enemyCount=0;var n=Array.from(Array(c),function(){return Array(d).fill(!0)}),p=function(a,b){return mapKeys({right:n[a+1]?n[a+1][b]:void 0,left:n[a-1]?n[a-1][b]:void 0,bottom:n[a][b+1],top:n[a][b-
1]}).filter(function(a){return void 0!==a})};e=function(a,b){return 0<p(a,b).filter(function(a){return!a}).length};l=randomMinMax(2,c-1)-1;var q=randomMinMax(2,d-1)-1;n[l][q]=!1;PLAYER1.x=l*a+15;PLAYER1.y=q*a+12.5;PLAYER1.toSide=1;PLAYER1.life=100;PLAYER1.speed=200;f.things.players=[PLAYER1];PLAYER1.reactToBulletCollision=function(){this.life-=10;aa.play("damage");byId("life").innerHTML=""+this.life;0>=this.life&&(WORLD.lost=!0,LEVEL=0,byId("pressAnyKey").style.display="none",acceptKeyForNewGame=
!1,window.setTimeout(function(){acceptKeyForNewGame=!0;byId("pressAnyKey").innerHTML="PRESS ANY KEY TO PLAY AGAIN";byId("pressAnyKey").style.display="block"},2E3),byId("boardHeader").style.display="block",byId("boardHeader").innerHTML="You died.",fillBoard(),byId("board").style.display="block",ACCSCORE=0)};h=entityFactory({idle:[ShadowSprite]},recycle(f.things.shadows));h.x=PLAYER1.x;h.y=PLAYER1.y+35;PLAYER1.followers.push(h);var v={},B=0,k=randomMinMax(2,5);for(h=1.5*b;0<=h&&!(v=[{move:"left",p:1===
l?null:random()},{move:"right",p:l===c-2?null:random()},{move:"up",p:1===q?null:random()},{move:"down",p:q===d-2?null:random()}].filter(function(a){return!!a.p}).map(function(a){a.p*=v.move===a.move?1:k;return a}).map(function(a){return a}).sort(function(a,b){return a.p-b.p})[0],"right"===v.move&&++l,"left"===v.move&&--l,"down"===v.move&&++q,"up"===v.move&&--q,!1!==n[l][q]&&B++,n[l][q]=!1,.7<B/b);h--);f.things.walls=[];f.things.decorativeWalls=[];f.things.paths=[];for(h=n.length-1;0<=h;h--)for(l=
n[h].length-1;0<=l;l--)b=entityFactory(randomPick(TILESpritesSet)),b.x=h*a,b.y=l*a,b.yhit=5,b.hhit=b.h-b.yhit,n[h][l]?e(h,l)?f.things.walls.push(b):f.things.decorativeWalls.push(b):(b.sprites=FLOORSpritesSet[randomMinMax(0,FLOORSpritesSet.length-1)],f.things.paths.push(b));f.things.paths.map(function(a){a.pathNeighbors={};a.pathNeighbors.diagonal=f.things.paths.filter(function(b){return Math.abs(b.x-a.x)===a.w&&Math.abs(b.y-a.y)===a.h});a.pathNeighbors.orthogonal=f.things.paths.filter(function(b){return Math.abs(b.x-
a.x)===a.w&&b.y===a.y||Math.abs(b.y-a.y)===a.h&&b.x===a.x})});for(h=0;h<g;h++)(b=randomPick(f.things.paths.filter(function(a){return 4===a.pathNeighbors.diagonal.length&&4===a.pathNeighbors.orthogonal.length&&!a.hasAntenna})))?(b.hasAntenna=!0,a=entityFactory({idle:[spriteFactory(ANTENNASpriteTemplate,ANTENNASpritePalette),spriteFactory(ANTENNASpriteTemplate2,ANTENNASpritePalette)],caged:[spriteFactory(ANTENNASpriteCagedTemplate,ANTENNASpritePalette),spriteFactory(ANTENNASpriteCagedTemplate2,ANTENNASpritePalette)]},
recycle(f.things.antennas)),a.x=b.x,a.y=b.y,a.xhit=5,a.whit-=10,a.yhit=10,a.hhit-=20,a.type="antenna",a.caged=!1,a.buildingCagePct=0,f.cagesToBuild++):f.invalid=!0;g=f.things.paths.filter(function(a){for(var b=a.pathNeighbors.orthogonal,c=0;c<b.length;c++)if(b[c].y<a.y)return!1;return!0});for(h=0;h<g.length;h++)b=entityFactory(randomPick(WALLFACEpritesSet)),b.x=g[h].x,b.y=g[h].y,b.type="perspectiveWall",f.things.decorativeWalls.push(b),a=entityFactory({idle:[ShadowSprite2]},recycle(f.things.shadows)),
a.x=b.x,a.y=b.y+b.h,b.followers.push(a);for(h=0;h<f.things.paths.length;h++){var w=f.things.paths[h];f.things.walls.filter(function(a){return a.y===w.y&&Math.abs(a.x-w.x)===w.w}).map(function(a){a.xhit=6;a.whit=a.w-2*a.xhit;w.isSpawn=!0})}f.enemySpawnArea=f.things.paths.filter(function(a){return a.isSpawn});var t=f.things.walls.concat(f.things.decorativeWalls);f.things.walls.map(function(a){t.filter(function(b){return b.x===a.x+a.w&&b.y===a.y&&"perspectiveWall"!==b.type}).length||a.x/a.w===c-1||(a.sprites=
randomPick(TILESpritesSetHallL));t.filter(function(b){return b.x===a.x-a.w&&b.y===a.y&&"perspectiveWall"!==b.type}).length||0===a.x/a.w||(a.sprites=randomPick(TILESpritesSetHallR));t.filter(function(b){return Math.abs(b.x-a.x)===a.w&&b.y===a.y&&"perspectiveWall"!==b.type}).length||0===a.x/a.w||(a.sprites=randomPick(TILESpritesSetHallRL))});return f},entityFactory=function(a,c){var d={timeline:0,spriteCicle:10,spriteI:0};var b=c?c:{};a.moveLeft=a.moveLeft||a.idle;a.moveRight=a.moveRight||a.idle;b.h=
a.idleRight?a.idleRight[0].height:a.idle[0].height;b.w=a.idleRight?a.idleRight[0].width:a.idle[0].width;b.speed=200;b.lastShoot=null;b.coolDown=20;b.sprites=a;b.idle=Object.create(d);b.move=Object.create(d);b.toSide=null;b._toRecycle=!1;b.xhit=0;b.yhit=0;b.whit=b.w;b.hhit=b.h;b.type="";b.followers=[];b.life=0;b.x=0;b.y=0;b._prevx=0;b._prevy=0;b.spriteSet="";b.hasAntenna=!1;return b},enemyMap={SlimDroneAnim:{speed:200,life:1,coolDown:100,stateChange:30},FatDroneAnim:{speed:100,life:3,coolDown:150,
stateChange:150},TriDroneAnim:{speed:300,life:1,coolDown:50,stateChange:60}},Drone=function(){if(1===LEVEL)var a="SlimDroneAnim";2===LEVEL&&(a=randomPick(["SlimDroneAnim","SlimDroneAnim","FatDroneAnim"]));2<LEVEL&&(a=.3>random()/LEVEL?randomPick(Object.keys(enemyMap)):randomPick(["SlimDroneAnim","FatDroneAnim"]));var c=entityFactory({idle:window[a]},recycle(WORLD.things.enemies));c.explode=function(){this._toRecycle=!0;aa.play("explode");var a=entityFactory({idle:ExplosionIdleAnim},recycle(WORLD.things.explosions));
a.idle.timeline=randomMinMax(0,30);a.x=this.x;a.y=this.y;BOARD.drone+=1;for(a=this.followers.length-1;0<=a;a--)this.followers[a]._toRecycle=!0;--WORLD.enemyCount;a=entityFactory({idle:[spriteFactory(SCRAPSpriteTemplate,SCRAPSpritePalette)]},recycle(WORLD.things.scraps));a.x=this.x+this.w/2;a.y=this.y+.8*this.h};c.reactToBulletCollision=function(){--this.life;0>=this.life?this.explode():aa.play("enemyDamage")};c._aiTimeline=1;c._aiStateChange=enemyMap[a].stateChange;c.coolDown=enemyMap[a].coolDown;
c.speed=enemyMap[a].speed;c.life=enemyMap[a].life;c.ai=function(){this._aiTimeline++;var a=this.x===this._prevx&&this.y===this._prevy;this._aiTimeline%this._aiStateChange||(.6<Math.random()?this.movey=this.movex=0:(this.movex=[-1,0,1][randomMinMax(0,2)],this.movey=[-1,0,1][randomMinMax(0,2)]));if(.9<Math.random()&&a&&WORLD.count-this.lastShoot>=this.coolDown){this.lastShoot=WORLD.count;a=recycle(WORLD.things.enemyBullets);aa.play("enemyShot");a.x=this.x+this.w/2-4*PSIZE/2;a.y=this.y+this.h/2-4*PSIZE/
2;a.w=4*PSIZE;a.h=4*PSIZE;a.speed=400;var b=Math.atan2(PLAYER1.y-this.y,PLAYER1.x-this.x);b+=(randomMinMax(0,10)-5)/20;a.movex=Math.cos(b);a.movey=Math.sin(b);a.color="#FF3D00FF"}};return c},FLOORSpalette={a:"#fd00ff",b:"#92B4B5",c:"#00f9ff",d:"#16EBF0"},FLOORSpritesSet=[],s=0;10>s;s++){for(var FLOOR=[],i=0;30>i;i++){FLOOR.push([]);for(var j=0;30>j;j++)FLOOR[i]+=["c","d"][randomMinMax(0,1)]}FLOORSpritesSet.push({idle:[spriteFactory(FLOOR,FLOORSpalette)]})}
var P1SpriteTemplate=" pypy ; mympppym ; ypmppyppmmym ; yymmmmppmpmymyp ;bHGGGGGbbbGGGbbbb;bHGGGGbwwbbGbwwbb;bHGGGGbwwwbGbwwwb;bHgGGGGbbbGGGbbb ;bHgxGGGGGGGbGGHb ;bHgxGGGGGGGGGGHb ;bHgxGGGGGGbbbGHb ;bHgxGGGGGbwwwbHb ;bHHgxGGGGGbbbGHb ;bHGGGGGGGGGGGGHb ;bHGGGGGGGGGGGHHb ; bHGHHHHHHHdggb ; bHHHHHHHgggb ; bHHbbbbbgggb ; bHb bgb ; bb bb ".split(";"),P1palette={" ":"rgba(255,255,255,0)",x:"#EA9CAE",G:"#C36278",H:"#9C344C",g:"#75142A",b:"black",w:"white",B:"blue",
r:"red",y:"#B9B9B9",m:"#9C9C9C",p:"#828282"},MOVING_LEGS=[spriteFactory(P1SpriteTemplate.map(function(a,c){return c===P1SpriteTemplate.length-4?" bHHHHHHHHgggb ":c===P1SpriteTemplate.length-3?" bgggbbbbbgggb ":c===P1SpriteTemplate.length-2?" bgbb bbb ":c===P1SpriteTemplate.length-1?" bb ":a}),P1palette),spriteFactory(P1SpriteTemplate.map(function(a,c){return c===P1SpriteTemplate.length-4?" bHHHbbbbbgggb ":c===P1SpriteTemplate.length-3?" bbbb bbbb ":c===P1SpriteTemplate.length-
2||c===P1SpriteTemplate.length-1?" ":a}),P1palette),spriteFactory(P1SpriteTemplate.map(function(a,c){return c===P1SpriteTemplate.length-4?" bHHHHHHHHgggb ":c===P1SpriteTemplate.length-3?" bbbbbbbbbggb ":c===P1SpriteTemplate.length-2?" bgb ":c===P1SpriteTemplate.length-1?" bb ":a}),P1palette),spriteFactory(P1SpriteTemplate.map(function(a,c){return c===P1SpriteTemplate.length-4?" bbHHHHHHHgggb ":c===P1SpriteTemplate.length-3?" bbbbbbbggb ":
c===P1SpriteTemplate.length-2?" bgb ":c===P1SpriteTemplate.length-1?" bb ":a}),P1palette),null];MOVING_LEGS[4]=MOVING_LEGS[1];
for(var MOVING_EYES=[spriteFactory(P1SpriteTemplate.map(function(a,c){return c===P1SpriteTemplate.length-10?"bHGGGGGbbbGGGbbbb":c===P1SpriteTemplate.length-11?"bHGGGGbwwbbGbwwbb":c===P1SpriteTemplate.length-12?"bHGGGGbwwwbGbwwwb":c===P1SpriteTemplate.length-13?"bHgGGGGbbbGGGbbb ":a}),P1palette),spriteFactory(P1SpriteTemplate.map(function(a,c){return c===P1SpriteTemplate.length-10?"bHGGGGGbbbGGGbbbb":c===P1SpriteTemplate.length-11?"bHGGGGbbwwbGbbwwb":c===P1SpriteTemplate.length-12?"bHGGGGbwwwbGbwwwb":
c===P1SpriteTemplate.length-13?"bHgGGGGbbbGGGbbb ":a}),P1palette),spriteFactory(P1SpriteTemplate.map(function(a,c){return c===P1SpriteTemplate.length-10?"bHGGGGGbbbGGGbbbb":c===P1SpriteTemplate.length-11?"bHGGGGbwwwbGbwwwb":c===P1SpriteTemplate.length-12?"bHGGGGbbwwbGbbwwb":c===P1SpriteTemplate.length-13?"bHgGGGGbbbGGGbbb ":a}),P1palette),spriteFactory(P1SpriteTemplate.map(function(a,c){return c===P1SpriteTemplate.length-10?"bHGGGGGbbbGGGbbbb":c===P1SpriteTemplate.length-11?"bHGGGGbwwwbGbwwwb":c===
P1SpriteTemplate.length-12?"bHGGGGbwwbbGbwwbb":c===P1SpriteTemplate.length-13?"bHgGGGGbbbGGGbbb ":a}),P1palette)],BLINK_EYES=[],EYE_OPEN=spriteFactory(P1SpriteTemplate.map(function(a,c){return 4===c?"bHGGGGGbbbGGGbbbb":5===c?"bHGGGGbwwbbGbwwbb":6===c?"bHGGGGbwwwbGbwwwb":7===c?"bHgGGGGbbbGGGbbb ":a}),P1palette),_i=0;20>_i;_i++)BLINK_EYES.push(EYE_OPEN);
for(_i=0;1>_i;_i++)BLINK_EYES.push(spriteFactory(P1SpriteTemplate.map(function(a,c){return 4===c?"bHGGGGGGGGGGGGGGb":5===c||6===c?"bHGGGGbbbbbGbbbbb":7===c?"bHgGGGGGGGGGGGGb ":a}),P1palette));var P1Sprites={idleRight:BLINK_EYES,idleLeft:BLINK_EYES.map(function(a){return mirrorCanvas(a)}),moveRight:MOVING_LEGS,moveLeft:MOVING_LEGS.map(mirrorCanvas)},PLAYER1=entityFactory(P1Sprites),TILEpalette={x:"#580758",1:"#520052",2:"#560056",3:"#404040",4:"#78630A"},TILETemplates=[];TILETemplates.push("xxxxxx1xxxxxxxxxxxxxxxxxxxxxxx xxxxxxx1111xxxxxxxxxxxxxxxxxxx xxxxxxxxxxx11xxxxxxxxxxxxxxxxx xxxxxxxxxxxxx1xxxxxxxxxxxxxxxx xxxxxxxxxxxxxx11111xxxxxxxxxxx xxxxxxxxxxxxxxxxxxx1xxxxxxxxxx xxxxxxxxxxxxxxxxxxx1xxxxxxxxxx xxxxxxxxxxxxxxxxxxx1xxxxxxxxxx xxxxxxxxxxxxxxxxxxx1xxxxxxxxxx xxxxxxxx1xxxxxxxxxx11xxxxxxxxx xxxxxxx121xx11xxxxxx1xxxxxxxxx xxx11112x211221xxxxx1xxxxxxxxx xx12222xxx22xx2111xx1xxxxxxxxx x12xxxxxxxxxxxx2221x1xxxxxxxxx 12xxxxxxxxxxxxxxxx21xxxxxx1111 211xxxxxxxxxxxxxxxx2111xx12222 x221xxx1xxxxxxxxxxxx2221122xxx xxx211121xxxxxxxxxxxxxx222111x xxxx222x2111xxxxxxxxxxxxxx2221 xxxxxxxxx22211xxxxxxxxxx111122 xxxxxxxxxxxx221xxxxxx1x12222xx xxxxxxxxxxxxx12111x11212xxxxxx xxxxxxxxxxxx1xx222122x2xxxxxxx xxxxxxxxxxx1xxxxxx2xxxxxxxxxxx xxxxxxxxx11xxxxxxxxxxxxxxxxxxx xxxxxxxxx1xxxxxxxxxxxxxxxxxxxx xxxxxxx111xxxxxxxxxxxxxxxxxxxx xxxxxxx1xxxxxxxxxxxxxxxxxxxxxx xxxxxxx1xxxxxxxxxxxxxxxxxxxxxx xxxxxxx1xxxxxxxxxxxxxxxxxxxxxx".split(" "));
TILETemplates.push("xxxxxxx1xxxxxxxxxxxxxxx11xxxxx xxxxxxx1xxxxxxxxxxxxxxx1xxxxxx xxxxxxx1xxxxxxxxxxxxx111xxxxxx xxxx1111xxxxxxxxxxxxx1xxxxxxxx xxxx1xxxxxxx1111xx1xx1xxxxxxxx xxxx1xxxxxx1222211211xxxxxxxxx xxxx1xxxxx12xxxx22x21xxxxxxxxx xxxx1xxxx12xxxxxxxxx21xxxxxxxx xxxx1xxx12xxxxxxxxxxx2xxxxxxxx xxxx11112xxxxxxxxxxxx2xxxxxxxx xxxx1222xxxxxxxxxxxxx21xxxxxxx xxx12xxxxxxxxxxxxxxxx221xxxxxx xx12xxxxxxxxxxxxxxxxxxx21xxxxx x12xxxxxxxxxxxxxxxxxxxx22111xx 12xxxxxxxxxxxxxxxxxxxxxxx22211 2xxxxxxxxxxxxxxxxxxxxxxx111122 2111xxxxxxxxxxxxxxxxxx112222xx x22211xxxxxxxxxxxxxxx122xxxxxx xxxx221xxxxxxxxxxxxx12xxx11111 xxxxxx2xxxxxxxxxxxx1221x122222 xxxxxx2xxxxxxxxxxx12xx212xxxxx xxxxxx211xxxxxxxx12xxxx2xxxxxx xxxxxx222xxxxxxx12xxxxxxxxxxxx xxxxxxxx2xxxxx112111111xxxxxxx xxxxxxxx2xxxx122xxxxxxx11xxxxx xxxxx111211x12xxxxxxxxxxx1xxxx xxxx11xx22212xxxxxxxxxxx1xxxxx xxxxx1xxxxx2xxxxxxxxxxxx1xxxxx xxxxxx1xxxxxxxxxxxxxxxxx1xxxxx xxxxxxx1xxxxxxxxxxxxxxxx1xxxxx".split(" "));
TILETemplates.push("xxxxxxx1xxxxxxxxxxxxxxx11xxxxx xxxxxxx1xxxxxxxxxxxxxxx1xxxxxx xxxxxxx1xxxxxxxxxxxxx111xxxxxx xxxx1111xxxxxxxxxxxxx1xxxxxxxx xxxx1xxxxxxx1111xx1xx1xxxxxxxx xxxx1xxxxxx1222211211xxxxxxxxx xxxx1xxxxx12xxxx22x21xxxxxxxxx xxxx1xxxx12xxxxxxxxx21xxxxxxxx xxxx1xxx12xxxxxxxxxxx2xxxxxxxx xxxx11112xxxxxxxxxxxx2xxxxxxxx xxxx1222x1xxx11xx1xxx21xxxxxxx xxx12xxxxx111xx11xxxx221xxxxxx xx12xxxxxx11xxx1xxxxxxx21xxxxx x12xxxxxx1xx1x1xx1xxxxx22111xx 12xxxxxx1xxxx1xxxx1xxxxxx22211 2xxxxxxxx1xx1x1xxx1xxxxx111122 2111xx111111111111111x112222xx x22211xxxx11xxxx1xxxx122xxxxxx xxxx221xx1xx1111x1xx12xxx11111 xxxxxx2xxxxxxxxxxxx1221x122222 xxxxxx2xxxxxxxxxxx12xx212xxxxx xxxxxx211xxxxxxxx12xxxx2xxxxxx xxxxxx222xxxxxxx12xxxxxxxxxxxx xxxxxxxx2xxxxx112111111xxxxxxx xxxxxxxx2xxxx122xxxxxxx11xxxxx xxxxx111211x12xxxxxxxxxxx1xxxx xxxx11xx22212xxxxxxxxxxx1xxxxx xxxxx1xxxxx2xxxxxxxxxxxx1xxxxx xxxxxx1xxxxxxxxxxxxxxxxx1xxxxx xxxxxxx1xxxxxxxxxxxxxxxx1xxxxx".split(" "));
TILETemplates.push("xxxxxx12xxxxxxxxxxxxxxxx12xxxx xxxxxx12xxxxxxxxxxxxxxxx12xxxx xxxxxx12xxxxxxxxxxxxxxxx12xxxx xxxxxx12xxxxxxxxxxxxxxx12xxxxx xxxxxx122xxxxxxxxxxxxx12xxxxxx xxxxxxx12xxxxxxxxxxxx12xxxxxxx xxxxxxx12xxxxxxxxxxx12xxxxxxxx xxxxxxx12xxxxxxxxx122xxxxxxxxx xxxxxxx122xxxxxxx12xxxxxxxxxxx xxxxxxxx12xxxxxx12xxxxxxxxxxxx xxxxxxxx12xxxxx12xxxxxxxxxxxxx xxxxxxxx122xxxx12xxxxxxxxxxxxx xxxxxxxxx12xxxxx12xxxxxxxxxxxx xxxxxxxxxx122xxxx12xxxxxxxxxxx 111xxxxxxxx12xxxx12xxxxxx11111 xxx1xxxxxxx12xxxx12xxxxx1xxxxx xxxx1111xxxx12xxx12xxxx1xxxxxx xxxxxxxx111x12x122xxx11xxxxxxx xxxxxxxxxxx1x12211111xxxxxxxxx xxxxxxxxxxxxx122xxxxx1xxxxxxxx xxxxxxxxxxx122x12xxxxx11xxxxxx xxxxxxxxxx12xxx12xxxxxxx1xxxxx xxxxxxxxx12xxxxx122xxxxxx1111x xxxxxxxx122xxxxxxx12xxxxxxxxx1 xxxxxxx12xxxxxxxxxx12xxxxxxxxx xxxx1222xxxxxxxxxxxx12xxxxxxxx xxx122xxxxxxxxxxxxxxx12xxxxxxx xxx12xxxxxxxxxxxxxxxxx122xxxxx xxx12xxxxxxxxxxxxxxxxxxx12xxxx xxx12xxxxxxxxxxxxxxxxxxx12xxxx".split(" "));
TILETemplates.push("xxxxxxxxxxxxxxxxxxxxxxxx1xxxxx xxxxxxxxxxxxxxxxxxxxxx11xxxxxx xxxxxxxxxxxxxxxxxxxxx1xxxxxxxx xxxx2xx2xxxxxxxxxxxx1xxxxxxxxx xxx212212xxxxxxxxxx1xxxxxxxxxx xx21x11x12xxxxxxxx1xxxxxxxxxxx xx1xx1xxx12xxxxxx1xxxxxxxxxxxx xxxxxx1xxx1xxxxxx1xxxxxxxxxxxx xxxxxxx1xxxxxxxxx2xx2xxxxxxxxx xxxxxxxx11xxxxxx212212xxxxxxxx xxxxxxxxxx1xxxx21x11x12xxxxxxx xxxxxxxxxxx1xx21xxxxxx12xxxxxx xxxxxxxxxxx1x11xxxxxxxx2211111 xxxxxxxxxxxx1xxxxxxxxxx111xxxx xxxxxxxxxx11xxxxxxxxxxxxxx1xxx xxxxxxxxx1xxxxxxx2x2xxxxxx1xxx xxxxxxxx1xxxxxxx21212xxxxx1xxx xxxxxxx1xxxxxxx21x1x12xxxx1xxx xxxx2x22xxxxxxx1xxxxx1xxxx1xxx xxx212112xxxxxxxxxxxxx2xxx1xxx xx21x1xx12xxxxxxxxxxxx1xxx1xxx x21xxxxxx12xxxxxxxxxxxxxxxx1xx x1xxxxxxxx1xxxxxxxxx2xxxxxxx1x xxxxxxxxxxxxxxxxxxx212x2xxxx1x xxxxxxxxxxxxxxxxxx21x1212xxx1x xxxxxxxxxxxxxxxxx21xxx1x12xx1x xxxxxxxxxxxxxxxx21xxxxxxx1xxx1 xxxxxxxxxxxxxxxx1xxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".split(" "));
var TILERowVersionBuilder=function(a,c){var d="",b=a.length,g=!1;a.split("").map(function(a,c){"x"===a&&changeCondition(c,b)||g?(d+=["3","4"][randomMinMax(0,1)],g=!g):d+=a;return d});return d},changeCondition=function(a,c){return.996<Math.random()},TILESpritesSet=buildIdleTileVersions(TILETemplates,TILEpalette,TILERowVersionBuilder);changeCondition=function(a,c){return a>c-3&&.8<Math.random()};var TILESpritesSetHallL=buildIdleTileVersions(TILETemplates,TILEpalette,TILERowVersionBuilder);
changeCondition=function(a,c){return 2>a&&.8<Math.random()};var TILESpritesSetHallR=buildIdleTileVersions(TILETemplates,TILEpalette,TILERowVersionBuilder);changeCondition=function(a,c){return(2>a||a>c-3)&&.8<Math.random()};var TILESpritesSetHallRL=buildIdleTileVersions(TILETemplates,TILEpalette,TILERowVersionBuilder),WALLFACEpalette={x:"#2A032A",b:"#2A032A",c:"#2A032A",1:"#331533",2:"#2F002F",3:"#2D2D2D",4:"#584701"},WALLFACETemplates=[];WALLFACETemplates.push("xxxxx1xxxxxxxxxxxxxxxxxxxxxxxx xxxxx1xxxxxxxxxxxxxxxxxxxxxxxx xxxxx1xxxxxxxxxxxxxxxxxxxxxxxx xxxxx1xxxxxxxxxxxxxxxxxxxxxxxx xxxxx1xxxxxxxxxx1xxxxxxxxxxxxx 111111xxxxxxxxxx1xxxxxxxxxxxxx 22222111xxxxx1112xxxxxxxxxxxxx xbbbb2221xxxx122bxxxxxxxxxxxxx xbbbbbbb111112bbbxxxxxxxxxxxxx xbbbbbbb12222bbbbxxxxx44xxxxxx xbbbbbbb1bbbbbbbbxx1xx44xxxxxx".split(" "));
WALLFACETemplates.push("xxxxxxx1xxxxxxxxxxxxxxxxxxxxxx xxxxxx1xxxxxxxxxxxxxxxxxxxxxxx xxxxx1xxxxxxxxxxxxxxxxxxxxxxxx xxx1111xxxxxxxxxxxxxxxxxxxxxxx x1122221xxxxxxxxxxxxxxxxxxxxxx 122bbbbbb2xxxxxxxxxxxxxxxxxxxx 2bbbbbbbb2xxxxxxxxxxxxxxxxxxxx bbbbbbbbb2xxxxxxxxxxxxxxxxxxxx bbbbbbbbb2xxxxxxxxxxxxxxxxxxxx bbb44bbbb2xxxxx2xxxxx111xxx44x bbb44bbbb2xxxxx2111112221xx44x".split(" "));WALLFACETemplates.push("xxxxxxx12xxxxxxxxxxxxxxxxxxxxx xxxxxxxx12xxxxxxxxxxxxxxxxxxxx xxxxxxxx12xxxxxxxxxxxxxxxxxxxx xxxxxxxx12xxxxxxxxxxxxxxxxxxxx xxxxxxxx122xxxxxxxxxxxxxxxxxxx xxxxxxx12x12xxxxxxxxxxxxxxx111 xxxxxxx12bb12xxxxxxxxxxxxxx122 xxxxx122bbbbbxxxxxxxxxx11111bb xxxxx12bbbbbbxxxxxxxxxx12222bb 4xxxx12bbbbbbxxxx44xxxx12bbbbb 4xxx2cbbbbbbb1xxx44xxxxcbbbbbb".split(" "));
var WALLFACEpritesSet=buildIdleTileVersions(WALLFACETemplates,WALLFACEpalette,function(a,c){var d="",b=!1;a.split("").map(function(a){"x"===a&&.97<Math.random()?d+=6<c?"2":"1":0===c&&.8<Math.random()||b?(d+=["3","4"][randomMinMax(0,1)],b=!b):d+=a;return d});return d}),ExplodeTemplate=" ; ; ; ; fffff ; f f ; f f ; fffff ; ; ff ; f f ; f ff ; f f ; f ; ".split(";"),
ExplodeTemplate2=" ; ; ; yyyyyyyy ; y y ; y y ; y y ; yyyyyyyyy ; yyyyyy ; y y ; ff y y ; y y y y ; y y yyyyyy ; ff ; ".split(";"),ExplodeTemplate3=" f f ; ; RRRRRRRRRR ; R RR ; R R ; R R ; R RRRRRRRR ; R R R R ; RRRRRRRRRRRRR ; yyy R R ; y yR R ; y yR R ; y yRRRRRRRR ; yyy ; f ".split(";"),
DroneSpriteTemplate=" bb YY bb ; bbPPbbYYbbPPbb ; bwPPPbYYbwPPPb ;bPPwwPbHHbPwwPPb; bPPPbCCCCbPPwb ; HbbbbMCCMbbbbH ; HCCCCNNNNCCCCH ; HCCCCNjjNCCCCH ; HbbCNNNNCbbH ; bbPPbMCCMbPPbb ; bwPPPbCCbwPPPb ;bPPwwPbHHbPwwPPb; bPPPwbYYbPPPwb ; bbPPbbYYbbPPbb ; bb YY bb ".split(";"),DroneSpriteTemplate2=" bb YY bb ; bbPPbbYYbbPPbb ; bPPPPbYYbPPPPb ;bwwwwwbHHbwwwwwb; bPPPbCCCCbPPPb ; HbbbbMCCMbbbbH ; HCCCCNNNNCCCCH ; HCCCCNjjNCCCCH ; HbbCNNNNCbbH ; bbPPbMCCMbPPbb ; bPPPPbCCbPPPPb ;bwwwwwbHHbwwwwwb; bPPPPbYYbPPPPb ; bbPPbbYYbbPPbb ; bb YY bb ".split(";"),
DroneSpriteTemplate3=" bb YY bb ; bbPPbbYYbbPPbb ; bPPPwbYYbPPPwb ;bPPwwPbHHbPwwPPb; bwPPbCCCCbPPPb ; HbbbbMCCMbbbbH ; HCCCCNNNNCCCCH ; HCCCCNjjNCCCCH ; HbbCNNNNCbbH ; bbPPbMCCMbPPbb ; bPPPwbCCbPPPwb ;bPPwwPbHHbPwwPPb; bwPPPbYYbwPPPb ; bbPPbbYYbbPPbb ; bb YY bb ".split(";"),DroneSpriteTemplate4=" bb YY bb ; bbwPbbYYbbwPbb ; bPwPPbYYbPwPPb ;bPPPwPbHHbPPwPPb; bPPwbCCCCbPwPb ; HbbbbMCCMbbbbH ; HCCCCNNNNCCCCH ; HCCCCNjjNCCCCH ; HbbCNNNNCbbH ; bbwPbMCCMbwPbb ; bPwPPbCCbPwPPb ;bPPPwPbHHbPPwPPb; bPPwPbYYbPPwPb ; bbwwbbYYbbwwbb ; bb YY bb ".split(";"),
TriDroneSpriteTemplate=" bb ; bbPPbb ; bwPPPb ; bPPwwPPb ; bPPPbb ; bbbb ; NN ; NjjN ; bb NNNN bb ; bbPPbM MbPPbb ; bwPPPb bwPPPb ;bPPwwPb bPwwPPb; bPPPwb bPPPwb ; bbPPbb bbPPbb ; bb bb ".split(";"),TriDroneSpriteTemplate2=" bb ; bbPPbb ; bPPPPb ; bwwwwwPb ; bPPPbb ; bbbb ; NN ; NjjN ; bb NNNN bb ; bbPPbM MbPPbb ; bPPPPb bPPPPb ;bwwwwwb bwwwwwb; bPPPPb bPPPPb ; bbPPbb bbPPbb ; bb bb ".split(";"),
TriDroneSpriteTemplate3=" bb ; bbPPbb ; bPPPwb ; bPPwwPPb ; bwPPbb ; bbbb ; NN ; NjjN ; bb NNNN bb ; bbPPbM MbPPbb ; bPPPwb bPPPwb ;bPPwwPb bPwwPPb; bwPPPb bwPPPb ; bbPPbb bbPPbb ; bb bb ".split(";"),TriDroneSpriteTemplate4=" bb ; bbwPbb ; bPwPPb ; bPPPwPPb ; bPPwbb ; bbbb ; NN ; NjjN ; bb NNNN bb ; bbwPbM MbwPbb ; bPwPPb bPwPPb ;bPPPwPb bPPwPPb; bPPwPb bPPwPb ; bbwwbb bbwwbb ; bb bb ".split(";"),
DroneSpritePalette={" ":"rgba(255,255,255,0)",b:"black",w:"#232323A4",g:"#C1BEBEFF",N:"#2B2B2B",M:"#2B2B2BFF",r:"red",P:"#7D7A7A8A",j:"#0F0060FF",f:"#D2D301FF",y:"#D59C12FF",R:"#B42200FF",C:"#130077FF",H:"black"},ExplosionIdleAnim=[spriteFactory(ExplodeTemplate,DroneSpritePalette),spriteFactory(ExplodeTemplate2,DroneSpritePalette),spriteFactory(ExplodeTemplate3,DroneSpritePalette),spriteFactory(ExplodeTemplate3,DroneSpritePalette)],EnemyTemplateArray=[DroneSpriteTemplate,DroneSpriteTemplate2,DroneSpriteTemplate3,
DroneSpriteTemplate4],spriteFactorySequence=function(a,c){return a.map(function(a){return spriteFactory(a,c)})},SlimDroneAnimTemplateArray=EnemyTemplateArray.map(function(a){return a.map(function(a){return a.replace(/C/g," ").replace(/H/g," ").replace(/Y/g," ")})}),SlimDroneAnim=spriteFactorySequence(SlimDroneAnimTemplateArray,DroneSpritePalette),FatDroneAnimTemplateArray=EnemyTemplateArray.map(function(a){return a.map(function(a){return a.replace(/N/g,"C").replace(/M/g,"C").replace(/Y/g,"C").replace(/H/g,
"C")})}),FatDroneAnim=spriteFactorySequence(FatDroneAnimTemplateArray,DroneSpritePalette),EnemyTriDroneTemplateArray=[TriDroneSpriteTemplate,TriDroneSpriteTemplate2,TriDroneSpriteTemplate3,TriDroneSpriteTemplate4],SlimTriDroneAnimTemplateArray=EnemyTriDroneTemplateArray.map(function(a){return a.map(function(a){return a.replace(/C/g," ").replace(/H/g," ")})}),TriDroneAnim=spriteFactorySequence(SlimTriDroneAnimTemplateArray,DroneSpritePalette),ANTENNASpriteTemplate=" R ; r ; x ; xxxxxxxxxxxxxxxxxxxxxxxxxxx ; x x x x x x x x x x x ;xx x x x x x x x x x x;xddddddddddddbbwbbddddddddddddx;x x x x x xw x x x x x; xx x x x x xw x x x xx ; xxxxxxxxxxxxxxxxxxxxxxxxx ; xx xx ; vvvvvvvvx x x x x ; bbbbbbbbbxbbxcxxxbbxbbbbbbbbb ;bbcccccccbbxxxxxxxxxbbbbbbbbbbb;bncccccccccccnxxxccnccccccccccc;bcccccccccnccccccccccnnnnnnnccc;bccccbccccccccccnbccncccccbbccc".split(";"),
ANTENNASpriteTemplate2=Object.create(ANTENNASpriteTemplate);ANTENNASpriteTemplate2[0]=ANTENNASpriteTemplate[0].replace("R","r");var ANTENNASpriteCagedTemplate="eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee;e e e e e e e;e e e e e e e;e e e e e e e;eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee;e e e e e e e;e e e e e e e;e b e e e e e;eeeeeeeeeeeeeeeeeebbeeeeeeeeeee;e e e e e e e;e e e e b e e;e e b e e e e;eeeeeeebeeeeeeeeeeeeeeeeeeeeeee;e e e e e e e;e b e e b e e;e e e e e e e;eebeeeeeeeeeeeeeeeeeeeebeeeeeee".split(";");
ANTENNASpriteCagedTemplate=ANTENNASpriteTemplate.map(function(a,c){return c%4?a.split("").map(function(a,b){return b%6?ANTENNASpriteTemplate[c][b]:"e"}).join(""):"e".repeat(a.length)});var ANTENNASpriteCagedTemplate2=Object.create(ANTENNASpriteCagedTemplate);ANTENNASpriteCagedTemplate2[0]=ANTENNASpriteCagedTemplate[0].replace("R","r");
var ANTENNASpritePalette={" ":"rgba(255,255,255,0)",x:"black",b:"#4C4C4CFF",c:"#736767FF",n:"#7F7373FF",d:"#292929FF",e:"#292929FF",r:"#9A0000",R:"#FF3737",w:"white"},SCRAPSpriteTemplate=["cccdc","cbcdd","bdccc","cccdd","cccdc"],SCRAPSpritePalette={b:"#4C4C4CFF",d:"#BDBDBDFF",c:"#736767FF"};
spriteFactory=function(a,c){a=a||"BBBBBB BBBBBB BBBBBB BBBBBB BBBBBB BBBBBB".split(" ");c=c||{" ":"rgba(255,255,255,0)",b:"black",B:"blue",R:"red",w:"white",g:"green",G:"#438043",1:"#438043"};var d=document.createElement("canvas");d.width=a[0].length*PSIZE;d.height=a.length*PSIZE;for(var b=d.getContext("2d",{alpha:!0}),g=0;g<a.length;g++)for(var e=a[g].split(""),f=0;f<e.length;f++)b.beginPath(),b.rect(f*PSIZE,g*PSIZE,PSIZE,PSIZE),b.fillStyle=c[e[f]],b.fill(),b.closePath();return d};
mirrorCanvas=function(a){var c=document.createElement("canvas"),d=c.getContext("2d");d.height=a.height;d.width=a.width;d.drawImage(a,0,0);d.clearRect(0,0,a.width,a.height);d.scale(-1,1);d.drawImage(a,0,0,-1*a.width,a.height);return c};buildIdleTileVersions=function(a,c,d){for(var b=[],g=0;g<a.length;g++){var e=d?a[g].map(d):a[g];e={idle:[spriteFactory(e,c)]};b.push(e)}return b};ShadowPalet={" ":"rgba(255,255,255,0)",x:"rgba(0,0,0,0.5)",y:"rgba(0,0,0,0.4)"};
ShadowTemplate=[" xxxxxxxxxxx "," xxxxxxxxxxxxxxxxx ","xxxxxxxxxxxxxxxxxxxxx"," xxxxxxxxxxxxxxxxx "," xxxxxxxxxxx "];ShadowSprite=spriteFactory(ShadowTemplate,ShadowPalet);ShadowTemplate2=["yxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","yxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","xyxxxxxxxxxxxxxxxxxxxxxxxxxxxx","yyxxxyxxxxxyyyxxxxxxxxyxxxxyxx"];ShadowSprite2=spriteFactory(ShadowTemplate2,ShadowPalet);ShadowTemplate3=[" xxxxxx "," xxxxxxxxxxxx ","xxxxxxxxxxxxxxxx"," xxxxxxxxxxxx "," xxxxxx "];
ShadowSprite3=spriteFactory(ShadowTemplate3,ShadowPalet);
var getBodyCoords=function(a){return{x0:a.x+(a.xhit||0),x1:a.x+(a.whit||a.w)+(a.xhit||0),y0:a.y+(a.yhit||0),y1:a.y+(a.hhit||a.h)+(a.yhit||0)}},getPrevItemProps=function(a){return{x:a._prevx?a._prevx:a.x,y:a._prevy?a._prevy:a.y,w:a.w,h:a.h,xhit:a.xhit,yhit:a.yhit,whit:a.whit,hhit:a.hhit}},checkAxisOverlap=function(a,c,d){var b=[a[d+"0"],a[d+"1"],c[d+"0"],c[d+"1"]];b=b[0]<=b[1]&&b[1]<=b[2]&&b[2]<=b[3]?b:b[0]<=b[2]&&b[2]<=b[1]&&b[1]<=b[3]?[b[0],b[2],b[1],b[3]]:b[2]<=b[3]&&b[3]<=b[0]&&b[0]<=b[1]?[b[2],
b[3],b[0],b[1]]:b.sort(function(a,b){return a-b});return{overlap:a[d+"1"]>c[d+"0"]&&a[d+"0"]<c[d+"1"],val:b[2]-b[1]}},checkCollision=function(a,c,d,b){d=d?d:4*a.w;b=[];for(var g,e,f=0;f<c.length;f++)c[f]._toRecycle||(g=c[f].x-a.x,g=0>g?-1*g:g,e=c[f].y-a.y,e=0>e?-1*e:e,(g<d||e<d)&&b.push(c[f]));c=getBodyCoords(a);g=[];for(f=b.length-1;0<=f;f--){d=b[f];var l=getBodyCoords(d);e=checkAxisOverlap(c,l,"x");var h=checkAxisOverlap(c,l,"y");e.overlap&&h.overlap&&(l=e.val*h.val,g.push({source:a,target:d,area:l,
overlapx:e,overlapy:h}))}return g.sort(function(a,b){return a.area-b.area})},handlePlayerColl=function(a){2!==a.length||a[0].target.y!==a[1].target.y&&a[0].target.x!==a[1].target.x||(a=[Math.abs(a[0].area)>Math.abs(a[1].area)?a[0]:a[1]]);var c=["y","x"];for(var d=a.length-1;0<=d;d--){var b=a[d].source;var g=a[d].target;var e=getBodyCoords(b);var f=getBodyCoords(g);for(var l=c.length-1;0<=l;l--){var h=getBodyCoords(getPrevItemProps(b));var n=getBodyCoords(getPrevItemProps(g));var p=c[l];if(n=!checkAxisOverlap(h,
n,p).overlap)h=Math.abs(b[p]-h[p+"0"])/(b[p]-h[p+"0"])||0,n=Math.min(Math.abs(e[p+"0"]-f[p+"1"]),Math.abs(e[p+"1"]-f[p+"0"])),b[p]-=n*h}}},handleBulletWallColl=function(a){a.length&&(a[0].source._toRecycle=!0)},handlePlayerScrapColl=function(a){if(a.length)for(var c=a.length-1;0<=c;c--)a[c].target._toRecycle=!0,WORLD.scrapCount+=1,BOARD.scrap+=1,aa.play("powerup")},handleBulletThingColl=function(a){if(a.length){for(var c=a.length-1;0<=c;c--)a[c].target.reactToBulletCollision&&a[c].target.reactToBulletCollision(a);
a[0].source._toRecycle=!0}},lastTime=timestamp(),stats;function timestamp(){return window.performance&&window.performance.now?window.performance.now():Date.now()}function raf(a){return window.requestAnimationFrame(function(){stats&&stats.begin();var c=timestamp(),d=c-lastTime;lastTime=c;a(999<d?1/60:d/1E3);stats&&stats.end()})}
var start=function(a){return raf(function b(d){a(d);raf(b)})},lifeEl=byId("life"),scrapEl=byId("scrap"),buildingCageEl=byId("buildingCage"),pressAnyKeyEl=byId("pressAnyKey"),levelMsgEl=byId("levelMsg"),boardHeaderEl=byId("boardHeader"),boardEl=byId("board"),scrapCountEl=byId("scrapCount"),introEl=byId("intro"),statsEl=byId("stats"),tinfoilHatEnergyEl=byId("tinfoilHatEnergy"),canvas=document.createElement("canvas");canvas.id="canvas";document.body.appendChild(canvas);
var vw,vh,setCanvasSize=function(){vw=Math.min(window.innerWidth,640);vh=Math.min(window.innerHeight,480);canvas.width=vw;canvas.height=vh};setCanvasSize();window.onresize=function(a){setCanvasSize()};var CAMERA,ctx=canvas.getContext("2d",{alpha:!1}),TYPES=THINGS_PAINT_ORDER.reverse(),TIME_FACTOR,WasCloseToBuildCage=null;
function update(a){0===WORLD.count&&(lifeEl.innerHTML=player.life,levelMsgEl.style.display="block",levelMsgEl.innerHTML="Level "+LEVEL,aa.play("newLevel"),window.setTimeout(function(){levelMsgEl.style.display="none"},1500));TIME_FACTOR=.01;WORLD.scrapCount!==scrapCountPrev&&(scrapCountPrev=scrapCountEl.innerHTML=WORLD.scrapCount);WORLD.lost||(ctx.clearRect(0,0,canvas.width,canvas.height),ctx.rect(0,0,canvas.width,canvas.height),ctx.fillStyle="#000000",ctx.fill(),ctx.closePath());WORLD.recoredInput?
(CAMERA={xoffset:player.w/2+player.x-vw/2,yoffset:player.h/2+player.y-vh/2},WORLD.recoredInput[WORLD.count]?INPUT=WORLD.recoredInput[WORLD.count]:WORLD.test()):CAMERA={xoffset:~~(.8*CAMERA.xoffset+.2*(player.w/2+player.x-vw+INPUT.mousex)),yoffset:~~(.8*CAMERA.yoffset+.2*(player.h/2+player.y-vh+INPUT.mousey))};RECORD_INPUT&&RECORDED_INPUT.push(cloneInput());for(var c=TYPES.length-1;0<=c;c--){a=WORLD.things[TYPES[c]];for(var d=a.length-1;0<=d;d--){var b=a[d];if(!b._toRecycle){if(b.x+b.w>CAMERA.xoffset&&
b.x<CAMERA.xoffset+vw&&b.y+b.h>CAMERA.yoffset&&b.y<CAMERA.yoffset+vh&&b.sprites){var g=null;if(b.movex||b.movey){g=-1===b.toSide?"moveLeft":"moveRight";var e="move"}else g=""!==b.spriteSet?b.spriteSet:b.toSide?-1===b.toSide?"idleLeft":"idleRight":"idle",e="idle";if(g){var f=b.sprites[g][b[e].spriteI];b[e].timeline%b[e].spriteCicle||(b[e].spriteI<b.sprites[g].length-1?b[e].spriteI++:b[e].spriteI=0);ctx.drawImage(f,~~(b.x-CAMERA.xoffset),~~(b.y-CAMERA.yoffset));b[e].timeline++}}else b.x+b.w>CAMERA.xoffset&&
b.x<CAMERA.xoffset+vw&&b.y+b.h>CAMERA.yoffset&&b.y<CAMERA.yoffset+vh&&(ctx.beginPath(),ctx.rect(~~(b.x-CAMERA.xoffset),~~(b.y-CAMERA.yoffset),~~b.w,~~b.h),ctx.fillStyle=b.color||"#00ff00",ctx.fill(),ctx.closePath());if(!WORLD.lost){b._prevx=b.x;b._prevy=b.y;"explosions"===TYPES[c]&&40===b.idle.timeline&&(b._toRecycle=!0);if("playerBullets"===TYPES[c]||"enemyBullets"===TYPES[c]){if(b.x>WORLD.w||0>b.x+b.w||b.y>WORLD.h||0>b.y+b.h){b._toRecycle=!0;continue}e=checkCollision(b,WORLD.things.walls,void 0,
!0);handleBulletWallColl(e);"playerBullets"===TYPES[c]&&(e=checkCollision(b,WORLD.things.enemies),handleBulletThingColl(e));"enemyBullets"===TYPES[c]&&(e=checkCollision(b,WORLD.things.players),handleBulletThingColl(e))}b.movex&&(b.x+=b.movex*TIME_FACTOR*b.speed);b.movey&&(b.y+=b.movey*TIME_FACTOR*b.speed);b.ai&&b.ai();if("enemies"===TYPES[c]||"players"===TYPES[c])e=checkCollision(b,WORLD.things.walls.concat(WORLD.things.antennas)),handlePlayerColl(e),tinfoilHatEnergyEl.innerHTML=~~WORLD.energy;"enemies"!==
TYPES[c]||WORLD.cagesToBuild||b.explode();"players"===TYPES[c]&&(handleInput(player),e=checkCollision(b,WORLD.things.scraps),handlePlayerScrapColl(e));"antennas"!==TYPES[c]||b.caged||(e=b.x-player.x+15,g=b.y-player.y,f=b.w/2+player.w/2,f*=f,e=e*e+g*g,100>WORLD.energy&&(WORLD.energy+=1/e*200),e<=1.5*f?(b.closeToBuildCage=!0,WORLD.scrapCount<scrapsToBuildCage||(b.buildingCage||(b.buildingCage=!0),b.buildingCagePct+=1,buildingCageEl.innerHTML=~~(b.buildingCagePct/buildingCagePctTarget*100),b.buildingCagePct>=
buildingCagePctTarget&&(b.buildingCagePct=0,WORLD.cagesToBuild--,b.caged=!0,aa.play("caged"),b.closeToBuildCage=!1,b.spriteSet="caged",BOARD.cage+=1,WORLD.scrapCount-=scrapsToBuildCage))):(b.closeToBuildCage=!1,b.buildingCage&&(b.buildingCage=!1,b.buildingCagePct=0)));if(b.followers)for(e=b.followers.length-1;0<=e;e--)b.followers[e].x+=b.x-b._prevx,b.followers[e].y+=b.y-b._prevy}}}}if(!WORLD.lost){a=!1;for(b=WORLD.things.antennas.length-1;0<=b;b--)a=a||WORLD.things.antennas[b].closeToBuildCage;WasCloseToBuildCage!==
a&&(a&&WORLD.scrapCount<scrapsToBuildCage&&(buildingCageEl.innerHTML="You need 10 scraps to build a cage",aa.play("unable")),a||(buildingCageEl.innerHTML=""));WasCloseToBuildCage=a;0===WORLD.cagesToBuild&&(WORLD.cagesToBuild=null,levelMsgEl.style.display="block",levelMsgEl.innerHTML="Level Disrupted!",pressAnyKeyEl.style.display="none",window.setTimeout(function(){levelMsgEl.style.display="none";window.setTimeout(function(){boardHeaderEl.style.display="block";boardHeaderEl.innerHTML="";boardEl.style.display=
"block";fillBoard();window.setTimeout(function(){acceptKeyForNewGame=!0;pressAnyKeyEl.innerHTML="PRESS ANY KEY TO NEXT LEVEL";pressAnyKeyEl.style.display="block"},2E3)},2E3)},2E3));a=0>=WORLD.enemyCount&&!((WORLD.count+1)%30);WORLD.cagesToBuild&&(a||!((WORLD.count+1)%100)&&WORLD.enemyCount<WORLD.maxEnemies)&&(a=randomMinMax(0,WORLD.enemySpawnArea.length-1),b=WORLD.enemySpawnArea[a],Math.abs(b.x-WORLD.things.players[0].x)>ORT_BORN_DIST||Math.abs(b.x-WORLD.things.players[0].x)>ORT_BORN_DIST)&&(a=Drone(),
WORLD.enemyCount+=1,a.x=b.x,a.y=b.y,b=entityFactory({idle:[ShadowSprite3]},recycle(WORLD.things.shadows)),b.x=a.x+2,b.y=a.y+30,a.followers.push(b));WORLD.count+=1}}
var WORLD,scrapCountPrev,player,buildingCagePctTarget=400,scrapsToBuildCage=10,LEVEL=0,ACCSCORE=0,BOARD,fillBoard=function(){var a=1*BOARD.scrap;document.getElementById("scrapPts").innerText=a;var c=2*BOARD.drone;document.getElementById("dronePts").innerText=c;var d=10*BOARD.cage;document.getElementById("cagePts").innerText=d;document.getElementById("scrapQtd").innerText=BOARD.scrap;document.getElementById("droneQtd").innerText=BOARD.drone;document.getElementById("cageQtd").innerText=BOARD.cage;var b=
a+c+d;document.getElementById("totalPts").innerText=a+c+d;ACCSCORE+=b;a=~~localStorage.getItem("highScore");ACCSCORE>a?(document.getElementById("accScore").innerText="ACCUMULATED: "+ACCSCORE+" pts. NEW HIGHSCORE!",localStorage.setItem("highScore",ACCSCORE)):document.getElementById("accScore").innerText="ACCUMULATED: "+ACCSCORE+" pts. HIGHSCORE: "+a},newLevel=function(a,c,d,b){LEVEL++;a=Math.min(8+LEVEL,15)||13;c=c||a;d=a*a;b=b||Date.now();for(var g,e=Math.min(POOLSize.antennas,~~(1+.4*LEVEL)),f=0;100>
f&&(g=worldFactory(TILESCALE,a,c,d,e,b),g.invalid);f++);g.maxEnemies=~~(2.4*LEVEL);buildingCagePctTarget=400;scrapsToBuildCage=10;player=g.things.players[0];player.lastShoot=-1;scrapCountPrev=null;BOARD={scrap:0,drone:0,cage:0};WORLD=g},INPUT={moveLeft:null,moveRight:null,moveUp:null,moveDown:null,fireLeft:null,fireRight:null,fireUp:null,fireDown:null,mousex:null,mousey:null,mouseDownCount:0,mouseDown:[0,0,0,0,0,0,0,0,0]},acceptKeyForNewGame=!0,startNewLevel=function(){acceptKeyForNewGame=!1;WORLD||
start(update);newLevel();CAMERA={xoffset:player.w/2+player.x-vw+INPUT.mousex,yoffset:player.h/2+player.y-vh+INPUT.mousey};WORLD.lost=!1;document.getElementById("board").style.display="none";introEl.style.display="none";statsEl.style.display="flex";INPUT.moveLeft=null;INPUT.moveRight=null;INPUT.moveUp=null;INPUT.moveDown=null;INPUT.fireLeft=null;INPUT.fireRight=null;INPUT.fireUp=null;INPUT.fireDown=null;INPUT.mouseDownCount=0;INPUT.mouseDown=[0,0,0,0,0,0,0,0,0]};
document.onkeydown=function(a){acceptKeyForNewGame&&startNewLevel();27===a.keyCode&&RECORD_INPUT&&stopRecordFn();83===a.keyCode&&(INPUT.moveLeft=!0);70===a.keyCode&&(INPUT.moveRight=!0);69===a.keyCode&&(INPUT.moveUp=!0);68===a.keyCode&&(INPUT.moveDown=!0);37===a.keyCode&&(INPUT.fireLeft=!0);39===a.keyCode&&(INPUT.fireRight=!0);38===a.keyCode&&(INPUT.fireUp=!0);40===a.keyCode&&(INPUT.fireDown=!0)};
document.onkeyup=function(a){83===a.keyCode&&(INPUT.moveLeft=!1);70===a.keyCode&&(INPUT.moveRight=!1);69===a.keyCode&&(INPUT.moveUp=!1);68===a.keyCode&&(INPUT.moveDown=!1);37===a.keyCode&&(INPUT.fireLeft=!1);39===a.keyCode&&(INPUT.fireRight=!1);38===a.keyCode&&(INPUT.fireUp=!1);40===a.keyCode&&(INPUT.fireDown=!1)};INPUT.mousex=~~window.innerWidth/2;INPUT.mousey=~~window.innerHeight/2;
document.onmousemove=function(a){if(!WORLD||!WORLD.lost){var c=canvas.getBoundingClientRect();INPUT.mousex=a.clientX-c.x;INPUT.mousey=a.clientY-c.top}};INPUT.mouseDown=[0,0,0,0,0,0,0,0,0];INPUT.mouseDownCount=0;document.onmousedown=function(a){acceptKeyForNewGame&&startNewLevel();++INPUT.mouseDown[a.button];0===INPUT.mouseDownCount&&++INPUT.mouseDownCount};document.onmouseup=function(a){acceptKeyForNewGame&&startNewLevel();--INPUT.mouseDown[a.button];0<INPUT.mouseDownCount&&--INPUT.mouseDownCount};
var cloneInput=function(){return{moveLeft:INPUT.moveLeft,moveRight:INPUT.moveRight,moveUp:INPUT.moveUp,moveDown:INPUT.moveDown,fireLeft:INPUT.fireLeft,fireRight:INPUT.fireRight,fireUp:INPUT.fireUp,fireDown:INPUT.fireDown,mousex:INPUT.mousex,mousey:INPUT.mousey,mouseDownCount:INPUT.mouseDownCount,mouseDown:INPUT.mouseDown}},handleInput=function(a){a.movex=0;a.movey=0;INPUT.moveLeft&&INPUT.moveRight||(INPUT.moveLeft&&(a.movex=-1),INPUT.moveRight&&(a.movex=1));a.toSide=0!==a.movex?a.movex:a.toSide;INPUT.moveUp&&
INPUT.moveDown||(INPUT.moveUp&&(a.movey=-1),INPUT.moveDown&&(a.movey=1));if((INPUT.mouseDownCount||INPUT.fireRight||INPUT.fireLeft||INPUT.fireUp||INPUT.fireDown)&&WORLD.energy&&!(WORLD.count-a.lastShoot<a.coolDown)){var c=4*PSIZE;var d=recycle(WORLD.things.playerBullets);d.x=~~a.x+a.w/2-c/2;d.y=~~a.y+a.h/10;d.w=c;d.h=c;d.xhit=c;d.yhit=c;d.speed=800;d.movex=0;d.movey=0;d.whit=c;d.hhit=c;INPUT.mouseDownCount?(c=Math.atan2(INPUT.mousey-(d.y+d.w/2-CAMERA.yoffset),INPUT.mousex-(d.x+d.h/2-CAMERA.xoffset)),
c+=randomMinMax(-5,5)/100,d.movex=Math.cos(c),d.movey=Math.sin(c)):INPUT.fireRight||INPUT.fireLeft?d.movex=INPUT.fireRight?1:-1:d.movey=INPUT.fireDown?1:-1;d.color="#C36278";a.lastShoot=WORLD.count;--WORLD.energy;0>WORLD.energy&&(WORLD.energy=0);aa.play("laser")}};
</script>
</body>
</html>