PVector[] record = new PVector[100];
int curr = 0;
void setup() {
size(800, 800);
for (int i = 0; i<record.length; i++) {
record[i]= new PVector(100, 100);
}
}
void draw() {
}
void mousePressed() {
record[curr].x = mouseX;
record[curr].y = mouseY;
curr++;
print (curr);
if (curr==1) {
for (int i=1; i<record.length; i++) {
record[i] = record[0];
print("ladida"); //debug
}
print("ladida"); //debug
}
print (record[0]);
print (record[1]);
print (record[2]);
print (record[3]);
print (record[4]);
print (record[curr]);
println ();
}
What the code is suppose to do.
First Click should store Mouse X and Y value in record[0] and then make all the other values of record(eg1,2,3,4,5,6β¦) equal to record[0]. So, at this point all the values in record should be the same. From the second click, only the values of the next record gets updated. So, the second click should update record[1] and the third should update record[2] and the forth record[3] and so on.
What it does.
First Click stores Mouse X and Y value in record[0] and then makes all the other values of record(eg1,2,3,4,5,6β¦) equal to record[0]. The second click also does the same, it again copies the value onto all the array instead of only 1 box.