CMapEditor is a simple and efficient interface for using a multi-level matrix of values. This can be easily used in games or any other program that requires a versatile map structure.
How to use
Include the .h file in your code. Keep also in mind that
CMapEditor requires the
<vector> header to be present on your machine.
To initialize a map just use:
CMapEditor *meEditor = new CMapEditor(WIDTH,HEIGHT,LEVELS);
To set a cell's value in the map, use:
You can also use advanced operations, such as region fill, or drag-like procedures:
CMapEditor also supports basic undo and redo operations. You can decide what is going to be undone by calling
before performing other operations. For example:
in this case, the
SetMapValue() and the
Fill() effects will be undone together. To perform undo and redo, just use:
Why did I write this class
Actually, the purpose of this class was for me to learn. And I did. As a matter of fact, class programming was a bizarre way of thinking about stuff before, therefore, I decided to start from the basics, and started learning about that. OK, I got the basics, but if you have any comments on how I programmed the class, please let me know. Secondly, I wanted to get familiar with Hungarian notation (all my other projects are big messes), so if you have comments also on that, let me know. And finally, I learned how to use vectors, which I didn't expect to use (actually, I didn't even know what thery were) and they seem to be pretty useful. Another reason for which I decided to write this class, is that I wanted to contribute something hopefully useful to CodeProject.
- Last Update (15 Oct 2003)
- I have fixed some memory leaks issues. Now the class destructor is correct.