PicoPicoGameEngine

Quick Links

Source Code

g=ppgraph

world=b2World.new(0,20)

e_count=10

function createGround()
shape=b2Shape.polygon()
sp=ppoffscreen.new()
sp:create(320,200)
sp:fill(0,0,320,200,g.skin)
sp:box(0,0,320,200,g.white)
shape:setSprite(sp)
ground=world:createBody(16,55)
ground:createFixture(shape)
end

function createPyramid()
d=1.4
x=pppoint((16-d*1.1*8)/2,0)
y=pppoint()
deltaX=pppoint(d/2,-d*1.1)*2
deltaY=pppoint(d,0.0)*2

sp=ppoffscreen.new()
sp:create(24,24)
sp:fill(0,0,24,24,g.orange)
sp:fill(0,0,24,2,g.white)
sp:fill(8,0,2,12,g.white)
sp:fill(0,12,24,2,g.white)
sp:fill(16,12,2,12,g.white)

for i=0,e_count do
  y = pppoint(x);
  for j=i,e_count do
    shape=b2Shape.polygon()
    shape:setSprite(sp)
    local body
    body=world:createBody(
      "dynamic",y.x,y.y+35,0)
    body:createFixture(
      shape,{density=5})
    y=y+deltaY
  end
  x=x+deltaX
end
end

createGround()
createPyramid()

function start()
  g:fill(
    ppscreen:size(),g.cyan)
  world:debugDrag(pptouch())
  world:step()
  -- world:debugDrawBody()
  world:drawBody()
end