Larry's Project 2
Skip to end of metadata
Go to start of metadata


This week's project had a focus on the ability to repeat functions through the use of definitions. When "layering" definitions, the created image grows in complexity. Also we were introduced in this lab further organization of programs, to make it easier for readers to follow. Specifically, we will be creating a "shapes".py which will be used to store created definitions. Then through the use of importing that .py, we gain access to all it's definitions.


Required Pictures:

1) Underwater Scene:

Our first task was to create an underwater scene using the skills we have acquired thus far. When first completing this scene all I had was some fish, sand, and a treasure chest. It felt bland due to the fish all facing the same direction, so I decided create a cool effect of the fish swimming different directions. At first I thought their would be a "mirror" command that can flip an image, but soon discovered that didn't exist. I had to recreate the original fish diagram but flipped over (drawFishes versus drawFishesOppo). I accomplished this by drawing out the two fish on graph paper to attain a visualization. I go on to create more randomness and originality through 3 extensions which I go into more detail in the extensions section below. Here is the final product.

2) Other Scene (Forest Scene):

Our second task was to create a scene of our choice. I decided to do a forest scene with the goal of creating a mini-animation factor by switching the scene from day to night. This scene was by far the more difficult of the two for creating simple trees was not simple in the least bit. I finally got it to work through the "stacking" of triangles in a similar fashion from the practice in the lab. This took multiple attempts to line up the triangles and make sure the turtles approach to each triangle was in the same direction.

To create a feeling of depth to the picture, I had a group of trees randomly placed on the same x-axis, and then another group on the x-axis in front of the first, and then finally a third group repeating that technique.

I accomplished my mini-animation by having program prompt the user to "Press Enter to go to Nighttime" by using the raw_input command. Then the sun turns to a moon (by overlapping the creation of a new, white circle) and the sky changes by having the background changed to navy. To add more change, when hitting enter, it starts the creation of stars in the night sky.


Within Undersea Scene:

For the fish in the underwater scene there are four completely randomized occurrences taking place. They are:

1. Each fish is random placed on the scene. The x and y coordinate of their starting point is chosen at random by using "random.random()".

2. Within the same block of code, size is decided randomly as well, being the third generated number within "drawFish()"

3. As I mentioned above, there are fish swimming in different directions. I leave it up to the program to decide how many fish are facing to the left or right. I did this by having the program randomly generate an integer between 0 and 6, and then have one program draw that many fish while the other draws 6 minus that number.

4. The final, very small detail in this scene is the presence or absence of bubbles next to a fish. I accomplished this through an random integer generator command and the "if" and "else" commands. I had it generate an integer between 0 and 100, and if the number was greater than 50, air bubbles would be generated. Also the program will print "air bubbles" or "no air bubbles" based on the result.

Within Forest Scene:

1. The first extensions I completed in this scene was the creation of the trees. They took the use of a prior used program but with some serious alterations. The biggest changes to the program block was the manipulation of x and y coordinates by a percentage of the scale. This gives it the "stacking effect". This process also utilized multi-staged definitions and repetitions.

2. When focusing on the stars, one can notice that each is slightly rotated differently. This gives it a certain uniqueness.

What I learned:

I now feel very comfortable with python, specifically within turtle. I focused this time around to stay very organized, and I hope it shows through use of #'s to divide up the shapes with the two "shapes" programs.