← All guides

How the games are built

A short tour of the code: one canvas, one loop, a few hundred lines.

All eight games live in a single HTML file of about fifteen kilobytes. There are no images, libraries or downloads. This is how it fits.

One canvas

Every game draws on the same 320 by 320 pixel canvas using filled rectangles and a little text. The browser scales the canvas to your screen and keeps the pixels sharp.

A loop per game

Action games run a timer that fires a fixed number of times per second. Each tick does three things in order: read the keys, update the state, redraw the screen. Snake ticks about eight times a second, the ball games fifty.

Puzzle games have no timer at all. They redraw only when you press a key or tap, which is why they use almost no battery.

State is just numbers

Input

Keyboard and touch feed the same function. The on-screen buttons simply pretend to be keys, so no game needs special code for phones.

No storage

Scores are kept in memory only. Nothing is written to your device and nothing is sent anywhere.