Last active
November 30, 2020 07:56
-
-
Save liamstrilchuk/848df92b56bd329e23294e20316a7ac6 to your computer and use it in GitHub Desktop.
Flappy Bird in 373 bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body onload="z=c.getContext`2d`;c.width=W=400,c.height=H=600,Y=E=200,Q=z.fillRect.bind(z),M=S=p=0;N=M=>z.fillStyle=M;c.onclick=_=>M=9;R=_=>{M=S=p=0,Y=E};setInterval(_=>{p=p||[W,Math.random()*W],N`red`,Q(0,0,W,H),Y-=M-=.5,X=p[0]-=8,N`black`,Q(X,0,V=50,Z=p[1]),Q(X,Z+E,V,H),(Y<Z||Y>Z+E)&&X<B&&R(),X<-V&&(p=0,S++),Y>H&&R(),Q(0,Y-9,B,B),z.fillText(S,9,B)},B=24)"><canvas id=c> |
Inspiration from https://www.reddit.com/r/programming/comments/ihuisz/flappy_bird_in_481_bytes/
Click to jump
Should this:
(Y<Z||Y>Z+E)&&X<V
be this: ...?
(Y<Z||Y>Z+E)&&X<B
@mauvexephos Yeah, it works better that way. It just changes how close you have to get to the pipes to die (B: 24px, V: 50px).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dataurl:
data:text/html,<body onload="z=c.getContext`2d`;c.width=W=400,c.height=H=600,Y=E=200,Q=z.fillRect.bind(z),M=S=p=0;N=M=>z.fillStyle=M;c.onclick=_=>M=9;R=_=>{M=S=p=0,Y=E};setInterval(_=>{p=p||[W,Math.random()*W],N`red`,Q(0,0,W,H),Y-=M-=.5,X=p[0]-=8,N`black`,Q(X,0,V=50,Z=p[1]),Q(X,Z+E,V,H),(Y<Z||Y>Z+E)&&X<B&&R(),X<-V&&(p=0,S++),Y>H&&R(),Q(0,Y-9,B,B),z.fillText(S,9,B)},B=24)"><canvas id=c>