# Pages CS 151 Computational Thinking Fall 2012 Animated City

The purpose of the task was to make an animated city scene. The main tasks were to use primitive, aggregate, and scene to create the final scene. With each object there could be animation.

The first task was to draw the cityscape and make a collection of complex objects. The complex objects I used were car, building, sky, and person. I also had a road object but it has no animation. Each of my object files at an init function, draw function and animate function. Then each of these files had a main function to test the object before putting it into the scene.py file. An example of a complex object is my car:

Then I had to create the scene.py file that would call all my images and make the scene. An important part of the scene.py file is the duples used. In the sceneInit function I needed to call the complex object I wanted, create a duple for it and then append it to the scene:
def sceneInit( x, y, scale ):
scenelist = []

#sky object
s = sky.skyInit( x, y, scale )
scenelist.append( ('sky', s) )

another example is the buildings:
b = building.buildingInit( x+10*scale, y+145*scale, scale*1.1 )
scenelist.append( ('building', b) )
b = building.buildingInit( x+110*scale, y+105*scale, scale*1.3 )
scenelist.append( ('building', b) )

by doing this I was able to create a list of all my objects and add them to the scene by setting their x, y values and the scale.

The next step was to draw each item. I crated a loop to draw the second item in each duple like this:
def sceneDraw( scenelist, win ):
for duple in scenelist:
aggregate.draw( duple1, win )

Next was to animate each complex object. The objects that needed animation had to have a frameNum in the functions: