Time for action – building on the square
Let's clean up our code, get back to a common starting position, and explore some additional shapes by performing the following steps:
- After the when (d) key pressed block, add a hide block and a clear block from the Looks and Pen palettes, respectively. This will hide the sprite and remove the previous drawing if any.
- After the clear block, add the go to x: (0) y: (0) and point in direction (90) blocks.
- Now, attach a repeat () block to pen down. Then drag the move (50) steps and turn (90) degrees blocks inside the repeat () block. Delete the remaining move and turn blocks.
- Change the value in the repeat () block to
4
. - At the end of the stack, add the pen up block.
- Double-check your work by pressing the d key. You should get a square, and the cat should be hidden. The final script should look like the following screenshot:
- Now, change the value in the repeat (4) block to
3
and in the turn (90) degrees block to120
to get a triangle. - Next, try...