AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Drawing shapes with loops

Week 10 · Unit 4: Be a storyteller · 3 lessons
1

Drawing with the pen

Computing 4: Unit 4, pp. 48–61
GoalUse the pen blocks and the move and turn blocks to draw lines and corners.
New words
pen down · a pen block that makes the sprite draw a line when it movespen up · a pen block that lifts the pen so the sprite moves without drawingdirection · the way a sprite faces: 90 is right, 180 is down, −90 is left and 0 is up
Explanation

A sprite can draw if we give it a pen. The pen blocks are in the Pen group, which you add as an extension. When “pen down” runs, the sprite leaves a line behind it wherever it moves. When “pen up” runs, it moves without drawing. The block “erase all” wipes the drawing from the stage. A sprite starts facing direction 90, which is to the right. The block “turn ↻ (90) degrees” turns it clockwise but does not move it. The sprite only draws when it moves, so the order of the blocks matters: pen down must come before the move.

x 240−240y 180−180start
Worked examples
whenclickederase allgo to x:-50y:0pen downmove100steps
This script draws the line in the picture above: from x: −50 to x: 50, because the sprite moves 100 steps to the right with the pen down.
x 240−240y 180−180start
To draw a corner we turn between two moves. The sprite starts at x: −40, y: 30, draws 60 steps to the right, turns 90 degrees clockwise so that it faces down, and draws 40 steps. The picture shows the line the pen leaves.
whenclickederase allgo to x:-60y:20pen downmove50stepspen upgo to x:-60y:-20pen downmove50steps
Use “pen up” to jump to a new place without drawing. This script draws two short lines, one above the other. The sprite lifts the pen before it goes to the second start place.
Class activity

Be the pen (with a friend): you are the sprite and use a pencil on paper. Your friend reads the commands: “pen down, move 6 steps (6 cm), turn right 90 degrees, move 4 steps, pen up, move 3 steps, pen down, move 4 steps”. Use a ruler for each move and the corner of a card to turn exactly a quarter. Lift the pencil on “pen up”. What did you draw? Swap and write your own commands for a letter L.

Practice
1
What does the block “pen down” do?
2
The sprite starts at x: −50, y: 0 facing right. Where does the line end and how long is it?
whenclickedgo to x:-50y:0pen downmove70steps
3
Which script draws a line? Why does the other script draw nothing?
Awhenclickedgo to x:0y:0move50stepspen downBwhenclickedgo to x:0y:0pen downmove50steps
4
The sprite faces right and runs “turn ↻ (90) degrees” and then “move (30) steps”. In which direction does it move?