← Project routes

Project 02 · After Snake

Build a small Breakout

Breakout is the next complete loop after Snake: the paddle is continuous input, the ball is velocity, and a hit is not enough — you also have to decide the response.

Runnable mini Breakout

Move with Left and Right or A and D. The ball’s bounce angle depends on where it hits the paddle. Click Restart after a miss or a cleared board.

What you need

Collision detection plus the idea of velocity. Read collision response if a bounce still feels like a guess.

What you will learn

How an arcade rule — reverse vy, aim with hit position — is clearer than a full physics engine for this game.

Build in five checkpoints

  1. Draw a paddle and a ball. The paddle is a rectangle with only an x. The ball stores x, y, vx, vy, r.
  2. Move the paddle from held keys. This is continuous input, not a Snake queue.
  3. Bounce on walls. Reverse vx on the sides and vy on the ceiling. A miss at the bottom is a life, not a bounce.
  4. Aim with the paddle hit. Detection says the boxes overlap. Response sets a new heading from the contact point.
  5. Remove bricks and end the board. Mark a brick destroyed, add score, and restart when none remain or the last life is gone.

The bounce is a game rule

const hit = (ball.x - (paddle.x + paddle.w / 2)) / (paddle.w / 2);
const angle = Math.max(-1, Math.min(1, hit)) * Math.PI / 3;
const speed = Math.hypot(ball.vx, ball.vy);
ball.vx = Math.sin(angle) * speed;
ball.vy = -Math.abs(Math.cos(angle) * speed);

That is the same idea used in the playable Breakout: hit the left side to send the ball left, and keep a minimum upward speed so the ball cannot flatten into a horizontal slide. You do not need a rigid-body solver for this.

Mini version vs the playable game

IdeaThis pagePlayable Breakout
WorldOne small 2D canvas board2D rules, with optional WebGL presentation
Paddle bounceHit position sets angleSame rule, plus a minimum upward speed
BricksOne static row setMultiple layouts and levels
FailureOne miss ends the runLives, reset ball, keep the remaining bricks
FeedbackScore textParticles and hit sounds

Common mistakes

Use it when you want a second complete project after Snake. Skip a physics library until the arcade rule is no longer enough.

Lessons used

Input · Collision · Collision response · State and score

Next

Play the full Breakout reference, then either stay with physics or return to Snake if the first project still has gaps.

Collision ideas follow MDN’s 2D collision notes. Updated 2026-08-13; the mini game was checked locally with keyboard aiming and restart.