For this lesson, we are going to create a game where we avoid meteors that fall from the sky.
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.
For this project, we are going to have three different screens; Start Screen, Game Screen and Game Over Screen.
The Start Screen will appear when the game starts and will show the title of the game and the Start button.
The Game Screen will appear once we click the Start button. In this screen, our dog sprite and rock sprites will appear.
The Game Over Screen will appear when the game ends. In this screen, all the sprites will disappear and all the codes will stop.
To add a backdrop from the backdrop library follow these steps:
You can use search box or the filter links (Fantasy, Music, Sports etc) to locate your backdrop.
We are going to add a start button to our project.
First, we need to add a new sprite that looks like a button.
This button sprite will be shown when the game starts and hides when clicked. This button will also change our backdrop to the Game Screen when it is clicked.
The code below will handle the showing, hiding and clicking of the start button.
when green flag clicked
show
when this sprite clicked
switch backdrop to (Game Screen v)
hide
You can create your own sprites using the sprite editor. To create a new sprite put your mouse over the Choose a Sprite button and then click on the paintbrush.
This create a blank sprite and will open the sprite editor where you can use the tools to create your sprite. You can even create extra costumes for your sprite!
Tip: give your sprite a name so that you can recognise it in the code blocks.
For this part, we are going to add our main character, the dog.
We need to add a dog sprite and we can do that by going into the sprite library and looking for the dog sprite.
You can create your own sprites using the sprite editor. To create a new sprite put your mouse over the Choose a Sprite button and then click on the paintbrush.
This create a blank sprite and will open the sprite editor where you can use the tools to create your sprite. You can even create extra costumes for your sprite!
Tip: give your sprite a name so that you can recognise it in the code blocks.
When we start the game, we want to hide the dog sprite. We can use the code below to do this.
when green flag clicked
hide
Now, we want our dog to show when we switch to our Game Screen. We also want our dog to start at our desired location, x = 0 and y = -170. We can do that by following the code.
when backdrop switches to [Game Screen v]
go to x: (0) y: (-170)
show