For this lesson, we are going to create a game about clicking balloons that move around the game screen.
Go to the Scratch website and create a new project and delete the cat sprite.
Go to the Scratch website using the link below and click on the 'Create' link in the blue bar at the top.
By default, each new project starts with the cat sprite already added. To delete the cat click on the x in the blue circle beside the cat in the sprite list.
Open up the sprite library and add in the balloon sprite.
To add a sprite from the sprite library follow these steps:
You can use search box or the filter links (Animals, People, Fantasy etc) to locate your sprite.
In this game we will be creating lots of clones of the balloon sprite so that we can try and pop them!
First, let's hide the balloon sprite and set it's size to 75%. To do it, add this code to the balloon sprite.
when green flag clicked
set size to (75) %
hide
Next, we want to keep creating clones every few seconds. To do this, we have to add a forever block to the previous code.
when green flag clicked
set size to (75) %
hide
forever // add new code under here
end
Inside the forever block, we can add the wait and the create clone block. This will handle the creation of clones every few seconds.
when green flag clicked
set size to (75) %
hide
forever
wait(5) seconds
create clone of (myself v)
We want the clones to move around the game screen.
First, we have to get the when I start as a clone block and we need to show the created clone. We can use the code below to our balloon sprite.
when I start as a clone
show
Next, we want the the created clone to move around and bounce once it touches the edge of the screen. To do this, we can use the code below.
when I start as a clone
show
forever
glide (3) secs to (random position v)
if on edge, bounce
To make our game challenging, we have to add scores and timers.
To do this, we can go to our balloon sprite and add two variables and we name them Score and Time.
In the Variables palette, create a new variable by clicking the 'Make a Variable' button.
Once you click this button a box will appear asking what you want to call your variable. Give it a name that reminds you what you will be using it for. For example, if you wanted to keep track of your score in a game, you would create a variable called 'score'.