Scratch Turtle Tutorial: Paint A New Sprite
Scratch Turtle Tutorial: Paint A New Sprite
Click on the blocks to get the turtle to draw a square. How many times did you click to make a square? Change the values in move and turn to make a triangle. How many times did you click to make a triangle? 360 divided by 90 = 4, a square has 4 sides. How would you calculate the number of degrees to turn for a 3 sided shape? How would you calculate the number of degrees to turn for an octagon?
How is the behaviour different when the clear block is separate from the rest of the blocks?
Add a repeat block with the value 4 and click the block
We can see that repeat and degrees determines the number of sides and move determines the size. Lets make it more flexible so we dont have to change the numbers. To do this we will create a variable for the number of sides.
Set sides to 4 and drag the sides variable into the repeat block. So far this is not very useful but how can we use this variable to set the number of degrees to turn?
Drag a divide operator block from the Operators palette Now you can create different polygons by entering the number of sides.
Lets find a better way to get the number of sides. Drag ask to ask a question and answer from the sensing palette and click the block to see what happens.
This is not very useful because you cant access your code. How can we start and clear? Where can we get user input from? Answer, keyboard and mouse.
From the Control palette drag a when block to control when it starts. Now switch to presentation mode and try it.
To make it more user friendly lets make a clear and start button.
Create a new sprite by importing a button then edit the costume to add the text clear.
Now add a simple script to run clear when the sprite is clicked The start button is a bit more complicated because you have send a message from the start sprite to the turtle sprite to get the turtle script to run. Use broadcast new type start.
Now go back to the turtle script and add a when I receive control block to the top of your script. This will receive the start signal when the Start button is clicked.