void positionSegment(int a, int b, int l) { x[b][l] = x[a][l] + cos(angle[a]) * segLength; y[b][l] = y[a][l] + sin(angle[a]) * segLength; } void reachSegment(int i, float xin, float yin, int l) { float dx = xin - x[i][l]; float dy = yin - y[i][l]; angle[i] = atan2(dy, dx); targetX = xin - cos(angle[i]) * segLength; targetY = yin - sin(angle[i]) * segLength; } void segment(float x, float y, float a, float sw) { strokeWeight(sw); pushMatrix(); translate(x, y); rotate(a); line(0, 0, segLength, 0); popMatrix(); } void moveBall() { 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, 30, 30); }