# Generating a physics body for 2D Worms-like Terrain

I wrote a processing sketch that generates hills for a scorched earth clone, like this:

I'm trying to figure out how to make this a physics object in libgdx, but I'm having problems figuring out how to do that.

I thinking about doing this through a ChainShape composed of a vector2 array at each point on the slope. I've tried running this on an android device through a Box2DDebugRenderer and SpriteBatch, but I can't get anything to show up (although that's another problem).

Does anyone know how to make a physics object like this in box2d?

• – MichaelHouse Jun 6 '13 at 13:42
• Using a ChainShape looks like the correct approach to me (should be easy with a landscape as in your image). What doesn't work with that approach? – bummzack Jun 6 '13 at 14:51
• From what I can tell it does work, and it doesn't seem to be terribly inefficient (I'm not noticing any crippling slowdowns anyway). I just had some problems with implementing the Debug Renderer camera. Whether this is an effective way to generate terrain is something I'm not 100% on. – BrotherJack Jun 8 '13 at 1:52

There's a tutorial here that shows the creation of these shapes. Essentially, you're creating a polygon using a definition object, then passing that definition into m_world.CreateBody(...).