Programming for Children
Primary 6 · Science and Elementary Technology
Programming for Children
Lesson 4 of 6
30 min
Let's begin
Keza's class loved drawing polygons with the turtle. "Can a Scratch sprite draw too?" asks Keza. It can! A sprite can carry a pen, just like the turtle. Today you will use Motion, Pen and Control blocks to draw shapes and patterns.
The Pen blocks are hidden at first. Click the Add Extension button in the bottom-left corner of Scratch and choose Pen. A new green Pen category appears:
| Pen block | What it does |
|---|---|
| erase all | Clears every line and stamp from the stage. |
| pen down | The sprite draws a line wherever it moves. |
| pen up | The sprite moves without drawing. |
| stamp | Leaves a picture of the sprite on the stage. |
| set pen color to / set pen size to | Changes the colour or thickness of the line. |
move (10) steps moves the sprite forward; turn ↻ (15) degrees turns it clockwise; go to x: ( ) y: ( ) jumps to a place; point in direction (90) makes it face right. The centre of the stage is x: 0, y: 0. The x number goes from left (−240) to right (240), and the y number from bottom (−180) to top (180). So x: −200, y: −100 is near the bottom left.
when green flag clicked
erase all
go to x: (0) y: (0)
point in direction (90)
pen down
repeat (4)
move (100) steps
turn ↻ (90) degrees
pen up
The polygon rule from Turtle Blocks still works: turn = 360 ÷ number of sides. Change repeat (4) and 90 to repeat (6) and 60, and you get a hexagon.
In the Raspberry Pi project Lost in space, a rocket flies to the Earth with repeat (200) [move (2) steps], and a monkey spins with forever [turn ↻ (1) degrees].
repeat (12)
stamp
turn ↻ (30) degrees
This leaves 12 copies of the sprite in a full circle, because 12 × 30 = 360, like the petals of a flower. You can also put a loop inside a loop: repeat (36) [draw a square, then turn ↻ (10) degrees] makes a beautiful spinning-squares pattern.
Tip
Pen DOWN to draw, pen UP to travel. Start every drawing program with erase all for a clean page.
Answers
What you learned today
Sources and credits
The exercises (Try it yourself and the practice questions) are written by Ganzaa.
This lesson adapts CC BY-SA material and is shared under CC BY-SA 4.0.
Quick check
Match each Pen block to what it does.
Tap one on the left, then its partner on the right.