Sign in to follow this  
  • entries
    292
  • comments
    557
  • views
    153566

Global Warming My Big Toe!

Sign in to follow this  
TANSTAAFL

157 views

Left work early today because of the BIG SNOW STORM in SE Wisconsin.

After nearly killing myself shoveling the SIX INCHES OF SLUSH off of my driveway, I got about 90 minutes of work on Adventure Maker done, so I'm at least happy about that.

I came up with, I think, a halfway decent way of getting one portion of the game entities in contact with another portion, by having everything contain a link to it's parent.

The reason this came up is because my Lock objects, which are contained in a Locks collection object, which is contained within an Adventure object, which holds the whole thing (so, Adventure contains Locks contains Lock) has to link to an Item, but only does so by array index (Item is in Items is in Adventure).

So now a Lock has a link to Locks, Locks has a link to Adventure, and similarly for Item and Items, so I can navigate up the tree from a Lock object to access the Item used to unlock it (so that I can print the name).

Why did this need to be done?

Each entity and entity collection has an Edit function, which runs an input loop to edit the entity or collection (or exit to higher in the tree). Most of the functionality is handled in the base classes, and only a few minor things that customize the experience are handled at the entity or collection level.

Why not just have a link directly to the object in question?

Mainly, because that's not how it was done when I originally made this game. Everything was array indices. In a way, however, this helps somewhat with the XML save/load problem.

XML is really great for hierarchical information, but lousy for relational information, which the Adventure object is. Locks link to Items. Rooms link to Monsters, and contain Directions which link to Doors, Locks, Items, Traps, and other Rooms and Epilogues.

So, having everthing kept track of by array index makes the XML doable, and I don't have to have a string "id" tag, which would then require a Dictionary object, and so on and so forth. Simpler just to have a number.

But what if the number is out of the bounds of the array indices?

That's an easy one. Those are treated as null.

So that's progress. Soon, I have to make some dinner, but now I have to put up some shades.
Sign in to follow this  


1 Comment


Recommended Comments

You should look into using Typed Datasets in .NET (if you're using C#).


They allow you to store data in a relational manner, and neatly import/export themselves into 3-level XML (database->table->row).

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now