From eff39f1f49d5223cb27b5874f8ac29ce8a2ef85f Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 6 Apr 2017 16:28:21 +0200 Subject: Moved damping back to Hero from Player --- not/Hero.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'not/Hero.lua') diff --git a/not/Hero.lua b/not/Hero.lua index 7c2555a..a22cc2e 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -84,6 +84,23 @@ function Hero:update (dt) self.angle = 0 end + -- Custom linear damping. + if not self.isWalking then + local face = nil + local x, y = self:getLinearVelocity() + if x < -12 then + face = 1 + elseif x > 12 then + face = -1 + else + face = 0 + end + self:applyForce(40*face,0) + if not self.inAir then + self:applyForce(80*face,0) + end + end + -- Could you please die? -- TODO: World/Map function for testing if Point is inside playable area. local m = self.world.map -- cgit v1.1