I am trying to write a program that remembers the past mouseX and mouseY values that the user inputs for a defined number of milliseconds in order to create a trail of objects behind the mouse's current position. I have this code so far that has no such function, but renders a rotating cube that follows the mouse:
I want to be able to set the number of ms to delay more instances of Cube behind the mouse, but I cannot figure out how to do so. I believe that something involving two arrays, one for each mouse axis, would have to be set up that have the same number of points as the time that the "tail" objects are being delayed, and every entry in both arrays after an initial period would be shifted over and then the last ones would be used for the object's position. I tried to implement this myself, but I was unable to do so.
Sorry if my description was not coherent, I am a beginner to computer programming. It is also very possible that I am overlooking a very simple solution to my problem. Thank you in advance for your help. :)