summaryrefslogtreecommitdiffhomepage
path: root/not
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-04-06 16:28:21 +0200
committerAki <nthirtyone@gmail.com>2017-04-06 16:28:21 +0200
commiteff39f1f49d5223cb27b5874f8ac29ce8a2ef85f (patch)
treebb4cd82d2c63c3aed26b6cc68064b7db7b45c123 /not
parent970655737ce7f497f0725d28605fc296c9923a64 (diff)
downloadroflnauts-eff39f1f49d5223cb27b5874f8ac29ce8a2ef85f.zip
roflnauts-eff39f1f49d5223cb27b5874f8ac29ce8a2ef85f.tar.gz
roflnauts-eff39f1f49d5223cb27b5874f8ac29ce8a2ef85f.tar.bz2
Moved damping back to Hero from Player
Diffstat (limited to 'not')
-rw-r--r--not/Hero.lua17
-rw-r--r--not/Player.lua18
2 files changed, 17 insertions, 18 deletions
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
diff --git a/not/Player.lua b/not/Player.lua
index 30057bb..2a4b2e6 100644
--- a/not/Player.lua
+++ b/not/Player.lua
@@ -69,24 +69,6 @@ function Player:update (dt)
self:applyForce(-250, 0)
end
end
-
- -- Limiting walking speed.
- if not self:isControlDown("left") and
- not self:isControlDown("right")
- then
- local face = nil
- 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
end
-- Controller callbacks.