EDIT:

Box2D v2.1.2 released!
**---------**
**~~ OLD ~~**
**---------**
See latest post for details.

__UPDATED 14 APRIL 09__
After a week of hard work, I've finally (I think) finished wrapping v2.0.0 of Box2D for DBP

It has a total of ~400 functions, (as large as Dark Physics!)

edit:

I have now fixed a few bugs which Xlaydos pointed out

Here is a very simple test program to show how it works:

sync on : sync rate 60
offsetx = screen width()/2
offsety = screen height()/2
myworld = b2CreateWorld(-100,-100,100,100,0,10)
mycircledef = b2CreateCircleShapeTemplate(1,1,1,0.9)
mybodydef = b2CreateBodyTemplate(0,0,0)
mybody = b2CreateDynamicBody(myworld,mybodydef)
mycircle = b2CreateShape(mybody,mycircledef)
b2CalculateBodyMass mybody
myfloordef = b2CreateBodyTemplate(0,0,0)
myfloor = b2CreateStaticBody(myworld,mybodydef)
myfloorshape = b2CreateBoxShape(myfloor,50,1,0,0.5,1)
b2CalculateBodyMass myfloor
b2SetBodyPosition myfloor,0,18
f1 = 1
miny = 1000
b2SetWorldDebug myworld,1
b2SetDebugTransform offsetx,offsety,20,20
b2SetDebugFlags f1,f2,f3,f4,f5,f6,f7
do
k$ = inkey$()
if k$ <> ""
if pressing = 0
pressing = 1
if k$ = "1" then f1 = 1-f1
if k$ = "2" then f2 = 1-f2
if k$ = "3" then f3 = 1-f3
if k$ = "4" then f4 = 1-f4
if k$ = "5" then f5 = 1-f5
if k$ = "6" then f6 = 1-f6
if k$ = "7" then f7 = 1-f7
b2SetDebugFlags f1,f2,f3,f4,f5,f6,f7
endif
else
pressing = 0
endif
b2WorldStep myworld
sync
cls 0
loop

As you can see, there are a number of different ways you can create bodies. If you don't need to set much information about them, the simplest way to create a dynamic box is this:

mybox = b2CreateDynamicBody(0,0,0)
myboxshape = b2CreateBoxShape(mybox,1,1,1,0.5,1)
b2CalculateBodyMass mybox

That will firstly create a dynamic body at location (0,0) with an angle of 0. Then it will add a box shape to that body with a width of 1, a height of 1, a density of 1, a friction of 0.5, and a restitution of 1. Finally, it will recalculate the mass of the body. You must do this whenever you finish adding/removing shapes on a body!

Here is a NEW wiki for the plugin! The help files redirect to files on the wiki, so you can now edit and view pages from within the IDE

Before adding a new page documenting a command, please look at some existing pages to see how they are laid out, both for functions, and commands.

**The plugin uses these units:**
Distance: Meters

Angles: Radians

Forces: Newtons (kg.m/s²)

Mass: Kilograms

Density: kg/m²

Time: Seconds

Torque: Newton Meters (N.m)

Speed: m/s

Acceleration: m/s²