Welcome to our exciting coding adventure! Today, we're going to create a fun game using Scratch. In this game, you'll control a dinosaur who loves to eat beetles. Your job is to help the dinosaur catch as many beetles as it can. We'll learn how to add characters, make them move, and even add sounds. Let's get started!
Open the Scratch website 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:
when green flag clicked
set size to (50) %
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:
when [up arrow v] key pressed
point in direction (0)
move (10) steps
when [down arrow v] key pressed
point in direction (180)
move (10) steps
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:
when [left arrow v] key pressed
move (10) steps
if < key [left arrow v] pressed? > then
move (10) steps
end
You need to add an on-screen button (like an arrow sprite) and use this code:
when this sprite clicked
move (10) steps
Now, just tap the button on the screen to perform the same action!