Project 6: Animated Scene
The purpose of this project is to give you experience with both top-down design and efficient coding practices that take advantage of things with similar structures.
The result of this assignment will be similar to project 3. You'll create a scene that is a collection of complex objects. The complex objects will all be collections of Zelle graphics primitives and have the same organization as the steam plant you created in lab. Each complex object will have a function that initializes it and any complex object that changes will have a function that animates it.
The big difference from project 3 is that your scene can be animated, with objects moving or changing colors.
Think about a scene you want to create. Design the scene on paper as
a collection of complex objects like buildings, streets, stoplights,
and cars. Keep it simple. Come up with at least 2 complex objects of
your own that you want to create for your scene. At least one of them
will need to animate in some way. Animation can involve motion or
For each of the complex objects, create a new init function in component.py. For the steam plant we created steam_init. Follow the same convention for your other complex objects. For a stoplight, for example, create stoplight_init.
The init function should always take an x, y, and scale, which you should use just as in project 3 so that the object can be placed anywhere at any scale. The init function should return a list of the primitive objects that make up the complex object, just like we did with the steam_init function.
If your complex object should animate, create an animation function for the complex object. Use the same naming scheme, putting a _animate after the object's name. We created steam_animate for the steam plant. You would create stoplight_animate for a stoplight.
You ned to animate at least one of your new complex objects, even if it means just changing colors. The animate function should take in at least three parameters: the list of objects in the shape, the frame number, and the window, just like our steam_animate function. You can give the animate function any number of other parameters necessary for it to work properly.
For each complex object you create, make a test function in component.py, just like we did with test_steam. The test function should create a window, create multiple versions of the complex object, and then wait for a mouse click to quit. If your animate function does something interesting, test that out as well.
Include a small picture for each complex object in your writeup.
Make a file scene.py and import your component package, the graphics
package, and the time package. This file should have at least a main
function (you can create others as you see fit to organize the
The main function should initialize the complex objects in the scene, store them in a list, then draw all of the complex objects. It should then execute a loop and animate the objects that change. It will be very similar to the lab6test.py main function from lab.
Do something creative within this framework.
Include several pictures of your scene animating in your writeup.
Note, you can use the time.sleep() function to make your animation slow enough that you can do a screen capture on each frame. If you do that, then you can create an animated gif using the following command inside the directory where your screen shots are saved.
convert -delay 60 *.png myanimation.gif
The file myanimation.gif will be an animated gif that you can put on a web page.
Alternatively, you can also create movies of your screen using Quicktime.
- Create a clone function in aggregate.py that works for the complex objects. It should create a complete copy of the complex object list. Demonstrate the clone function in one of your test functions or the sceneInit function.
- Use command line arguments to control aspects of your scene.
- Make additional complex objects beyond the required 2-3.
- Following the idea of the dynamic collage, set up a system that creates a scene out of complex objects based on a list that gives the name, location, and scale of each complex object in the scene.
- Figure out how to call the animate function for the proper kind of object without using an if/elif control structure.
Make a new wiki page for your assignment. Give the page a useful title using English words (cs151f12project6 is not a useful title). Put the label cs151f12project6 on the page.
In addition to making the wiki page writeup, put the python files you wrote on the Courses server in your handin directory.
In general, your writeup should follow the outline below.
- A brief summary of the task, in your own words. This should be no more than a few sentences. Give the reader context and identify the key purpose of the assignment.
- A description of your solution to the tasks, including any images you created. This should be a description of the form and functionality of your final code. You may want to incorporate code snippets in your description to point out relevant features, but try to explain your solution without them. Note any unique computational solutions you developed.
- A description of any extensions you undertook, including images demonstrating those extensions. If you added any modules, functions, or other design components, note their structure and the algorithms you used.
- A brief description (1-3 sentences) of what you learned.
- Don't forget to label your writeup so that it appears in the listing on the main wiki page for the course. For this lab, use cs151f12project6