ok so i think im done but one last thing is that is there a way to connect each ball to its nearest neighbour like
int length = 101;
PVector[] position = new PVector[length];
int BallNum;
void setup() {
size(600, 600);
background(255);
}
void draw() {
fill(255);
layout();
fill(0);
}
void mousePressed()
{
BallNum++;
position[BallNum]= new PVector(mouseX, mouseY);
circle(position[BallNum].x, position[BallNum].y, 20);
if (BallNum > 1) {
line(position[BallNum].x,position[BallNum].y,position[BallNum-1].x,position[BallNum-1].y);
line(position[1].x,position[1].y,position[BallNum].x,position[BallNum].y);
}
}
void layout() {
for (int yLine=0; yLine<=width; yLine+=width/10) {
for (int xLine=0; xLine<=height; xLine+=height/10) {
line(yLine, 0, yLine, height);
line(0, xLine, width, xLine);
}
}
}