# Pages CS 151 Computational Thinking Fall 2012 Assignment 6 by Philip Prosapio

Philip Prosapio
Spring 2010- CS 151

Note- All the code for this project is on the academic server under pwprosap

Summary
For project 6, our task was to build city scenes using Zell's Graphics and complex objects. I was first asked to create two to three new complex objects, where for each object there was an Init function and an Animate function. I was next asked to make a file named scene.py and create sceneInit and sceneAnimate functions that would take in the complex objects that I made above and create a scene. Then I needed to make a new file with a function that would allow me to draw multiple copies of my earlier scene at different positions and at different scales. The final task asked me to do something interesting with the scenes that I made.

1) For the first task I created two different complex objects, buildings and a car. The names of these functions are buildingagg.py and caragg.py respectively. The car had the ability to be animated to drive forward. I did this with this code:

for object in objlist:
#assign to dx a random integer between -10 and 10
dx = 5
#assign to dy a random integer between -10 and 10
dy = 0
#call the move method of the object, passing in dx and dy
object.move(dx, dy)

The two pictures of my original two complex objects are attached and named picture1lab6.png for the buildings and picture2lab6.png for the cars.

2) For the second task, I created the scene.py file and made the required functions. The key concept for this task was how you input the different objects that you wanted drawn. So if I wanted the scene functions to draw a build at a certain location and scale I needed to type in:

obj = buildingagg.buildingInit(x+50*scale, y+175*scale, scale)
scenelist.append(('building', obj))

The picture of this scene of a car and some buildings is attached and labelled picture3lab6.png .

3) For the third task we had to replicate what we did in lab three, which was the shrinking and moving of entire scenes. This was done by calling my original scene and assigning it to a variable and then adding in a scalar variable so I could switch the size of my scenes, like so:

scene1 = scene.sceneInit(x, y, 0.4*scale)
scene2 = scene.sceneInit(x+260*scale, y+scale*260, 0.3*scale)
scene3 = scene.sceneInit(x+10*scale, y+250*scale, 0.45*scale)

The picture of my three scaled and moved scenes is attached and named picture4lab6.png .

4) For the final task that wanted me to get more creative with my scene, I added the earth and sky and a road. The earth and sky were just simple primitive rectangle objects that were filled with color. The road was made up of three parts, two rectangles and a polygon, to create a polygon I needed to call this command.

r = graphics.Polygon(graphics.Point(x, y+h*11/10), graphics.Point(x+w*1/2, y+h*11/10),
graphics.Point(x, y+h*13/10))

This picture is attached and named picture5lab6.png .

Extensions

Extension 1- For the first extension which fulfills the extension that requires us to create more complex shapes, I added in two cop cars, and some human bystanders watching a police chase. I animated the two new cop cars the same way as the the original car, and the humans were also animated to shake in fear of the criminal escaping in his car. To animate objects in my scenes I needed to assign the animate function to a string that was within the the duple that described the object.

elif name == 'person':
human.personAnimate(obj, 0)

So if python saw the word "person" in the first spot of the duple it would know to call the personAnimate() function. The picture for the extension is attached and labelled car.gif. And just for fun, this picture is animated so when you click on it the cars will drive across the screen. On the server I have the seven pictures on it and my one .gif file also on it.

Extension 2- For the second extension, I created a function that fulfills the extension that requires us to create a clone function for a complex object. I used the clone function on my caragg.py and made two clones of the car. Here is the code I used:
def clone( objlist, win ):

1. for each thing in objlist
clonelist = []
for thing in objlist:
2. call the clone method on thing
x = thing.clone()
clonelist.append( x )
return clonelist

The picture of my 3 cars, two of which are clones, is attached and named picture7lab6.png .

What I Learned
For this project we were introduced to the "while" loop, which is probably the most important thing I learned from this lab. The while loop come in handy and can be used for many different things.

Review of the Video Game Talk at Diamond
This is my recap of the presentation by Chris Melissinos on how video games affect our society.
I found this to be a very interesting talk because I am myself a gamer. And as a gamer, I see video games not only as forms of entertainment, but also as social entities. I thought that one of Mr. Melissinos' key points that we as the new generation will never witness the world with out computers again interesting. The age of computers has ushered in a level of interconnectivity never seen before; from Facebook, Twitter, to XBox Live. These new mediums grant us the ability to communicate and socialize with people hundreds of miles away from us while also being entertained. Mr. Melissinos also brought up the good point that now-a-days, you can't truly tell who is a gamer and who isn't. This is because the video game society has become so interwoven with our everyday society. In his talk, Chris gave the statistic that the biggest demographic of online gamers are women over 35, must people would have never guessed that. All in all,I believe that Mr. Melissinos' talk is extremely relevant in our modern society, because the affects that we are seeing now in our society by the gaming culture are just the beginning. Sometime in the near future, the gaming culture with become a consistent part of our society, and it is people like Mr. Milissinos that are leading the way and getting us prepared.
P.S. - If I was trapped in a room for a year with only one game, it would be Elder Scrolls III: Morrowind.

Attached Pictures
picture1lab6.png

picture2lab6.png

picture3lab6.png

picture4lab6.png

picture5lab6.png

car.gif

picture7lab6.png

Labels