Particles – Culture

Project Title: Culture 

Link

This is a representation of a bacteria culture inside a Petri dish. The color is randomized and the bacterium themselves have many different interactive functions. They will avoid the mouse, are created with mouse click, rotate, and grow and shrink. They can also be taken away with mouse dragged. 

An important part of this code is the mouse dragged splicing. This took the longest for me to figure out how to make it work. 

function mouseDragged(){
if (particles.length > 0) {
let index = 0; // the first index = the oldest object
// remove the oldest object
particles.splice(index, 1);
}
}

The thing that I have struggled with most with this project is the size increase and decrease. I wanted them to breathe like little bacteria, but the oscillation gets increasingly fast and I don’t like that. I want to be able to make them move at a set speed for the whole time the program runs, but I cannot figure it out. 

As for references, I utilized the p5js reference as well as the examples provided in the project powerpoint. 

Object-Oriented Programming is a style that is focused to an object rather than the entire script. This allows for us to break up the code into more manageable pieces. It also makes it so that each version of the object does not have to be redrawn or duplicated, but all the needed instances can just be called instead. The class is one of these pieces, housing the information about the object that is being programmed. These instances can be called in the draw function.

My objects in my code have properties making them rotate, oscillate, explode, move, bounce, and repel the mouse. These are all within my particles class. 

Leave a Reply

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