Page 99 - PlugGPT_V2.0_C5_Flipbook
P. 99
Step 3 Drag the pen down block and set pen color to block from Pen blocks
menu.
Step 4 Now, drag the move 10 steps block and turn 15 degrees block from
Motion blocks menu. Change the values to 100 and 90 respectively. This
becomes Move 100 steps and Turn 90 degrees.
Step 5 Now, drag the wait 1 secs block from Control block menu. This will let
the program wait for 1 second before going to the next statement.
Step 6 Repeat Step 4 and 5 three more times.
Drawing a Square using REPEAT
In the previous example, a square was drawn by using Pen, Move and Turn blocks. In
order to avoid repetition of commands, REPEAT command is used. This command
reduces the number of lines of commands you need to write to draw a figure. The
Repeat block in the Control blocks menu is used to do this task. You can drag
the blocks and keep inside the Repeat block. Let’s draw a square using the Repeat
block.
repeat 10
Step 1 Drag the block from Control blocks menu.
Step 2 Drag the move 10 steps block, turn 15 degrees block and wait 1 secs
block one by one and attach inside the Repeat block. Change the values.
Step 3 Change the Repeat value to 4 because a square has 4 sides and these
commands have to be repeated 4 times to make a square.
The script will be like this now:
Programming in Scratch 97

