Build a Scratch Game: My Digital Pet
Time: 15–20 minutes
What You’ll Need:
A computer or laptop
A Scratch account
A "Pet" sprite (like a Cat, Dog, or Monkey)
Project Overview
In this project, you’ll create a virtual pet that needs your attention! You will use a variable to track how hungry your pet is. If you don't click the pet to feed it, its hunger level will drop until the game ends.
Instructions
1. Pick Your Pet and Backdrop
Go to Scratch and click Create.
Delete the default cat (unless you want it as your pet!).
Click Choose a Sprite and pick any animal (e.g., "Monkey" or "Giga").
Click Choose a Backdrop and pick a nice home for your pet, like "Garden" or "Bedroom."
2. Create the "Hunger" Variable
Go to the orange Variables category.
Click the Make a Variable button.
Name the variable Hunger and click OK.
You should now see "Hunger" on the game screen.
3. Setup and the "Hunger" Timer
We need the pet to start full and get hungrier as time passes.
Select your Pet sprite and add this code:
when green flag clicked
set [Hunger] to 10
forever:
wait 3 seconds
change [Hunger] by -1
4. Feed Your Pet
Make the pet react when you click on it to "feed" it.
In the same sprite area, add this new block of code:
when this sprite clicked
change [Hunger] by 1
play sound [Chirp] until done (or any happy sound!)
say [Yum!] for 1 seconds
5. The "Game Over" Check
If the hunger level drops too low, the pet needs to tell you the game is over.
Go back to your first script (under the green flag) and add the check inside the loop:
Inside the forever loop, after the change hunger block, add:
if <(Hunger) < 1> then:
say [I'm hungry! Game Over!]
stop [all]
Testing Your Game
Click the Green Flag.
Watch the Hunger variable count down every 3 seconds.
Click your pet quickly! You should see the hunger number go up and hear a sound.
Let the timer reach 0 to make sure the "Game Over" message works.