I am currently learning Box2d, a 2D physics engine within libgdx. But Box2d seems to be in every game framework these days so I am not really talking about libgdx.
I understand Box2d comes with lots of new concepts such as shape, bodydef, body, fixture, sprite, joint. But I think I can slowly but surely manage to learn about them.
My question, however, is how to organize them into a game object for better maintenance of code. Naturally, I am thinking about following fields in the game object class.
- GameArea gameArea
- Body body
- BodyDef bodyDef;
- FixtureDef fixtureDef
- Shape shape;
- Sprite sprite;
As for its methods, it has constructor, update, and display. But I am talking without experience. For example, I don't know how I can organize joints - maybe in GameArea. Any thought from experienced would be appreciated.