In this project you'll create a game in Scratch. You'll add sprites, program them to move, add sounds and keep score!
In the game a dinosaur will roam around and catch beetles for food.
Open the Scratch website in a new tab and create a new project. Delete the cat sprite from the project.
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.
In the game we are going to make a dinosaur move around by using the arrow keys on our keyboard.
But first let's add the Dinosaur4 sprite from the sprite library.
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.
When the dinosaur sprite gets added to our project, it's a bit too big for our game so let's add some code to shrink it and make it smaller.
Add the following code to the dinosaur sprite:
Click on the green flag and the dinosaur sprite will shrink to half it's normal size.
Next we will program the dinosaur sprite to move up and down when we press the up and down arrow keys on our keyboard.
Each time we press an arrow key, we will point the dinosaur in that direction and then make them move 10 steps.
Add the following code to the dinosaur sprite:
Once you've added the code test that it works by pressing the up and down arrow keys and checking that the dinosaur moves in the correct direction. If the dinosaur goes in the wrong direction, check that you have the right numbers in the code blocks.
Since your tablet or iPad doesn’t have a physical keyboard, you’ll use on-screen buttons to complete this task. Wherever the instructions in this lesson mention pressing a key, you’ll need to tap a button on the screen instead. So, while your steps are a little different, you’ll still be able to make everything happen in your project.
So for example, instead of doing either of these:
You need to add an on-screen button (like an arrow sprite) and use this code:
Now, just tap the button on the screen to perform the same action!
Now we will program the dinosaur sprite to move left and right when we press the left and right arrow keys on our keyboard.
Each time we press an arrow key, we will point the dinosaur in that direction and then make them move 10 steps.
Add the following code to the dinosaur sprite:
Once you've added the code test that it works by pressing the left and right arrow keys and checking that the dinosaur moves in the correct direction. If the dinosaur goes in the wrong direction, check that you have the right numbers in the code blocks.
You will notice that the dinosaur goes upside down when you make it move left. We can fix this by using the "set rotation style [left-right]" code block. Add it underneath the "set size to (50) %" block:
Since your tablet or iPad doesn’t have a physical keyboard, you’ll use on-screen buttons to complete this task. Wherever the instructions in this lesson mention pressing a key, you’ll need to tap a button on the screen instead. So, while your steps are a little different, you’ll still be able to make everything happen in your project.
So for example, instead of doing either of these:
You need to add an on-screen button (like an arrow sprite) and use this code:
Now, just tap the button on the screen to perform the same action!