The main objective for project 2 was to grasp a firm understanding of how code functions inside of other functions, use scale and learn how to call functions from other TextWrangler files. We began this project by creating a TextWrangler file called shapely.py. The purpose of this was to hold all of the functions for our individual shapes and for our collective shape functions. Our other file was titled main.py. The purpose of this file was to call all of the functions from shapelib.py. These functions would collectively create our coastal Maine scenes.
I first started by coding a few simple shapes. These shapes combined made up the larger shapes that came together to from the scene.
I then combined the shapes to form two of my key images for the scene. The first being a lighthouse, constructed of a square, triangle and trapezoid. The second being a boat, made up of a semi circle and a triangle. In order to show that I know how to simply move the images around and scale them differently, below is a compilation of these images in different sizes and locations.
For example, here is a snippet of coding for my semi circle. By multiplying the lengths by scale, I was able to quickly change how large or how small I wanted the shape to be. This is an extremely useful tool to have.
Coast Scene 1:
Below is my first coastal Maine scene. It combines my lighthouse function, wave function and boat function. I added additional detail by using the fill color command.
This is how I called the functions from shapelib.py to my main.py file.
Coast Scene 2:
The following image is my second coastal Maine scene. I totally rearranged the point of view, as I moved the land and lighthouse to the right of the image and put the boats and additional boats in the water to the left.
For my extensions, I played around with the random functions. First, I randomized just the lighthouse so that 50 of them would show up around the entire screen. Then, I added the boat, and programmed 25 of each shape to show up on the screen. I put parameters on the boat so it could only show up on the left side, and put parameters on the lighthouse so it could only show up on the right side. Here is what it looks like.
Here is what my code looked like for the extensions:
What I learned this project:
I learned many important skills during this project. I learned how to call functions from other TextWrangler files. I successfully learned how to use scale and draw the same image on different parts of the screen and different sizes. I also learned how to use the random function. Moving forward, these are very useful skills to know.
I received help from Professor Taylor and Vlad Murad on this project.