Hi Jim,
I may misunderstand what you are trying to do so if you feel I am telling you obvious things that you already know please don't take offense!
First of all, check the loop() reference, it may show you exactly what you want.
Quote:Hi folks,
What I would like to do is to be able to get draw to reach a predefined point and then stop and wait for input from me (a mouse press for example) before proceeding.
OK, do you want the same thing drawn each time the sketch runs or are you happy to have random things drawn?
Quote: Code:
int loopEnd=1000;
boolean wait4mouse=true;
int strokC=0;
void setup(){
size(400,400);
background(255); strokeWeight(2); smooth();
stroke(strokC);
} // end setup
background() must be called each time the draw method is called if you want the screen to be redrawn. I think the unspecified framerate is 60 frames a second, but this may have changed.
Quote: Code:
void draw() {
for(int i=1; i < loopEnd; i++) {
ellipse(random(0,width),random(0,height),4,4);
} // end loop
This will draw 1000 random ellipses before the following lines are reached, and this is expected to happen 60 times a second. Is this what you want?
Quote: Code:
while(wait4mouse) {
if (mousePressed == true) {
strokC+=5;
stroke(strokC);
background(255);
println("****** NEW SCREEN ******");
wait4mouse=false;
} // end mousepressed
} // end wait4mouse loop
wait4mouse=true;
} // end draw
This final while could cause some issues, I think nothing will be displayed while you wait for the mouse press, but as soon as you have it it blanks what has already been drawn (but not displayed). I could be wrong. Here is my version which I think does what you want. I try to avoid for and while loops in the draw that could potentially freeze everything.
Here is a reworked version of the code you posted:
Quote:boolean paused = true;
void setup()
{
size(400,400);
background(255);
strokeWeight(2);
smooth();
}
void draw()
{
stroke(random(255), random(255), random(255));
ellipse(random(0,width),random(0,height),4,4);
}
void keyPressed()
{
paused = !paused;
if(paused)
noLoop();
else
loop();
}
Regards,
Stephen