class bug { int diameter; int brightAdjust = 10;//getting brighter or darker int bright = 0;//how bright at the moment boolean glowing = true;//is it glowing float x, y, xmove, ymove; //for movement float angle = 0.0; float speed = 0.03; float displacement = 0.2; //constructor bug(float xpos, float ypos, float sx, float sy, int dia){ x = xpos;//assigned higher in code^ y = ypos;//assigned higher in code^ diameter = dia; xmove = sx; ymove = sy; } void move() { angle += speed;//moves the item forward float sinval = sin(angle); float cosval = cos(angle); float _x = x + (cosval * displacement);// x here shifts the bugs into position float _y = y + (sinval * displacement);// y here shifts the bugs into position float x2 = _x + cos(angle * xmove) * displacement/2; float y2 = _y + sin(angle * ymove) * displacement/2; // ellipse(x2, y2, 10, 10); x = x2; y = y2; } void display(){ noStroke(); /*bug * * * * */ fill((bright/2) + 20); ellipse(x, y, diameter, diameter); } void glow(int speed){ // (( (halo) )) \\ //speed/(1000/frameRate) formula to find out how many frames are needed to match miliseconds //44 is how long it takes the light to strobe if ((frameCount%(round(speed/(1000/frameRate))+ 44) ) == 0){ glowing = true; } if(glowing){//glow sequance bright = bright + brightAdjust;//get brighter if(bright >= 255){ brightAdjust = -15;//get darker } else if (bright <= 0){ bright=0;//nothing, darkest, 0 glowing=false;//stop glowing sequance brightAdjust = 10;//return brightness adjustment to formar state } } fill(200, 200, 0, bright/3);//brightness og halo ellipse(x, y, diameter * 10, diameter * 10); //halo itself } }