summaryrefslogtreecommitdiffhomepage
path: root/not
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-07-17 14:15:36 +0200
committerAki <nthirtyone@gmail.com>2017-07-17 14:15:36 +0200
commit7ad366dcec68c703499e3f6f72b345d1adeac1da (patch)
tree869234374f264c1dba08bfa3461d576109a6dc34 /not
parentfc43bcb81b5dbfc8ef8dd164193014aa0cf43c9f (diff)
downloadroflnauts-7ad366dcec68c703499e3f6f72b345d1adeac1da.zip
roflnauts-7ad366dcec68c703499e3f6f72b345d1adeac1da.tar.gz
roflnauts-7ad366dcec68c703499e3f6f72b345d1adeac1da.tar.bz2
Moved landing method to Hero from World
Diffstat (limited to 'not')
-rw-r--r--not/Hero.lua9
-rw-r--r--not/World.lua8
2 files changed, 10 insertions, 7 deletions
diff --git a/not/Hero.lua b/not/Hero.lua
index 014eeb2..ff07c36 100644
--- a/not/Hero.lua
+++ b/not/Hero.lua
@@ -219,6 +219,15 @@ function Hero:createEffect (name, dx, dy)
self.world:createEffect(name, x, y)
end
+-- Called by World when Hero starts contact with Platform (lands).
+function Hero:land ()
+ self.inAir = false
+ self.jumpCounter = 2
+ self.salto = false
+ self.smoke = false
+ self:createEffect("land")
+end
+
-- Creates temporary fixture for hero's body that acts as sensor.
-- direction: ("left", "right", "up", "down")
-- Sensor fixture is deleted after time set in UserData[1]; deleted by `not.Hero.update`.
diff --git a/not/World.lua b/not/World.lua
index 3a5b051..47a1237 100644
--- a/not/World.lua
+++ b/not/World.lua
@@ -332,13 +332,7 @@ function World.beginContact (a, b, coll)
if a:getCategory() == 1 then
local x,y = coll:getNormal()
if y < -0.6 then
- -- TODO: move landing to `not.Hero`
- -- Move them to Hero
- b:getUserData().inAir = false
- b:getUserData().jumpCounter = 2
- b:getUserData().salto = false
- b:getUserData().smoke = false
- b:getUserData():createEffect("land")
+ b:getUserData():land()
end
local vx, vy = b:getUserData().body:getLinearVelocity()
if math.abs(x) == 1 or (y < -0.6 and x == 0) then