ピコピココード
world=b2World.new(0,20)
groundBody=world:createBody()
e_count=20
y = -16.0;
L = -12.0;
a = 1.0;
b = 2.0;
shape=b2Shape.edge({density=0})
shape:set(-40,0,40,0)
body=world:createBody(0,0)
body:createFixture(shape)
shape1=b2Shape.circle()
shape1.radius=2
shape1.p=pppoint(-10.0,y+b+L)
shape2=b2Shape.circle(2)
shape2.radius=2
shape2.p=pppoint( 10.0,y+b+L)
ground=world:createBody()
ground:createFixture(shape1)
ground:createFixture(shape2)
shape=b2Shape.polygon({density=5})
shape:setAsBox(a,b)
body1=world:createBody(
"dynamic",-10,y)
body1:createFixture(shape)
body2=world:createBody(
"dynamic", 10,y)
body2:createFixture(shape)
world:createJoint(
"pulley",body1,body2,{
groundAnchorA={x=-10,y=y+b+L},
groundAnchorB={x= 10,y=y+b+L},
anchorA={x=-10,y=y},
anchorB={x= 10,y=y},
ratio=1.5})
world:shiftOrigin(-15,-40)
function start()
world:debugDrag(pptouch())
world:step()
world:debugDrawBody()
world:debugDrawJoint()
end