Lab 2 - Turtle drawing with functions

Due Sept 25, 11:59pm

Moodle Link

Screenshot_20180919_152651.png


Goal

To learn about funtions and Turtle graphics

Turtle Graphics functions

Method

1. First consider the simple the code below:

Note it uses no comments.

2. Consider a better version below, with functions:

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

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

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

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

7. 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.

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

9. 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.

10. Extra credit:

  • Pick random colors for the houses and people (5%)
  • 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)

Grading

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

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


SolutionWeb.SolutionLab2

*

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng Screen_Shot_2018-09-19_at_1.09.38_PM.png r1 manage 56.1 K 2018-09-19 - 17:12 JimSkon  
PNGpng Screenshot_20180918_001125.png r1 manage 10.3 K 2018-09-18 - 04:12 JimSkon  
PNGpng Screenshot_20180919_151657.png r1 manage 15.8 K 2018-09-19 - 19:18 JimSkon  
PNGpng Screenshot_20180919_152651.png r1 manage 18.1 K 2018-09-19 - 19:33 JimSkon  
Edit | Attach | Watch | Print version | History: r15 | r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r9 - 2018-09-25 - JimSkon
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback