Last active
November 3, 2016 11:27
-
-
Save iegik/20cb21d58eeed856fa1e756f25cefdff to your computer and use it in GitHub Desktop.
Space Inviders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body><script>eval('!function(t,i,s,h,n,o,e,a,r){function f(){var t=this.contro\ | |
ls,i=this.id=this.id||(1e17*Math.random()).toString(32);this.I=function(s){for(\ | |
var h in t)s.which===t[h]&&dispatchEvent(new Event(h+i))},this.A()}function p(t\ | |
){return function(){var i,s=this.controls,h=this.id;for(i in s)t(i+h,this[i].bi\ | |
nd(this));t(\"keydown\",this.I)}}function l(i){this.h=this.g=0,s(this,i),this.x\ | |
=this.g,this.y=this.h,this.path=new t(this.d),f.apply(this,arguments),this.move\ | |
To()}function u(){l.apply(this,arguments)}function d(){clearInterval(this.m),th\ | |
is.i()}function y(){l.apply(this,arguments)}function v(){l.apply(this,arguments\ | |
),this.o()}function b(t){var c=i.body.appendChild(i.createElement(\"canvas\"));\ | |
s(this,t),c.height=1.5*(c.width=170),this.a=[],this.b=c.getContext(\"2d\"),f.ap\ | |
ply(this,arguments),this.start()}return t.prototype.u=function(i){return functi\ | |
on(s,h){return\"string\"==typeof s?new t(s.replace(/M(\\d+)[\\s,](\\d+)/,\"M\"+\ | |
(h.e||\"$1\")+\" \"+(h.C||\"$2\"))):i.apply(this,arguments)}}(t.prototype.u),f.\ | |
prototype={A:p(n),G:p(o)},l.prototype=s({},f.prototype,{collapse:function(t){t.\ | |
j(\"crashed by \"+this.id),this.j(\"crashed into \"+t.id)},l:h,moveTo:function(\ | |
i,s){var h=this.b,n=this.f,o=this.c,a=typeof this.x===e?this.g:this.x,r=typeof \ | |
this.y===e?this.h:this.y;i=typeof i===e?a:i,s=typeof s===e?r:s,h.clearRect(this\ | |
.x,this.y,this.f,this.c),this.L||(0>=i||i+n>h.canvas.width||0>=s||s+o>h.canvas.\ | |
height?this.l():this.w&&this.w(i,s)||(this.x=i,this.y=s,this.J=this.x+~~(this.f\ | |
/2),this.K=this.y+~~(this.c/2),this.path=(new t).u(this.d,{e:this.x,C:this.y+th\ | |
is.c}),requestAnimationFrame(this.B.bind(this))))},left:function(){this.moveTo(\ | |
this.x-this.step,this.y)},right:function(){this.moveTo(this.x+this.step,this.y)\ | |
},s:function(){this.moveTo(this.x,this.y-this.step)},v:function(){this.moveTo(t\ | |
his.x,this.y+this.step)},B:function(){var i=this.b;i.fillStyle=this.color,i.fil\ | |
l(new t(this.path))},w:function(){var t=this.b;return this.a?this.a.some(functi\ | |
on(i){this.id!==i.id&&t.isPointInPath(i.path,this.J,this.K)&&this.collapse(i)}.\ | |
bind(this)):void 0},j:function(){this.F--?this.moveTo(this.g,this.h):(this.i(),\ | |
alert(this.id+r))},i:function(){this.b.clearRect(this.x,this.y,this.f,this.c),t\ | |
his.a.splice(this.a.indexOf(this),1),this.G()}}),u.prototype=s({},l.prototype,{\ | |
D:function(){var t;t=new v({b:this.b,controls:{s:56,v:50},g:this.x+~~(this.f/2)\ | |
,h:this.y-this.c,a:this.a}),this.a.push(t)},f:15,c:15,step:2,d:\"M0 0l1 -7l2 2l\ | |
3 -3l1 -5l1 0l1 5l3 3l2 -2l1 6l-6 -2l-1 1l-1 0l-1 -1l-4 2Z\"},u),y.prototype=s(\ | |
{},l.prototype,{j:function(){var t=this.a.filter(function(t){return t instanceo\ | |
f y}).length;clearInterval(this.m),this.i(),t||alert(r)},l:d,round:function(){}\ | |
,o:function(){this.m=a(this.round.bind(this),1e3)},d:\"M0 0m8 -8a 4 4 0 1 0 1 0\ | |
Z\",f:16,c:8},y),v.prototype=s({},l.prototype,{j:d,l:d,o:function(){this.m=a(th\ | |
is.s.bind(this),50)},f:2,c:3,step:6,d:\"M0 0l1 0l0 -2l-1 0\"},v),b.prototype=s(\ | |
{},f.prototype,{start:function(){var t=this.b,i=t.canvas,i=new u({b:t,F:3,contr\ | |
ols:{left:37,right:39,s:38,v:40,D:32},g:i.width/2-7,h:i.height-32,a:this.a});th\ | |
is.a.push(i),[[20,20],[52,20],[84,20],[116,20],[148,20],[36,40],[68,40],[100,40\ | |
],[130,40],[20,60],[52,60],[84,60],[116,60],[148,60]].forEach(function(i){i=new\ | |
y({b:t,g:i[0],h:i[1],a:this.a}),this.a.push(i),i.o()}.bind(this))},end:functio\ | |
n(){this.a.forEach(function(t){t.i()})},H:function(){this.end(),this.start()}})\ | |
,new b({id:\"SpaceInvaders\",controls:{start:13,end:27,H:82}})}(Path2D,document\ | |
,Object.assign,function(){},addEventListener,removeEventListener,\"undefined\",\ | |
setInterval,\"game over\");')</script><a href="http://arturs.jansons.net">iegik |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment