Im really confused, i wrote/copied whatever, this piece of code about 2 years ago and just came across it as it is perfect for some other idea am working on... its working but i just dont understand how...
this is the code :
Quote:int anzahl=29;
float[] oldX = new float[anzahl];
float[] oldY = new float[anzahl];
void setup(){
size(400,400);
background(255);
frameRate(40);
for(int i=0; i<anzahl; i++){
oldX[i] = 0;
oldY[i] = 0;
}
}
void draw(){
background(255);
float[] tmpX = new float[anzahl];
float[] tmpY = new float[anzahl];
for(int i=0; i<anzahl-1; i++){
tmpX[i+1] = oldX[i];
tmpY[i+1] = oldY[i];
}
tmpX[0]=mouseX;
tmpY[0]=mouseY;
oldX=tmpX;
oldY=tmpY;
for(int i=0; i<anzahl-1; i++){
line(oldX[i],oldY[i],oldX[i+1],oldY[i+1]);
}
}
And ive got the following questions...
Why doesnt it work when i declare
float[] tmpX = new float[anzahl];
float[] tmpY = new float[anzahl];
outside of the draw function... its just declared there, why does it behave different when i do this outside the draw function?!
the next thing is, what the crappity smack am i doing here?
oldX=tmpX;
oldY=tmpY;
isnt it an array? what does it mean in this case? just a simple way for putting every single part of one array into another?
Why is there this Line going to the origin(0/0) at the beginning of the sketch? i mean i know there must be an array which is not filled and is still 0 but where is it?
its not: oldX[i] = 0;oldY[i] = 0; ...
and last but not least...
How should i change my code so that the line stays the same when i dont move the mouse and only erases itself when i keep on moving...
WOW, im feeling stupid... this is for those people who love so solve Problems and reading code :) Thank you Guys!!