Simple side-scrolled space game. Control spaceship with your mouse and try to avoid pink rects. I made first version of that game in almost 1,7kb and it looks much better nicer, try it here: http://no…
var i=document,h=i.getElementById("c"),f=300,g=150,l=k=q=1,A="addColorStop",e=Math,x=e.random,b=h.getContext("2d"),j,d=100,o=new Image(),p=new Image(),c=[],F="fillStyle",Q="#fff",n=[],C="closePath",W="fill",B="beginPath",T=W+"Text",D="drawImage",E='xUAOw%3D%3D',G="data:image/gif;base64,R0lGODlhC";h=5;while(h--){n[h]=[x()*g,f,x()*9]}o.src=G+"gAKAJEDAF8XF50DBSYcIQAAACH5BAEAAAMALAAAAAAKAAoAAAIdnACjaxLBlDgvTprkQQ+IhgDdcYXIUgaZJq5SG"+E;p.src=G+"wAOAIAAAPKyUQAAACH5BAEAAAEALAAAAAALAA4AAAIajA95G6mM3gJNTsecjRQanGmQ9pCiKYbbh"+E;function r(){n.forEach(function(a){if(40<a[1]+15&&77>a[1]&&d+38>a[0]&&d<a[0]+15)q=0;if(a[1]+15<0){a[1]=f;a[0]=x()*g;a[2]=l/6}else a[1]-=a[2];b[F]="#A7D";b.fillRect(a[1],a[0],30,30)})}function X(){b[F]="#046";b[B]();b.rect(0,0,f,g);b[C]();b[W]();try{b[D](o,40,d,37,38);b[D](p,0,7*k,11,7,18,d+12,22,14);k==0?k=1:k=0}catch(m){}r();b[F]=Q;b[T](l,5,9);l++;q&&setTimeout(X,99)}i.onmousemove=function(a){if(d<a.pageY&&d+38<g)d+=5;if(d>a.pageY)d-=5};X()
dmFyIGk9ZG9jdW1lbnQsaD1pLmdldEVsZW1lbnRCeUlkKCJjIiksZj0zMDAsZz0xNTAsbD1rPXE9MSxBPSJhZGRDb2xvclN0b3AiLGU9TWF0aCx4PWUucmFuZG9tLGI9aC5nZXRDb250ZXh0KCIyZCIpLGosZD0xMDAsbz1uZXcgSW1hZ2UoKSxwPW5ldyBJbWFnZSgpLGM9W10sRj0iZmlsbFN0eWxlIixRPSIjZmZmIixuPVtdLEM9ImNsb3NlUG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b = f.getContext("2d");
f.width = 640;
f.height = 300;
var k = function () {
b.fillStyle = "#046";
b.clearRect(0, 0, 640, 300);
b.beginPath();
b.rect(0, 0, 640, 300);
b.closePath();
b.fill()
},
d = [],
h, l = [];
for (f = 0; f < 7; f++) {
d.push([c.random() * 640, c.random() * 300, c.random() * 99, c.random() / 5]);
l.push([c.random() * 300, 670, c.random() * 30, ~~ (c.random() * 2)])
}
var e = 100,
m = g.createElement("img"),
n = g.createElement("img"),
i = 0;
m.src = "data:image/gif;base64,R0lGODlhCgAKAJEDAF8XF50DBSYcIQAAACH5BAEAAAMALAAAAAAKAAoAAAIdnACjaxLBlDgvTprkQQ+IhgDdcYXIUgaZJq5SGxUAOw%3D%3D";
n.src = "data:image/gif;base64,R0lGODlhCwAOAIAAAPKyUQAAACH5BAEAAAEALAAAAAALAA4AAAIajA95G6mM3gJNTsecjRQanGmQ9pCiKYbbhxUAOw%3D%3D";
var p = function () {
l.forEach(function (a) {
if (40 < a[1] + 30 && 77 > a[1] && e + 38 > a[0] && e < a[0] + 30) {
o = 0;
k();
b.fillStyle = "#fff";
b.fillText("GameOver", 270, 150)
}
if (a[1] + 30 < 0) {
a[1] = 670;
a[0] = c.random() * 300;
a[2] = ~~ (j / 30) + 30 * c.random()
} else a[1] -= a[2];
h = b.createRadialGradient(a[1] + 30, a[0] + 30, (a[3] + 1) * 5, a[1] + 30, a[0] + 30, 30);
h.addColorStop(0, "#A7D");
h.addColorStop(1, "rgba(62,0,255,0)");
b.fillStyle = h;
b.fillRect(a[1], a[0], 60, 60);
a[3] == 0 ? a[3] = 1 : a[3] = 0
})
},
o = 1;
(function () {
k();
for (var a = 0; a < 7; a++) {
b.fillStyle = "rgba(0, 170, 255, " + d[a][3] + ")";
b.beginPath();
b.arc(d[a][0], d[a][1], d[a][2], 0, c.PI * 2, true);
b.closePath();
b.fill()
}
for (a = 0; a < 7; a++) if (d[a][0] + d[a][2] < 0) {
d[a][1] = c.random() * 300;
d[a][2] = c.random() * 100;
d[a][0] = 640 + d[a][2];
d[a][3] = c.random() / 5
} else d[a][0] -= 10 * (a / 2 + 1);
try {
b.drawImage(m, 40, e, 37, 38);
b.drawImage(n, 0, 7 * i, 11, 7, 18, e + 12, 22, 14);
i == 0 ? i = 1 : i = 0
} catch (q) {}
p();
b.fillStyle = "#fff";
b.fillText("KM " + j, 5, 9);
j++;
o && setTimeout(arguments.callee, 99)
})();
g.onmousemove = function (a) {
if (e < a.pageY) {
if (e + 38 < 300) e += 5
} else if (e > a.pageY) if (e > 0) e -= 5
}
})(document);