How to make a brick breaker game on scratch

A classic! Making a Brick Breaker game on Scratch is a great project for beginners and experienced users alike. Here's a step-by-step guide to help you create a basic Brick Breaker game on Scratch:

Game Overview

In Brick Breaker, the player controls a paddle at the bottom of the screen, and the goal is to break bricks by bouncing a ball off the paddle. The game ends when the ball hits the bottom of the screen or all the bricks are broken.

Scratch Setup

  1. Create a new project in Scratch by clicking on "File" > "New Project" or by using the shortcut key "Ctrl + N" (Windows) or "Cmd + N" (Mac).
  2. Set the stage size to 480x360 pixels by clicking on "File" > "Project Settings" > "Stage" and adjusting the values.
  3. Create a new sprite by clicking on "Sprites" > "New Sprite" or by using the shortcut key "Ctrl + Shift + S" (Windows) or "Cmd + Shift + S" (Mac). Name the sprite "Paddle".

Paddle Sprite

  1. Add a rectangle shape to the Paddle sprite by clicking on "Costumes" > "New Costume" and then selecting "Rectangle" from the shape options.
  2. Set the rectangle's size to 100x20 pixels by adjusting the values in the "Costume" panel.
  3. Add a script to the Paddle sprite by clicking on the "Scripts" tab and then clicking on the "New Script" button. Name the script "movePaddle".

movePaddle Script

  1. Add the following code to the movePaddle script:
    when green flag clicked
    forever
     if key [left arrow] pressed
       set x to (x - 5)
     end
     if key [right arrow] pressed
       set x to (x + 5)
     end
    end

    This script makes the paddle move left and right when the left and right arrow keys are pressed.

Ball Sprite

  1. Create a new sprite by clicking on "Sprites" > "New Sprite" or by using the shortcut key "Ctrl + Shift + S" (Windows) or "Cmd + Shift + S" (Mac). Name the sprite "Ball".
  2. Add a circle shape to the Ball sprite by clicking on "Costumes" > "New Costume" and then selecting "Circle" from the shape options.
  3. Set the circle's size to 10x10 pixels by adjusting the values in the "Costume" panel.
  4. Add a script to the Ball sprite by clicking on the "Scripts" tab and then clicking on the "New Script" button. Name the script "moveBall".

moveBall Script

  1. Add the following code to the moveBall script:
    when green flag clicked
    forever
     move 5 steps
     if touches edge
       if touching edge [bottom edge]
         delete this clone
       else
         bounce off edge
       end
     end

    This script makes the ball move 5 steps at a time and bounces off the edges of the stage.

Bricks Sprite

  1. Create a new sprite by clicking on "Sprites" > "New Sprite" or by using the shortcut key "Ctrl + Shift + S" (Windows) or "Cmd + Shift + S" (Mac). Name the sprite "Bricks".
  2. Add a rectangle shape to the Bricks sprite by clicking on "Costumes" > "New Costume" and then selecting "Rectangle" from the shape options.
  3. Set the rectangle's size to 50x20 pixels by adjusting the values in the "Costume" panel.
  4. Add a script to the Bricks sprite by clicking on the "Scripts" tab and then clicking on the "New Script" button. Name the script "breakBrick".

breakBrick Script

  1. Add the following code to the breakBrick script:
    when this sprite clicked
    delete this clone

    This script deletes the brick sprite when it's clicked.

Game Logic

  1. Add the following code to the Paddle sprite's script:

    when green flag clicked
    forever
     if key [space] pressed
       create clone of [Ball]
     end

    This script creates a new ball clone when the space bar is pressed.

  2. Add the following code to the Ball sprite's script:

    when green flag clicked
    forever
     if touching [Bricks]
       delete this clone
       create clone of [Bricks]
     end

    This script deletes the ball clone and creates a new brick clone when it touches a brick.

Putting it all together

  1. Add the Paddle, Ball, and Bricks sprites to the stage by dragging and dropping them from the "Sprites" panel.
  2. Set the initial position of the Paddle sprite to the bottom of the stage.
  3. Set the initial position of the Ball sprite to the top of the stage.
  4. Run the game by clicking on the "Green Flag" button or by using the shortcut key "Ctrl + Enter" (Windows) or "Cmd + Enter" (Mac).

That's it! You now have a basic Brick Breaker game on Scratch. You can customize the game by adding more features, such as scoring, levels, and power-ups. Have fun!