v1.2 of Missile Command like game. Score is now alerted before game restarts. Use mouse to aim and shoot.
d=document;c=d.getElementById('c');n=c.getContext('2d');w=c.width=640;h=c.height=480;a=Math;r=a.random;A=a.atan2;B=a.ceil;q();d.onclick=function(e){y=e.pageY;O.push([w/2,h,y,A(y-h,e.pageX-w/2),7,0]);t--};setInterval(function(){if(t<0)t=0;n.fillStyle="#000";n.fillRect(i=0,0,w,h);n.fillStyle="#FFF";n.fillText(m+"♥ "+t,H=3,9);while(i<O.length){o=O[i];x=o[s=0];y=o[1];g=o[2];F=o[3];if(o.length<6){n.beginPath();n.arc(x,y,g,0,9,0);n.closePath();n.fill();o[2]+=F;if(g>48)o[3]=-1;if(!g)E(i)}else{u=B(o[5]*(a.cos(F)))+x;v=B(o[5]*(a.sin(F)))+y;while(!g&&s<O.length){e=O[s++];if(e.length<6){X=e[0]-u;Y=e[1]-v;j=a.sqrt(X*X+Y*Y);if(j<=e[2]){E(i);E(u,v);t+=2;M();break}}}n.beginPath();n.moveTo(x,y);n.lineTo(u,v);n.closePath();n.strokeStyle="#00F";if(!y)n.strokeStyle="red";n.stroke();o[5]+=o[4];if(v>h){E(i);M();m--;if(!m){alert(t);q()}}if(v<g){E(u,v);E(i)}}i++}},9);function q(){m=3;t=5;O=[];while(--t)M()}function M(){k=B(r()*w);O.push([k,0,0,A(h,B(r()*w)-k),t/50+.3,0])}function E(x,y){if(y)O.push([x,y,4,1]);else O.splice(x,1)}
ZD1kb2N1bWVudDtjPWQuZ2V0RWxlbWVudEJ5SWQoJ2MnKTtuPWMuZ2V0Q29udGV4dCgnMmQnKTt3PWMud2lkdGg9NjQwO2g9Yy5oZWlnaHQ9NDgwO2E9TWF0aDtyPWEucmFuZG9tO0E9YS5hdGFuMjtCPWEuY2VpbDtxKCk7ZC5vbmNsaWNrPWZ1bmN0aW9uKGUpe3k9ZS5wYWdlWTtPLnB1c2goW3cvMixoLHksQSh5LWgsZS5wYWdlWC13LzIpLDcsMF0pO3QtLX07c2V0SW50ZX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BsaWNlKHgsMSl9
d = document;
c = d.getElementById('c');
n = c.getContext('2d');
w = c.width = 640;
h = c.height = 480;
a = Math;
r = a.random;
A = a.atan2;
B = a.ceil;
q();
d.onclick = function(e)
{
y = e.pageY;
O.push([w/2, h, y, A(y - h, e.pageX - w/2), 7, 0]);
t--
};
setInterval(function ()
{
if(t<0)
t=0;
n.fillStyle = "#000";
n.fillRect(i=0, 0, w, h);
n.fillStyle = "#FFF";
n.fillText(m + "♥ " + t, H=3, 9);
while(i < O.length)
{
o = O[i];
x = o[s=0];
y = o[1];
g = o[2];
F = o[3];
if(o.length < 6)
{
n.beginPath();
n.arc(x, y, g, 0, 9, 0);
n.closePath();
n.fill();
o[2] += F;
if(g > 48)
o[3] = -1;
if(!g)
E(i)
}
else
{
u = B(o[5] * (a.cos(F))) + x;
v = B(o[5] * (a.sin(F))) + y;
while(!g&&s < O.length)
{
e = O[s++];
if(e.length < 6)
{
X = e[0] - u;
Y = e[1] - v;
j = a.sqrt(X * X + Y * Y);
if(j <= e[2])
{
E(i);
E(u, v);
t+=2;
M();
break
}
}
}
n.beginPath();
n.moveTo(x, y);
n.lineTo(u, v);
n.closePath();
n.strokeStyle = "#00F";
if(!y)
n.strokeStyle = "red";
n.stroke();
o[5] += o[4];
if(v > h)
{
E(i);
M();
m--;
if(!m)
{
alert(t);
q()
}
}
if(v < g)
{
E(u, v);
E(i)
}
}
i++
}
}, 9);
function q()
{
m = 3;
t = 5;
O = [];
while(--t)
M()
}
function M()
{
k = B(r() * w);
O.push([k, 0, 0, A(h, B(r() * w) - k), t/50+.3, 0])
}
function E(x, y)
{
if(y)
O.push([x, y, 4, 1]);
else
O.splice(x, 1)
}