Games feel like a harder category than apps. Mechanically they're often easier: no database, no accounts, no deployment complexity. One HTML file will get you a real, playable, shareable game.

The three parts of every game

State — everything true right now. Player position, score, what's on screen, whether you're playing or on the game-over screen. One object holding all of it.

Update — given the state and how much time has passed, what's the new state? Movement, collisions, spawning, scoring. No drawing here.

Draw — given the state, put it on screen. No decisions here.

Keeping update and draw separate is the single structural decision that determines whether your game stays workable. Mix them and every new feature becomes tangled.

The loop

game-loop.txt
Build me the skeleton of a browser game in one HTML file. Canvas, no
libraries, no build step.

Structure it as:
- A single `state` object holding everything mutable.
- `update(dt)` — changes state only, never draws. Takes elapsed time.
- `draw()` — reads state and renders, changes nothing.
- A requestAnimationFrame loop calling both.

Include a paused state and a game-over state from the start. Put a
placeholder square on screen that I can move with the arrow keys.

Explain where I'd add: a new entity type, a collision, a score.

Get that running before you think about your actual game. Once a square moves, everything else is variations.

Use delta time from the start

Move things by "speed × elapsed seconds", never by a fixed amount per frame. Otherwise your game runs at a different speed on a 120Hz monitor than a 60Hz one — a bug that's invisible on your machine and obvious on someone else's.

Make it feel good before making it bigger

The difference between a dull prototype and something people play for ten minutes is almost never more features. It's feedback: a small screen shake, a sound on hit, a particle, a brief pause on impact, acceleration instead of instant movement.

Spend an hour on that before adding a second level.

Playtest with one person who hasn't seen it. Say nothing, watch their hands. Everything confusing about your game becomes obvious in ninety seconds.