Move your player with the mouse, try to avoid the red dots, and the green dots give you (temporary) invulnerability. Your score is in the upper left hand corner. Based on Hakim El Hattab's Sinuous at…
with(document.body)style.background="#111",c=children[C=X=x=S=n=0];addEventListener('mousemove',function(L){x=L.clientX;y=L.clientY},0);c.width=w=innerWidth-15;c.height=y=Y=h=innerHeight-40;L=1;P={};X=Y=300;T=[];I=setInterval("with(c.getContext('2d'))with(Math){font='12px';r=random;clearRect(0,0,w,h);e=x-X;f=y-Y;X=min(X+e*.1,w);Y=min(Y+f*.1,h);T.push({a:X,b:Y});beginPath();strokeStyle='#699';for(O=0;O<T.length;O++){with(T[O])u=T[O+1],O==0?moveTo(a,b):u&&quadraticCurveTo(a,b,a+(u.a-a)/2,b+(u.b-b)/2),a-=1.3*L,b+=L;if(O>60)T.shift();}stroke();C+=L+sqrt(e*e+f*f)/99;for(O in P)with(P[O])a-=L*d,b+=L*d,M=X-a,N=Y-b,(a<0||b>h?1:0)||sqrt(M*M+N*N)<(S>0?16:3)+c&&(e?S=300:(S>0?C+=20:clearInterval(I)))?(delete P[O],n--):0,_e?'#0fc':'#f00'_a,b,c_p={a:r()*w,b:0,c:3+r()*4,d:2+r(),e:S--<1&&r()>.99?1:(n<L<<7?0:2)};if(r()>w/(w+h))p.a=w,p.b=h*r();if(p.e<2)n++,P[L]=p;if(S>99||S>0&&S%3>1)_'#066'_X,Y,17__'#9ff'_X,Y,4_fillText(C|0,9,15);}L+=.001".replace(/_([^_]+)_([^_]+)_/g,'fillStyle=$1,beginPath(),arc($2,0,PI*2,1),fill();'),42)
d2l0aChkb2N1bWVudC5ib2R5KXN0eWxlLmJhY2tncm91bmQ9IiMxMTEiLGM9Y2hpbGRyZW5bQz1YPXg9Uz1uPTBdO2FkZEV2ZW50TGlzdGVuZXIoJ21vdXNlbW92ZScsZnVuY3Rpb24oTCl7eD1MLmNsaWVudFg7eT1MLmNsaWVudFl9LDApO2Mud2lkdGg9dz1pbm5lcldpZHRoLTE1O2MuaGVpZ2h0PXk9W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QxLGJlZ2luUGF0aCgpLGFyYygkMiwwLFBJKjIsMSksZmlsbCgpOycpLDQyKQ==
/*
Sinuous, by Dmitri Gaskin and Hakim El Hattab.
Sinous is a simple game - move your player with the mouse, try to avoid the red
dots, and the green dots give you (temporary) invulnerability. Your score is in
the upper left hand corner.
---
Based on Hakim's Sinuous at http://www.hakim.se/experiments/html5/sinuous/01/
(vote for it at 10k apart: http://10k.aneventapart.com/Entry/83), with
permission.
---
The code is full of abbreviations - single letters instead of variable names.
These are all documented. Deal with it :-).
---
The code you see here is run through a custom minifier that brutally gets rid
of pretty much all whitespace.
*/
with (document.body)
style.background = "#111",
// Set the X (of the mouse and player) to 0, but set the Y to window height
// so it starts at the bottom left (and the things come in from the top
// right).
c = children[C = X = x = S = n = 0];
// c: canvas
// C: score
// X: current player X
// x: mouse x
// b: current boost
// n: number of particles.
addEventListener('mousemove', function(L) {
x = L.clientX;
y = L.clientY
}, 0);
c.width = w = innerWidth - 15; // w: window width
c.height = y = Y = h = innerHeight - 40; // h: window height
// Y: current player Y
// y: mouse y
L = 1; // Advancement (place in the game)
P = {}; // Particles
X = Y = 300;
T = [];
I = setInterval(---
with (c.getContext('2d'))
with (Math) {
font = '12px';
r = random; // Just a quick shortcut.
clearRect(0, 0, w, h); // Clear the whole screen.
e = x - X; // Calculate x and y distance from mouse to point
f = y - Y;
X = min(X + e * .1, w); // Only go slowly towards the mouse.
Y = min(Y + f * .1, h);
T.push({a: X, b: Y});
beginPath();
strokeStyle = '#699';
for (O = 0; O < T.length; O++) {
with (T[O])
u = T[O + 1],
O == 0 ? moveTo(a, b) : u && quadraticCurveTo(a, b, a + (u.a - a) / 2, b + (u.b - b) / 2),
a -= 1.3 * L,
b += L;
if (O > 60)
T.shift();
}
stroke();
C += L + sqrt(e * e + f * f) / 99; // Add to the score:
// - A little but for staying alive.
// - Delta - movement is encouraged.
for (O in P)
with (P[O])
// Advance the int
a -= L * d,
b += L * d,
// Find the distance between two ints [x,y] and [x,y] using the thagorean.
M = X - a,
N = Y - b,
(a < 0 || b > h ? 1 : 0) || // Piggyback on - are we off the screen?
sqrt(M * M + N * N) < (S > 0 ? 16 : 3) + c && // Collision
(e ? S = 300 : (S > 0 ? C += 20 : clearInterval(I))) // If its a blue dot, put up the shield
// If it's a red dot and the sheld is up,
// Add to the score (and delete it).
// If the shield isn't up, end the game.
?
(delete P[O], n--) : // Hide the dot (either blue or red with shield).
0, // Do nothing, no collision, on the screen.
// Draw the dot.
_e ? '#0fc' : '#f00'_a, b, c_
p = {
a: r() * w, // X
b: 0, // Y
c: 3 + r() * 4, // Diameter
d: 2 + r(), // Speed
e: S-- < 1 && r() > .99 ? 1 : (n < L << 7 ? 0 : 2) // type: 0 = enemy, 1 = bonus, 2 = nothing.
// <<7 multiplies by 128 and saves a character
};
if (r() > w / (w + h))
p.a = w,
p.b = h * r();
if (p.e < 2)
n++,
P[L] = p; // Evil evil evil: L goes up every round, so use that as
// the key.
if (S > 99 || S > 0 && S % 3 > 1)
_'#066'_X, Y, 17_
_'#9ff'_X, Y, 4_
fillText(C | 0, 9, 15); // Show the current score.
}
L += .001 // Advance the game, ever-so-slightly
---.replace(/_([^_]+)_([^_]+)_/g,'fillStyle=$1,beginPath(),arc($2,0,PI*2,1),fill();'), 42)