- Author:
- Paweł Brzeziński
- Twitter:
- @
- GitHub:
- brzez
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- brzez.com
- Compo:
- classic
- Demo link:
- https://js1k.com/2011-trail/demo/943
- Shortlink:
- https://js1k.com/943
- Blog post:
- please update here!
- Bytes:
- 1024
- Chars:
- 1024
- Submission
w=640;h=480;c.width=w;c.height=h;up=[];_d=[];_r=15;m=!1;_x=60;_y=h/2;g=1;_s=!1;p=function(){var b=_x,e=_y;b-=x;r=w/_r;d=Math.floor(b/r);x1=d*r;x2=Math.floor(b/r+1)*r;i=(b-x1)/r;i*=up[d+1]-up[d];i+=up[d];j=(b-x1)/r;j*=_d[d+1]-_d[d];j+=_d[d];j=h-j;return e-16<i||e+16>j?1:0};gen=function(){up.push(Math.random()*200);_d.push(100+Math.random()*100)};for(i=0;i<_r+2;i++)gen();
t=setInterval(function(){if(_s)return 0;x-=spd;_l+=spd;spd+=0.005;x<-(w/_r)&&(up.shift(),_d.shift(),gen(),x=0);a.fillStyle="rgba(0,0,0,0.3)";spd<4?a.clearRect(0,0,w,h):a.fillRect(0,0,w,h);a.fillStyle="#9c9";a.beginPath();a.moveTo(0,0);for(i=0;i<_r+2;i++)a.lineTo(x+w/_r*i,up[i]);a.lineTo(w,0);a.fill();a.beginPath();a.moveTo(0,h);for(i=0;i<_r+2;i++)a.lineTo(x+w/_r*i,h-_d[i]);a.lineTo(w,h);a.fill();_y+=g*spd;p()&&(alert("Score: "+Math.floor(_l/100)),_s=!0);m&&(_y-=g*spd*2);a.fillStyle=
"#ff0";a.beginPath();a.arc(_x,_y,11+Math.sin(x/10)*5,0,9,0);a.fill()},33);_l=x=0;spd=3;document.onmousedown=function(){m=!0};document.onmouseup=function(){m=!1};
- Description
- Just a simple cave flying game.
My highscore : 151 :P
tested on :
chrome 10.0.648.204
ffx 3.6.3
opera 11.10
safari 5.0.4
- Base64 encoded
dz02NDA7aD00ODA7Yy53aWR0aD13O2MuaGVpZ2h0PW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JihfeS09ZypzcGQqMik7YS5maWxsU3R5bGU9DQoiI2ZmMCI7YS5iZWdpblBhdGgoKTthLmFyYyhfeCxfeSwxMStNYXRoLnNpbih4LzEwKSo1LDAsOSwwKTthLmZpbGwoKX0sMzMpO19sPXg9MDtzcGQ9Mztkb2N1bWVudC5vbm1vdXNlZG93bj1mdW5jdGlvbigpe209ITB9O2RvY3VtZW50Lm9ubW91c2V1cD1mdW5jdGlvbigpe209ITF9Ow==
- Original source
w=640;h=480;
c.width=w;
c.height=h;
up=new Array();
down=new Array();
res=15;
m=false;
//player
_x=60;
_y=h/2;
g=1;
stop=false;
function lt(x,y){a.lineTo(x,y);}
function bp(){a.beginPath()}
function fl(x){return Math.floor(x)};
p=function(cx,cy)
{
cx-=x;
r=w/res;
d=fl((cx)/r);
x1=d*r;
x2=fl((cx)/r+1)*r;
i=(cx-x1)/r;
i=(up[d+1]-up[d])*i;
i+=up[d];
j=(cx-x1)/r;
j=(down[d+1]-down[d])*j;
j+=down[d];
j=h-j;
if(cy-16<i||cy+16>j) return 1;//collision
else return 0;
}
gen=function()
{
up.push(Math.random()*200);
down.push(100+Math.random()*100);
}
for(i=0;i<res+2;i++)
{
gen();
}
t=setInterval(function()
{
if(stop)return 0;
x-=spd;len+=spd;
spd+=0.005;
if(x<-(w/res))
{
up.shift();
down.shift();
gen();
x=0;
}
a.fillStyle="rgba(0,0,0,0.3)";
spd<4?a.clearRect(0,0,w,h):a.fillRect(0,0,w,h);
a.fillStyle="9c9";
bp();
a.moveTo(0,0);
for(i=0;i<res+2;i++)
{
lt(x+w/res*i,up[i]);
}
lt(w,0);
a.fill();
bp();
a.moveTo(0,h);
for(i=0;i<res+2;i++)
{
lt(x+w/res*i,h-down[i]);
}
lt(w,h);
a.fill();
//player
_y+=g*spd;
if(p(_x,_y)) {
alert("Score: "+fl(len/100));
stop=true;
}
if(m)_y-=g*spd*2;
a.fillStyle="ff0"
bp();
a.arc(_x,_y, 11+Math.sin(x/10)*5, 0, 9,0);
a.fill();
},33);
x=0;len=0;spd=3;
document.onmousedown=function(){m=true;}
document.onmouseup=function(){m=false;}