Learn creative coding writing simple programs

65. Are we getting close? Use dist() to find out the distance

The dist() function can be used to find out the distance between to points. In our example we test how far is a moving circle from the mouse pointer by writing: float d = dist(x, y, mouseX, mouseY);
Now that we know the distance, we can do different things when we are getting close to our destination.

Tags: dist, distance, Lesson

Code editor

You can make changes to the code below. Then
Questions and comments are welcome! :) But please try to stay close to the topic of this episode. Use the Processing forums for help with your Processing projects (or hire me for help ;-)