CLICK TO FLAP!

A Flappy Bird demake that fits in a single tweet!

Here's the super minified version, the entire HTML file is only 244 bytes!

<canvas onclick=V=1 style=width:100% id=c><svg onload="C=c.getContext`2d`;T=-1;setInterval(`X=(c.width=99)-T%128;i=T++>>7;for(j=2;j--;C.fillRect(X+3,7+o-120*j,19,99))o=18+i**2%25;C.fillText(i,9,T&&X*X>144|(Y-o)**2<49?Y-=V-=.03:T=Y=V=0,9)`,16)">

Here is a cleaner version with white space and comments...

<canvas style=width:100% id=c><script> // html canvas and script
x = c.getContext`2d`                   // get 2d canvas context
T = -1                                 // init time value
setInterval( _=> {                     // update interval
  X = (c.width=99) - T%128             // get wall position and clear screen
  i = T++ >> 7                         // get wall index
  H = 18 + i**2%25                     // get pseudo random wall height
  T && X*X>144 | (Y-H)**2<49 ?         // collision detection
    onclick =_=> V=1 :                 // click to flap
    T = Y = V = 0                      // reset if collided
  for ( j = 2; j--; )                  // top and bottom part of wall
    x.fillRect(X+3, 7+H-120*j, 19, 99) // draw wall parts
  x.fillText(i, 9, Y -= V -= .03, 9)   // draw player and update physics
},16)                                  // 60 fps update
</script>                              // end html

Leave a comment

Log in with itch.io to leave a comment.