timing animation with millis()
in
Programming Questions
•
2 years ago
- void setup(){
- size(400,400);
- }
- void draw(){
- for(int x=1; x<10;x++){
- println(x);
- if((millis()00)==0){
- int w=int(random(0,5));
- rectMode(CENTER);
- fill(255);
- rect(width/2, height/2,200 ,200);
- fill(0);
- textAlign(CENTER);
- text(w, width/2,height/2);
- }
- }
- }
Also I wanted this to happen 9 times.
My problem is, that the loop does not end if I do not stop the sketch, althoug the counter variable x does not get bigger than 9, the loop does not stop, but starts over with the counter variable reset to 1. Perhaps that has something to do with the looping of draw.
My second problem is, that I don't know how to display every rectangle with the random number for a second, I tried it by using an if-condition, that only draws the rectangel with the number when the value of millis () is dividable by1000 with no remainder, but this does not seem to work in the way I intended it to.
If somebody could explain me why the above code does not work and make any suggestion how I could get it working, I would be very thankful.
I am a complete beginner with Processing, so I might miss something very obvious,
Thanks in advance,
Millimanie
1