Now, after trying this, you may see that the stuff inside of the if statement will get executed whenever the mouse is pressed. We usually want to know when the mouse is first pressed, rather than whether it is down or not. To do this, we have to add a little bit more to our program.
The basic idea is that we need to store the previous mouse state, and then when it is time to update, we can check to make sure that the button was released before, and pressed now. That would constitute a mouse click.
So let's start by adding the following line as an instance variable to our class: