πFirefliesπ

π Interact with the “Fireflies” on p5.js
VIDEO RECORDING
WORK PROCESS
Inspiration

My inspiration for this project came from the fireflies in the forest. According to my research, fireflies are famous for their enchanting luminescent displays and exhibit diverse light patterns utilized primarily for nocturnal communication and mating rituals. They are active predominantly at night, these insects rest during the day in shaded areas like grasses and trees to evade predators. Notably, firefly larvae thrive in aquatic or semi-aquatic environments, inhabiting moist soil or vegetation near bodies of water where they feed on small invertebrates, embodying a dual terrestrial and aquatic lifestyle.
Simulation of Fireflies in Nature
Thus, when I began to simulate the living process of fireflies in the forest, I decided to realize 3 features: 1. Firefly larvae rest in aquatic environments during the day; 2. Fireflies awake, gradually grow up, and light up during the night; 3. Fireflies get attracted by the artificial light during the night.

Resistance and Buoyancy
The visualization of the first feature is related to the resistance and buoyancy. By referring to what we learned in class, I modified the code to make the little firefly larvae float on the surface of the water.
Emphasizing the Physical Concepts (Collision)

The second feature describes that in the night view, the fireflies start flying above the water surface and gradually grow up. To better visualize the effect, I added the collision function to the firefly. In that sense, when fireflies come into contact with the water surface, they will spring away in the direction away from the water, and meanwhile, a circle of ripples will form on the water surface.
REFLECTION

Background Image
The background image was generated with the help of the AI-generating tool Stable Diffusion for better visualizing the concept of fireflies living in the forest with a lake. After inserting the image into the code, I also modify the initial background element to indicate the changes of day and night.


Emphasizing the Physical Concepts (Attraction)
For the third feature, I also tried multiple times to add the attraction function to the fireflies when the mouse is pressed and the light/fire is turned on. However, I only managed to cope with the light object while the fireflies didn’t seem to be attracted to the right position. Perhaps it’s related to the random vector stuff and I’ll keep trying to fix the problem and finalize the function in the future.