Lesson+2-+Walk+the+Cat

Lesson 2: Walking the Cat

In this lesson we will start to work with variables. Variables are ways you can tell the computer to do one thing if something is true and to do another if something is false.

We will start to create a simple maze. By the end of the lesson today, your sprite will be able to keep going when it is touching some colors and stop when it is touching others.

**-First,** open the Scratch program. Refer back to lesson 1 if you need help opening the CD.

-**Next,** we need to create the simple maze. Next to where you can see your sprites, there is a blank rectangle that says “Stage” Click on this. Now click on “backgrounds” and you can edit this to look like a maze.



-Choose ONE color for the background. Choose only ONE other color and draw some simple lines. When you are happy with how it looks, choose ok.



**-Now** click on your sprite. Under the control menu, we will choose “When the green flag is clicked,” and we will also choose the “forever if” loop. This means that what you are doing will happen forever as long as something else is true.

**-Now** go to the motions menu and have the sprite walk 2 steps. Put this in the “forever if” loop.

-We’re going to look at the **variables** menu now. We want the sprite to walk when he is on your background color, but to stop when he is on the lines you drew. Choose, “color __is touching color__ _.” Put this in the blank spot in the “forever if” loop.

-We need to change the sprite a little to make him work better. Edit the sprite and draw a small black circle right in front of him.



-Click on the first color in the variable. You should now have a little dropper for your mouse. Click on the little black dot we made. The box should change to black Do the same thing for the other box, but change this color to the color of your background.



Move your sprite to one side of the stage. When you click on your script, the sprite should move until his leg touches one part of the line your have drawn.

-For an extra challenge: Can you help your sprite go through the whole maze? Make another script to have to sprite turn 90 degrees and click on the original script or the one to make him turn to get the sprite through the maze.