aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-03-05 19:39:08 +0100
committermetamuffin <metamuffin@disroot.org>2026-03-05 19:39:08 +0100
commit051d24bf65475e08fb7c11e258e503192c0cb52e (patch)
tree068c730523f8d0009c36e0590a2bb83f85b5857e /client
parente1dc33a6923a840953b8da5fb9f6eac30ff05f28 (diff)
downloadhurrycurry-051d24bf65475e08fb7c11e258e503192c0cb52e.tar
hurrycurry-051d24bf65475e08fb7c11e258e503192c0cb52e.tar.bz2
hurrycurry-051d24bf65475e08fb7c11e258e503192c0cb52e.tar.zst
new movement math varies less with tick rate
Diffstat (limited to 'client')
-rw-r--r--client/player/player.gd9
1 files changed, 4 insertions, 5 deletions
diff --git a/client/player/player.gd b/client/player/player.gd
index dd705423..a72104b5 100644
--- a/client/player/player.gd
+++ b/client/player/player.gd
@@ -21,8 +21,8 @@ const ITEM_BUBBLE: PackedScene = preload("res://player/item_bubble.tscn")
const EFFECT: PackedScene = preload("res://player/particles/effect.tscn")
const PLAYER_SIZE: float = 0.4
-const PLAYER_SPEED = 55
-const PLAYER_FRICTION = 15
+const PLAYER_ACCELERATION = 10
+const PLAYER_SPEED = 3.8
const BOOST_FACTOR = 2.5
const BOOST_DURATION = 0.3
const BOOST_RESTORE = 0.5
@@ -145,10 +145,9 @@ func update_movement(dt: float, boost: bool):
if boosting: stamina -= dt / BOOST_DURATION
else: stamina += dt / BOOST_RESTORE
stamina = max(min(stamina, 1.0), 0.0)
- var speed = PLAYER_SPEED * (BOOST_FACTOR if boosting else 1.)
- velocity_ += direction * dt * speed
+ var target_v = direction * PLAYER_SPEED * (BOOST_FACTOR if boosting else 1.)
+ velocity_ = target_v + (velocity_ - target_v) * exp(-dt * PLAYER_ACCELERATION)
position_ += velocity_ * dt
- velocity_ = velocity_ * exp(-dt * PLAYER_FRICTION)
collide(dt)
func collide(dt: float):