In all the games I have made I have never been that happy with the architecture. Using PureMVC and more recently Robotlegs on a more or less daily basis has shown me the benefits of a well designed common framework. The down side of MVC which both are based on is that its not suitable for game development it’s ideal for the into screens and menus and perhaps even the UI but its not designed for problems found in game development.

So what do you do? Well if you like me then you will probably come up with something like this.

OK details may vary but it should be familiar to most people who have built games. So we have a nice inheritance tree and its all looking pretty straight forward. But then may be you decide actually what your game needs is moveable platforms. OK no real problem just change Platform to inherit from Movable and were done. Well some still don’t move so we need a boolean to flag the movable ones but that not to difficult.

So what’s the issue? Well perhaps now we decide we need a enemy that doesn’t move. What’s the simple solution to that? The point I’m trying to make is inheritance sucks. Its fine if everything is predetermined and well designed but games are not like that. Even if you have designed you game by some freak in-site to the n’th degree when you start on you next game how much code are you going to be able to reuse? Finally what if you want to make these changes at run time with out having to recompile?

Let me put another way would it be better if you could pick and choose the attributes you want for each item in your game.

As you can see we could make a moveable platform just by sticking a tick in the correct box.

So this is the ideal how can we do this in practice. Well we can use an “Entity System” also called “Component Systems” and “ Entity Component Systems” and loads of other names. I’m going to use Entity System as Component has to many meaning especially in flash. As well as having many different names there are as many interpretations as to how to implement one. Not being happy with any I had come across implemented in flash I have created my own framework Ember and made it open source. In my next post I look at the various ways of implementing entity systems.

Read more:

Evlove your Heirarchy

T-Machines posts on entity systems

What is an entity framework

Why use an entity framework

Tagged with:
 

One Response to Game Architecture

  1. Telstra says:

    whoah this blog is wonderful i love reading your articles. Keep up the great work! You know, many people are hunting around for this information, you could aid them greatly.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>