Time for action – enabling the user to create custom shapes
In this exercise, we're going to create variables and enable user-entered values via sliders:
- Create four variables named
sides
,length
,angle
, andpen size
. This automatically adds a stage monitor for each variable. - Hide the angle stage monitor. We're going to turn the other monitors into slider controls. Right-click on each monitor and select slider, as shown in the following screenshot:
- Next, add a set () to block from the Data palette as the first block after the when (d) key pressed block. We want to calculate the angle of the shape by dividing
360
bysides
. The set () to block becomes set (angle) to (360/sides). - Add the sides reporter block to the repeat block.
- Add the length reporter block to the move () steps block.
- Add the angle reporter block to the turn () degrees block.
- Insert the set pen size to () block above pen down. Add the pen size block as the size value in set pen size to ().
- The script looks like the...