--# Main
require(asset.documents["Physics Lab+.codea"])

-- Cards run at Box2D's default restitution rather than PhysicsLab+'s 0.25,
-- which is what they have always done and what makes them slide rather than
-- bounce. If cards ever start feeling springy, print
-- physics.body(CIRCLE, 1).restitution and check this still matches.
CARD_RESTITUTION = 0

function setup()
  physics.gravity(0, 0)
  lab = PhysicsLab()
  lab.playSounds = false
  lab.draggable = false
  lab.shouldDraw = {bodies = false, joints = false, contacts = false, drags = false}
  lab.make.restitution = CARD_RESTITUTION
  cardTable = CardTable()
  cardTouch = CardTouch(lab, cardTable)
end

function draw()
  background(0)
  cardTable:draw()
  cardTouch:update()
end

function touched(touch)
  cardTouch:touched(touch)
end

function collide(contact)
  lab:collide(contact)
end
--now what?