Breakout Game In Scratch

This blog post will guide you through the main steps needed to create a breakout game in scratch.

scratch-final-breakout-game

Step 1Step 2Step 3Step 4Step 5Step 6Step 7

Step 1: The Paddle

You will first need to delete the cat sprite that comes per default when you create a new Scratch project.

You will then create a new sprite and use the Paddle sprite from the scratch library.
scratch-paddle-sprite

You will then need to add the code required to control the paddle using both the left and right arrow keys:
scratch-paddle-code

Step 2: The Bouncing Ball


Add a new Ball sprite.
scratch-ball-sprite
You can resize this sprite to make it smaller:
scratch-ball-resize
Now let’s add the code to make this ball bounce around the edges of the screen:
scratch-ball-bouncing-code

Step 3: Bouncing off the Paddle


We need to add some code to the ball sprite to make it bounce when it hits the paddle.
scratch-ball-bouncing-code-complete

Step 4: Adding a score variable


Let’s make a new variable called score. We will use this variable to score 1 point per brick we break. To do so you will need to go to the variable section:
scratch-variables-section
Then you will click on the “Make a Variable button”.
scratch-make-variable
Give a name to your variable: score and tick the option “For all sprites”
scratch-ball-bouncing-code-complete
Make sure your variable is visible (Tick the checkbox next to the variable itself):
scratch-make-variable-visible
Let’s add the following code (for the paddle sprite) to initialise our score to 0 when the game starts:
scratch-set-score-0

Step 5: Adding bricks


We will now add a brick sprite:
scratch-button3-sprite
Let’s rename this sprite to brick and resize it to make it smaller (e.g. size: 50).
scratch-brick-sprite
Now let’s add the code to make the brick disappear when the ball hits it. We will also increment (add 1 point) our score when this happens:scratch-break-a-brick

We can now duplicate our sprites at least 10 times to create the brick wall:
scratch-duplicate-sprite
scratch-break-out-game

Step 6: Losing lives


Let’s create a new variable called Number Of Lives, available for all sprites.
scratch-number-of-lives-variable
Let’s update the code of the paddle sprite to initialise our variable to 3 lives when the game start:
scratch-initialise-number-of-lives-variable
Now let’s add a new line sprite:
scratch-line-sprite
Let’s make sure we position sprite just underneath the paddle:
scratch-line-sprite-position
Let’s add some code to the ball sprite that will check if the ball hits this “life line” and if it does the player will lose a life and the ball will bounce back.
scratch-number-of-lives-code

Step 7: Game Over Screen


When the number of lives reaches 0, the game will stop and display a Game Over Screen.
So let’s first create a new Game Over backdrop:
scratch-game-over-screen
Then let’s add some code on the ball sprite:
scratch-number-of-lives-final-code

The End.

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 3.4 / 5. Vote count: 125

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: