I made a prototype recently of a moon lander type game using LibGDX and Box2D in which I could attach parts (e.g. core, thrusters, fuel tank, structural parts) to each other and then attempt to safely land on a randomly generated landscape and get back to a mothership.
The code is slighly messy and not very well documented, but maybe it may be of some inspiration to you. I think it will compile in its current state.
And when run it should give a pre-made lander which you can control and fly around (until fuel runs out and you crash). Thats pretty much it, no editing (currently parts are attached using code), no mothership or anything else. But it does show that making a ship-building type game using Box2D is quite doable. I may continue with it at some point, or some variant of it.
Here’s the code, do with it whatever you like at your own risk:
https://bitbucket.org/BasvS/lander/overview
The thruster particles in this prototype are (if I remember correctly) propelled out at a speed independent from the ship’s movement speed, but I’m not 100% sure of that. Took some experimenting to get right, and it still looks a bit weird if the lander goes at very high speed.
Edit: some highlights:
- it combines the Artemis entity system with LibGDX and Box2D (a nice combination of frameworks imho)
- The entity factory that creates parts using Box2D and attaches them to each other
- Simple particle system
- Here is how thrust is applied to a part using Box2D applyForce
- Part configuration file which is editable using the part editor