CS 151: Project #6

Cityscape Take 2

The goal of this project is to use the Zelle graphics package to create a new cityscape using all of the tools you've learned so far: loops, conditionals, parameters, and so on. An important part of this project will be process and coding style. Comment your code appropriately, and try to make it easy to read.


The task is to create a cityscape using the Zelle graphics package. Each element of your city should be implemented as a function that takes in no fewer than four parameters: the window, the x and y location of the object and a scale factor. You should be able to place any object in the scene anywhere in the image at any reasonable scale.

Beyond the parameterization of each element of the city design, the requirements of the scene are as follows.

  1. Your design should have a function called building that takes four parameters: the window to draw in, x0, y0, and a scale factor dx, where dx corresponds to the horizontal width of the building (its footprint). The building function should create all of the elements of the building (you can choose what they are). If there are no elements of the building that will change over time (see below), the building function can go ahead and draw the elements of the building and not return anything.

    If you want to be able to modify your building, go through lab 7 and write your building function so that it has the following properties:

    • all of the visible graphics elements of the building are collected into a list,
    • the elements are only created, not drawn, in the building function, and
    • the function returns the list of graphics elements.

  2. Your design should have a second function building2 that works the same way as building, but draws a different building.
  3. All of the functions creating the elements of the city should be located in a single file called city2.py. There should not be any code besides the functions in that file so that it can be imported into other python programs. Your scene program should import your city2.py file in order to call the building functions and other elements of the scene.
  4. The first required image is to create a scene with two buildings of each type at different locations and different sizes.
  5. Your overall cityscape must incorporate each of the basic Zelle graphics objects Line, Rectangle, Polygon, Circle, Oval, and Text at least once. The Image object is not required, but can produce interesting effects.
  6. Once the cityscape is drawn, at least one element of the scene must be animated (change over time). Things don't necessarily need to move, but they need to do something different over time. You may find the time package helpful in controlling the speed of the animation. The function time.sleep(t) freezes program execution for t seconds, where t can be a floating point number for fractions of a second.
  7. Your code should be well-commented. There should be a brief description of each function and then a short comment for each significant step in the function.


Below are some suggested extensions.

  1. Add more animated elements to the city.
  2. Incorporate user input into the scene.
  3. Adjust the visible elements of a building based on its size parameters.
  4. Use randomness to generate interesting visual effects.
  5. Whatever extensions you choose, use them to demonstrate features like loops, conditionals, and parameterization that save coding time.


Create a web page for your writeup. Your writeup should include the following.

Handing in

When your writeup is ready for viewing and linked to your index page, send me an email.

To hand in your python code, place it on the Academics fileserver in the private folder. Do not post it on the web. You may include snippets from your code in your writeup to demonstrate how certain aspects of the function work, but please do not include the whole thing.

To place the code on the fileserver, go to the server fileserver1 and select the Academics volume. Within that there ought to be a CS151 folder, and within that there should be a folder with your username, and within that ought to be a folder labeled private. You can read and write files to the private directory and I can read them, but no one else can access them. Put your python files in that directory to hand them in. Please organize your files into folders by project.