Sign in to follow this  
  • entries
    53
  • comments
    225
  • views
    69285

Game Objects

Sign in to follow this  

326 views

So a really profound change for my code this week - I think I've finally got a solution to the game world vs scene graph problem that's been haunting me for an awfully long time.

Over the past few months, I've been slowly populating my framework with nicely re-usable game objects: doors and switches, lifts and guns, items and characters. At first, it was going along really nicely. I had a few different game prototype building on top of the framework, and they were all nicely sharing these objects even though some were 3d and some were 2d, one starred a cow, and one had a spaceship. But as time went on, things started to get more complicated. The games had subtle differences in how they needed to use these things - the cow game (being a bit RPG-ish when it's done) wanted a serious inventory with equipable objects. But the space shooter wanted a lightweight gun swapping inventory. The Gun in the cow game was an item you equipped, but the guns in the space ship game needed to be part of a ShipComponent heirarchy.

Very quickly, I found myself spending more and more time trying to reconcile all the differences into a set of super-object that could be configured to be all things to all people. After all, these were objects in the framework darn it - so they better be re-usable!

So my "ah-ha!" moment came in two parts:

The first realisation was that I needed to formally separate game objects from scene objects. Previously, game objects were just another type of generic Behaviour object you could attach to a part of the scene - just like animation, a particle emitter, or a joystick controller. The problem with this is that you (i.e. the game, the scripts, the AI) couldn't unambiguously determine what something in the 3d world represents in the game world. Now, there's a new base class purely for game objects - allowing any game code to go up to a 3d object and know that it's a Door, or an Item, or a ShipComponent, or an Asteroid, or an EvilSorceror ... or any other game object your game wants to use.

The second realisation is that trying to commonise these things is a waste of time. Even if 3 games all have inventories, they're always going to need different gameplay rules, different slots, they'll need to know about different categories of items, they'll need to know how to map themselves onto different character models, etc. And the same is true for Guns, Items, and most everything else too. If I find myself re-using a set of objects across games in the future, I'll wrap them up into a re-usable game object library - but for now, a little code duplication is a glorious thing.

With these two changes under my belt, it's like a huge weight has been lifted off my shoulders! I honestly didn't realise how much this has been holding me back. Instead of agonising over every little addition to game logic (worrying about whether it's general enough, and how other types of games might want to use it and what options they should have, where it should fit into the class heirarchy, etc), I'm now totally free to just experiment with things - as each game project is in its own little sandbox, and the worst it can do is create a little mess of the small number of game objects it defines, while the framework code stays nice and clean.

Unfortunately, none of that translates particularly well into screenshots. But given I don't like to post without one, here's a cool ship prototype a friend of mine put together in Maya using the modular particle system I talked about last time:

Disabled


Cheers!

Sign in to follow this  


6 Comments


Recommended Comments

I felt a similar burden lifted from my shoulders a couple of weeks back when I (at least temporarily) abandoned my ambitious project and started a new one with no attention paid to reuse in future projects. I don't have to think about making everything really generic and reusable, at least not right now! It's such a relief.

Share this comment


Link to comment
Quote:
Original post by EasilyConfused
I've missed your journal. Please update more often with the cow game stuff.


Very nice of you to say that EC =)

I am hoping to post some updates to the Cow game soon. It's currently back in pen and paper design land - trying to pick a real environment to put him in, and who's going to be in there with him.

Share this comment


Link to comment
As long as we're getting in touch with our emotional side: I'd also like to express my love for the little bugger :-). He deserves more media-time imho.

Share this comment


Link to comment
Quote:
Original post by Selkrank
I felt a similar burden lifted from my shoulders a couple of weeks back when I (at least temporarily) abandoned my ambitious project and started a new one with no attention paid to reuse in future projects. I don't have to think about making everything really generic and reusable, at least not right now! It's such a relief.


I'm about a week in now - and I'm still just reveling in the freedom.

I don't think I'm ever going to be the kind of person who can totally ignore design/re-use (and given you say "temporarily" above, I'm guessing you're not either) - and that's what's so liberating about the clean split between code that belongs to just this game, and code that belongs to the framework. I found it a surprisingly hard separation to make (as there's so much you want to be able to re-use that ends up being intimately related to the game) - but I certainly feel it's been worth it. I've already found the first component to merge back from a game into the framework too (object-level particle support), so I'm feeling really good about the change.

Share this comment


Link to comment
Quote:
Original post by Todo
As long as we're getting in touch with our emotional side: I'd also like to express my love for the little bugger :-). He deserves more media-time imho.


I'm sure if I had colour per vertex animation support working, the little chap would be blushing about now =)

Its amazing how a little bit of encouragement from you pair has got me really enthusiastic about getting back to work on him. I spent a good hour or two jotting down story ideas and related NPC/enemy character designs that might go with them. I also modelled up a pretty cool Moose head a week or so back - as that will probably be the second of the 4 main characters I add.

At the minute, I think I'm leaning towards the whole evil Empire + resistance, with these little dudes being spies or agents of the latter who need to do a bit of Indiana Jones style adventuring to achieve their objectives.

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