Breakout Game In Scratch

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


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.

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

Step 2: The Bouncing Ball

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

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.

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:
Then you will click on the “Make a Variable button”.
Give a name to your variable: score and tick the option “For all sprites”
Make sure your variable is visible (Tick the checkbox next to the variable itself):
Let’s add the following code (for the paddle sprite) to initialise our score to 0 when the game starts:

Step 5: Adding bricks

We will now add a brick sprite:
Let’s rename this sprite to brick and resize it to make it smaller (e.g. size: 50).
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:

Step 6: Losing lives

Let’s create a new variable called Number Of Lives, available for all sprites.
Let’s update the code of the paddle sprite to initialise our variable to 3 lives when the game start:
Now let’s add a new line sprite:
Let’s make sure we position sprite just underneath the paddle:
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.

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:
Then let’s add some code on the ball sprite:

The End.

Share Button
Tagged with: