[size="3"]What is it?
Component Based Game Design is a somewhat new idea that has grown in popularity over the past couple of years. In CBGD entities in a game world are defined as aggregates of components that provide different pieces of functionality. A ball, for example, might have a physics component for handling physics (duh) and a graphics component for displaying the ball onto the screen. In the ideal implementation each component is independent and provides specific functionality to the entity, and components can be toggled on and off at any time without having an effect on other systems in the game.
[size="3"]What's so great about it?
CBGD makes it much easier to add new objects to the game. To add a new object all I need to do is specify the properties of the object within its components. Continuing with the ball example, I might tell the physics component that it is a circle with a radius of 0.5 meters and a restitution, or bounciness, of 0.5. The ball will automatically start to respond to physics without any other instructions.
[size="3"]How did I do it?
I got a lot of the ideas about my implementation from this forum thread at GameDev.net. In my implementation components store the data relevant to their particular functionality, and other systems in the game do the real work. A PhysicsComponent, for example, only stores data about the entity's shape and material properties, and the PhysicsManager does the actual physics processing. I have found that this makes for a much more flexible system than one that relies on the components themselves to do all the work.
[size="3"]Where can someone find out more?
I have found a number of resources that talk about implementing this type of system in a game:
- Outboard component-based entity system architecture- the previously mentioned forum thread
- Component based game engine design- look here for even more links
- Evolve Your Hierarchy
- A Data-Driven Game Object System Powerpoint
Hopefully I'll have something exciting to show off by the end of this week. Thanks for reading!
Reposted from my blog.