Project Title: Soaring Spacecraft
Link to my project:
https://editor.p5js.org/sf3972/sketches/BeWtojDAd
Brief Description and Concept:
By defining several classes with different properties and behaviors, I created this soaring spacecraft. I used an array and random speeds for the x-ais and y-ais, multiplying cos(frameCount) with the y speed so that it looks like the jet is going up and down. For the shooting stars, I mainly adopted the same method. Except for the y speed, I was only adding cos(frameCount), not multiplying, so that they keep going down and give an illusion as if the spacecraft is going up. Also, I made the spacecraft slightly move to look more authentic.
Demo/Visual Documentation:
Coding:
I referred to a video of The Coding Train on YouTube and had a better understanding of Class and the operation of particles after I watched the video. The instructor offered a lot of inspiration and helped me build a clearer structure in my codes. What was noteworthy was that after using multiple arrays and classes, the code ran much slower than in the past. And for this case, the instructor recommended using the splice function to remove unseen particles so that the code can run faster. It is a very useful piece of advice and I eventually solved the problem by adopting it.
Reflection/Lessons Learned
What is Object-Oriented Programming (OOP), a Class and an Instance of the Class?
Object-Oriented Programming is a kind of programming that focuses on manipulating objects rather than functions and logic. A Class is a template used to create objects and to define object data types and methods. In the class, we learned in a vivid way that If the objects are seen as cookies, then a class is a cookie cutter. An instance of the Class is an object.
Discuss the effectiveness of OOP. When is OOP useful? In what way can it be utilized?
OOP can be beneficial when there is a lot of code that needs to be shared, reused, or put together, just like what we did for the Grand Party.
Describe the objects you have created. What properties and methods were implemented? What kind of behaviors did you create by manipulating them?
I once created a CD Player. I used arrays and the random function to create tens of music notes coming out of the player. Additionally, I tried to use user-defined functions for each part of my cd player to manipulate their sizes, positions, and rotating directions, which was super fun to explore.
Please share it if there is any challenging and confusing aspect(s) in the OOP concepts and techniques.
Though it makes the code modular and more reusable by adopting the concept of OOP, it adds difficulty to the creation of each object because the modularity has to be taken into account when coding.