0% found this document useful (0 votes)
44 views10 pages

Cats

This document outlines a project to create a line-following game in Scratch where players guide cats to safety by drawing a path. It includes instructions on setting up the game, coding the cat sprites, and implementing scoring. The project encourages creativity by suggesting additional challenges to enhance gameplay.

Uploaded by

goonijon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views10 pages

Cats

This document outlines a project to create a line-following game in Scratch where players guide cats to safety by drawing a path. It includes instructions on setting up the game, coding the cat sprites, and implementing scoring. The project encourages creativity by suggesting additional challenges to enhance gameplay.

Uploaded by

goonijon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

11/05/2018 Raspberry Pi Projects

Raspberry Pi Projects

CATS!
Introduction
In this project, you will create a simple line-following game in Scratch. Guide the cats to
safety, and don’t let any of them fall through the gaps!

What you will make


Click and drag with the mouse to draw a line with the pencil. Your objective is to stop the
cats falling to their doom by creating a safe path to the exit.

What you will learn


This project covers elements from the following strands of the Raspberry Pi Digital Making
Curriculum (http://rpf.io/curriculum):

Apply basic programming constructs to solve a problem


(https://curriculum.raspberrypi.org/programming/builder/)

What you will need


Hardware
A computer capable of running Scratch

Software
Scratch 2.0 (either online (https://scratch.mit.edu/projects/editor/) or o ine
(https://scratch.mit.edu/scratch2download/))

Drawing lines
Open the starter project

I'm using Scratch online


Open the ‘CATS!’ Scratch starter project at jumpto.cc/cats-go
(http://jumpto.cc/cats-go).

If you have a Scratch account, you can click on Remix in the top right-hand corner
to save a copy of the project to your account.

I'm using Scratch o ine


Download the cats.sb2 (https://projects-
static.raspberrypi.org/projects/cats/9bc40c392d65 8439e739b7d26226f5a1a04363/en/r
Scratch starter project, and open it using the o ine editor.

https://projects.raspberrypi.org/en/projects/cats/print 1/10
11/05/2018 Raspberry Pi Projects

Click on the sprite called Pen, and add code to set the pen colour to the same blue as the
obstacles on the stage. Clear the screen and set the pen size to 5.

You can select a colour by clicking on the colour block (circled) to get the pipette cursor,
followed by clicking on the colour you want on the stage.

Add some more code to make the sprite follow the mouse pointer. Test your program to
check that the code works.

Saving a Scratch project


Give your program a name by typing into the text box in the top-left corner.

You can click File and then Save now to save your project.

Note: if you’re using Scratch online but don’t have a Scratch account, you can
save a copy of your project by clicking Download to your computer instead.

Add some code to tell the sprite to draw a line on the stage if the mouse button is
pressed down.

I need a hint

https://projects.raspberrypi.org/en/projects/cats/print 2/10
11/05/2018 Raspberry Pi Projects

This is what your code should look like:

Test your code. You should be able to click and drag with the mouse to draw a blue line
on the screen.

You will probably notice that a blue dot always appears in the top right corner of your stage
(circled in red). This is because when you click the green ag to start the game, the mouse is
pressed down so the pen immediately starts drawing.

Add a block to wait one second before the forever block to stop this from happening.

https://projects.raspberrypi.org/en/projects/cats/print 3/10
11/05/2018 Raspberry Pi Projects

Cloning cats
We want to generate an in nite stream of cats that the player will guide along the path to the
exit.

Click on the sprite called Cat, and add some code to make it invisible, and also to clone it
every three seconds.

If you run the program at the moment, nothing will happen. Let’s make each cloned cat
appear and fall out of the sky, so we can check that a new one is being created every three
seconds.

Add some code to tell the sprite that when it starts as a clone, it should become visible
and fall until it reaches the blue oor which is drawn on the stage

I need a hint
This is what your code should look like:

When you press the green ag, you should see a new cat falling out of the sky every three
seconds and landing in a big pile of overlapping cats on the blue oor at the bottom.

https://projects.raspberrypi.org/en/projects/cats/print 4/10
11/05/2018 Raspberry Pi Projects

Moving cats
When a cat has appeared and fallen until it reaches the oor, we want it to step slowly to the
right.

Add some code to the when I start as a clone section to make the cat sprite
move ten steps, and switch between the two costumes every 0.1 seconds to make it look
like the cat is walking.

I need a hint
This is what your code should look like:

https://projects.raspberrypi.org/en/projects/cats/print 5/10
11/05/2018 Raspberry Pi Projects

Press the green ag and check that the cats now move along the blue platform at the
bottom.

You will notice that, if you draw a bridge across the gap so that the cats can get all the way
to the right edge of the screen, they end up getting stuck walking into the wall.

Remove the forever loop you added, and instead add a di erent loop to make the cats
only walk until they reach an edge. When a cat reaches the edge of the screen, it should
disappear.

I need a hint
This is what your code should look like:

Press the green ag and check that the cats disappear when they reach the edge of the
screen.

You might notice that the cats don’t disappear properly if they fall into the hole, they just get
stuck at the bottom. This is because the sprite is getting stuck trying to fall!

This code tells the cat to keep falling until it touches blue. However, in the hole the cat will
never reach blue, so it is stuck forever.

https://projects.raspberrypi.org/en/projects/cats/print 6/10
11/05/2018 Raspberry Pi Projects

Add more blocks to this loop to tell it to repeat until it is touching blue or touching
the edge. This way, the sprite will stop trying to fall if it reaches the edge of the screen.

Sticking to the lines


When testing your game, you might notice that if you draw a low bridge between the two
platforms, or a line that slopes upwards, the cats end up walking through the platform rather
than on top of it!

In the code for the cat sprite, add another loop after the loop which makes the cat fall.
This time, the loop should tell the cat to move upwards by two until it is not touching
blue.

I need a hint

https://projects.raspberrypi.org/en/projects/cats/print 7/10
11/05/2018 Raspberry Pi Projects

This is what your code should look like:

Click the green ag and try drawing a line which slopes upwards. Check that your cat
follows the line.

Getting to safety
The object of the game is to guide the cats to safety by creating a safe path for them to
reach the door. Let’s make a score variable to keep track of how many cats have successfully
reached the door.

Create a variable called score.

Add a variable in Scratch


Click on Data in the Scripts tab, then click on Make a Variable.

Type in the name of your variable. You can choose whether you would like your
variable to be available to all sprites, or to only this sprite. Press OK.

https://projects.raspberrypi.org/en/projects/cats/print 8/10
11/05/2018 Raspberry Pi Projects

Once you have created the variable, it will be displayed on the Stage, or you can
untick the variable in the Scripts tab to hide it.

New blocks will appear and allow you to change the value of the variable.

Add some code to your cat sprite to add one to the score each time a cat reaches the
door. Don’t forget to also set the score to zero at the start of the game.

I need a hint
This is what your code should look like:

Add some more code so that a cat sprite that reaches the door makes a ‘meow’ sound
and then disappears.

Challenge: more obstacles

https://projects.raspberrypi.org/en/projects/cats/print 9/10
11/05/2018 Raspberry Pi Projects

The level we have created at the moment is rather easy to win. Could you make your game
harder?

Add more backgrounds with di erent platform designs.

Move the location of the door depending on which background is displayed.

Add some more sprites to represent moving obstacles. Perhaps you could have roaming
dogs or rotating spikes for the cats to avoid?

Only allow the player to use a xed amount of “ink” to draw extra lines on the game. You
can keep track of how much “ink” is used by creating a variable and using the timer to
time how long the mouse is held down.

Create a sprite to represent to the player how much ink they have left.

Published by Raspberry Pi Foundation (https://www.raspberrypi.org) under a Creative


Commons license (https://creativecommons.org/licenses/by-sa/4.0/).
View project & license on GitHub (https://github.com/RaspberryPiLearning/cats)

https://projects.raspberrypi.org/en/projects/cats/print 10/10

You might also like