CS110: Spring 2020

Intro to Computer Programming with Python

CS110: Spring 2020

Assignments > HW3: Make a Creature

Due on Tue, 04/28 @ 11:59PM. 8 Points.

Homework Starter Files

LEARNING OBJECTIVES:

  1. More practice working with built-in functions
  2. Practice writing your own functions

In this assignment, you are going to write a program to draw a creature of your own design/choosing using tkinter. At the end of this assignment, someone should be able to use your function to draw your creature: anywhere on the screen at any size or color. In other words, your function needs to honor the parameters that are passed into it. If you don’t quite know what this means (it’s a confusing concept for people just learning to program), ask Sarah during class or ask your TAs during tutorial / office hours.

Part 1: Design your creature

On paper, sketch out at least 3 creature ideas — it can be different variations of the same creature or all different ones. You can just implement the head of your creature (similar to the bear at the top) or the whole thing — the choice is up to you. Here are some links to ideas:

Feel free to post simple creature drawing ideas on the course Piazza under hw3. From your 3 sketched ideas, select the one that you would like to use for the assignment and draw the creature bigger on a different piece of paper — ideally graph paper — and label the points that will help you to program your creature.

NOTE: Making a simple creature (e.g using 4-8 shapes) is totally fine. You don’t need to get too detailed unless you want to!

Part 2: Implement your “make_creature” function

Once you are satisfied with your animal concept, create a make_creature function, inside of creature.py, using any combination of shapes (points, lines, polygons, rectangles, ovals, etc.). Feel free to use the make_circle and make_oval functions that you already implemented in homework 2. Also feel free to use any of the code in warm_up.py.

Tips:

  1. Keep it simple (we recommend anywhere between 4-8 shapes)! You can always add more functionality later.
  2. Make only one or two changes at a time and then test out those changes by running your main.py file. This makes things easier to debug.

Once your function successfully draws the creature that you sketched (in Part 2), you will start adding positional and keyword parameters. There is already 1 positional parameter, canvas, used in the sample make_creature function. You will add to this:

When you’re done, please add at least three calls to the make_creature function in your main.py file, using different arguments. For instance, after completing the assignment, I used my make_creature function in the following way to produce the drawing below (feel free to use whatever arguments you want for your positional / keyword parameters):

# with a function, you can make slightly different versions of your design, 
# thereby reusing the same code over and over again

make_creature(canvas, (92, 115), size=85, primary_color='#5e6976', secondary_color='#1b324d')
make_creature(canvas, (487, 110), size=101, primary_color='#bfdc65', secondary_color='#abb880')
make_creature(canvas, (454, 423), size=141, primary_color='#aebb83', secondary_color='#227876')
make_creature(canvas, (333, 227), size=99, primary_color='#94ba77', secondary_color='#3f5364')
make_creature(canvas, (117, 314), size=91, primary_color='#648d8e', secondary_color='#afc272')
make_creature(canvas, (199, 469), size=122, primary_color='#3f5364', secondary_color='#bfdc65')

# helper code for making a grid
make_grid(canvas, screen_width, screen_height)

What to Submit

Before you submit, please do test your make creature function by invoking the function calls above. If your function is working correctly, all of the input parameters will be honored (i.e. the creature will be drawn at the correct position at (roughly) the specified size, with the specified colors).

When you’re done, please create a zip file that includes the following files:

  1. A photo / scan of your sketches (PDF or JPG)
  2. Your helpers.py file
  3. Your creature.py file
  4. Your main.py file