summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-07-19 14:50:25 +0200
committerAki <nthirtyone@gmail.com>2017-07-19 14:50:25 +0200
commit657eb912abc89a71d16ea60516458ad6c72f6a4e (patch)
treea7e5a3c23e309aa954f95511cfa6f911536fb7b5
parent9b75ea38f0194dfffc89c0144c1ab0efb8b4f392 (diff)
downloadroflnauts-657eb912abc89a71d16ea60516458ad6c72f6a4e.zip
roflnauts-657eb912abc89a71d16ea60516458ad6c72f6a4e.tar.gz
roflnauts-657eb912abc89a71d16ea60516458ad6c72f6a4e.tar.bz2
Initial clash
No additional effect, rusty mechanics for now
-rw-r--r--not/Hero.lua2
-rw-r--r--not/PhysicalBody.lua1
-rw-r--r--not/World.lua16
3 files changed, 16 insertions, 3 deletions
diff --git a/not/Hero.lua b/not/Hero.lua
index 13ab3dd..5c3d9f4 100644
--- a/not/Hero.lua
+++ b/not/Hero.lua
@@ -234,7 +234,7 @@ function Hero:punch (direction)
local fixture = self:addFixture(shape, 0)
fixture:setSensor(true)
fixture:setCategory(3)
- fixture:setMask(1,3)
+ fixture:setMask(1)
fixture:setGroupIndex(self.group)
fixture:setUserData({Hero.PUNCH_FIXTURE_LIFETIME, direction})
self:playSound(4)
diff --git a/not/PhysicalBody.lua b/not/PhysicalBody.lua
index fd92f89..804c706 100644
--- a/not/PhysicalBody.lua
+++ b/not/PhysicalBody.lua
@@ -11,6 +11,7 @@ PhysicalBody.body =--[[love.physics.newBody]]nil
function PhysicalBody:new (x, y, world, imagePath)
PhysicalBody.__super.new(self, world, imagePath)
self.body = love.physics.newBody(world.world, x, y)
+ self.body:setUserData(self)
end
-- Add new fixture to body.
diff --git a/not/World.lua b/not/World.lua
index 47a1237..92b71ea 100644
--- a/not/World.lua
+++ b/not/World.lua
@@ -329,6 +329,10 @@ end
-- Box2D callbacks
-- beginContact
function World.beginContact (a, b, coll)
+ -- TODO: Stop using magical numbers:
+ -- [1] -> Platform
+ -- [2] -> Hero
+ -- [3] -> Punch sensor
if a:getCategory() == 1 then
local x,y = coll:getNormal()
if y < -0.6 then
@@ -340,10 +344,18 @@ function World.beginContact (a, b, coll)
end
end
if a:getCategory() == 3 then
- b:getUserData():damage(a:getUserData()[2])
+ if b:getCategory() == 2 then
+ b:getUserData():damage(a:getUserData()[2])
+ end
+ if b:getCategory() == 3 then
+ a:getBody():getUserData():damage(b:getUserData()[2])
+ b:getBody():getUserData():damage(a:getUserData()[2])
+ end
end
if b:getCategory() == 3 then
- a:getUserData():damage(b:getUserData()[2])
+ if a:getCategory() == 2 then
+ a:getUserData():damage(b:getUserData()[2])
+ end
end
end
-- endContact