Tuesday, April 5, 2011

All my designs

The past week I've mostly spent on theoretics.

In particular, the implementation of the Dynamic_Actor class. Currently the level is created with a few pointer arrays for all the elements in it. There's an array for tiles, one for Goody type objects and one for Static_Actor objects. For Dynamic_Actors I initially thought to just add another array of that type, and have that class contain all variables and functions required for all types.

Then I thought about the things I actually wanted Dynamic_Actors to do, and all of a sudden that plan seemed overly convoluted.

You see, then I'll end up with, for instance, a 'query' function that has all these different cases for all the different types of Dynamic_Actors. The code will become hard to read (and thus manage) and I'll need this base class with a ridiculous amount of variables to accommodate the (often complex) behaviour of all the different types of Dynamic_Actors.

Instead, I've been thinking on giving the Dynamic_Actors class a very limited amount of variables and functions and create child classes of different types to accommodate each different type of Dynamic_Actor. So I'll have an "Enemy" subclass that has variables such as hitpoints, response time or whatever and another subclass called "Door" which won't have any of those, but instead will have things like waiting time or key colour required. As most of this different behaviour is handled by the class functions themselves, you technically don't *need* to know which subtype it is for it to be handled properly!

So I've been planning out how I want to do that, and looking at all the caveats for that. I've written very little code, though I have begun some optimizations because of this process. It's interesting the things you find out as you plan other, similar things.

Also, I've been watching the Alien films today and was shocked, SHOCKED to find how many games take cue from the first 2 ones. Stylistically I mean. Just look at the gunship in Aliens and tell me that doesn't look like a Halo dropship... or Command & Conquers Orca gunship... or sounds like StarCraft 2's banshee... etc. etc.

See you next week!

No comments: