Pausing a for statement until action occurs
in
Programming Questions
•
2 years ago
hey guys
i making a drawing program and the outcome is exactly how i want it to look, however i want it to be reactive as you can see there are 3 "for" statements one that creates 50 random points, the other 2 create the lines that join the points together, i would like it pause after the first for loop until the mouse is pressed and then having completed the the first set of connecting lines (line 22) which draws 50 lines from the first point to every other point i would like it to pause before it starts drawing lines from the second point to every other point until the mouse is pressed when it would draw 50 lines from the second point to all other points and then pause again until the mouse is pressed. i know i haven't been very clear in this explanation so please ask if anything is unclear. really appreciate any help with this project its my first attempt at writing a sketch from scratch.
thanks
ditchweed
- float[] dotx;
- float[] doty;
- size(screen.width,720);
- smooth();
- strokeWeight (0.2);
- background (255);
- dotx = new float [50];
- doty = new float [50];
- for (int i=0; i < 50; i++){
- float x=random(0,width);
- float y=random(0,height);
- dotx[i] = x;
- doty[i] = y;
- point(x,y);
- }
- for (int i=0; i<50; i++){
- for (int j=0; j<50; j++) {
- line (dotx[i],doty[i],dotx[j],doty[j]);
- }
- }
1