wheel encoder location recall?

I’m building an autonomous robot car. I’m using encoders to track distance. Lets say if I go off coarse to retrieve something , what code will use to remember my “way-point”. here is an example of what i’m trying to do. DPRG Fall Contest - 6 Can - YouTube

It's not about code, it's about design. How would you solve the problem? Then you can translate the solution into code. If you don't know how to do something, you can't code it.

what code will use to remember my "way-point".

In order to accomplish this, the code has to know where the vehicle is at all times, say X & Y.

Just save the two values as a "waypoint":

X1 = X;
Y1 = Y;