// The Cell class class Cells { // Properties to help tracking and drawing the cells // Position, growth, which is size, color, direction of movement, velocity and speed float xpos; float ypos; float xgrowth; float ygrowth; color gcolor; float directionX, directionY; float velocityX, velocityY; // The constructor for the Cell class // X and Y positions, growth, which is actually size, color and direction Cells(float _x, float _y, float _xg, float _yg, color _gcolor, float _directionX, float _directionY) { xpos = _x; ypos = _y; xgrowth = _xg; ygrowth = _yg; gcolor = _gcolor; directionX = _directionX; directionY = _directionY; } // Display function for the cells // Nostroke, color and draw an ellipse void display() { noStroke(); fill(color(gcolor)); ellipse(xpos,ypos,xgrowth,ygrowth); } // Move function for the cells // X and Y velocity set by velocity, which is direction and speed // Which in turns gives us an X and Y position void move(){ velocityX = directionX; velocityY = directionY; xpos += velocityX; ypos += velocityY; } // Grow and shrink function for the cells // Growth per frame circle set, if the cells grow bigger than 150 pixels we invert the growth // This means its a negative number when they shrink, which is important to remember void grow() { xgrowth = xgrowth +0.05; ygrowth = ygrowth +0.05; if (xgrowth > 150) { xgrowth = - xgrowth; ygrowth = - ygrowth; } } }