Java beginner, who would appreciate feedback on how best to approach a problem which I'm working on in isolation.....
Trying to build a basic game, where a player moves around a grid/board. Have up/down/left/right methods (e.g. public void playerMovesUp() etc), and need to implement undo/redo move functionality, so a player can retrace x number of steps, and then retake x number at any point during game play.
Have been looking into ways to do this i.e. to record the order of the up/down/left/right method calls, and then re-call both in reverse order (undo) and then redo.
A stack, or queue collection seems logical....and I have also looked into the java stack memory storing the order of function calls, and have just read about java.lang.Thread.getStackTrace().
Current thoughts.....If I isolate those four methods into one thread, then I could use java.lang.Thread.getStackTrace() to return an array, and call getMethodName(), to then somehow call applicable methods in order?
Also, is it possible to store a queue/stack of method calls?
I feel like I'm on the right path, but the last suggestion seems a bit messy/illogical! Any pointers/advice would be appreciated.