Last active
August 29, 2015 14:26
-
-
Save JavaScript-Packer/18fde7d514352cf97651 to your computer and use it in GitHub Desktop.
This is a miniature ascii text version of the classic Space Invaders game. Live demo on http://jsfiddle.net/6hb5yfbw/1/ (click on link to play). It is written in the smallest amount of JavaScript that I could squeeze it. Entire game is 527 bytes! The core logic of the game is a single function that fits in less than 140 bytes.
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
<h1><pre id=x><script>function a(a,b,f,j){for(j="",a=0;10>a;a++){for(b=0;16>b;b++)f=b==c&9==a?3:0,a==e&&(f=g&1<<b-d?1:f),a==e+1&&(f=w&1<<b-d?1:f),f=b==h&a==i?1==f?4:2:f,f=9>e-!w+1?f:5,j+=".#i^@*"[f];j+="\n"}x.innerHTML=j}function b(){var c=0,j=0,c=1<<h-d;g-=j=i==e?g&c:0,w-=c=i==e+1?w&c:0,i-=j|c?10:1,g|w?0:(d=4,e=0,g=w=Z),(g|w)&1<<15*(f>0)-d?(e++,f=-f):d+=f,a(),setTimeout(b,300)}var c=8,d=4,e=0,f=1,g=w=Z=85,h=0,i=-1;this.onkeydown=function(b){b=event.keyCode,c-=37==b&c>0,c+=39==b&15>c,38==b&0>i&&(h=c,i=8),a()},b()</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment