Settings

Theme

I wrote a Flappy Bird game in TypeScript's type system

zackoverflow.dev

7 points by zackoverflow · 1 comment

Reader

1 thread
zackoverflowOP

Hey HN, I got inspired by a recent hack someone did of creating flappy bird in MacOS Finder, so I tried to do the same with type-level Typescript.

If you don't know, Typescript's type annotations are Turing complete, allowing you to compute anything with some clever type trickery.

In order to render graphics from Typescript's types, I ended up creating a compiler that compiles Typescript's types into bytecode, and a custom VM that can execute that bytecode.

Each frame, the VM takes draw commands from type-level Typescript, and renders it using the configured graphics backend. It can run in the browser by compiling the VM to Wasm and using the web's Canvas API.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection