Syntaxus Dogmata

An Insane Developer's Journal

On To Frames!

All right, so it took more effort than I thought, but after much weeping, wailing and gnashing of teeth (and I don’t mean in a good way), I achieved what I set out to do in my last post.  No longer is the SetUp() method having to check for valid objects among the parent and children along the class hierarchy.  It required a few default objects to be made, which I hadn’t anticipated, but there you have it.  This also bought me the liberty to review the code already in place, and make a few minor adjustments.  Mostly it was eliminating code that I’d written under pretenses that ended up not working out in the end, and I neglected to go back and remove it.

So now, on to frames!

You’re gonna want to slap me around after I spent all that time fussing over sealing the Screen class a couple posts back, but I’m reconsidering the conclusion I reached.

If you’ll recall, I decided against it in order to keep screen creation simple.  If the Screen class isn’t extensible, that means all the custom, game-specific objects that compose a screen (sprites mainly) would have to be instantiated and added to the screen by the outside world, making that code more complex than it needs to be just to set up a screen.  I delight in simplicity, and the mechanism of choice by which I achieve it is through encapsulation.  That means the Screen class will need to be extensible, and I still stand by that.

So no, I’m not contemplating a sealed Screen class in the future (not that I’ll confess to, anyway), but I am thinking of abstracting the Update() and Render() methods from its descendant classes.

This wouldn’t make sense if the Screen dealt with all manner of sprites, all bouncing around the screen higglety-pigglety.  How else would the screen manage the various drawing effects and parameters of all those sprites?  The way XNA employs the SpriteBatch ensures any standard algorithm set in stone would be implausible.

But now the screen isn’t dealing with all those sprites.  With the introduction of the Frame class, sprites are now effectively abstracted from the Screen class.  Instead, screens deal exclusively with frames — a far simpler notion — leaving the frames themselves to deal with all those pesky sprites.  All it would take is for the Screen class to store its frames in a standard collection, and then call their execution methods successive to the order they were added.

In short, I’m making a compromise here between the two extremes of letting the game programmer go nuts overriding the fundamental operation of screens, and shutting them out of all customization completely with a single keyword.  Screens will execute the same across the board, but will remain extensible for the purposes of composition setup.

In the words of Gurney Halleck, “Behold, as a wild ass in the desert, go I forth to my work.”

Advertisements

Apr 14, 2010 - Posted by | VertX™, Video Games | , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: