int numSegments = 6; float[] x = new float[numSegments]; float[] y = new float[numSegments]; float[] angle = new float[numSegments]; float segLength = 25; float targetX, targetY; float ballX = 70; float ballY = 50; int ballXDirection = 1; int ballYDirection = -1; void setup() { size(400, 200); smooth(); stroke(255 ,100); fill(255,255,8); x[x.length-1] = width/2; y[x.length-1] = height; } void draw() { background(255); strokeWeight(5); ballX = ballX + 1.0 * ballXDirection; ballY = ballY + 0.8 * ballYDirection; if(ballX > width-25 || ballX < 25) { ballXDirection *= -1; } if(ballY > height-25 || ballY < 25) { ballYDirection *= -1; } ellipse(ballX, ballY, 20, 20); reachSegment(0, ballX, ballY); for(int i=1; i=1; i--) { positionSegment(i, i-1); } for(int i=0; i