So in my game, there is a static object which using the mouse you constantly shift its world location. I cannot calculate how quick the static object "moves" since it technically doesn't move. However (here comes a long explanation) I was told I could use an array of 5 indexes, which could hold various locations and collecting an average to try and calculate speed by using distance over time. So for example, the 1st index would be the latest location, and the 5th would be an earlier location. And every 0.10 seconds it would get the latest location of said object, changing the value of index 1 to the latest location, and making the previous index 1 location into index 2. Then, whatever was the 5th index location would be erased and replaced by the 4th index location. My problem is that I don't actually know how to do this? I know how to change these various indexes and where to pull these locations that I would use, but how can I make it so it kind of creates a sort of queue of different locations? Perhaps there is an easier way of solving this than the method I'm talking about?
An easier explanation of what I'm trying to do, just in case it confuses anyone:
How can I "insert" an index 1, pushing all the previous indexes into higher number indexes while also deleting any index past 5?
An easier explanation of what I'm trying to do, just in case it confuses anyone:
How can I "insert" an index 1, pushing all the previous indexes into higher number indexes while also deleting any index past 5?
Comment