Jump to content
  • Advertisement
Sign in to follow this  
DarkZoulz

Component-based engine

This topic is 4548 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm attempting to implement a component-based entity system for my game engine. Let's first see if i've got the concept down correctly. Instead of making a base entity class and derive lots of different sub class entites from it. We make a generic entity class that holds a list of components that the particular entity require. Components can be anything from a position in the world-space, a flag for if the entity is movable or affected by physics for instance. How do I go about implementing this? What puzzles me the most is how components will be able to communicate with eachother. For instance, if a component needs the entities position. Should the component code look through that entities list of components and grab the position component? Any good articles or example code available?

Share this post


Link to post
Share on other sites
Advertisement
What is the advantage to your design over inheritence? I sounds much more complicated. Not to mention for your components to communicate with each other they will need some sort of base class in order for them to share communication functions and to be stored together easily.

Share this post


Link to post
Share on other sites
Typically, communication will be done through message passing. The designs I've seen have all used messaging to disperse data between the components.

The advantage of this design is that you don't end up with the inevitable diamond inheritance problems. For example, with inheritance, if you have "props" and "actors" as entities, and then have a "door" as a prop, and a "talker" as an actor, but then you want a "talking door," then you have no choice but move "talking" up towards the top of the object -- in the end, all interesting behavior ends up at the base Entity level.

Share this post


Link to post
Share on other sites
For component based design, I recommend http://gamearchitect.net/, and the two articles on component systems in Game Programming Gems 5. If you can't get hold of the book, just try googling about; there's plenty of useful information on component based design out there! Also, a month or two back, there was an article in the Game Developer Magazine (http://www.gdmag.com/homepage.htm), entitled 'flatten your hierarchy' or something like that; apparently that's a very good read, though I haven't read it myself.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!