Lenticular wrote on Aug 18th, 2009, 3:41pm:If I understand this correctly; On the first frame, x has to get over endLegs or processing will not go to step 4 which is to draw frame 2 of the 30 or so frames a second. Like the frames (or pictures of a movie or television that makes up the flickering images we see on the monitor).
x has to get over endLegs on
every frame, otherwise the program will be stuck in the while loop. When you set up a loop you
must ensure that the condition will get triggered at some point.
Lenticular wrote on Aug 18th, 2009, 3:41pm:Adding the + 1 to (spacing = (mouseX / 2) + 1;) makes the while loop complete itself all within the first frame which is step 3 : call draw() before going to step 4 which is to call draw() again for the next frame to paint or draw() on.
If mouseX only updates once a frame then the draw loop has to complete at least once before mouseX updates from the starting value of 0. For the draw loop to complete the first frame, the while loop has to complete. In your original code the while loop would only complete if mouseX was greater than 0, which wouldn't happen because you couldn't get beyond the first frame... i.e. it would never complete, you wouldn't pass Go and wouldn't collect £200...
By including the "+1" the condition in the while loop will be triggered, since each repetition of the while loop will add 1 to x, meaning it will eventually be greater than endLegs,
even if mouseX=0.
And note that the while loop will complete each and every frame - it has to in order for Processing to move on to the next frame...