Tags: %TAGME{ tpaction="" web="Main" tag="" }% view all tags

# Lab 2 - Turtle drawing with functions

### Goal

To learn about funtions and Turtle graphics

### Method

1. First consider the simple the code below:

2. Start a new repl.it with the previous code.

3. Finish the drawPolygon and drawRectangle functions. Draw several Polygons and rectangles.

4. Add a color option, and color fill option to every object type. (add parameters to do this)

5. Rewrite the drawSquare and drawTriangle functions use the drawPolygon function to do the work.

6. Finish the drawHouse function. The house should make use of the other functions to make a house with a roof, a door, some windows, and anything else you feel is nice. The house should use color and fill to make it look nice. The trick is the make the house scalable. In order to do that you will need to draw everything relative to the starting position of where you start the house. An example of a scalable drawing is below. Not that I use a function I wrote called moveRelative to relative to my current position, and that moves are a fraction of the size. Notice also that the size of everything is a fraction of the original size. Thus when chage the size of the object, everything in the object scales accourtingly.

<iframe frameborder="0" height="500px" src="https://repl.it/@JimSkon/ThoseFirsthandSystemintegrator?lite=true" width="100%"></iframe>

7. Make a function drawPerson to draw a stick figure of a given size, color and fill. This should be scalable too.

8. Make function "buildNeighborhood(t,h,p) that displays 3 houses, and 5 people. Your goal is to try to make the sizes of the elements in a range that makes sense (not to big or small), and that are actually on the screen (not in some far of location). The program should also put a sun in the sky using the built-in circle function.

9. Extra credit:

• 5% - Pick random colors for the houses and people
• 10% Place the houses and people on the screen in random locations choosen each time you run the program (with a random number generator). IT is ok if items overlap each other.
• 10% Have the buildNeighborhood actually place the houses on the screen by where you click with the mouse. E.g. 3 clicks for the 3 houses, and 5 clicks for the 5 people. (10%) (Example here: repl.it)

Turn in a Repl.it link, as well as screenshots of three runs

Completion of all functional requirements 60
Code broken up in small, single function functions 10
Appropriate code formatting 5
Meaningful identifier names (variables, functions) 10
Comments at the top, and on all functions 5
Document with screen capture of picture 10
Extra credit (25 max)
Total 100

Topic revision: r1 - 2020-07-24 - JimSkon

 Home Main Web P View Edit Account
Copyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback