PicoPicoGameEngine

Quick Links

Source Code

world=b2World.new(0,-10)
world:drawScale(10,-10)
groundBody=world:createBody()

shape=b2Shape.edge()
shape:set(-40,0,40,0)
ground=world:createBody()
ground:createFixture(shape)

shape=b2Shape.polygon()
shape:setAsBox(13,0.25)
body=world:createBody(
   -4,22,{angle=-0.25})
body:createFixture(shape)

shape=b2Shape.polygon()
shape:setAsBox(0.25,1)
body=world:createBody(
   10.5,19)
body:createFixture(shape)

shape=b2Shape.polygon()
shape:setAsBox(13,0.25)
body=world:createBody(
   4,14,{angle=0.25})
body:createFixture(shape)

shape=b2Shape.polygon()
shape:setAsBox(0.25,1)
body=world:createBody(
   -10.5,11)
body:createFixture(shape)

shape=b2Shape.polygon()
shape:setAsBox(13,0.25)
body=world:createBody(
   -4,6,{angle=-0.25})
body:createFixture(shape)

friction = {0.75,
            0.5,
            0.35,
            0.1,
            0.0}

for i=0,4 do
  shape=b2Shape.polygon(
    {density=25,
     friction=friction[i+1]})
  shape:setAsBox(0.5,0.5)
  body=world:createBody(
      "dynamic",-15+4*i,28)
  body:createFixture(shape)
end

world:shiftOrigin(-16,30)

function start()
  world:debugDrag(pptouch())
  world:step()
  world:debugDrawBody()
  world:debugDrawJoint()
end