Lesson goal: Breakout: Reflection Angles & Paddle

Previous: Lunar Lander: Gravity & Retro-Thrust | Home | Next: Pole Position: Speed, Curves & Steering

In 1976, Atari released Breakout, conceptualized by Nolan Bushnell and Steve Bristow, with the original hardware prototype famously built by Apple co-founders Steve Wozniak and Steve Jobs!

Breakout launched the entire brick-breaking arcade genre. Behind the fast-paced gameplay is pure geometry: angles of reflection, coordinate geometry, and the paddle deflection curve!

The Court & The Law of Reflection

The court is a 2D Cartesian plane ($600 \times 400$):
  • Arena Walls: Left wall at $x = 14$, Right wall at $x = 586$, and Ceiling at $y = 14$.
  • The Law of Reflection: When a ball hits a vertical wall, its angle of incidence equals its angle of reflection. In code, the horizontal velocity simply reverses while vertical speed stays the same: $$V_x' = -V_x, \quad V_y' = V_y$$
  • When the ball hits the ceiling or the horizontal face of a brick, the vertical speed reverses: $$V_x' = V_x, \quad V_y' = -V_y$$


The Paddle Deflection Curve

Your paddle is not a flat mirror! The angle the ball rebounds off your paddle depends on where it makes contact relative to the center:
  • Dead Center: Rebounds straight up ($90^\circ$).
  • Towards the Right Edge: Slices sharply to the right (down to $25^\circ$).
  • Towards the Left Edge: Slices sharply to the left (up to $155^\circ$).
By positioning your paddle precisely, you can aim the ball into specific high-scoring bricks!

Controlling the Paddle with Code

Instead of twitch paddle knob twists, you program interception commands:
  • breakout_game(n): Initializes deterministic Stage #$n$. Every run with game #$n$ produces 100% reproducible ball trajectories!
  • launch(angle): Launches the ball from your paddle at angle degrees (e.g. launch(65)). $90^\circ$ is straight UP.
  • paddle(x): Moves the paddle center to horizontal position x (between $14$ and $586$).
  • paddle_left(dx) and paddle_right(dx): Shifts the paddle left or right by dx pixels.
  • wait(seconds): Lets time advance while the ball travels and bricks shatter.
breakout_game(1)
launch(65)

wait(1.5)

paddle(315)
Move the mouse over a dotted box for more information.

  • Live Angle & Rally HUD: The instruments at the top display your score, remaining bricks, current rally hit streak, and live reflection angle.
  • Trajectory Guide: The dotted cyan guide line extending from the ball shows its current heading and velocity vector.
  • Manual Play: You can also control the paddle with the keyboard: ← / → to move and Spacebar to launch!

Now you try. Can you intercept the ball in Stage #1, or try breakout_game(2) to slice into the upper corner bricks?

Type your code here:


See your results here: