A simple typing game made with only 500 characters for TweetTweetJam 8.

Type letters as they appear. The game ends if the letters reach the bottom. Backspace to restart.


Source code: (exactly 500 characters)

<style>*{background:#111;color:#1d1;font-size:8.9vw;line-height:8.2vh}</style><pre id="a"></pre><script>g=String.fromCharCode,h=document,m=Math,i=1200,s=0,a=[],r=e=>m.floor(m.random()*e),d=e=>{h.getElementById("a").innerHTML=e||a.join("\n")},f=()=>{a.splice(0,0," ".repeat(r(18)+1)+g(r(26)+65)),d(),i-=10,a.length<13?setTimeout(f,i):(d("Game Over\n\nScore: "+s),a=[])},h.onkeydown=e=>{k=e.keyCode,c=g(k),a.length<1?8==k&&(s=0,i=1200,f()):32!=k&&a.at(-1).search(c)>-1&&(a.pop(),s++,d())},f();</script>

Comments

Log in with itch.io to leave a comment.

Wow! This is very well golfed and a fun game all around! 😊

Good job!

I did find a way to shave off another 12 bytes:

<pre id=a></pre><script>g=String.fromCharCode
h=document
m=Math
i=q=1200
s=0
a=[]
r=e=>m.floor(m.random()*e)
d=e=>{h.getElementById("a").innerHTML=e||a.join(`
`)}
f=()=>{a.splice(0,0," ".repeat(r(18)+1)+g(r(26)+65)),d(),i-=10,a.length<13?setTimeout(f,i):(d(`Game Over

Score: `+s),a=[])}
h.onkeydown=e=>{k=e.keyCode,c=g(k)
a.length<1?8==k&&(s=0,i=q,f()):32!=k&&a.at(-1).search(c)>-1&&(a.pop(),s++,d())}
f()</script><style>*{background:#111;color:#1d1;font-size:8.9vw;line-height:8.2vh}

Ooh nice! I didn't know the closing style tag could be omitted.

Yeah, browsers close tags for you. HTML parsing is really permissive. I have only recently learned about this when golfing my own game for the jam!

Unfortunately this does not work with the <script> tag.