Here's an idea of how the code is now
I'm pretty sure that that code won't compile. Post your real code.
You could create a macro that took several arguments, called movingForwardRight, but I don't recommend that.
Perhaps better would be to break the code down into a moving forward and a moving backward section. Make each section a function. In each section/function, determine if you are/should be moving left or right, and call the appropriate function.
Do the same, in those functions, for up and down, if needed.