Mouse Position is not Updated in while-loop

So I’d been racking my brain on this for some time, wondering why my sketch wasn’t working. Then I realized what was wrong. Hopefully anyone in the same predicament and searching the web will find this helpful.

Mouse Position cannot updated inside of a while-loop.

Run this and see:
void setup(){
size(300,300);

}

void draw(){

while (mouseX < 150){
println(“in while-loop”);
println(“frameCount: ” +frameCount);
println(“mouse position: “+mouseX+”, ” +mouseY);
}
println(“out of loop”); //you will never see this

}

Proudly powered by WordPress
Theme: Esquire by Matthew Buchanan.