Arraylist Processing
in
Programming Questions
•
1 year ago
Hi to all.
Based on the following example, I would like to know how it is possible to create a line that connects the first added ellipse with the second added ellipse (and then the second with the third, the third with the fourth, and so on.
I have tried the following but it connects the newly added ellipse with all the previous ellipses, and I want to avoid that.
(The returnPosX and returnPosY is a return statement from the ball class that gives me back the position of x and y).
for (int i = balls.size()-1; i >= 0; i--) {
Ball ball = (Ball) balls.get(i);
for (int j = balls.size()-1; j >= 0; j--) {
Ball ball2 = (Ball) balls.get(j);
line(ball.returnPosX(),ball.returnPosY(), ball2.returnPosX(), ball2.returnPosY());
ball.move();
ball.display();
}
1