top of page

Assignment 5: Functions (Updated Project)

  • Writer: Kiya Brown
    Kiya Brown
  • Mar 15, 2021
  • 2 min read

For this week's assignment I decided to update my week three project of a city skyline. The original purpose of that project was to use buttons and switches to integrate user interaction into the sketch.

The original project had a lot of little tiny details that were very tedious to make. The buildings, although they are only composed of rectangles, took a long time, and the tiny squares for each window took even longer! I used functions in this updated code to create a function or "template" for the buildings. I set the parameters to be their x, y location as well as their height and width. I called the buildings functions to create the skyline and it was a lot easier, as well as cleaner, to do it this way. The only thing is that I had to create three different building functions because there were different layers that had different colors. I couldn't figure out how to include colors in the parameter of the function so I had to make the separate ones. If I were able to include color in the parameters, that would save even more time and energy as I would only need one function for the buildings and I could just change the location, size, and color when I call the function.

I feel I could have added another function or two, especially in the creation of the sun and the cloud. They have different details that are generally just small discrepancies. But because there was only one sun and one cloud I didn't really see the need to create a function for them, although I can definitely see how it would be used.

As for the updated code, I also added for loops and nested loops to create the windows. This saved soooo much time and space in my code, not having to make each individual rectangle/square.

And for small things that I ended up updated as well: I now made the sun and cloud repeat their animations so when they reach the end of the screen they are called back again and repeat over and over. I also updated the rain "button" that I had in the source code. Although it is not much better, I turned the button into a raindrop labeled "press me" so that it is a little bit more intuitive and matches better with the theme.

There are of course even more things I could've added to this sketch to improve it even more. For example, I could make the sky get darker as the sun set or make the sky get darker when it is raining. Just small details.

My partner for this week was Izzi and she was a lot of help in breaking my code down into more concise chunks, but I also generally knew what I was going to do to update it. This is just because my source code already had such distinct parts and shapes (the buildings, windows, sun, etc.) that making them into functions/loops made the most sense for me.





Comments


© 2023 by Kiya Brown

bottom of page