Mouse Clicked function and storing variables

Here is a few things you might find helpful:

Here’s what I would try:

Create an arraylist and in setup add a random (or mouseX and mouseY) location to it.

Use the mouse clicked function add a location to the end of an arraylist.

Then in draw you have the object move towards the first thing in the arraylist. And If the object is within a certain distance (look into dist()) and the arraylist.size() is greater than 1 remove the first element in the arraylist.

Hope that make sense and is helpful.

1 Like