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.

Currently i'm working with my own physics engine, however given the fact that the emscripten ports have gotten incredibly good, i wanted to try and incorporate Box2D into my entity system for the next project (and Bullet for future ones). Currently though, my own physics engine works on components directly, like Position (x, y), Dynamic (mass, velocity, drag) or Collidable (friction, restitution), which allows the user to pick an choose what kind of a body the entity is dynamically and fiddle with the variables directly, this isn't possible with Box2D, so i'll somehow have to create a component out of the Box2D objects.

Do you guys have any experience with this? Incorporating OOP engines like Box2D or Bullet seems daunting when i try to think about it, for example the physics component would hold the position, so my rendering system would require a physics component, which isn't desirable, since not every sprite i render is a physics object, etc. To solve issues like these, i thought about just creating a Position component and having the rendering system hold entities with a Position or Box2DBody and Sprite components, but i'm not sure if this is the most robust solution. I'd love to hear some input from people that have experience with these things.

EDIT: This isn't just for Javascript, the question should be language agnostic.

share|improve this question

closed as too broad by Josh Petrie Dec 5 '13 at 6:05

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
You could have physicscomponent containing box2d physics object with position, and when its position change change transformation component (containing your position) of your object. –  Kikaimaru Mar 29 '13 at 19:14
2  
You can put the Box2D specific objects into a component. Then a system that uses Box2D to do the physics and updates a separate Position component to be in sync to the position that the Box2D object already have. The reason for having a separate position component is because not necessarily all entities with Position need to have physics. –  Hatoru Hansou Mar 29 '13 at 20:51
    
@HatoruHansou why not post this as an answer? –  Den Apr 1 '13 at 14:27
    
@Den, because of this "I'd love to hear some input from people that have experience with these things." My comment is a reasoning. I think the OP want an answer from somebody that actually did it. –  Hatoru Hansou Apr 4 '13 at 20:13