Tutoring

Learn

Resources

How to Make a Game with Levels on Scratch? Step-by-Step Tutorial

Updated By

Reviewed By

How to make a game with levels on Scratch
Image

Games can be of different types with some having only one level and some having more than one. However, games with more than one level are considered to be the best games because a game having multiple levels are more exciting to play and brings new challenges for the players to explore and win.

So, in this blog, we will give you a step-by-step game tutorial on how to make a game with levels on Scratch and help you in creating a “Balloon-Pop” game.

How to make a game with levels on Scratch?

This game with levels is called the “Ballon-Pop” game. This is a multilevel game in which the player has to pop at least 10 balloons which will be moving at a fast pace. As the player accomplishes the challenge, he/she will be moving onto the next level and with each increasing level, it will become harder to ‘pop’ the balloons.

So, to create the “Balloon-Pop” game in Scratch, just patiently follow the below-given steps:

  • Step 1: Open Scratch and start creating sprites. For this game, you will be using the pre-made Scratch cat sprite as the sonic character, so rename it as ‘Player’ to avoid confusion while coding.
using the pre-made Scratch cat sprite
  • Step 2: It’s time to choose another sprite, so to choose another sprite, click on the blue circle with the cat icon.
click on the blue circle with the cat icon
  • Step 3: After clicking on the blue circle for choosing a sprite, select the first option from below that says ‘Choose a Sprite’.
select the first option
  • Step 4: Once you click on the ‘Choose a Sprite’ option, the following screen will appear.
click on the ‘Choose a Sprite’ option
  • Step 5: Search for ‘Balloon’ and ‘Robot’ and select them, as shown below. Rename the sprites as ‘Balloon’ and ‘Robot’ to avoid confusion while coding.
Search for ‘Balloon’ and ‘Robot’
  • Step 6: Now, it’s time to choose the backdrops for this game. So, to choose the backdrop, click on the blue circle available at the extreme right of the screen.
click on the blue circle
  • Step 7: After clicking on the blue circle for choosing a backdrop, select the first option from below that says ‘Choose a Backdrop’.
select the first option
  • Step 8: Once you click on the ‘Choose a Backdrop’ option, the following screen will appear.
click on the 'Choose a Backdrop' option
  • Step 9: Search for ‘Rays’ and ‘Circles’ and select them, as shown below. Leave the name of the backdrops as ‘Rays’ and ‘Circles’ to avoid confusion while coding.
Search for 'Rays' and 'Circles'
  • Step 10: After selecting the sprites and the backdrops, it’s time to make the variables of the game. So, first, switch to the ‘Code’ section, then go to the “Variables” block in the block palette, click on the ‘Make a Variable’ option, and create variables named ‘timeLeft’ and ‘point’. Make sure to select the ‘For this sprite only’ option while creating the sprites.
go to the "Variables" block

Code for the ‘Balloon’ sprite

It’s time for coding, so let’s start by creating a code for the ‘Balloon’ sprite. Make sure that the ‘Balloon’ sprite and ‘Rays’ backdrop is selected while coding this part.

  • Step 1: Go to the “Events” block in the block palette, select the ‘when green flag clicked’ block, and drag it to the coding area.
Go to the "Events" block
  • Step 2: Go to the “Control” block in the block palette, select the ‘forever’ block, drag it to the coding area, and place it under the ‘when green flag clicked’ block.
Go to the "Control" block
  • Step 3: Go to the “Looks” block in the block palette, select the ‘show’ block, drag it to the coding area, and place it inside the ‘forever’ block.
Go to the "Looks" block
  • Step 4: Go to the “Motion” block in the block palette, select the ‘go to x: ( ) y: ( )’ block, drag it to the coding area, and place it under the ‘show’ block inside the ‘forever’ block.
Go to the "Motion" block
  • Step 5: Go to the “Operators” block in the block palette, select the ‘pick random ( ) to ( )’ block, drag it to the coding area, and place it in the first value part of the ‘go to x: ( ) y: ( )’ block and enter the value ‘-254’ in the second value part of the ‘go to x: ( ) y: ( )’ block.
Go to the "Operators" block
  • Step 6: In the ‘pick random ( ) to ( )’ block, enter the values ‘-234’ and ‘234’ in the first and second value places, respectively.
enter the values '-234' and '234'
  • Step 7: Go to the “Motion” block in the block palette, select the ‘glide ( ) secs to x: ( ) y: ( )’ block, drag it to the coding area, and place it under the ‘go to x: ( ) y: ( )’ block inside the ‘forever’ block.
Go to the "Motion" block
  • Step 8: From the “Motion” block in the block palette, select the ‘x position’ block, drag it to the coding area, and place it in the second value place of the ‘glide ( ) secs to x: ( ) y: ( )’ block. For the third value place of the ‘glide ( ) secs to x: ( ) y: ( )’ block, enter the value ‘254’ and for the first value place of the ‘glide ( ) secs to x: ( ) y: ( )’ block, leave the value as ‘1’.
select the 'x position' block
  • Step 9: Go to the “Looks” block in the block palette, select the ‘hide’ block, drag it to the coding area, and place it under the ‘glide ( ) secs to x: ( ) y: ( )’ block inside the ‘forever’ block.
Go to the "Looks" block

Code for counting the points and moving up

The player gets 1 point in the game for every click on the ‘Balloon’ sprite and the player needs a total of 5 points for moving to the next level. Make sure that the ‘Balloon’ sprite is selected while coding this part.

  • Step 1: Go to the “Variables” block in the block palette, select ‘set ( ) to ( )’ block, drag it to the coding area, and place it under the ‘when green flag clicked’ block and above the ‘forever’ block in the above-explained code of the ‘Balloon’ sprite.
Go to the "Variables" block
  • Step 2: Now go to the “Events” block in the block palette, select the ‘when this sprite clicked’ block, and drag it to the coding area.
go to the "Events" block
  • Step 3: Go to the “Variables” block in the block palette, select the ‘change ( ) by ( )’ block, drag it to the coding area, and place it under the ‘when this sprite clicked’ block. In the ‘change ( ) by ( )’ block, leave the first and second values as ‘my variable’ and ‘1’, respectively.
Go to the "Variables" block

Code to change the backdrop

Make sure that the ‘Balloon’ sprite is selected while coding this part.

  • Step 1: Go to the “Control” block in the block palette, select ‘if ( ) then ( )’ block, drag it to the coding area, and place it under the ‘hide’ block inside the ‘forever’ block in the above-explained code of the ‘Balloon’ sprite for counting the points and moving up.
Go to the "Control" block
  • Step 2: Go to the “Operators” block in the block palette, select the ‘( ) = ( )’ block, drag it to the coding area, and place it in the if condition of the ‘if ( ) then ( )’ block.
Go to the "Operators" block
  • Step 3: Go to the “Variables” block in the block palette, select the ‘my variable’ block, drag it to the coding area, and place it in the first value part of the ‘( ) = ( )’ block and in the second value part of the ‘( ) = ( )’, enter the value ‘10’, as shown below.
Go to the "Variables" block
  • Step 4: Go to the “Looks” block in the block palette, select the ‘switch backdrop to ( )’ block, drag it to the coding area, and place it in the then condition of the ‘if ( ) then ( )’ block.
Go to the "Looks" block
  • Step 5: In the ‘switch backdrop to ( )’ block, select the value as ‘next backdrop’ from the drop-down menu.
select the value as 'next backdrop'

Code to move to the next level

In this part, you need to code to move the player to the next level if he matches all the requirements needed to go to the next level. Make sure that the ‘Player’ sprite is selected while coding this part.

  • Step 1: Go to the “Events” block in the block palette, select the ‘when green flag clicked’ block, and drag it to the coding area.
Go to the "Events" block
  • Step 2: Go to the “Variables” block in the block palette, select 2 ‘set ( ) to ( )’ blocks, drag them to the coding area, and place them under the ‘when green flag clicked’ block.
Go to the "Variables" block
  • Step 3: In the first ‘set ( ) to ( )’ block, select the first value as ‘timeLeft’ from the drop-down menu and change the second value to ‘10’ and in the second ‘set ( ) to ( )’ block, select the first value as ‘point’ from the drop-down menu and leave the second value as ‘0’, as shown below.
select the first value as 'timeLeft'
  • Step 4: Go to the “Control” block in the block palette, select the ‘forever’ block, drag it to the coding area, and place it under the second ‘set ( ) to ( )’ block.
Go to the "Control" block
  • Step 5: From the “Control” block in the block palette, select the ‘repeat until ( )’ block, drag it to the coding area, and place it inside the ‘forever’ block.
select the 'repeat until ( )' block
  • Step 6: Go to the “Operators” block in the block palette, select the ‘( ) = ( )’ block, drag it to the coding area, and place it in the value part of the ‘repeat until ( )’ block.
Go to the "Operators" block
  • Step 7: Go to the “Variables” block in the block palette, select the ‘timeLeft’ block, drag it to the coding area, and place it in the first value part of the ‘( ) = ( )’ block and in the second value part of the ‘( ) = ( )’, enter the value ‘0’, as shown below.
Go to the "Variables" block
  • Step 8: Go to the “Control” block in the block palette, select ‘if ( ) then ( ) else ( )’ block, drag it to the coding area, and place it inside the ‘repeat until ( )’ block which is inside the ‘forever’ block.
Go to the "Control" block
  • Step 9: Go to the “Operators” block in the block palette, select the ‘( ) > ( )’ block, drag it to the coding area, and place it in the if condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Operators" block
  • Step 10: Go to the “Variables” block in the block palette, select the ‘point’ block, drag it to the coding area, and place it in the first value part of the ‘( ) > ( )’ block and in the second value part of the ‘( ) > ( )’, enter the value ‘4’, as shown below.
Go to the "Variables" block
  • Step 11: Go to the “Looks” block in the block palette, select the ‘show’ block, drag it to the coding area, and place it the then condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Looks" block
  • Step 12: Go to the “Motion” block in the block palette, select the ‘go to x: ( ) y: ( )’ block, drag it to the coding area, and place it under the ‘show’ block inside the then condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Motion" block
  • Step 13: Go to the “Operators” block in the block palette, select the ‘pick random ( ) to ( )’ block, drag it to the coding area, and place it in the first value part of the ‘go to x: ( ) y: ( )’ block and enter the value ‘-254’ in the second value part of the ‘go to x: ( ) y: ( )’ block.
Go to the "Operators" block
  • Step 14: In the ‘pick random ( ) to ( )’ block, enter the values ‘-234’ and ‘234’ in the first and second value places, respectively.
enter the values '-234' and '234'
  • Step 15: Go to the “Motion” block in the block palette, select the ‘glide ( ) secs to x: ( ) y: ( )’ block, drag it to the coding area, and place it under the ‘go to x: ( ) y: ( )’ block inside the then condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Motion" block
  • Step 16: From the “Motion” block in the block palette, select the ‘x position’ block, drag it to the coding area, and place it in the second value place of the ‘glide ( ) secs to x: ( ) y: ( )’ block. For the third value place of the ‘glide ( ) secs to x: ( ) y: ( )’ block, enter the value ‘254’ and for the first value place of the ‘glide ( ) secs to x: ( ) y: ( )’ block, leave the value as ‘1’.
select the 'x position' block
  • Step 17: Go to the “Looks” block in the block palette, select the ‘hide’ block, drag it to the coding area, and place it under the ‘glide ( ) secs to x: ( ) y: ( )’ block inside the then condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Looks" block
  • Step 18: Go to the “Variables” block in the block palette, select ‘change ( ) by ( )’ blocks, drag them to the coding area, and place it under the ‘hide’ block inside the then condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Variables" block
  • Step 19: In the ‘change ( ) by ( )’ block, select the first value as ‘timeLeft’ from the drop-down menu and change the second value to ‘-1’.
select the first value as 'timeLeft'
  • Step 20: Repeat the steps from 11 to 19 and place the blocks in the else condition of the ‘if ( ) then ( ) else ( )’ block with the only change in the ‘glide ( ) secs to x: ( ) y: ( )’ block. In the ‘glide ( ) secs to x: ( ) y: ( )’ block, for the first value place, enter the value ‘2’, as shown below.
  • Step 21: Go to the “Events” block in the block palette, select the ‘when this sprite clicked’ block, and drag it to the coding area.
Go to the "Events" block
  • Step 22: Go to the “Looks” block in the block palette, select the ‘play sound ( ) until done’ block, drag it to the coding area, and place it under the ‘when this sprite clicked’ block.
Go to the "Looks" block
  • Step 23: Go to the “Variables” block in the block palette, select the ‘change ( ) by ( )’ block, drag it to the coding area, and place it under the ‘play sound ( ) until done’ block.
Go to the "Variables" block
  • Step 24: In the ‘change ( ) by ( )’ block, select the first value as ‘point’ from the drop-down menu and leave the second value as ‘1’.
select the first value as 'point'
  • Step 25: Go to the “Looks” block in the block palette, select the ‘hide’ block, drag it to the coding area, and place it under the ‘change ( ) by ( )’ block.
Go to the "Looks" block

Code to control the backdrop display

In this part, you need to code to control the backdrop display. In the first level of the game, the ‘Rays’ backdrop will be visible and in the second level of the game, the ‘Circles’ backdrop will be visible. Make sure that the ‘Backdrop’ option is selected while coding this part.

  • Step 1: Go to the “Events” block in the block palette, select the ‘when green flag clicked’ block, and drag it to the coding area.
Go to the "Events" block
  • Step 2: Go to the “Control” block in the block palette, select the ‘forever’ block, drag it to the coding area, and place it under the ‘when green flag clicked’ block.
Go to the "Control" block
  • Step 3: From the “Control” block in the block palette, select the ‘if ( ) then ( ) else ( )’ block, drag it to the coding area, and place it inside the ‘forever’ block.
select the 'if ( ) then ( ) else ( )' block
  • Step 4: Go to the “Operators” block in the block palette, select the ‘( ) and ( )’ block, drag it to the coding area, and place it in the if condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Operators" block
  • Step 5: From the “Operators” block in the block palette, select the ‘( ) > ( )’ block and ‘( ) < ( )’ block, drag them to the coding area, and place them in the first and second value places of the ‘( ) and ( )’, respectively.
select the ‘( ) > ( )’ block and ‘( ) < ( )’ block
  • Step 6: Go to the “Variables” block in the block palette, select the ‘point’ block, drag it to the coding area, and place it in the first value part of the ‘( ) > ( )’ block and in the second value part of the ‘( ) > ( )’, enter the value ‘4’, as shown below.
Go to the "Variables" block
  • Step 7: Again go to the “Variables” block in the block palette, select the ‘timeLeft’ block, drag it to the coding area, and place it in the first value part of the ‘( ) < ( )’ block and in the second value part of the ‘( ) < ( )’, enter the value ‘11’, as shown below.
select the 'timeLeft' block
  • Step 8: Go to the “Looks” block in the block palette, select the ‘switch backdrop to ( )’ block, drag it to the coding area, and place it in the then condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Looks" block
  • Step 9: In the ‘switch backdrop to ( )’ block, select the value as ‘Circles’ from the drop-down menu.
select the value as 'Circles'
  • Step 10: From the “Looks” block in the block palette, again select the ‘switch backdrop to ( )’ block, drag it to the coding area, and place it in the else condition of the ‘if ( ) then ( ) else ( )’ block.
select the 'switch backdrop to ( )' block
  • Step 11: In the ‘switch backdrop to ( )’ block, select the value as ‘Rays’ from the drop-down menu.
select the value as 'Rays'

Code for the ‘Robot’ sprite

In this part, you need to code for the ‘Robot’ sprite which will keep track of the time which is left in the game for the player. Make sure that the ‘Robot’ sprite is selected while coding this part.

  • Step 1: Go to the “Events” block in the block palette, select the ‘when green flag clicked’ block, and drag it to the coding area.
Go to the "Events" block
  • Step 2: Go to the “Control” block in the block palette, select the ‘forever’ block, drag it to the coding area, and place it under the ‘when green flag clicked’ block.
Go to the "Control" block
  • Step 3: From the “Control” block in the block palette, select the ‘if ( ) then ( ) else ( )’ block, drag it to the coding area, and place it inside the ‘forever’ block.
select the 'if ( ) then ( ) else ( )' block
  • Step 4: Go to the “Operators” block in the block palette, select the ‘( ) and ( )’ block, drag it to the coding area, and place it in the if condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Operators" block
  • Step 5: From the “Operators” block in the block palette, select the ‘( ) = ( )’ block and ‘( ) < ( )’ block, drag them to the coding area, and place them in the first and second value places of the ‘( ) and ( )’, respectively.
select the ‘( ) = ( )’ block and ‘( ) < ( )’ block
  • Step 6: Go to the “Variables” block in the block palette, select the ‘timeLeft’ block, drag it to the coding area, and place it in the first value part of the ‘( ) = ( )’ block and in the second value part of the ‘( ) = ( )’, enter the value ‘0’, as shown below.
Go to the "Variables" block
  • Step 7: Again go to the “Variables” block in the block palette, select the ‘point’ block, drag it to the coding area, and place it in the first value part of the ‘( ) < ( )’ block and in the second value part of the ‘( ) < ( )’, enter the value ‘5’, as shown below.
go to the "Variables" block
  • Step 8: Go to the “Looks” block in the block palette, select the ‘say ( ) for ( ) seconds’ block, drag it to the coding area, and place it in the then condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Looks" block
  • Step 9: In the ‘say ( ) for ( ) seconds’ block, enter the text ‘Sorry you lost!!’ in the first value place, and for the second value place, enter the value ‘5’.
enter the text 'Sorry you lost!!'
  • Step 10: Go to the “Control” block in the block palette, select the ‘stop (all)’ block, drag it to the coding area, and place it under the ‘say ( ) for ( ) seconds’ block in the then condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Control" block
  • Step 11: Go to the “Control” block in the block palette, again select the ‘if ( ) then ( ) else ( )’ block, drag it to the coding area, and place it in the else condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Control" block
  • Step 12: Go to the “Operators” block in the block palette, select the ‘( ) = ( )’ block, drag it to the coding area, and place it in the if condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Operators" block
  • Step 13: Go to the “Variables” block in the block palette, select the ‘timeLeft’ block, drag it to the coding area, and place it in the first value part of the ‘( ) = ( )’ block and in the second value part of the ‘( ) = ( )’, enter the value ‘0’, as shown below.
Go to the "Variables" block
  • Step 14: Go to the “Looks” block in the block palette, select the ‘say ( ) for ( ) seconds’ block, drag it to the coding area, and place it in the then condition of the ‘if ( ) then ( ) else ( )’ block.
Go to the "Looks" block
  • Step 15: In the ‘say ( ) for ( ) seconds’ block, enter the text ‘Game Ended!!’ in the first value place and for the second value place, enter the value ‘2’.
enter the text 'Game Ended!!'
  • Step 16: From the “Looks” block in the block palette, again select the ‘say ( ) for ( ) seconds’ block, drag it to the coding area, and place it under the first ‘say ( ) for ( ) seconds’ block in the then condition of the ‘if ( ) then ( ) else ( )’ block.
select the ‘say ( ) for ( ) seconds’ block
  • Step 17: Go to the “Operators” block in the block palette, select the ‘join ( ) ( )’ block, drag it to the coding area, and place it in the first vale part of the ‘say ( ) for ( ) seconds’ block.
Go to the "Operators" block
  • Step 18: Go to the “Variables” block in the block palette, select the ‘point’ block, drag it to the coding area, and place it in the second value part of the ‘join ( ) ( )’ block and in the first value part of the ‘join ( ) ( )’ block, enter the text ‘Total points’. Also, enter the value ‘2’ in the second value part of the second ‘say ( ) for ( ) seconds’.
Go to the "Variables" block
  • Step 19: Go to the “Control” block in the block palette, select the ‘if ( ) then ( )’ block, drag it to the coding area, and place it in the else condition of the second ‘if ( ) then ( ) else ( )’ block.
Go to the "Control" block
  • Step 20: Go to the “Operators” block in the block palette, select the ‘( ) and ( )’ block, drag it to the coding area, and place it in the if condition of the ‘if ( ) then ( )’ block.
  • Step 21: From the “Operators” block in the block palette, select the ‘( ) < ( )’ block and ‘( ) > ( )’ block, drag them to the coding area, and place them in the first and second value places of the ‘( ) and ( )’, respectively.
select the ‘( ) < ( )’ block and ‘( ) > ( )’ block
  • Step 22: Go to the “Variables” block in the block palette, select the ‘timeLeft’ block, drag it to the coding area, and place it in the first value part of the ‘( ) < ( )’ block and in the second value part of the ‘( ) < ( )’, enter the value ‘10’, as shown below.
Go to the "Variables" block
  • Step 23: Again go to the “Variables” block in the block palette, select the ‘point’ block, drag it to the coding area, and place it in the first value part of the ‘( ) > ( )’ block and in the second value part of the ‘( ) > ( )’, enter the value ‘4’, as shown below.
go to the "Variables" block
  • Step 24: Go to the “Looks” block in the block palette, select the ‘say ( ) for ( ) seconds’ block, drag it to the coding area, and place it in the then condition of the ‘if ( ) then ( )’ block.
Go to the "Looks" block
  • Step 25: In the ‘say ( ) for ( ) seconds’ block, enter the text ‘Level 2!!’ in the first value place and for the second value place, enter the value ‘2’.
enter the text ‘Level 2!!’

Your ‘Balloon-Pop’ game is finally ready !!

Free game code access

Conclusion

Making multi-level games in Scratch is super fun!! Adding levels to a simple game makes the game more exciting, fun, adventurous, and interesting for the players to play. Also, multi-level games are always considered better than single-level games by the users.

FAQs on How to make a game with levels in Scratch

Which types of games among the single-level games and multi-level games are more fun to play?
Multi-level games are more fun to play because a game having multiple levels brings new challenges for the players to explore and win.

Why more levels should be added to a game?
More levels should be added to the games as the levels keep the players going. The more levels the player completes, the more powerful and achievable they feel in the game which helps them in gaining more experience with each new level and challenge.

What is the purpose of the game explained in this blog?
The game explained in this blog is a “Balloon-Pop” game which is a multilevel game in which the player has to pop at least 10 balloons which will be moving at a fast pace and as the player accomplishes the challenge, he/she will be moving on to the next level.

How does a multi-level game works?
In multi-level games, each level contains some set of obstacles and the player needs to overcome the obstacles to complete the game. When a player clears one level, they will be moving on to the next level of that game which has slightly more difficulty than the previous level.

What is the use of Events blocks in Scratch?
In Scratch, Events blocks are the most important blocks as these blocks are used to define when a script should run.

We hope you understand how to make a game with levels in Scratch. If you have any doubts, you can ask your doubts in the comment section. If you found this game interesting, then read our other game tutorials like Pac-man game, multiplayer game, and many more!

Get 1-on-1 online Scratch classes
Don't forget to share this post!
tutor Pic
tutor Pic

First Lesson Free

No Credit Card

No Subscription