I need the rects on the left of the screen to move on the X coordinate in accordance to the spring over them. Anyone know a simple way to do that? I'm very new so as simplistic answer would be great. I'm thinking of making 3 more rects under the 3 I already have that match the background (making them invis) then having the white rects move using a PVector that changes the length of them when the spings are over the invis rects.
int num = 6;
Spring[] springs = new Spring[num];
int pop[];
void setup()
{
size(700, 500);
noStroke();
springs[0] = new Spring(460, 410, 30, 0.98, 8.0, 0.08, springs, 0);
springs[1] = new Spring(460, 340, 30, 0.95, 9.0, 0.1, springs, 1);
springs[2] = new Spring(460, 270, 30, 0.90, 9.9, 0.1, springs, 2);
springs[3] = new Spring(460, 200, 30, 0.98, 8.0, 0.08, springs, 3);
springs[4] = new Spring(460, 120, 30, 0.98, 8.0, 0.08, springs, 4);
springs[5] = new Spring(460, 40, 30, 0.98, 8.0, 0.08, springs, 5);
}
void draw()
{
background(51);
for (int i = 0; i < num; i++) {
springs[i].update();
springs[i].display();
}
stroke(20);
fill(255,255,255);
rect(0,0,400,160);
rect(0,160,400,150);
rect(0,310,400,140);
}
void mousePressed()
{
for (int i = 0; i < num; i++) {
springs[i].pressed();
}
}