Tetris

Active

This project is an experiment with OpenAI's coding agent (Codex). I wanted to see how well AI can actually code, so I built a modern web version of Tetris together with the agent.

Created
2025-09-09
Updated
2026-06-25
typescriptreactviteweb-audiopnpmgame
If the demo fails to load in your browser, open it in a new tab: Play Online

Background and motivation

This project started with curiosity. I wanted to see how far I could get using an AI coding agent, OpenAI Codex, for an entire application rather than individual snippets.

I chose Tetris because the familiar game mechanics gave me a clear goal and a practical way to check progress.

Programming through delegation

I normally initialise a project myself, plan its structure and spend time getting familiar with the stack through documentation and experimentation.

Here I started by telling the agent that I wanted to build Tetris. Through a planning conversation, we worked out the scope, stack, architecture, game mechanics, milestones and completion criteria. The agent recorded the plan in Markdown.

To keep the work focused, I added an AGENTS.md file and refined it as the project developed. Its instructions included working on one task at a time, splitting large tasks and keeping the architecture modular.

Most of my contribution was reviewing the output and expressing requirements clearly. When the agent went off track, I primarily corrected its instructions. This project is therefore an experiment in directing and reviewing AI-assisted development.

Architecture and stack

The resulting pnpm monorepo separates the game into two packages.

  • @tetris/core contains the game logic and can be tested without the UI.
  • @tetris/web uses Canvas and React to render the game and consumes the core package.

Dedicated modules handle pieces, the board, scoring and audio. Tests cover mechanics such as the Super Rotation System and the 7-bag randomiser.

The result

The playable web version includes configurable controls, local highscores, a ghost piece and audio built around the Web Audio API.

One of my favourite parts is the soundtrack. I asked the agent to generate 8-bit sounds with a script rather than use downloaded sound effects. It used ffmpeg to combine waveforms into a chiptune soundtrack that fitted the game well.

The audio layer maps game events, such as clearing a line, to sounds. Together with configurable movement timing, these details make the game feel more complete.

What I learned

Working with a coding agent made planning, precise requirements and reviewing the result especially important. I learned a lot about guiding development from a higher level and defining rules that help keep a project manageable.

I still enjoy playing the result, particularly with its 8-bit music. It also gives me a concrete example of what AI-assisted development can produce and where my own role in that process lies.

  • In-game action at high level with colorful tetromino stack.
  • Settings modal with controls, DAS/ARR, theme, audio, and highscores actions.
  • Game Over dialog showing score table with new #1 score.