summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-13 22:29:33 +0200
committerAki <nthirtyone@gmail.com>2016-08-13 22:29:33 +0200
commitc2f861b5f4c27ab5946506eb640a03c64971b218 (patch)
tree50bf7ce2c263593488510d0f8e552b6b1ba525ac
parentd364ebe82e21018e3ef8645915e7f9ceacf84dd9 (diff)
downloadroflnauts-c2f861b5f4c27ab5946506eb640a03c64971b218.zip
roflnauts-c2f861b5f4c27ab5946506eb640a03c64971b218.tar.gz
roflnauts-c2f861b5f4c27ab5946506eb640a03c64971b218.tar.bz2
temporary multishape
-rw-r--r--ground.lua28
1 files changed, 22 insertions, 6 deletions
diff --git a/ground.lua b/ground.lua
index 683966b..cd2b607 100644
--- a/ground.lua
+++ b/ground.lua
@@ -18,12 +18,26 @@ function Ground:new (game, world, x, y, shape, sprite)
local o = {}
setmetatable(o, self)
self.__index = self
- o.body = love.physics.newBody(world, x, y)
- o.shape = love.physics.newPolygonShape(shape)
- o.fixture = love.physics.newFixture(o.body, o.shape)
+ o.body = love.physics.newBody(world, x, y)
+ -- MULTIPLE SHAPES NEED TO BE REWRITED!
+ o.shape = {}
+ if type(shape[1]) == "number" then
+ local poly = love.physics.newPolygonShape(shape)
+ table.insert(o.shape, poly)
+ o.fixture = love.physics.newFixture(o.body, poly)
+ o.fixture:setCategory(1)
+ o.fixture:setFriction(0.2)
+ else
+ for i,v in pairs(shape) do
+ local poly = love.physics.newPolygonShape(v)
+ table.insert(o.shape, poly)
+ local fixture = love.physics.newFixture(o.body, poly)
+ fixture:setCategory(1)
+ fixture:setFriction(0.2)
+ end
+ end
+ -- END HERE
o.sprite = love.graphics.newImage(sprite)
- o.fixture:setCategory(1)
- o.fixture:setFriction(0.2)
o.world = game
return o
end
@@ -56,6 +70,8 @@ function Ground:draw (offset_x, offset_y, scale, debug)
-- debug draw
if debug then
love.graphics.setColor(255, 69, 0, 140)
- love.graphics.polygon("fill", self.world.camera:translatePoints(self.body:getWorldPoints(self.shape:getPoints())))
+ for i,v in pairs(self.shape) do
+ love.graphics.polygon("fill", self.world.camera:translatePoints(self.body:getWorldPoints(v:getPoints())))
+ end
end
end \ No newline at end of file