No screenies this month, and possibly not for a wee while – I’ve mainly been writing code.
This month I worked more on the level editor – You can now place monsters in a map and edit the walkable areas (as well as set tiles to have a default walk/no-walk flag, which pretty much means you don’t have to set no-walk areas at all…)
I also did more work on the C++ game engine side of things. Most of the engine is a port of the Java class structure from Caverns of Underkeep – With some improvements and refactorings and taking into account that this game is going to be more data-driven.
So at the beginning of the month I did what I almost never do and wrote a class diagram on a scrap piece of paper, showing inheritance trees and associations between objects, I’m sure my diagram doesn’t follow the UML spec what-so-ever, but it was helpful enough for me to start fleshing out the header files, and providing some basic implementation for the classes that I was going to be working with.
The feature that took me the longest to implement was remembering how to load data in C++ and convert it into some meaningful structures that the game can use. This turned out to be a pain, Esp. as I use non-null terminated strings of arbitrary length in many places – And I’ve mainly been working with garbage collected languages for the last 3 or 4 years.
So I spent quite a while in the debugger that day.
For example:
- When reading a file do I use .read() or .get() on an input stream. Which method increments the read position pointer automatically and which one doesn’t? (Hint: The first one I used didn’t.)
- If I create an object on the stack and then add it to a collection, what happens when the object goes out of scope? (Does it make a difference if it is a value type? Should I declare it on the heap? Should I store a pointer or a copy?)
- Why aren’t variables initalised to reasonable values, such as NULL for objects and 0 for value types?
- How do I create a dynamic multi-dimensional array that I can resize? (Hint: ObjectName **myArray) – And how am I supposed to clean up the memory when I resize it?
- Why are strings such a pain? How can I easily convert from char * myCharString to String myString? And back again?
So it probably took me about an hour to write the save/load map functions in the C# map editor and about 8 hours to write the equivalent feature in the C++ engine. (Too be fair, if I used C++ instead of C# every day at my day job, I’m sure the converse would be the case.)
That said, the C++ engine can now display maps created in the C# map editor, which is pretty cool.
Next month will probably be working on UI components and maybe getting some basic AI/Combat in place.
#1 by Erik Hogan on March 1, 2009 - 4:25 am
Sounds cool man, though I’m surprised that you’re not using shared libraries or even the same language for both the game and the editor!
#2 by Kristie on March 1, 2009 - 5:04 pm
I didn’t understand most of this blog… Maybe I should go back to brunette
#3 by Pamela on May 31, 2011 - 6:53 pm
Oh wow! This does seem quite tricky. I am also surprised you did not use shared libraries. That would have made it a little easier. This was two years ago, so what is the status now? Is it completely done?