Try taking a journey by spacecraft across 20000000 miles of space, space, and space. Try! Will you slash your ship on an asteroid or get lost in the depths of space? If for some reason you don't survi…
W=c.width=innerWidth;H=c.height=innerHeight;c.style.display='block';N=[K=[0,0,0,0],I=P=[99,A=X=Y=S=0],R=2];Q=W/4;M=Math;J=M.min;B=M.sin;G=M.cos;E=M.random;L=M.sqrt;function D(c,x,y,r,k){a.beginPath(a.fillStyle='rgb('+(k?c:[c*=64,c,c])+')');a.fill(x?a.arc(x,y,r,0,8,0):a.rect(0,0,W,H))}setInterval(function(){D(0,X+S,Y+S,R);R=m=n=2;if(I)for(F=V=I=0;m--;)for(l=2+m;l--;)if(!m||N[l])for(i=p=m?20:200;i--;D(0,x,y,1))D(!m&i<P[l]*2?4:1,x=(m?Q+(l-1?0:3)-l*3:l*W/2)+Q-E(o=m?3:49)*1.4+B(k=i*6.3/p)*o,y=H/2+G(k)*o+m*(l*60-40),2);if(P[0]){if(F){for(;n--;)for(l=2+n;l--;)x=X-Q-(n?Q+(l-1?0:3)-l*3:l*W/2),y=Y-H/2-n*(l*60-40),k=L(x*x+y*y),n&&!N[l]||(m=k*k*(n?8:.4),T-=x/m,k<(n?6:52)?(I=P[0]--,!n&V<3?P[l]++:(R=9,n?N[l]=0:0)):U-=y/m);X=(X+T+W)%W;Y=(Y+U+H)%H;K[3]?(I=P[0]--,R=9):V=L(T*T+U*U)}else X=Q+53*G(A+=K[2]-K[0]),Y=H/2+53*B(A),K[1]?V=J(4,V+.1):(F=V,T=G(A)*V,U=B(A)*V);S=E()*.4,D([J(k=255,i=-J(-J(V*80|0,k),0)*2),J(k,575-i),0],X+S,Y+S,R,1)}},20);(d=document).onkeydown=d.onkeyup=function(e){K[(k=e.keyCode-37)>>2?4:k]=e.type[5]?.02:0}
Vz1jLndpZHRoPWlubmVyV2lkdGg7SD1jLmhlaWdodD1pbm5lckhlaWdodDtjLnN0eWxlLmRpc3BsYXk9J2Jsb2NrJztOPVtLPVswLDAsMCwwXSxJPVA9Wzk5L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kpLDBdLFgrUyxZK1MsUiwxKX19LDIwKTsoZD1kb2N1bWVudCkub25rZXlkb3duPWQub25rZXl1cD1mdW5jdGlvbihlKXtLWyhrPWUua2V5Q29kZS0zNyk+PjI/NDprXT1lLnR5cGVbNV0/LjAyOjB9
//________________________________________________________________________
//########################################################################
//## |## |%% |##
//## _______ |## ________|%%________ |##
//## /\ ,-' `-. |## ##################### |##
//## / / \ |## /## ## |##
//## (_ / ,.------.___,` |##____|## ORION * |##____|##
//## \__/ 0) \ |##%%%%### * * * |##%%%%###
//## ( ( .__`o |## |## * TRAIL /## |##
//## ) ,--' |## ## __________________/## |##
//## / ( M |## ##################### |##
//## | ' E |## |%% |##
//## | '| E |##________________|%%________________|##
//## ` | | | R |########################################
//## | \ | K |##__by @veubeke and @UlrikeErdmann___|##
//## | \_ \ | A |########################################
//## | \ \|\ T |## Code and converter script at |##
//##___| `\ \ \____________|##___http://games.23inch.de/orion____|##
//########################################################################
//
// Optimizations:
// * used only one-character variables
// * avoided using functions where possible
// * used decreasing "for" loops: "for(i=n;i--;)"
// * see code for details...
//________________________________________________________________________
//## Initialization ######################################################
// resize canvas
width = c.width = innerWidth;
height = c.height = innerHeight;
// get rid of the extra 4 pixel below the canvas
c.style.display = 'block';
// init destructable asteroids
// opt: values are completely unrelated but evaluate to "true"
asteroids = [
// init key states
keys = [0,0,0,0],
// queue setup and init ship
// opt: combined initialization of population and ship variables
// opt: setup only has to be truthy
setup = population = [99,angle=shipX=shipY=shipRand=0],
shipR = 2
];
// opt: remember planet position
qwidth = width/4;
// opt: remember math functions
M = Math;
min = M.min;
sin = M.sin;
cos = M.cos;
rand = M.random;
sqrt = M.sqrt;
//________________________________________________________________________
//## Painting ############################################################
// draws a circle or the background
// opt: different functionality for 1, 4 and 5 parameters
// 1 - background (hue)
// 4 - grey circle (hue,x,y,radius)
// 5 - coloured circle (color,x,y,radius,1)
function draw(c,x,y,r,k) {
// opt: empty parameter list is used for preceding command
// opt: parameter c reused for derived value
a.beginPath(a.fillStyle='rgb('+(k?c:[c*=64,c,c])+')');
// floating point values make sure that x is never 0 after the start
a.fill(x?a.arc(x,y,r,0,8,0):a.rect(0,0,width,height))
}
//________________________________________________________________________
//## Main Loop ###########################################################
setInterval(function() {
// remove ship at previous position
// opt: also creates the black background in the beginning
draw(0,shipX+shipRand,shipY+shipRand,shipR);
// reset ship size
// opt: loop variables and ship radius are set together
shipR = m = n = 2;
// setup - reset ship, draw planets and asteroids
if(setup)
// opt: empty loop header is used to reset ship variables
for(flying=speed=setup=0;m--;)
// draw 2 planets and 3 asteroids
for(l=2+m;l--;)
// if asteroid is still there
if(!m||asteroids[l])
// compose all objects of small rings to create a black board
// look and add small random shifts to increase the effect
for(i=p=m?20:200;i--;draw(0,x,y,1))
// opt: "&" replaces "&&" if both operands are truth values
draw(!m&i<population[l]*2?4:1,
// opt: "l==1?3:0" -> "l-1?0:3"
x = (m?qwidth+(l-1?0:3)-l*3:l*width/2)+qwidth
// opt: "Math.PI*2" -> "6.3"
-rand(o=m?3:49)*1.4+sin(k=i*6.3/p)*o,
y = height/2+cos(k)*o+m*(l*60-40),2);
// opt: used condition instead of "clearInterval" to stop game
if(population[0]) {
// update flying ship
if(flying) {
for(;n--;)
// update ship speed with gravitation of all objects
for(l=2+n;l--;)
x = shipX-qwidth-(n?qwidth+(l-1?0:3)-l*3:l*width/2),
y = shipY-height/2-n*(l*60-40),
k = sqrt(x*x+y*y),
n&&!asteroids[l] || (m = k*k*(n?8:.4),shipSX -= x/m,
// reset if ship had a collision
// opt: change ship radius to create a simple explosion
// opt: "n&&(asteroids[l]=0)" -> "n?asteroids[l]=0:0"
k<(n?6:52)
? (setup = population[0]--,
!n&speed<3?population[l]++:(shipR=9,n?asteroids[l]=0:0))
: shipSY -= y/m);
shipX = (shipX+shipSX+width)%width;
shipY = (shipY+shipSY+height)%height;
// reset if aborted
keys[3] ? (setup = population[0]--,shipR=9)
: speed = sqrt(shipSX*shipSX+shipSY*shipSY)
}
// update launch position
else
shipX = qwidth+53*cos(angle+=keys[2]-keys[0]),
shipY = height/2+53*sin(angle),
// increase speed as long as "up" is pressed
keys[1] ? speed = min(4,speed+.1)
// launch if "up" has been pressed
: (flying = speed,
shipSX = cos(angle)*speed,
shipSY = sin(angle)*speed);
shipRand = rand()*.4,
// opt: "Math.max(x,y)" -> "-Math.min(-x,-y)"
draw([min(k=255,i=-min(-min(speed*80|0,k),0)*2),min(k,575-i),0],
shipX+shipRand,shipY+shipRand,shipR,1)
}
},20);
//________________________________________________________________________
//## Event Handler #######################################################
(d=document).onkeydown = d.onkeyup = function(e) {
// opt: "key < 0 || key > 4" -> "key >> 2"
// opt: "key[4]" is used as a catch-all to avoid using "if"
// opt: "e.type == 'keydown'" -> e.type[5]
// opt: key states are actually needed values instead of true/false
keys[(k=e.keyCode-37)>>2?4:k] = e.type[5]?.02:0
}
//________________________________________________________________________
//########################################################################
//## / / / / / / / / / / / / / / |##
//## demo / / / / / / / / / / / / / / |##
//## for / /__/ /________/ / /_____/ /__/ / /__/ / |##
//## / |%%| |%%%%%%%%|/ |%%%%%| |%%| / /%%/ / |##
//## / |%%| /|%%|/____/ / |%%| /|%%|/_/%%/ / |##
//## / |%%| / |%%%%%%%%| / |%%| / |%%%%%%%%\ / |##
//## /_____|%%| / /_____|%%| / |%%| / |%%| / \%%\ / |##
//## |%%%%%%%%|/ |%%%%%%%%|/ |%%|/ |%%|/ \%%\/ .com |##
//##___________________________________________________________________|##
//########################################################################