Friday 8 May 2009

Dull Technical Post

Real life events have again made it difficult to contribute time to XAGE, but there has been some small progress in the last few weeks.

I remember now why I put off implementing the conversation system for so long - there are a lot of design ramfications of doing so. The basic structure is in place and its now possible to initiate and select various conversation options in a similar way to a LucasArts game.

The reason it is incomplete is a long one. I've found that the more time I've spent on XAGE, the more inclined I am to want to do things right, rather than use any cheap or ugly hacks. One such case is that the dialogue system requires new Action Types in order to initiate conversations, amend option visibility etc. Rather than plumb these in as before, I wanted to completely rewrite how the Actions are organised both internally and externally.

Internally: At the moment, actions are simply stored as a type and a string of associated content, which is delimited by the tilde character. This is simple to implement but is quite brittle. After discovering Nick Gravelyn's post about serialization, I realised that it was actually possible to put Action types in their own class and still serialize them. This is a much cleaner and correct OOP way of doing things.

Externally: The original Action editor relies mostly on combo boxes. Given that the number of action types was swelling to thirty and beyond, it was becoming obvious that this list would become daunting to any unfamiliar users. It's also quite a backwards thing to select the action type before the item it is being performed on. By selecting the item first, you automatically narrow down the number of possible actions you can perform. Its also more intuitive:

(old) Walk -> (Character, ToXY, Direction, Pause)
(new) Character -> Walk -> (ToXY, Direction, Pause)

Its not especially easy to illustrate using text alone, but the benefits should become obvious after a few minutes of use. The above also means I can wrap up each piece of information into a seperate class and re-use as necessary for each Action (e.g. Pause after action is used in various). Certain items are now selected via popup buttons rather than combo boxes, as this is more visual and easier to understand.

All of these changes require quite a large rewrite. One problem is that, previously, I've completely seperated the codebase of XAGE and the Editor itself, as they only shared a dozen or so classes. As the number of classes has grown massively due to the new Action structure, it has become obvious that I need to wrap all the shared classes into a Global project, and expand any functionality in XAGE or the Editor via partial classes.

None of these required changes are particularly exciting in any way, and will take some time to complete. The end result will be a cleaner, more flexible XAGE v0.4, which should be the first wholly public alpha.


Keith Weatherby II said...

Sounds like things are coming along. For my 2d platformer I started out wanting to do things "the right way", but found the project a bit daunting. So I would put it off, and put it off. Finally someone said to me "just start coding it". I can always re-factor later if I need to. Because of that I've got the beginnings of a working map editor. Obviously what works for me doesn't necessarily work for you. Just as long as you're making progress.

And I seriously have almost no idea what you mean by "new action types" maybe you mean actual adventure game character actions (such as walk, talk, etc) but if it's programming related you've lost me. Also I don't know squat about serialization, why it's used, how it's used, or what it's used for.

It's weird I just hear all these new terms popping up every day and it's like if I'm a programmer I'm instantly supposed to know what they mean. So like Nick Gravelyn or John Sedlak would suddenly tell you how to do something in c# and xna, and I would be like "huh?" because they're like XNA MVP's or whatever (at least Nick is) so they've been working on this from the get go. Plus they probably have a good grounding in certain subjects. But me I'm just eeking out a coding existence based on what I do, or the internet or something.

Makes me not enjoy programming very much.

Clarvalon said...

There's definitely an expected level of programming competence at the XNA forums, and that's no bad thing. It's right to politely point people towards C# learning material when they haven't grasped things like basic OO principles.

As for the more advanced topics, google is your friend. The MSDN site is a good starting point, though it can sometimes be a little dry. There are plenty of decent websites with friendlier tutorials. I find that seeing what other people have done on to be quite useful.

But yes, it can be a balancing act at times, knowing when to utilise a new and unfamiliar technique or to just stick with what you know. Often I've found that if I've put a problem to one side then I'm usually better equiped to solve it with the knowledge gained from doing other things.

Serialisation is just a way of persisting objects (think: loading and saving your game, highscore etc.). There are various pitfalls with XML serialisation but overall its pretty straightforward. Without it the AGS conversion would be a lot harder, for instance.

As for the action types, yes, I was referring to the building blocks for each XAGE script. I was in the process of adding new Actions to start and end conversations when the major refactoring process began. I doubt many people enjoy refactoring code. It's a bit like spring cleaning, the only real satisfaction comes from having a clean new base to build upon.

My advice to you would be to make sure you've got the basic elements in your platformer before investing too much time in the editor. Hardcoding a few levels is the simplest way of testing out your main game mechanic. I had XAGE up and running with entirely hardcoded room items, animation frames etc. before work began on the Editor. Chances are that if I'd spent months on the Editor first I'd have overlooked a lot more things than I already have done.