hello i need help with my code. i need to be able to click the picture with the cross hair and for it to fall but nothing ive done seems to work. if possible could you guys show me how to do it using a while loop? also hi m new
So slight issue with your code… It contains images. You see, when you download an image and import it to your code, then it becomes unique to you. In order to run this code, I have to find and download each and everyone of those images. But I can’t do that, so i can’t really run your code…
However, I can tell you how a while loop works. So here’s how:
while (something is true)
So basically, the code inside the loop with run as long as the condition is true. For example:
int number = 0;
while (number < 10)
println(number + " ");
number += 1;
So this will print a sort of list to the console. It will print number, and then add one to it. So the output should look something like this:
0 1 2 3 4 5 6 7 8 9
Notice how the loop stopped after number equaled 10.
And yeah, that’s about it for while loops. Hope this helps!
You can also watch on The Coding Train channel – aka Dan Shiffman – on youtube for additional explanation about conditional statements / boolean expressions. That playlist is here:
Second, after you have set up the boolean switch statement, then you need to add a line of code that moves the y position of the image down after you have clicked on it.
This should get you going in the right direction but, if you need more help, please ask.
****I know you mentioned in your original question about using a while loop. I recommend reading about the while loop in the reference to confirm how and when to use. Here: https://processing.org/reference/while.html