class Ball { boolean alive = true; boolean captured = false; float posX ; float posY ; float side = 20; float velX = 0; float velY = random(-1,1); float bdifx ; float bdify ; float nextVelX ; float nextVelY ; float grav = 0.05; float bounce = 0.9; float energyX = 0; float energyY = 0; //Ball [] the_array; //int my_element; float R = 255; float G = 255; float B = 255; Split [] splt = new Split [3]; Ball() { posX = random(20, width-50); posY = height+10; for (int j = 0; j < splt.length; j++) { splt[j] = new Split (); } } void draw() { if (alive){ fill (R, G, B); ellipse(posX,posY,side,side); if (captured) { energyX *= 0.75; energyX +=mouseX-posX; posX = mouseX; energyY *= 0.9; energyY +=mouseY-posY; posY = mouseY; } else { posX += velX*4; posY += velY*4; velY += grav; } } // stay in screen bounds if (posX > width-(side/2) || posX < (side/2)) { velX = -velX; this.R = (random(50,255)); this.G = (random(50,255)); this.B = (random(50,255)); } if (posY > height-(side/2)) { velY = -velY; } if (posY < (side/2)) { velY = -velY; for (int j=0; j