Assignment – Stack
1
) Implement a history system to allow the player to undo his
actions by pressing a key.
–
–
–
Every time the player presses an arrow key (up, down, left, and right),
the character must move one unit to the corresponding direction.
•
Use the Input.GetKeyDown function to move only in the first frame when the
player starts pressing the key.
When the player presses the undo key (e.g. spacebar), the player
character must undo the last movement.
•
If the player keeps pressing again the undo key, the player character must undo all
his movements in the correct order.
You must use a stack structure to store the player positions.
•
The last position is always on the top of the stack.