Week 3 – Generative Art OOP

Concept:

The desert is a big part of the UAE’s landscape, and one thing I would always notice during desert trips was how bright the night sky was compared to in the city. I was also inspired by the nightsky timelapses where it showed the movement of the Earth and the various stars. I wanted to mimic that in my artwork, by randomizing the stars shape, size, speed and the positioning of stars with every click.

My Artwork:

 

Code that I am proud of:

// Move the stars across the sky
  update() {
    this.posX = this.posX + this.speed;

    // Move star back to the left when it leaves the canvas
    if (this.posX > width) {
      this.posX = 0;

The reason as to why I am proud of this code is because I used the update() function to make each star across the sky move not simultaneously, but across the sky with each having its own random speed. I also added an if statement that checks when a star would go past the edge of the canvas and moves it back to the beginning/left. I liked this as it helped solve the problem of how the stars would reappear as the sky would move.

 

Debugging/Issues:

My main struggle in the beginning was how the class, objects, and array all worked together because OOP is still a new concept to me. At first, I understood how to create one star, but I was confused about how I could use the same class to create multiple stars that each had their own position, size, speed, and color. I also had some issues with organizing my functions and understanding how drawSelf() and update() worked together to create the animation. I personally drew a lot of inspiration in the code from the Car class example we worked on in class, especially when creating the Star class and making the stars move. Using the same general structure helped me understand that I could take what we did with the cars and apply it in a completely different way for my own artwork. I also frequented The Coding Trains videos to fully understand the concepts and how they could be applied to my own code. I am still getting used to working with classes and objects, but building the artwork step by step definitely made the concept make more sense to me.
Reflection:

Leave a Reply