Create Breakout game in Scratch

Scratch 15-05-25
33 0

Tutorial plan

1- Objective of the tutorial

2- Step-by-Step to create Breakout game

Objective of the tutorial

Learn how to build a brick breaker game using Scratch. This tutorial includes paddle control, bouncing ball, brick collision, scoring, and win/loss logic.

By the end of this tutorial, learners will be able to:

Design and build a classic Brick Breaker (Casse-Brique) game using Scratch.

Create and control a paddle that follows the player’s mouse or keyboard.

Program a ball that bounces off walls, the paddle, and breaks bricks.

Detect collisions between the ball and bricks, and remove bricks when hit.

Add a scoring system to track player progress.

Implement game over and win conditions.

Apply basic coding concepts such as loops, conditionals, variables, and broadcast messages.

 

Step-by-Step to create Breakout game

Step 1: Create the racket sprite:

1) Go to the new sprites section and select the paint icon.

2) Draw the racket sprite using the drawing editor.

3) Move the racket left and right

Insert these program blocks in the code area of ​​the racket sprite which allows the racket to be directed to the left or to the right using the two arrows (right and left) on the keyboard.

Step 2: Create the ball sprite

1) Go to the new sprites section and select the paint icon.

2) Draw the ball sprite using the drawing editor.

3) Program the ball sprite:

a) Orient the ball sprite

We insert the block when the green flag is clicked from the Events category:

Place the ball in the initial position using this block from the Motion category.

We will now direct the movement of the ball in a random way using these blocks from the Motion category:

And get the first part of the program for the ball:

b) MOVE THE BALL

For the ball to move in the scene in an autonomous way it is necessary to put the Block to advance of 5 steps in the block to repeat indefinitely.

Then we add the block bounce if the edge is reached so that the ball changes direction if it touches the edges of the stage.

c) BOUNCE ON THE RACKET

We will need to use a condition for this Script.

If the Ball sprite touches the Paddle sprite then change orientation.

In the Control Category, drag the If _ Then Block.

In the Sensors Category, drag the Block key? and choose Racket.

d) Game Over

The game ends when the sprite ball hits the ground floor.

So we are going to use the y ordinate of the ball to test if the ball hits the ground and the stop all block to stop all scripts in the game.

1- In the Control Category, drag the if _ then block.

2- Insert the block (y_ordinate) < (-150) in the if block condition. 3- Insert the two blocks say(‘Game Over’) and stop all inside the if then block.

Here is the final bullet sprite program:

Step 3: Creating the brick sprite:

1) Go to the new sprites section and select the paint icon.

2) Draw the brick sprite using the drawing editor.

 

Program the brick to be destroyed by the ball

First, we must create the variable score.

The set score to 0 block is executed when the green flag is clicked.

Then we insert the Show block from the Appearance category to display the brick at the start of the game.

The code block allows its contents to be repeated indefinitely.

We insert the If Then block into the repeat forever loop.

To check if the ball hits a brick, the block must hit the ball.

If the ball hits a brick, the score variable is incremented by 1

and the brick disappears from the scene using this block:

Here is the complete brick sprite program:

Note: You have to duplicate the brick sprite to have multiple bricks in the game scene.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info