Project Title: Fireworks Show🎇
Link to the project: github
Brief Description
In this project, I aim to depict a fireworks show, with fireworks triggered by user’s mouse press and exploding in the night sky, evoking a sense of enchantment. Additionally, shooting stars streak across the horizon. People sitting by the water can not only gaze at the sky but also see reflections in the water below.🎆
Visual Docuentation
Coding
I create two classes for fireworks and shooting stars respectively. Given the gravity, I applied what we’ve learnt in class into use to adjust speedY over time, simulating the descent of fireworks following their explosion. I also make the size gradually become smaller and smaller to mimic the gradual disappearance of the fireworks against the backdrop of the night sky.
I also implemented a water surface on the canvas, allowing for the creation of the reflection effect. Using translate(), I mirrored the fireworks and shooting stars in the downward direction.
Additionally, I wanted to make objects disappear upon reaching the water surface and reappear at their initial positions. However, attempting to achieve this within the class using methods I we used before doesn’t work well. I tried to position objects at (this.startX, this.startY) , but failed. As a workaround, I utilized the reset() method to reposition objects accordingly.
Reflection
- What is Object-Oriented Programming (OOP), a Class and an Instance of the Class?
In my opinion, object-oriented programming (OOP) is like organizing code based on real-world objects, relying on concepts of classes and objects. Personally, I think a class is like a set of rules and blueprints that define how instances/objects should behave, but each instance/object created from a class is unique and distinct from others. For example, in my project, I created shooting stars represented by individual objects like star 1 and star 2. While they may share common properties and movements, they remain distinct entities.
- Discuss the effectiveness of OOP. When is OOP useful? In what way can it be utilized?
I personally think that the most effective feature of OOP is its reusability. A single class can correspond to multiple objects, making the coding process more concise and efficient. Also, by employing OOP, we can break down complex systems into individual, manageable objects. Each class can clearly define the properties and functions of one or more objects, making modifications easier.
- Describe the objects you have created. What properties and methods were implemented? What kind of behaviors did you create by manipulating them?
In the my project, I created several objects using OOP principles. Firstly, the Firework class represented individual fireworks, with properties such as position, color, size, and velocity. Methods were implemented to update the position of the fireworks over time and display them on the canvas. By manipulating these properties and methods, I created behaviors such as the movement of fireworks, their explosion upon reaching a certain height, and the gradual fading of their size over time.
Additionally, I created a ShootingStars class to represent shooting stars, with similar properties and behaviors as fireworks but with different initial positions and trajectories.
- Please share it if there is any challenging and confusing aspect(s) in the OOP concepts and techniques
I’m a bit unclear about the distinctions between an object and an instance in OOP. I tend to perceive them as the same entity, but I’m not sure about their precise differences.🧐
Leave a Reply