Today you are coding in Scratch. You will build a Pattern Creator step by step at your device.
You can already make a sprite move and turn. Today you will put those actions inside a loop so the pen draws circles, lines and spirals without copying the same blocks over and over.
Before you run anything, think: what might happen if the sprite keeps moving and turning a little bit each time?
To draw the spiral in this lesson, the ball has to move a little and turn a little, over and over, until it reaches the edge of the stage.
You could do that by dragging a move block and a turn block, then another pair, then another. A full spiral would take hundreds of them. And if you then wanted a different turn, you would have to change every single one.
A loop does the same job with one copy of each block. Change the block once and the whole pattern changes.
As you build, keep two questions in mind: what exactly is repeating, and what stops it?
Go to the Scratch website, create a new project and delete the cat sprite.
scratch.mit.edu/projects/editor
Go to the Scratch website using the link below and click on the 'Create' link in the blue bar at the top.
By default, each new project starts with the cat sprite already added. To delete the cat click on the x in the blue circle beside the cat in the sprite list.
We are going to use the Pen blocks to create patterns but first we'll need to add a sprite that will do the drawing. It doesn't really matter which sprite we use as we are going to hide it.
Add the Ball sprite from the sprite library and then give it the following code.
when green flag clicked
go to x (0) y (0) // we want to start it in the center
hide
To add a sprite from the sprite library follow these steps:
You can use search box or the filter links (Animals, People, Fantasy etc) to locate your sprite.
To draw the patterns we will be using the Pen blocks so add the Pen Extension to your project.
Once you've added the Pen Extension add the following new code blocks to the Ball sprite underneath the hide block.
when green flag clicked
go to x (0) y (0)
hide // add new code under here
pen up // start with the pen up
erase all // erase drawings from the last time
set pen color to [#3438df] // choose a color
pen down // put the pen down
Scratch Extensions are additional sets of blocks that expand the capabilities of your Scratch projects. They allow you to:
When you add an extension to your project:
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.