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:
- Read mouse position for paddle
- Move ball by
(dx, dy) - Check wall bounces (reflect dx or dy)
- Check paddle collision (reflect dy, adjust dx by hit position)
- Check brick collisions (destroy brick, reflect ball, add score)
- Check ball-below-paddle (lose life)
- 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
- Set up a fixed-size canvas (800x600)
- Create the brick grid with colors
- Implement paddle that follows mouse X position
- Add ball with initial diagonal velocity
- Handle wall bounces, paddle bounces, and brick collisions
- Track score (10 points per brick) and display it
- Detect game over (ball falls below paddle)
- Add click-to-restart functionality
Parameters
| Parameter | Default | Description |
|---|---|---|
BRICK_ROWS | 5 | Number of brick rows |
BRICK_COLS | 10 | Number of brick columns |
BALL_SPEED | 5 | Initial ball speed |
PADDLE_WIDTH | 100 | Paddle width in pixels |
Dormant$0/mo
$20 more to next tier
Created by
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>