Sketch freezes from uncalled while loop
in
Programming Questions
•
3 months ago
I'm using the Processing IDE 2.0.1 on Windows 7.
When I run a sketch containing this the sketch freezes, forcing me to use task manager to close it. What I don't get is I'm not even clicking the mouse, so why would the script freeze the sketch if it hasn't even been ran yet?
When I run a sketch containing this the sketch freezes, forcing me to use task manager to close it. What I don't get is I'm not even clicking the mouse, so why would the script freeze the sketch if it hasn't even been ran yet?
- int loopvar = 1;
int lx;
int ly;
int setup = 1;
void setup()
{
size(1280,720);
background(100,0,0);
}
void draw()
{
background(100,0,0);
if(setup == 1) {
setup = 0;
lx = width/2;
ly = height/2;
}
stroke(255,0,0);
fill(255,0,0);
ellipse(lx,ly,20,20);
}
void mousePressed()
{
//-This causes the problem, if taken out the sketch runs fine-
while(loopvar == 1) {
lx = mouseX;
ly = mouseY;
}//-------------------------------------------------------------------------------------
}
I also get the below error in the console after terminating the sketch's process
- Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.
I have found that even in a blank script with only the problem part of the script and declarations for loopvar, lx, and ly that it does the same thing, so I'm almost sure the rest of the script isn't causing this.
1