class BBug { float xPos; float yPos; float newX; float newY; color myCol; int maxTime = 100; int count = 0; BBug(int p_xPos, int p_yPos) { xPos = p_xPos; yPos = p_yPos; //myCol = new Color(random(0,1.0), random(0,1.0), random(0,1.0), .3); newX = xPos += random(-30,30); newY = yPos += random(-30,30); } void move() { int curDis = getDis(xPos,yPos, newX, newY); if(curDis < 5) { resetDistance(); } float dx = newX - xPos; float dy = newY - yPos; xPos += dx/15; yPos += dy/15; fill(100,75,50,30); noStroke(); ellipse(xPos,yPos,25,25); } void resetDistance() { newX += random(-150,150); newY += random(-150,150); if(newX < 0) { newX =width/2; }else if(newX > width) { newX =width/2; } if(newY < 0) { newY = height/2; }else if(newY > height) { newY = height/2; } } int getDis(float x1, float y1, float x2, float y2) { int dis = int(sqrt(sq(x2-x1) + sq(y1-y2))); return dis; } }