Monday, 12 October 2009

Component system is in place, couple of components added.

If you want an idea for what the component system I'm implementing looks like then head on over to the sourceforge page and download the latest release, since it's there! Only two components presently, one that stores a box2d body (for physics) and another that draws entities as polygons. When the user presses "New Game" on the main menu I've set up a little box falling test to make sure everything is working like expected, so far so good.

These components will probably need expanding, since one entity does not necessarily have only one body. The player vehicle for example will be made up of several moving parts (including wheels, chassis and a gun turret) as such I'll need to create a new component to handle multiple bodies. This will require a new drawing component also. The problem is getting the drawing component to interact with physics component, i.e. assuming these two components don't (and shouldn't) know anything about one-another how do you make it so the physics updates the positions/orientations of the bodies so that the drawing component knows and does the same? The solution? An intermediate component, which acts as a sort of adapter. It basically maps bodies onto shapes in the visual component. The other possible solution to this problem would be to use a messaging system, where when a physical object movies it fires off an event saying "body with this ID has moved", then in the visual component each shape could maintain the same ID and receive the message, updating the visual position/orientatition. This is why component orientated design really is the future, it gives you so many options of how to do things, rather than being tied down with long inheritence heirarchies.

Next thing I'll do is probably update the sound system like I said I would a few posts back. It's definitely not working optimally (create a new source voice for every sound effect really will destroy performance) after that maybe work on loading 2D "models" from memory to be used by the visual component to draw, rather than inputting them by hand (which for complex models would be laborious). This will facilitate two models, one a complex one for the renderer to use and the other the collision hull for the physics engine, using one for both systems wouldn't be recommended.

No comments:

Post a Comment