Coding Ireland STEM Report 2024 Have Your Say
Scratch Game
Beginner
60 mins
185 points
What you need:

Dino food game

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.

1 - Create a new Scratch project

Open the Scratch website in a new tab and create a new project. Delete the cat sprite from the project.

2 - Add a character

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.


3 - Shrink the dinosaur

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) %

Click on the green flag and the dinosaur sprite will shrink to half it's normal size.


4 - Make the dinosaur move up and down

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

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.


5 - Make the dinosaur move left and right

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:

when [left arrow v] key pressed point in direction (-90)// notice that this is MINUS 90 (-90) move (10) steps when [right arrow v] key pressed point in direction (90) move (10) steps

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:

when green flag clicked set size to (50) % // add it under here set rotation style [left-right v]



Join our club 😃

To view the remaining 7 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more