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