Virtual Pets - Free Coding Activity

Screenshot of a virtual pets Scratch coding game showing dogs

Follow our easy step-by-step instructions to create and clone poodles, huskies, corgis and many more in Scratch!

  1. 1

    Go to the Scratch website: https://scratch.mit.edu/

  2. 2

    Sign in or register for Scratch

    If you already have a Scratch account, click ‘Sign in’ and enter your login details. Otherwise click ‘Join Scratch’ and create your free Scratch account.

  3. 3

    Open this starter file: https://scratch.mit.edu/projects/993715327/

  4. 4

    Click the 'Remix' button to make your own copy

    Image to illustrate step 4
  5. 5

    Start by clicking on the 'Dogs' sprite.

    This sprite contains costumes for 10 different dogs.

    Image to illustrate step 5
  6. 6

    Add this code to hide the sprite and set up the 'Dogs Seen' list.

    We will use clones to show the dogs on the stage.

    Image to illustrate step 6
  7. 7

    Next, add this code to create a new clone every second.

    A clone is a copy of a sprite.

    Image to illustrate step 7
  8. 8

    To be able to see the clones, we'll need a bit more code.

    This will send the dogs to the left side of the stage and give them a random costume.

    Image to illustrate step 8
  9. 9

    Press the Green Flag. Can you see dogs appearing on the left?

    Image to illustrate step 9Image to illustrate step 9
  10. 10

    To make the dogs move, add these blocks.

    The dogs will disappear once they cross the stage.

    Image to illustrate step 10
  11. 11

    When we click a dog, this code will check if we've seen that type before.

    Image to illustrate step 11
  12. 12

    If we haven't, then that dog's name is added to the list!

    Image to illustrate step 12
  13. 13

    Test out your code.

    Can you see the types of dogs being added to the list as you click them?

    Image to illustrate step 13
  14. 14

    Finally, let's add some code to check if we've seen all the dogs.

    There are 10 dog types, so we'll have to check if our list has 10 items in it.

    Image to illustrate step 14
  15. 15

    If we have seen all the dogs, then we win and the game stops.

    Image to illustrate step 15
  16. 16

  17. 17

    Press the Green Flag and test it out!

    Can you spot all the dogs and win the game?

    Image to illustrate step 17

Thanks for building a game with us!

If you enjoyed this coding activity be sure to sign up for our online coding classes for kids. Our coding classes are a lot of fun, but they’re also really effective at teaching coding techniques and challenging students to develop their skills. You’ll learn about loops, variables and functions - and everything in between - and you’ll build your own games and animations with a small group of kids of the same age and experience level as you.

Sign up for one of our free coding lessons