1
0
mirror of https://github.com/osmarks/website synced 2025-09-01 02:07:57 +00:00

flappy bird & otherstuff update

This commit is contained in:
2021-02-24 10:30:34 +00:00
parent 1345f1b38a
commit b172d55713
2 changed files with 7 additions and 0 deletions

View File

@@ -16,7 +16,13 @@ comments: off
<li>???</li>
</ul>
This site uses a service worker to provide a limited offline mode, but it doesn't work for everything (dynamic pages, ones requiring a bit of server logic, the comments system, pages which haven't been cached), so you are being shown this instead.
Please enjoy the below "flappy bird" game until your connection comes back, thanks to palaiologos (click or press space).
</p>
<!--experimental miniaturized bird (flappy) (contributed by palaiologos and tweaked by me inelegantly)-->
<canvas style="border: 1px solid black"></canvas>
<script defer>
const q = document.querySelector("canvas")
let canstart = true
J=q.width=q.height=500;Q='50px monospace';with(Math)with(C=q.getContext`2d`)with(X=Y=R=0,init=e=(e=>{w=f=Y=X=0,R=1,H=250,q.focus(),canstart=false,V=-10,P=[],(F=(e=>{e-w>1/60&&(Y&&(V=-10,Y=0),H+=V,V+=.8,P.forEach(e=>e.P-=3),f%50||P.push({P:J,L:150+(0|200*random()),C:'rgb('+255*random()+','+255*random()+','+255*random()+')'}),(P.some(e=>abs(e.L-H+2)>60&&0<e.P&&e.P<25)||H>J||H<0)&&(R=0,setTimeout(e=>{font=Q,fillStyle='red',fillText(':(',50,90),canstart=true},99)),clearRect(0,0,J,J),P.forEach(e=>{with(e){fillStyle=C,fillRect(P,0,20,L-60),fillRect(P,L+60,20,J-(L+60))}}),fillStyle='red',fillRect(20,H,10,10),font=Q,fillStyle='red',fillText(ceil(f/50-10/3),40,40),f++,w=e),R&&requestAnimationFrame(F)}))()}),document)onkeydown=(e=>{' '==e.key&&R?++Y:' '==e.key; if (canstart) {init()}}),onmousedown=(e=>{R&&++Y; if (canstart) {init()}});
window.addEventListener("load", function() { if ("points" in window) { points.unlockAchievement("offline") }})
</script>