diff options
Diffstat (limited to 'src/phys.lua')
| -rw-r--r-- | src/phys.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/phys.lua b/src/phys.lua index 9adb915..08a610a 100644 --- a/src/phys.lua +++ b/src/phys.lua @@ -233,3 +233,15 @@ function phys.Box:draw() local x, y, w, h = self:get_rect() lg.rectangle("line", x, y, w, h) end + +register_comp("Body", function (ent, x, y, w, h, opts) + ent.vx = 0 + ent.vy = 0 + ent.box = phys.Box.new(x, y, w, h, opts) +end) + +function body_sys(ent, dt) + ent.vx, ent.vy = ent.box:update(ent.vx, ent.vy, dt) + ent.x = ent.box.x + ent.y = ent.box.y +end |
