Kevin Bennett

Spring 2010

Lab assignment 6

The first task was to create a scene made up of complex objects. I decided I wanted to make a skyline scene at night with buildings and twinkling stars.

The first step to making my first scene was to create complex objects. So in, I wrote a function that drew a building at (x,y) with a scale factor, rows of yellow points as windows, and a random color of gray between gray15 and gray25 for the color of the fa├žade. I decided, because I would be putting the base of all of the buildings I would create at the same y value, I should make the (x,y) point at the bottom-left corner of the building rather than the top. Here is what I ended up with:

The next object in my scene was the sky, complete with randomly-placed white stars. That was easy enough to write. Then I wrote an animate function which randomly selected stars and turned them slightly more dull or slightly brighter, creating a flicker effect. It's hard to tell from the picture, but that it what is happening here:

So then I put them together in the file and came up with this:

The next task was to create a new file that could place the scene anywhere at any size. Unfortunately, I never ended up getting the fairly simple problem of "expected int, got float," but any time I tried to fix it, my buildings would just become the same size. In retrospect, I probably should have changed the scale factor so I would not have to have scales of 1.25 for my buildings. I assume that would have solved the problem, but either way, despite the error message, it still drew the image, so I didn't worry about it for too long of a time. This is the image I ended up with:

One is 75% normal size, the second is 60%.

The next task was to create our own scene following the same sorts of guidelines as with the first. I made a file, a file, and animated both of them. My final product was in which a person with an umbrella runs for shelter as lightning randomly flashes from the corner of the window. Here is a still image:

This project was great in helping me just get comfortable using the time, random, and graphics modules. I really understood exactly what I was doing by the end, which was not always the case with some of the other projects.