Wednesday, October 15, 2008

A web of References

So, things are progressing along on the programming side of the new ATSS game. However, things are still slow going on the art side. Our team is working and moving along, but these are still the introductory weeks and everything is all about concepts and style at the moment. When the art team really kicks into gear I’m sure things will be moving along smoothly.

As for myself, I’m building a web of references. In a game like the one I’m building, every object in the game needs to be able to interact with several game systems that have to have a persistent state. If we were programming in VB, I might do this with global variables. But, since we are doing this in C# (which XNA is set up in), I have to do it by reference passing.

For those who aren’t programmers, the whole idea can be boiled down pretty simply. Say you have a word document that you want to distribute to your friends. You have a couple of options. You can put the document on a central computer and let everyone access it by placing a link on their desktop to that document (kind of like any page on the internet, it’s stored on someone else’s computer, and you just have a link to it), or you can send them a copy through e-mail.

Now in the second situation, if you send them a copy, they can make any changes they want to it and your original document doesn’t change. They have a completely independent copy. But what if you want them to see all of your changes? Or, what if you want to also see the changes they make to it? Well then the first situation is what you really want. In that set up, you only have one document stored on a computer, and everyone opens, reads, and edits the same document.

This is the difference between what we call “passing by value” and “passing by reference.” Passing by value means that you send a copy of one object to another object. This is fine for really small objects, and things that you don’t care about changing. But if you have a very large object, and you care about how it changes, and you want to keep track of its changes, you need to pass by reference.

And this is what I’m doing right now, creating a web of references throughout the main game engine. I’m not sure if this is how “real” game programmers do things, but it’s how I know to do it. When I get to a point where I’m serializing the data out (or “saving” it) from one test to the next, then I will have to set up a system for renewing these references every time the game loads. This is one of those things that will happen when the loading message comes up. My hope is to mask that message with images and story elements.

So, development is continuing, and piece by piece programming breakthroughs are popping up over the weeks. So for those who are getting excited for a game they know nothing about…stay there.

1 comment:

Machaira said...

For my RPG I'm plannning on implementing managers as game components with interfaces through the game object for the various system to tie everything together and control the systems. I haven't totally figured out the specifics yet but it should make everything easier to control and piece together.