Scratch exercise 111

Spirograph

In this exercise you will create 5 scripts, each of which draw a different geometric pattern automatically.

 

1. Create a new game and then delete the Cat sprite.

 

2. Select the stage and paint in black. This is essential if the sprites are to be as visible as possible.

 

3. Now create these variables ("for all sprites") ..

Hide "degrees" and then right-click "Which pattern" on the stage and choose "large readout". We will use this variable to display which pattern is currently being drawn.

 

4. Add these scripts to the stage ..

 

5. Use "File>Save as" to save your game. Name it "Spirograph".

 

6. Use the "Paint new sprite" to create a new sprite which consists of a single black dot. Use the smallest paintbrush size ..

Click "OK" to finish and re-name the sprite "Nib 1". A nib is the tip of a pen. Our pen nib will be used to draw the patterns.

 

7. Add this script to "Nib 1" ..

This script cleans up the stage if you stop a pattern whilst it is being drawn.

 

8. Duplicate "Nib 1" four times and re-name the sprites "Nib 2", "Nib 3", "Nib 4" and "Nib 5".

 

9. Select "Nib 1". You will now add the script which draws the first pattern. This first pattern is simple, like the spokes in a wheel. Take the time to look at the script and understand how it works. Note the following ..

Press the "B" key and then "1" to test your script. Press "E" to end when you are done.

 

10. Use "File>Save" to re-save your game.

 

11. Select "Nib 2" and add the second pattern drawing script. This is almost the same as the "Nib 1" script but this time the spokes curve a little (2 degrees) and there is a flourish at the end of each ..

Press the "B" key and then "2" to test your script. Press "E" to end when you are done.

 

12. Use "File>Save" to re-save your game.

 

13. Create the script for "Nib 3". This time each "spoke" has two curves and a flourish requiring 3 repeat blocks ..

Press the "B" key and then "3" to test your script. Press "E" to end when you are done.

 

14. Use "File>Save" to re-save your game.

 

15. Create the script for "Nib 4". This time each "spoke" has a curve, a reverse straight line ("move -10 steps") and a circle flourish ..

Press the "B" key and then "4" to test your script. Press "E" to end when you are done.

 

16. Use "File>Save" to re-save your game.

 

17. Create the final "Nib 5" pattern script. This time we have added repeat loops within repeat loops to create squares and pentagon shapes for each spoke ..

Press the "B" key and then "5" to test your script. Press "E" to end when you are done.

 

18. Use "File>Save" to re-save your game.

 

19. Well done. You've finished. Can you create additional patterns by adding more nibs?