summaryrefslogtreecommitdiffhomepage
path: root/not/World.lua
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 /not/World.lua
parent9b75ea38f0194dfffc89c0144c1ab0efb8b4f392 (diff)
downloadroflnauts-657eb912abc89a71d16ea60516458ad6c72f6a4e.zip
roflnauts-657eb912abc89a71d16ea60516458ad6c72f6a4e.tar.gz
roflnauts-657eb912abc89a71d16ea60516458ad6c72f6a4e.tar.bz2
Initial clash
No additional effect, rusty mechanics for now
Diffstat (limited to 'not/World.lua')
-rw-r--r--not/World.lua16
1 files changed, 14 insertions, 2 deletions
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