-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
2 lines (2 loc) · 996 Bytes
/
index.html
1
2
<canvas id='e' width=320 height=480 style='border:solid 1px'/><script>var m=Math,e=document.getElementById('e'),c=e.getContext('2d'),f=0,t=0;function r(){f=1;k=10;v=0;var s=0,w=[],i=0,l=0,g=setInterval(function(){if(!w[0]||w[w.length-1].x<20){w.push({x:80,h:~~(m.random()*80),q:0})}if(w[0].x<-20){w.shift()}v+=.025;if(t>0){t-=0.01;v=-0.75}k+=v;for(i in w){w[i].x-=0.2}c.clearRect(0,0,320,480);c.t(s,160,64);c.beginPath();c.arc(140,(k+5)*4,20,0,2*m.PI);for(i in w){l=w[i];c.rect(l.x*4,0,80,l.h*4);c.rect(l.x*4,(l.h+40)*4,80,480)}c.stroke();for(i in w){l=w[i];if(((40>l.x&&10<l.x)&&(k<l.h||k>l.h+30))||d(l.x,l.h)<5||d(l.x+20,l.h)<5||d(l.x,l.h+40)<5||d(l.x+20,l.h+40)<5||k>110){clearInterval(g);c.t('Game Over',0,240);f=0}if(!w[i].q&&w[i].x<40){s+=1;w[i].q=1}}},10);};function d(x,y){return m.sqrt((35-x)*(35-x)+m.pow(k+5-y,2))}window.onkeydown=function(e){e.keyCode===32&&(t=0.1)&&!f&&r()};c.font="bold 56px Arial";c.t=c.fillText;c.t('Hit Space',0,240);</script>
<!--github.heygears.com/x/Flappy-Bird-1k-->