Jump to content
  • Advertisement
Sign in to follow this  
rexTroianus

Undo & Redo question

This topic is 4798 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello guys, I'm working on a 2D Tile based Map Editor in VB.Net. I need your suggestions for Undo and Redo thingy. I just need suggestions, not the code, so you don't need to be a VB.Net programmer. I'd like to know how is it made in some professional applications? How do they store changes for undo and redo? What I need is availability of doing undo and redo for about 10 times. What the application should do is store last 10 changes and retrive them back in both ways (undo and redo). Now, the question is how to do it. An array with length of 20, and a counter, or something else? I hope you will help me with this problem, Thanks in advance, RexTroianus

Share this post


Link to post
Share on other sites
Advertisement
[google] "Command Pattern". Basically, you represent actions as objects, which can 'execute()' or 'undo()'. (In the worst case, you save the complete state of everything before any execute() invocation, and implement the undo() to restore some previous state.) As the user does stuff, you instantiate the appropriate object, call its execute(), and store it in a stack somewhere. If an undo is requested, you can then grab from the end of the stack, call that object's undo(), and toss it away. (To implement redo(), you need two stacks - after undo()ing something, you pass it to the redo stack.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!