Tuesday, November 16, 2010

Blog to the FUTURE

With this post we're going BACK IN TIME to late summer 2009 when, on a whim, I decided to port my unfinished game project (from back in highschool) from ancient C/DOS to a more modern Windows-based C#/XNA app. I'd been meaning to blog about the results for some time, but just never got around to it.

Welcome to The Final Reality

The project was (still is, I suppose) meant to be a parody of the Final Fantasy series in particular and of RPGs in general. The graphics were all created by me (and, I admit, they're not particularly fantastic) though were sometimes based on other things. However, I'm not going to talk much about the game itself or its storied history. Rather, I'm going to talk about how much my coding sucked back in highschool and some about the porting process. Though I will include lots of screenshots. Yay!
A googly-eyed alien, though he doesn't seem the friendly sort.

Porting from C to C# wasn't too hard, over all. I had to make some changes to from the DOS-based "I get the whole machine to myself so I don't have to play nice" approach to the multi-tasking based Windows approach, but that went fairly smoothly. I was able to poach some code from my QRT project to handle rendering, so that was fairly easy as well. The first main challenge I came across was that I had the wrong version of the code.

It'll make you glow. Blue magic does silly stuff like that. And yes, the menu is supposed to be aged dot-matrix printer paper.

Somehow, I seem to have lost the most recent version of the code which was missing some things like object animations (which I put back in) and some menu and inventory stuff (which I did not). This caused a problem because the data files were for the most recent version of the code (I still have a working version of the most recent executable...)

Somebody seems to have left their tie hanging on the wall of this cave.

This caused a problem because, in the main program file, there is what is called a "magic number" hard coded telling the game the position in the data file where it should start loading from when the game first starts and, because the version of the code I had was out of date, this number was wrong, thus resulting in reading essentially random junk from the data file.

The Tower of Harmony: what's with all the musical instruments laying around?

Fortunately, once I'd diagnosed the problem, I had enough of my old notes from highschoool sitting around (I am something of a pack rat) that I was able to deduced what the correct magic number was supposed to be. But this is a somewhat extreme example of one of the things that was horrible about my coding back then: way too many things hard coded. I've gotten much, much better about this over the years.

The clinic in the Elf Town. The names of the Elves in the clinic were taken from Tolkien's elvish languages and all mean things like "sickly" and so forth.

Other problems with my code were, perhaps, less severe but still annoying. My style was poor, formatting was bad, comments were lack luster or missing altogether, things were not nearly as organized as they should have been. Again, I've improved greatly in these areas over the years. I think switching to object-oriented languages like C++ and C# have helped tremendously and, these days, I put a lot more effort into structuring and organizing my code well.

In the music club The Wailing Cat. For some reason, the idea of cats being famous musicians amuses me.

As mentioned, some restructuring of code needed to be done in moving from a DOS to Windows based environments, but I was able to borrow some of my code from my QRT project so that made the switch fairly easy. However, since in C#, everything has to be in a class (unlike C/C++ which can have free floating functions), some extra restructuring was needed. I had originally thought of actually reorganizing everything so that it was actually well coded, but quickly decided this wasn't worth the effort. Essentially, each code file became its own class with all public members for easy access. (Don't worry if you don't understand the programmer-speak, the main thing is I took the easy way out since I wasn't going to do anything with the code beyond a simple port.)
The Dwarvish Pizzaria. In FR, dwarves are master chefs. Note the menu says "FR Combo" and the tray (lower right) reads "Quasi". I put several tidbits like that into the graphics.

Back when I was creating all the graphics, data files and whatnot, I had several independent tools for creating various resources - a graphics editor, map editor, item and dialog editor (which I think were just programs with the data hard coded that then wrote data files) - which I then assembled via a semi-automatic resource compiler (I still had to input several things manually). It was all rather archaic. This is one area where the QRT project is definately going to improve upon by having a whole integrated IDE and overall much more data driven approach which will make creating RPGs much easier (not to mention everything will be much more reusable).

Spelunking in an ancient mine.

One other thing that did give me a bit of a problem when porting was with text and dialog. Back in the DOS days (and even up until more recently), text was commonly just 8-bit ASCII by default. In C#, everything is unicode by default. This caused a bit of a problem because I was using certain ASCII codes to represent special symbols (item icons, for example) which didn't always translate as expected in unicode. So I had to put special checks in for some symbols, but I don't think I caught them all because the port occasionally crashes when opening certain treasure chests. Oops.
The graphics for house interiors were based on the house I lived in at the time. That's the clock I made in shop class.

That's really all I have to say about my little porting project and the crappiness of my coding back in highschool. As I've said, I've improved a lot since then (lots of additional experience under my belt) and my QRT project, as a result, will be much better designed and will be much more flexible and will be capable of a lot more overall.

A multi-layered tech dungeon. I liked multi-layered maps. Note the Star Trek styled replicator thing.

Hopefully I haven't bored anyone who's bothered to read this too much (I hope the pictures helped!), I've blathered on so long basically as an excuse to use as many screen shots as possible. I've mentioned QRT a few times and I'm still planning on blogging specifically about that project, eventually, whenever I get around to it. Until then, I'll just leave you with a few more screen shots.
In town, even pedestrians have to obey stop signs. Anachronism? What's that?

In the tech dungeon it's Quasi Cola! One of those little tidbits. Not sure why since I don't actually like cola that much.

A hallway in The Wailing Cat. The picture on the left is supposed to be me. The other picture says "Quasi".

Again in The Wailing Cat. For some reason, I seem to have made a point of including bathrooms in the game.

Freak Out,
-TFitC

(I should probably say something about images being copyright by me, yada yada, wheretofore and hereunto.)

No comments: