Project 2: Turtle Graphics
Questions and Answers
I don’t know where to start! What should I draw?
If you don’t know where to start, then start by creating 3 functions: one that draws a circle, one that draws a rectangle, and one that draws a triangle. Once you can draw a circle in one spot, make it so your code can draw many circles of different sizes, colors and borders in different locations. Now do the same thing with a tree, where a tree is a rectangle and a triangle combined.
Do I have to draw a scene or a landscape? Can I draw a mathematical pattern instead?
You don’t have to draw a scene. You can draw a tessellation or pseudo-tessellation of some kind, or draw other constructs as long as it’s clear that you satisfy the test cases above. We would just define shape loosely. If you’re not sure, ask your instructor.
Do you have an example I can look at?
I could show you a picture, but we want you to express yourself, not just copy other people. If you are struggling, start simple. Draw something by hand first, then ask yourself if it meets all the criteria. If not, add more until it does.
How do I rotate or tilt a shape?
Tilt is easier than most people think, especially with turtles. A turtle always has a heading. Manipulating tilt means changing the heading of the turtle before you draw something. One way make this easy in your turtle program is to make the code for drawing something that is tiltable independent of the turtle’s heading. Much like size, there are two ways of making tilt happen: you can change the direction of the turtle outside a function that draws it, or you can pass a parameter to the function and change the heading there. Which way you do it is up to you, as long as it’s easy to change the tilt value.
Do I have to put all of my code inside functions?
Yes. All of your code should be inside main or inside other functions that are called by main or called by other functions.
I’m only using one turtle in my code everywhere. My code works if I define it at the top of the file, but my code breaks if I define it in main. So is it okay to have the turtle defined outside of main or any other function?
No. Define your turtle in main and pass it as a parameter to each function that uses it.
How do I reduce the amount of copied (repeated) code?
When you notice that you are copying the exact same code but changing a few numbers, such as when drawing a bunch of trees or bubbles, try to find a pattern in the changes. Then you can do two things:
Put the repeated block of code in a function with parameters, and
Put the repeated block of code in a loop that changes the numbers.
Can I use more than one turtle in my program?
Yes, if you want. It’s up to you.
What do you mean by “atomic shape”?
It’s a shape that we don’t think or draw as a combination of other shapes. For example, a triangle is an atomic shape. A spiral might be an atomic shape. A house made out of rectangles and triangles is not an atomic shape. Olympic rings is not an atomic shape.