P5.js { attraction / repulsion / gravity / resistance / buoyance }
Inspiration:
To create an imaginary environment based on this inspiration, I first tried to draw the fish shape and put two fish on the canvas to do tests.
To visualize the fish leader and her advocates separately, I have thought about many ways to realize it. I first tried to create two different classes, so that there attributes would affect each other, but when finishing the coding, I found it quite redundant. So, I decided to apply the same class, but to push them separately and utilize the “this” and “other” concept we have learned in class to do the between object attraction.
But the attraction and repulsion turn out to be quite fast, and for my visualization, I need to let those advocates be attracted to the fish leader but stay surrounded by her. So I determined a different mult coefficient to accelarator in attractedTo and repelledFrom function to control this. In repelledFrom fuction, I made the acc really small to make them move but still surrounding the fish leader once they come close to the leader.
To add more fun, I also divided the canvas into two parts and applied different resistances to each of them. The above part would be the shallow sea water, and the down part would be the deep sea, and I put the resistance of deep sea pretty high, so that the fish shoal would move much slower in the deep sea area.
If I had more time, I would like to try building a more sophisticated and complicated atmosphere where some sea plants would exist to enrich the sea environment. Also, I could apply the attraction and repulsion forces between fishes and different kinds of plants, respectively. Or probably build a game on it, where people could use mouse or key interaction to drag certain fish to certain plant, and if this kind of fish do not like eating the chosen sea plant, a repulsion effect would be applied, and that player would lose one point~ something like that hhhh.