0

JBox2D, the Java port of the Box2D physics engine, features an extensible module for creating debug drawing of shapes. How can I use this with the Slick2D game library?

liamzebedee
  • 14,010
  • 21
  • 72
  • 118

1 Answers1

0

Using the JBox2D DebugDraw class for Slick2D it is simple to add debug drawing. Put the below code in your init method:

Slick2DJBox2DDebugDraw debugDraw = new Slick2DJBox2DDebugDraw(gameContainer);
debugDraw.setFlags(DebugDraw.e_shapeBit);
world.setDebugDraw(debugDraw); // Where world is your JBox2D world
liamzebedee
  • 14,010
  • 21
  • 72
  • 118
  • Great solution, but it doesn't take into account that objects may be smaller than 1 meter (currently drawing approximate shapes). It uses integers to draw objects position. I tried to adapt it to float values, but I can't seem to find out how the xIntsPool works. It would be great of you could give some sort of guide/tip to do so, or an alternative solution. – Gonzalo Feb 22 '13 at 17:08