Note:
Complete the code IN ORDER of the images below
Keep all code, DO NOT DELETE ANY! Each set of work builds on each previous set of code, much like a LEGO model.
COMMENT on your work as you go using my suggested comments plus your own.
This program does not work with the green flag. It's designed that way! Each code stack will run when you click on it.
CHECK that each stack of code works before you move on.
You do not need to include the 'wait 1 second' blocks - they are only included to show the different parts of the code running during the drawing of each shape.
Add the Pen blocks by clicking on the bottom left of your Scratch project [see image to the right]
You can also read these instructions for this task in a booklet / presentation [ HERE ]
Once you have completed this task, repeat the same process for the following two shapes:
Rectangle
Regular triangle
Challenge: Regular pentagon
Challenge: Circle
Notes:
You can find solutions to some of these shapes below.
You can remove the 'wait x seconds' blocks once you see and understand how the shapes are drawn.
Note:
You can change the circle My Block to Repeat 36 and move 10 steps - it will draw much faster.
Remember this code from before? NOTE:...don't make it again!
Now we can answer this question....Why is the code in Step 4 (below) "better"?
Please also note that the maths in the two green code blocks below translate to the following (do not worry about how it works, just know that it does for our purposes 😀) :
Set Internal Angle to (Number of Sides - 2) * 180 / Number of Sides
[Code is multiplied by 180 not addition]
Set External Angle to 180 - Internal Angle
[Code is 180 minus Internal Angle]
These procedures (Modules) allow you to define any shape. They are the building blocks for the Polygon2 modules.
This is your final task for abstracting tasks into smaller modules. Once you're finished, try to create some additional pattern modules that operate in a similar way!