Using the Mouse

You should have seen some examples in Khan Academy of how you can use the computer's mouse to interact with your sketches. Here is a very simple example for you to start with. Note that you can EITHER move the mouse to leave a trail of circles OR you can click the mouse button (press and release) to change colour. If you click while moving, the colour won't change.

Source code: Code for using mouse functions

Look at the source code by clicking on the link above. Do you understand how it works? Now YOU try it. You may start by copying code from this example, but then change it to make it more interesting:

Continue with how to use mouse variables.