// two-dimensional array? // i = 1, 8; // int F[], // shown an height // x[i], // // constrain x[i] sq(F[i]-mouseY)+sq(x[i]-mouseX)){ ibest = i; dist = sq(F[i]-mouseY)+sq(x[i]-mouseX); } } ellipse(x[ibest],F[ibest],20,20); // } if (mousePressed == true){ //now use ibest to move to mouseX, mouseY F[ibest] = mouseY; x[ibest] = min(x[ibest+1],mouseX); x[ibest] = max(x[ibest-1],mouseX); } }