In this Mini Project, I created a visual simulation of a jellyfish gracefully floating in the ocean while releasing bubbles. The idea was to recreate the peaceful, fluid motion of a jellyfish and combine it with a particle-based bubble system to give the scene a lively, underwater atmosphere.
https://github.com/ln7Lan-Qu/CCLab_25S/blob/main/particle-world/sketch.js
1) The blue gradient in background represents the water environment where the jellyfish lives. It is drawn by using progressively deeper colored blue lines. The cursor is also hidden using noCursor() duing setup and replaced by a jellyfish emoji at the mouse position. The jellyfish moves gradually because of the lerp() used within the code.
2) The bubble particles are generated directly below the jellyfish. To achieve a realistic underwater effect, an initial downwards speed is given to each bubble, and the speed gradually changes so that the bubbles start to move upwards and moves faster the longer it stays on the screen (to simulate bubbles floating in water).
3) The bubbles have 3 base colors: light blue, light green, and light purple. Each bubble's color is chosen as a blend of 2 out 3 colors.
1) Using noCursor() and putting the jellyfish at the position of the cursor ensured that the audience interaction with the cursor position is realistic and immersive
2) Using classes for the bubbles greatly helped me to organize all the particle elements on screen. Each bubble can have its position and move speed in both direction independent of each other, which helps as the project is designed to generate bubbles on mouse click.
1) What is Object-Oriented Programming (OOP), a Class and an Instance of the Class?
Object-Oriented Programming (OOP) is a way to structure code by grouping related data and behavior into objects. A class is like a blueprint that defines how an object should behave, and an instance is a specific object created from that blueprint. In my code, Particle is the class, and each bubble on the screen is an instance of that class.
2) Discuss the effectiveness of OOP. When is OOP useful? In what way can it be utilized?
OOP is especially effective when dealing with many similar objects that need to behave independently but share structure. It helps organize code clearly and makes it easier to reuse and manage. In this project, OOP made it simple to generate and control hundreds of bubbles with different appearances and movements.
3) Describe the objects you have created. What properties and methods were implemented? What kind of behaviors did you create by manipulating them?
I created a Particle object to represent each bubble. It has properties like position, size, speed, color, and transparency. The methods update(), display(), and checkOutOfCanvas() control how it moves, fades, and disappears. Together, they create the behavior of bubbles gently rising and drifting away from the jellyfish.
4) Please share it if there is any challenging and confusing aspect(s) in the OOP concepts and techniques.
At first, it was confusing to decide what should go inside the class and what should stay outside. Managing many instances efficiently also took some time to figure out, especially when updating and removing old particles from the array.