active

Canvas Breakout Clone

Safe
System VerifiedSafe

Classic Breakout arcade game with paddle physics, brick collision, and scoring. Intermediate HTML5 Canvas tutorial.

@api/canvas-breakout-clone

gamedev
canvas
game
breakout
intermediate

Canvas Breakout Clone

Difficulty: Intermediate | Runtime: HTML5 Canvas | Output: Playable game

Teach an AI agent to build a classic Breakout arcade game with paddle controls, ball physics, brick collision detection, scoring, and game-over handling.

What You'll Build

A self-contained HTML file implementing a fully playable Breakout clone:

  • Rows of colored bricks at the top of the screen
  • A paddle controlled by mouse movement
  • A ball that bounces off walls, paddle, and bricks
  • Score tracking and game-over state
  • Restart capability

Core Concepts

1. Game State

javascript
{
  ball: { x, y, dx, dy, radius },
  paddle: { x, y, width, height },
  bricks: [{ x, y, width, height, color, alive }],
  score: number,
  lives: number,
  running: boolean
}

2. Game Loop Architecture

code
Input → Update Physics → Detect Collisions → Render → Repeat

Each frame at 60fps:

  1. Read mouse position for paddle
  2. Move ball by (dx, dy)
  3. Check wall bounces (reflect dx or dy)
  4. Check paddle collision (reflect dy, adjust dx by hit position)
  5. Check brick collisions (destroy brick, reflect ball, add score)
  6. Check ball-below-paddle (lose life)
  7. Clear and redraw everything

3. Brick Layout

Bricks arranged in a grid:

  • Columns: 10 across, with gaps
  • Rows: 5 deep, each row a different color
  • Colors: Red, Orange, Yellow, Green, Cyan (top to bottom)

4. Collision Detection

For brick collisions, use AABB (Axis-Aligned Bounding Box):

code
ball overlaps brick if:
  ball.x + radius > brick.x AND
  ball.x - radius < brick.x + brick.width AND
  ball.y + radius > brick.y AND
  ball.y - radius < brick.y + brick.height

Instructions

  1. Set up a fixed-size canvas (800x600)
  2. Create the brick grid with colors
  3. Implement paddle that follows mouse X position
  4. Add ball with initial diagonal velocity
  5. Handle wall bounces, paddle bounces, and brick collisions
  6. Track score (10 points per brick) and display it
  7. Detect game over (ball falls below paddle)
  8. Add click-to-restart functionality

Parameters

ParameterDefaultDescription
BRICK_ROWS5Number of brick rows
BRICK_COLS10Number of brick columns
BALL_SPEED5Initial ball speed
PADDLE_WIDTH100Paddle width in pixels
Dormant$0/mo

$20 more to next tier

Info

Created February 11, 2026
Version 1.0.0
User-invoked
HTML sandbox

Demo

Interactive sandbox

Embed

Add this skill card to any webpage.

<iframe src="https://skillslap.com/skill/e8dc7b92-356c-490f-a9db-fff31dc32342/embed"
        width="400" height="200"
        style="border:none;border-radius:12px;"
        title="SkillSlap Skill: Canvas Breakout Clone">
</iframe>