Visualizations
179 / 500

179 · Games

Breakout

The arcade classic, with sparks, screen shake and an autopilot.

A complete small game: a paddle, a ball with angle-dependent bounces, bricks with hit points, lives and levels. Collisions use swept circle versus rectangle tests so the ball never tunnels through a brick. Broken bricks burst into particles, big hits shake the screen, and the occasional capsule turns one ball into three. Until you take over, a simple AI plays.

Try it. Move the pointer, or click the game and use the arrow keys, to control the paddle.

  • Game loop
  • Circle versus rectangle collision
  • Juice: particles and shake

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a Breakout game with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Use a dark background.
- Add a paddle near the bottom that follows the mouse (and the left and right arrow keys), a ball, and a grid of about 10 by 5 bricks across the top.
- Move the ball by velocity times delta time and bounce it off the side and top walls.
- When the ball hits the paddle, set its new angle from where it landed: dead center goes straight up, the edges send it off at about 60 degrees. Keep the speed constant.
- For brick collisions, grow each brick by the ball's radius and find where the ball's movement this frame first enters it (a swept test, the "slab method"), then bounce off that side. Use a few sub-steps per frame so a fast ball never tunnels through.
- Draw the score and 3 lives on the canvas. Clearing all bricks starts the next level.

Once that works, make it beautiful and juicy:
- Give bricks 1 to 3 hit points with a color for each, and show cracks when they are damaged.
- When a brick breaks, burst it into a dozen small particles with gravity, and add a short screen shake by offsetting the whole scene for a few frames.
- Add a simple AI that predicts where the ball will land, so the game plays itself until I move the mouse.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as power-ups like multiball, sound effects with the Web Audio API, or a level editor.
PreviousCore ArenaAssembly warriors battle for 8,000 cells of shared memory on a real Redcode VM. NextPhotoelasticityClear plastic parts under load light up with stress fringes between polarizers.

Related visualizations

  • AsteroidsGames The arcade classic with glowing vector lines and an AI pilot.
  • Ball PitPhysics Hundreds of colorful balls tumble, stack and bounce off each other.
  • Pool Trick ShotsGames Billiards with real spin physics and an AI that plans by simulating every shot.
  • Procedural PinballRetro Generated pinball tables in perspective, played by an AI that simulates its flips.
  • Marble LabyrinthGames A wooden tilt maze where a careful AI steers a steel ball between the holes.
  • Bubble Bank ShooterGames A pastel bubble shooter whose AI traces 640 bank shots before every throw.
  • FireworksGenerative art Shells arc, burst and crackle with glowing, fading sparks.
  • Dynamical BilliardsPhysics A fan of 1,000 balls in reshapable tables, linked live to the Birkhoff phase map.
  • Rigid BodiesPhysics Stacked towers of boxes knocked down by a swinging wrecking ball.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs