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

enter image description here

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?

  • 3
  • \$\begingroup\$ 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? \$\endgroup\$
    – bummzack
    Jun 6, 2013 at 14:51
  • \$\begingroup\$ 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. \$\endgroup\$ Jun 8, 2013 at 1:52

1 Answer 1


From the documentation on the Box2D site:

Worms Clones

Making a worms clone requires arbitrarily destructible terrain. This is beyond the scope of Box2D, so you will have to figure out how to do this on your own.

So you're on your own for building a new terrain when the old one gets a large crater blown into it. I think, following the questions I linked in my comment (How can I generate Worms-style terrain? and How can I convert a 2D bitmap (Used for terrain) to a 2D polygon mesh for collision?), you'll be able to create the terrain and then create a custom polygon shape. The shapes must be convex, so you'll have to break the terrain into smaller convex shapes if the other all shape includes concave portions (like craters, tunnels, etc.).

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(...).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .