Welcome!
Jump to the video on Conditional statements, Video 5.1 If, else if, else.
Read more about while loops on the Processing reference page.
Review mouseX on the Processing reference page.
See code below for another example of an interactive while loop using mouseX.