Project 2: A shape collection

In this project, you will practice using functions to make a gaming scene made up of simple and compound shapes that you design. You have wide latitude in your choice of subject, and the scene can be as simple or complex as you like. What is important is to properly structure your code and include good comments.

To help you flexibly use your shapes in your dream gaming scene, you will take advantage of functions with offsets and scales to place your shapes in any position and at any scale.

The goals of this project reinforce those from lab:

Extension points are awarded for complex scenes, especially those that show me that you can integrate concepts from lecture into making your scenes and take things to the next level!


Tasks

1. Create your project files

1a. Create shapelib.py: it will store all the functions that you write to draw different shapes

1b. Reset turtle heading in the goto function

In shapelib.py, add a call to the setheading turtle function so that the turtle always faces east when you call goto (We are using "standard mode").

This may be helpful when you create your scene because you will know the turtle is always facing east when it moves to draw a new shape.

1c. Create the main.py file: it will store functions that you write to draw your scene

2. Make two more simple shape functions in shapelib.py

They could be shapes like a rectangle, circle, non-equilateral triangle, n-gon, etc. Each function should minimally take parameters for:

Some important guidelines:

Test out each of your functions one-by-one as you make them. This means calling your two shapes in main code at the bottom of main.py several times to draw each in a few different positions and sizes.

Take a screenshot. This is Required Images 2 and 3 that you should include and describe in your written report.

3. Make two compound shape functions in shapelib.py

These should be gaming themed. The objects should be built from at least two of your simple shapes (e.g. triangles, rectangles, circles, etc.) from your shape library.

Just like triangleStack from lab, your compound shape functions should take at least three parameters:

Remember the process for designing complex shapes:

  1. Hard-code all parameter values in your function with actual numbers to make something that looks good.
  2. Replace the position of your first shape with (x, y). Convert the remaining shape positions to offsets.
  3. Multiply the scale parameter to sizes and offsets, not positions.

Your shapes should draw properly at any scale, location, or turtle orientation.

Take a screenshot of both compound objects. This is Required Images 4 and 5 that you should include and explain in your written report.

4. Make a gaming scene!

Write your code in a function called gaming1 in main.py. It should use the simple and compound shapes that you have made — drawing them in different positions and sizes. You can also use color, the random module, and for loops to make your scene more complex and interesting.

Take a screenshot. This is Required Image 6 that you should include in your report.


Check reproducibility

In order to grade your project, we need to be able to run your code and get the same results as you do! Here is a summary of the expected outputs from each of the source code files that you created (i.e. by running python3 <filename>.py):


Extensions

Congratulations on completing the core tasks! If your code and report meet the above expectations, you’ve already earned up to 26/30 points for this project.

The remaining 4/30 are a chance for you to earn credit for exploring parts of this project and digging deeper to express your creativity! This is entirely optional; 26/30 is a B and is a perfectly respectable place to stop. Extensions are open-ended and exist to compliment the structured core project. Explore and learn something new that interests you! Concentrating your energy on 1-2 "deep" extensions that challenge you will earn you more points than many small, "shallow" extensions.

You can pick your own topics that interest you. Here are a few examples:

  1. Creative or complex scenes above and beyond the basic expectations count as extensions
  2. Make additional basic or complex shape functions that make use of your other shape functions.
  3. Make additional scenes that show creative use of functions, loops, or randomness.
  4. Make use of other turtle properties such as line width, color, and fill capability to make your shapes more interesting.
  5. Add additional parameters to your shapes to control properties like line width and color.

Submission checklist

To turn in your project, make sure you do all of the following: