if any are true in iteration loop
in
Programming Questions
•
1 year ago
I'm having a tricky (to me) logic problem that I'm not sure how to solve.
I am iterating through an array to see if a cursor location is within a certain bounds. If it is true, I would like the cursor to disappear.
There are multiple points that the cursor could be over. So, the difficulty I'm having is that I have an array containing all of the points, and a loop comparing the cursor location to the various points. While the function correctly detects that the cursor is over one of the points, it is also, within the same loop, detecting that it is NOT over any of the other points, and so is being redrawn.
so, in psuedocode, it's like this:
-
float points = newList[numberOfPoints];boolean isOver = false;
setup(){size(the, universe);allMySetupStuff();cursorLocation(mouseX, mouseY);for (i = 0; i < numberOfPoints; i ++){points[i] = initializeThePointCoordinates();}}
void draw(){if (isOver = true){disappearCursor();}
for (int i = 0; i < numberOfPoints; i ++){if (cursorLocation isWithinCoordinates points[i]){isOver = true;}else{isOver = false;}}}
So, as you can see, it will be true once in the loop, but false for the rest of the loop. It will happen so fast that the cursor will never actually disappear. How can I get around this?
Thank you in advance.
/*
Please forgive my ignorance. I only know what I've already learned, and this world is a lot bigger than that.
*/
1