# An Introduction to Programming Using Scratch

Note : These materials are a rough lesson plan of a three hour activity conducted with fourth through sixth graders.  They are based on materials found at http://www.redware.com/scratch/

### Introductions and set up (15 minutes)

• Introduce facilitators
• What is Scratch
• A visual programming environment where you can (relatively easily) make some pretty cool game applications

### Introduction to simple commands (15 minutes)

1. Launch Scratch (Start - > All Programs or might even be right there from main start menu)
2. Notice that Scratch is divided up into several sections.
1. The first one of interest is on the right and is called the "stage"  This is the area in which we will move the "actors" in our programs.
2. Below this is a list of all of the current actors in our programs.  Notice that actors in our programs are called "sprites" and at the moment we only have one actore
3. In the Middle is a "script" / information area for our one of the actors.  At the moment this information area is empty.  We will work more with this later
4. On the Left side is a list of commands that we can send to our actor
3. To begin with, explore the blue commands currently in the command list.  What do they do?
4. [LARGER DISCUSSION : As appropriate discuss coordinates, direction, turn degrees, etc Notice that anything in the white "circle" can be changed.

### Introduction to a sequence of commands (15 minutes)

1. Sometimes we want to do several actions in a row.  For example, we might want to move forward 30 steps and then turn 45 degrees.
2. Drag the appropriate blocks to the middle "scripts" area and then double click on it to run the entire sequence.
3. What happens?
4. Create a sequence so that your sprite draws a square.  An Octagon.  An equilateral triangle
5. Use the pen to actually check what you drew

### Introduction to Iteration (15 minutes)

1. Notice that when you draw a square you have some repetition.  A square is four sides.  For each side you go forward some distance and then turn 90 degrees.
2. Rather than repeating our code blocks four times we can use the concept of iteration
3. Drag out the repeat block and set it's value to 4
4. Put a move/turn sequence inside of there.
5. Click the block and see what happens (remember to have the pen down if you want the sprite to draw a trail)

Experiment with different angles and sequences of commands to produce interesting shapes.

Flowers are produced by drawing a simple shape and then turning a little before repeating the shape to form a flower. The following example is a square flower but you can experiment with triangles and hexagons and other shapes.

The above example has a repeat iteration nested within another iteration.

A forever loop combined with a random number can produce continuous random behaviour easily.

### Introduction to Conditionals (15 minutes)

Suppose that we want to make a program where we move the cat around at random (like above, but we want to make sure that he doesn't wonder off the screen

What can you do ??

The following example (added after the wait in the previous example) causes the sprite to think each time it reaches the edge of the stage before bouncing off again:

Conditional statements have slots that are shaped with points on either side which evaluate to a true or a false value and execute if the statement is true. They are found in the controls programming blocks and are used for program flow with if, repeat, forever, and wait blocks. The conditional part of the statement is found amongst the numbers and the sensing areas.