-- BoxMove
-- Use this function to perform your initial setup
function setup()
pdb = PhysicsDebugDraw()
box = createBox(WIDTH/2,HEIGHT/2,20,20)
box.type = STATIC
end
function createBox(x,y,w,h)
-- polygons are defined by a series of points in counter-clockwise order
local box = physics.body(POLYGON, vec2(-w/2,h/2), vec2(-w/2,-h/2), vec2(w/2,-h/2), vec2(w/2,h/2))
box.interpolate = true
box.x = x
box.y = y
box.restitutions = 0.25
box.sleepingAllowed = false
pdb:addBody(box)
return box
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(5)
-- Do your drawing here
pdb:draw()
end
function touched(touch)
if touch.tapCount == 1 then
box.x = touch.x
elseif touch.tapCount == 2 then
box.y = touch.y
end
end
```
Using the PhysicsDebugDraw from Physics Lab example