Simple restart
in
Programming Questions
•
2 years ago
Having a little trouble with timed loops. Maybe someone might know? What I'm trying to do is get an animation to restart and replay after a set amount of time. I tried setup(); but it doesn't start again from the beginning which is what I'm after.
This is my code:
float x;
float y;
float r;
int startLoop = 0;
float speed = 1.0;
int direction = 1;
float d = 2.0;
void setup(){
size(400,400);
x=200;
y=100;
r=10;
}
void draw(){
background(220);
if (millis() < startLoop+1000){
d += speed * direction;
smooth();
noStroke();
fill(250,200,0);
ellipse(x,y,d+r,r);
} else{
setup();
}
}
1