Undo

Extend the switch and move commands to support an undo action and create a undo command that could be bound to a button.

This can be achieved by adding an additional method to the command objects. This new undo method, should do the  exact opposite of the execute method of the command. So for example, should the execute move a object 1 unit forward, the undo would have to move the object 1 unit backwards.

Additionally you will need to keep a history of the executed commands. Whenever a command is executed, it should be collected for undoing it later. 

For additional guidelines read the undo and redo section from Game Programming Patterns.

http://gameprogrammingpatterns.com/command.html#undo-and-redo

  • This task builds on switch and move command tasks and does not have to support the snake like movement.
  • If you bind the undo to a command, then be sure not to record the undo commands.
  • Redo is not necessary.
;