Coding Assignment Week #8 – Fleeing Butterflies

Inspiration :

In nature, there are several organisms and species that naturally are attracted to certain scents or colors in other organisms such as plants and animals. And on the contrary, they also flee from certain things. In more scientific terms, this process is also called, escape response.  It is a mechanism by which animals avoid potential predation.

Birds of a feather flock together to confuse potential predators

 

Concept: 

This program works with a butterfly class, that we instantiate several of and add a fleeing method to it. The class has properties such as position, velocity, acceleration, maximum speed, maximum force, radius, and wing color. The class includes methods for updating the butterfly’s position based on its velocity and acceleration, applying external forces to the butterfly, making the butterfly flee from a specified target (the ellipse in position mouseX MouseY)  if it is within a certain distance, and displaying the butterfly on a canvas using a shape resembling butterfly wings. The butterfly’s appearance is determined by random colors and the shape of its wings is drawn using ellipses.

33 Butterflies aesthetic ideas | butterfly, aesthetic, beautiful butterflies

Program:

 

https://editor.p5js.org/ea2749/sketches/d3LJADOUE

Leave a Reply

Your email address will not be published. Required fields are marked *