summaryrefslogtreecommitdiffhomepage
path: root/not/PhysicalBody.lua
diff options
context:
space:
mode:
Diffstat (limited to 'not/PhysicalBody.lua')
-rw-r--r--not/PhysicalBody.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/not/PhysicalBody.lua b/not/PhysicalBody.lua
index bbea3ac..54d334f 100644
--- a/not/PhysicalBody.lua
+++ b/not/PhysicalBody.lua
@@ -20,6 +20,31 @@ end
-- Initializator of `PhysicalBody`.
function PhysicalBody:init (world, x, y, imagePath)
Sprite.init(self, imagePath)
+ self.body = love.physics.newBody(world.world, x, y)
+end
+
+-- Add new fixture to body.
+function PhysicalBody:addFixture (shape, density)
+ local shape = love.physics.newPolygonShape(shape)
+ local fixture = love.physics.newFixture(self.body, shape, density)
+ return fixture
+end
+
+-- Position-related methods.
+function PhysicalBody:getPosition ()
+ return self.body:getPosition()
+end
+function PhysicalBody:setPosition (x, y)
+ self.body:setPosition(x, y)
+end
+
+-- Various setters from Body.
+-- type: BodyType ("static", "dynamic", "kinematic")
+function PhysicalBody:setBodyType (type)
+ self.body:setType(type)
+end
+function PhysicalBody:setBodyFixedRotation (bool)
+ self.body:setFixedRotation(bool)
end
-- Update of `PhysicalBody`.