CSC 111: Intro to Computer Science through Programming

Homework 6

Due: Tuesday, Mar. 28 at 11:59pm on Moodle

This is our first graphics homework, and it is meant to be an introduction to using graphics objects in the context of helper functions. For this assignment, you are welcome to discuss your work with other students, but all code you submit should be your own original work. It should be produced and understood by you, without looking at anyone else's assignment.

Quiz 6

Please take the short Week 6 quiz on Moodle (also due by Tuesday night). This is to help me understand what areas need work, and also help you understand what concepts might need extra practice. It is not a large part of the overall homework grade. Just for the quiz part, do not discuss the questions with other students, TAs, etc. (Note: quiz usually posted Wednesday afternoon.)

Creating a Comic Strip

In this homework you'll be creating your own comic strip using functions to produce similar graphics constructs in different parts of the window. The idea is that two entities (animals, people, fictional characters, etc) will be talking to each other over a series of frames, like the example shown below:

comic

I found this joke on Stack Overflow, I did not make it up :)

There are not specific steps for this homework, and you should feel free to approach the coding process however you like. You might choose to create your characters first in the main function, and then make a separate function for each one. Or you could start out with three separate frames and two circles in each one, and then build up the circles into a characters gradually. Try to break down the process into steps and concentrate on one step at a time, rather than trying to do everything all at once. This assignment is meant to be open-ended, but there are a few requirements and recommendations.

Requirements

  • You should have at least three panels (frames of the comic).

  • You should have at least two characters (heads are fine, but feel free to make them more detailed).

  • When creating your characters, you should use at least three types of graphics constructors (Point, Line, Circle, Oval, Rectangle, Polygon, etc).

  • For each character, you should have a separate function. This function should take at least three arguments: the center (position) of the character as a Point, the message the character will say as a string, and the window the character should be drawn on (of type GraphWin). Here is an example for the frog character:

    tweet

  • I would recommend storing the x and y coordinates of the center point as variables (x and y would be fine variables names). Then all the parts of your character should be in relation to these center coordinates.

  • There should be a short conversation between the characters, using instances of the Text class. If there character does not say anything during a frame, use an empty message string, and account for this case using a conditional statement in your character functions.

  • If you want to split the text onto multiple lines, you can use the "\n" character.

  • To keep your code organized in your helper functions, I would recommend drawing all the objects (using the .draw(..) method) at the end of the helper functions.

  • In your main method, call your helper functions with specific positions for each frame, and draw lines to separate the frames. You main method should not end up being very long.

  • I would recommend drawing out your plan on a piece of paper first. It can be tricky to get all the positions right, so drawing on paper first can help speed up the process. Nothing is for free in graphics! For example, it takes hundreds of people to create the animated films like Zootopia and Frozen (to name a few).

Extensions

Optional ideas to extend your code:

  1. In your helper functions, create additional parameters to determine different aspects of your characters. For example, you could have an expression parameter that could be set to "happy", "sad", "surprised", "asleep", etc, and then depending on the expression, you could change the character's mouth or eyes.

  2. Create a background function that repeats the background on each frame, with modifications as necessary (via passing in different parameters).

  3. Resize the text bubbles depending on the amount of text.

Submit

You do not have to submit a transcript for this homework. Instead, take a screenshot of your final result and submit that with your code. Make sure that you've thought about variable names and code structure, and that your code is well-commented. Include comments for each helper function describing the parameters and what the function does. It's okay to have a lot of hard-coded numbers in this assignment, but if you find yourself using the same ones over and over again, create a variable.

TO SUBMIT ON MOODLE:

  • hw6.py

  • comic_strip.png