Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Coming from an MVC background, I am trying to understand Entity-Component based model. However, i can see description about the use components( data objects ) and entities ( group of different data-objects ie components), but cannot see how view is created. I can see something called "render" components though. But how would i use it ? It seems, i don't need to bother about separation of view from data in this architecture. But i doubt, if this is the case, then things would mess up.

share|improve this question
1  
This question probably can't be answered in a reasonable manner, TBH. There's no point in comparing MVC and CBES, they're trying to achieve different goals using different means. Just read the T=Machine articles with a clear mind and forget about your background. –  dreta Jan 27 '13 at 16:59
    
I agree with @dreta. (Also, are you dreta from the Crunchbang forums?) –  akled Jan 27 '13 at 17:46
    
@Yannbane No, sorry. –  dreta Jan 27 '13 at 18:34
add comment

1 Answer

up vote 4 down vote accepted

Entity-Component systems are different from MVC systems. Specifically, an Entity-Component system is not a type of MVC system.

There are a broad range of component-based entity systems, each of them handling this a bit differently, but the way I decouple drawing from data is to use Systems. A system is a class that takes data from components and works with them as a group. Some examples of systems would be a CollisionDetectionSystem or an AnimationSystem or, being the point of this question, a GraphicsSystem. The GraphicsSystem would be registered with each component, and they could pass in their data to the system.

This pattern lets you decouple most, if not all logic from components (including rendering). There are definitely other ways of doing it, but I've found this one to be the most straightforward.

share|improve this answer
    
W.R.T "The GraphicsSystem would be registered with each component" . Does "registration" functions similar to how "eventlistners" work ? –  Vishwas Gagrani Jan 27 '13 at 18:54
    
Not necessarily, what I mean by registered is that each component receives each system once, either when the system is added or when the component is added. This can either be a message or a method with a System parameter. You should also do the same when the system is being removed, so that the component can clean up it's own data from the system. –  Robert Rouhani Jan 27 '13 at 19:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.