The Challenge

Published October 29, 2011
Advertisement
Hi everyone,

Last time I told you about my workflow for adding new units to the game. Well, before I talk about anything else, I have to make a few confessions:

I mentioned that I started the game 3-4 years ago and just recently dusted it off. One of the bad things about working on it is that the code sucks (I think all my code older than 1 month sucks).

But this code sucks more than normal. There are a couple reasons for this. The first is that it's written in VB6. That's not inherently bad, just the OO support is very lacking, and I can't unit test it easily. For the game itself there are about 31k lines of code. "That's not too bad!" you say. Practically nothing.

Except it's all in one source file.

Let's just say I've learned a lot since then. But before that, I hadn't worked on anything greater than say, 5k lines. So I dumped it all in one VB6 .frm file. Later additions added some separate files, but the OO model is still crappy. So I still have a 31k line source file.

Now you can see why I hesitated to dust it off over the years!

Why go back to it now instead of just dumping it and starting something new? Well, it's actually a pretty complete game. In fact, when I quit working on it the only thing I had left was some AI and more art work. I also like challenges. But don't worry, if the only way to extend it was writing more VB6 code in that file I would never work on it. And in fact I haven't worked on it for a couple years.

Luckily, I've been able to use .NET's COM interop support to write C# code that extends the game. In fact, the only VB code I've written is to provide more extensibility to C# objects. There are some quirks that require work-arounds (such as the fact that there are a slew of private types embedded in the form that I can't move), but I'm still managing along.

So now I'm able to write C# code for the game without touching the original VB6 code base, except to add more support. This is good, because it means I can:

- Write good, clean, modern OO code in C#
- Unit test game logic
- Gradually migrate VB6 code to C#
- Minimize the amount of new VB6 code

As you can probably tell, this project really is just for fun. I probably won't ever finish it, just keep adding to it as I see fit. But it's something that I like working on in-between projects.

Next time I'll show you the workflow for adding new, tested C# code to the game and wiring it up to the old code base.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement