On this page, you will learn about sprite turning angles, which are needed for drawing polygons. For starters, you'll draw various asterisks, like these:
When you were trying to draw an equilateral triangle on the previous page, you might have tried code like this:
and seen a result like this:
It's common to try this if you've learned that the angles in an equilateral triangle are all 60 degrees. However, the angle that the sprite needs to turn to make a triangle is actually 120 degrees, and it's important to understand why that is and how to find the correct angle for other polygons (five-sided, eleven-sided, etc.).
turn
90 degrees instead of 180). Adjust the number of repetitions (the number you give to repeat
) until you get the sprite to finish facing the same way it started.turn
36 degrees). What input must you give to repeat
to get the sprite to finish facing the same way it started? At the beginning of this page, you knew that to make a triangle you need 120° turns, but maybe you weren't sure why. Now you know why a three-spoke asterisk takes 120° turns, but what does that have to do with triangles?
move
-100 steps
block (first -90, then -50, then -10), and do some of the turning experiments (above) with each value. Does this change the values needed for the repeat
or turn
blocks? These pictures are called "pinwheels."move
-100 steps
block.move
-100 steps
block again.You can use say for
to get information about the state of your program while it's running.
This animation shows how to use say for
to determine the bug in code that is supposed to draw a rectangle. Notice how say for
makes the program pause and gives you information to help you identify the source of error.