summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHume2 <teratux.mail@gmail.com>2018-08-28 21:27:24 +0200
committerHume2 <teratux.mail@gmail.com>2018-08-28 21:27:24 +0200
commit3f788eddd335594e1177cd3e2f9734e02872b1ca (patch)
tree30062f2bf8fca98b825952e84ceb64ab84351272
parent1e1f0681a2630d05d5fb3efc6cad518bf15aba4d (diff)
Make the bike less controllable when faster
-rw-r--r--init.lua27
1 files changed, 15 insertions, 12 deletions
diff --git a/init.lua b/init.lua
index a4451a7..66ef15c 100644
--- a/init.lua
+++ b/init.lua
@@ -133,26 +133,29 @@ end
function bike.on_step(self, dtime)
+ local current_v = get_v(self.object:get_velocity()) * get_sign(self.v)
+ self.v = (current_v + self.v*3) / 4
if self.driver then
local ctrl = self.driver:get_player_control()
local yaw = self.object:get_yaw()
+ local agility = 0
+
+ if self.v > 0.4 then
+ agility = 1/math.sqrt(self.v)
+ else
+ agility = 1.58
+ end
+
if ctrl.up then
- self.v = self.v + 0.1
+ self.v = self.v + 0.3 * agility
elseif ctrl.down then
- self.v = self.v - 0.1
+ self.v = self.v - 1.2 * agility
end
+
if ctrl.left then
- if self.v < 0 then
- self.object:set_yaw(yaw - (1 + dtime) * 0.03)
- else
- self.object:set_yaw(yaw + (1 + dtime) * 0.03)
- end
+ self.object:set_yaw(yaw + (1 + dtime) * 0.06 * agility)
elseif ctrl.right then
- if self.v < 0 then
- self.object:set_yaw(yaw + (1 + dtime) * 0.03)
- else
- self.object:set_yaw(yaw - (1 + dtime) * 0.03)
- end
+ self.object:set_yaw(yaw - (1 + dtime) * 0.06 * agility)
end
end
local velo = self.object:get_velocity()