- Author:
- Yuri Ivatchkovitch
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- y3i12.tumblr.com
- Compo:
- classic
- Demo link:
- https://js1k.com/2010-xmas/demo/888
- Shortlink:
- https://js1k.com/888
- Blog post:
- please update here!
- Bytes:
- 1014
- Chars:
- 1014
- Submission
M=Math;U=M.max;L=M.min;R=M.random;P=M.pow;a.T=a.fillText;d=document;b.bgColor="#DDE";w=c.width=500;h=c.height=500;n=10;r=5;s=1;p={x:w/2,y:r*10};v={x:0,y:0};o=[{x:w/2,y:h,l:R()*5|0}];m=0;k=[];f=true;z="fillStyle";setInterval(function(){o.push({x:R()*w|0,y:h,l:R()*5|0});s+=0.2},3E3);function K(s){return function(e){t=e.keyCode;k[t]=s;if(t>36&t<41)f=!s}}d.onkeydown=K(1);d.onkeyup=K(0);k[37]=k[38]=k[39]=k[40]=0;setInterval(function(){a[z]="#DDE";a.fillRect(0,0,w,h);a.font="12px sans-serif";a.textAlign="center";if(f){v.x/=1.1;v.y/=1.1}v.x=L(U(v.x+k[39]-k[37],-5),5);v.y=L(U(v.y+k[40]-k[38],-5),5);p.x=L(U(p.x+v.x,0),w);p.y=L(U(p.y+v.y,0),h);for(t in o)with(o[t]){y-=s;if(y<=0){x=R()*w|0;y=h}if(P(x-p.x,2)+P(y-p.y,2)<P(r+10,2)){alert("End time: "+m/1E3);history.go(0)}a[z]="#333";a.T("("+["O_o","T_T","X_x","O_O","Q_Q"][l]+")",x,y-20);a.T("__|__",x,y-10);a.T("|",x,y);a.T("/ \\",x,y+10);a.T("/ \\",x,y+20)}a[z]="#FFF";a.beginPath();a.arc(p.x,p.y,r,0,M.PI*2,0);a.closePath();a.fill();m+=10;if(r<30)r+=0.0030},10);
- Description
- SnowBall Adventures
A little ski clone game, use the arrows to move the snow ball.
... just a fail. Other better demos are here, but ah, whatever, I just hadn't enough time to produce a second demo.
- Base64 encoded
TT1NYXRoO1U9TS5tYXg7TD1NL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IpIix4LHktMjApO2EuVCgiX198X18iLHgseS0xMCk7YS5UKCJ8Iix4LHkpO2EuVCgiLyBcXCIseCx5KzEwKTthLlQoIi8gICBcXCIseCx5KzIwKX1hW3pdPSIjRkZGIjthLmJlZ2luUGF0aCgpO2EuYXJjKHAueCxwLnksciwwLE0uUEkqMiwwKTthLmNsb3NlUGF0aCgpO2EuZmlsbCgpO20rPTEwO2lmKHI8MzApcis9MC4wMDMwfSwxMCk7
- Original source
M = Math; // Math shortcut
U = M.max; // max alias
L = M.min; // min alias
R = M.random; // Random shortcut
P = M.pow; // power shortuct
a.T = a.fillText; // text shortcut
d = document; // document... doh
b.bgColor = '#DDE'; // sets the body color
w = c.width = 500; // width
h = c.height = 500; // height
n = 10; // number of objects
r = 5; // radius
s = 1; // speed
p = {x:w/2,y:r*10}; // snowball position
v = {x:0,y:0}; // snowball relative velocity
o = [{x:w/2,y:h,l:R()*5|0}]; // objects
m = 0; // chronometer
k = []; // keys
f = true; // friction to stop the ball
z='fillStyle'; // fillstyle acessor
// initialization - also sets the bgcolor to black
setInterval(function ()
{
o.push({x:R() * w | 0, y: h,l:R()*5|0});
s+=0.2;
}, 3E3);
//keyDown/keyUp event handler generator
function K(s)
{
return function(e)
{
t = e.keyCode;
k[t] = s;
if(t>36 & t <41) f = !s;
//console.debug('key ' +e.keyCode+ ' event ' + s + ' - arr: ' + k);
};
}
d.onkeydown = K(1);
d.onkeyup = K(0);
//initialize keys:
k[37] = k[38] = k[39] = k[40] = 0;
// the megazordic function that does it all
setInterval(function ()
{
// clears everything
a[z] = '#DDE';
a.fillRect(0, 0, w, h);
a.font = '12px sans-serif';
a.textAlign = 'center';
// move the snowball according to the velocity
if (f)
{
v.x /= 1.1;
v.y /= 1.1;
}
v.x = L(U(v.x+k[39]-k[37],-5),5);
v.y = L(U(v.y+k[40]-k[38],-5),5);
p.x = L(U(p.x+v.x,0),w);
p.y = L(U(p.y+v.y,0),h);
// update the objects
for (t in o)
{
with( o[t] )
{
y -= s;
if ( y <= 0 )
{
x=R()*w|0;
y=h;
}
// test for collision
if (P(x-p.x,2)+P(y-p.y,2) < P(r+10,2))
{
alert('End time: ' + m/1E3);
history.go(0);
}
a[z] = '#333';
a.T( '('+['O_o','T_T','X_x','O_O','Q_Q'][l]+')', x, y-20 );
a.T( '__|__' , x, y-10 );
a.T( '|' , x, y );
a.T( '/ \\' , x, y+10 );
a.T( '/ \\', x, y+20);
}
}
// draw the snowball
a[z] = '#FFF';
a.beginPath();
a.arc(p.x, p.y, r, 0, M.PI*2, 0);
a.closePath();
a.fill();
m += 10;
if (r<30) r += .003;
}, 10);