summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-09-19 20:41:33 +0200
committermetamuffin <metamuffin@disroot.org>2024-09-19 20:41:40 +0200
commit02af3843b695857e9832434336cf093968f00ff5 (patch)
tree14b0763d1bea8f4f1bc9246320b140dee1dd5508
parent8b32c50e1bb2b8c8b00105c13c31b896ebab7f8a (diff)
downloadhurrycurry-02af3843b695857e9832434336cf093968f00ff5.tar
hurrycurry-02af3843b695857e9832434336cf093968f00ff5.tar.bz2
hurrycurry-02af3843b695857e9832434336cf093968f00ff5.tar.zst
update movement code everywhere
-rw-r--r--client/player/controllable_player.gd2
-rw-r--r--server/protocol/src/movement.rs7
-rw-r--r--test-client/movement.ts3
3 files changed, 8 insertions, 4 deletions
diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd
index 9e7ce2b2..016ee637 100644
--- a/client/player/controllable_player.gd
+++ b/client/player/controllable_player.gd
@@ -88,7 +88,7 @@ func _process_movement(delta):
rotation_anim = rotation_
func update(dt: float, boost: bool):
- direction = direction.limit_length(1.);
+ direction = direction.limit_length(1.)
if direction.length() > 0.05:
self.facing = direction + (self.facing - direction) * exp(-dt * 10.)
if direction.length() < 0.5:
diff --git a/server/protocol/src/movement.rs b/server/protocol/src/movement.rs
index ebcc627d..85accb31 100644
--- a/server/protocol/src/movement.rs
+++ b/server/protocol/src/movement.rs
@@ -58,10 +58,13 @@ impl MovementBase {
}
pub fn update(&mut self, map: &HashSet<IVec2>, dt: f32) {
let mut boost = self.input_boost;
- let direction = self.input_direction.clamp_length_max(1.);
- if direction.length() > 0.1 {
+ let mut direction = self.input_direction.clamp_length_max(1.);
+ if direction.length() > 0.05 {
self.facing = direction + (self.facing - direction) * (-dt * 10.).exp();
}
+ if direction.length() < 0.5 {
+ direction *= 0.;
+ }
self.rotation = self.facing.x.atan2(self.facing.y);
boost &= direction.length() > 0.1;
self.boosting = boost && (self.boosting || self.stamina >= 1.) && self.stamina > 0.;
diff --git a/test-client/movement.ts b/test-client/movement.ts
index 62846edf..7d395396 100644
--- a/test-client/movement.ts
+++ b/test-client/movement.ts
@@ -37,7 +37,8 @@ export interface MovementBase {
}
export function update_movement(p: MovementBase, dt: number, direction: V2, boost: boolean) {
- if (length(direction) > 0.1) lerp_exp_v2_mut(p.facing, direction, dt * 10.)
+ if (length(direction) > 0.05) lerp_exp_v2_mut(p.facing, direction, dt * 10.)
+ if (length(direction) < 0.5) direction.x = direction.y = 0
p.rot = Math.atan2(p.facing.x, p.facing.y)
boost &&= length(direction) > 0.1
p.boosting = boost && (p.boosting || p.stamina >= 1) && p.stamina > 0