Hey,
I’m just starting processing at university, so I feel a little lost in my code. I want to start my first void line1 and then, after some seconds, start the second void line2 too. I know that it should be possible to make if work with a if condition in draw somehow, but I just don’t get it?!
It would be grate if you could help me please. Thanks a lot!
int timePassed = 1;
int timeSpan = 100; //Zeitspanner in Timer
int anzahl = 1;
float BOLD = 0.5;
int RAD_MIN_STEP = 1;
int RAD_MAX_STEP = 20;
int LIM = 50;
PVector prevPos = new PVector();
PVector currPos = new PVector(prevPos.x, prevPos.y);
float ang, rad, dir;
boolean paused;
void setup() {
size(1080, 960);
smooth(2);
frameRate(60);
strokeCap(ROUND);
strokeJoin(ROUND);
strokeWeight(BOLD);
restart();
}
void draw () {
linie1();
//if ((millis() - timePassed) > timeSpan) {
// linie1();
// println ("tick");
// timePassed = millis ();
if count>10{
linie2();
}
}
void linie1() {
ang += dir/rad;
currPos.add(cos(ang) * rad, sin(ang) * rad);
int x = round(currPos.x), y = round(currPos.y);
if (x < 0 || x >= width || y < 0 || y >= height) {
bounce();
x = constrain(x, -LIM, width + LIM);
y = constrain(y, -LIM, height + LIM);
currPos.set(x, y);
} else if (get(x, y) != 255) bounce();
if ((millis() - timePassed) > timeSpan) {
Linie2();
timePassed = millis ();
}
line(prevPos.x, prevPos.y, currPos.x, currPos.y);
prevPos.set(currPos);
}
void Linie2() {
ang += dir/rad;
currPos.add(cos(ang) * rad, sin(ang) * rad);
int x = round(currPos.x), y = round(currPos.y);
if (x < 0 || x >= width || y < 0 || y >= height) {
bounce();
x = constrain(x, -LIM, width + LIM);
y = constrain(y, -LIM, height + LIM);
currPos.set(x, y);
} else if (get(x, y) != 255) bounce();
if ((millis() - timePassed) > timeSpan) {
stroke (random (0, 255), random (0, 255), random (0, 255));
//println ("tick");
timePassed = millis ();
}
line(prevPos.x, prevPos.y, currPos.x, currPos.y);
prevPos.set(currPos);
}
void mousePressed() {
if (mouseButton == LEFT)
if (paused ^= true) noLoop();
else loop();
else restart();
}
void bounce() {
rad = random(RAD_MIN_STEP, RAD_MAX_STEP);
//ang += PI * (dir *= -1);
ang += PI * (dir *= -1);
}
void restart() {
background(0);
//stroke(random(COLORS), 1, 1);
prevPos.set(width>>1, height>>1);
//prevPos.set(width>>2, height>>2);
currPos.set(prevPos);
//rad = dir = 1;
rad = dir = 80;
}