Using the Mouse Variables

There is another way of interacting with the mouse: inside the draw() function you can use if statements to test the values of several built-in variables that contain information about what the mouse is doing. Here is an example:

Source code: Code for using mouse variables

Notice that the behaviour of this sketch is a bit different from the first sketch. Look at the source code of this example and compare it with the previous one. Now try changing the code to make it do other interesting things.