From 4d12a02f9162d2a07d8a79e16905197c78b81c35 Mon Sep 17 00:00:00 2001 From: En Yi Date: Thu, 17 Aug 2023 23:20:52 +0800 Subject: [PATCH] Tweak player's movement Changelog: - Increase ground friction generally. - Reduce friction when the player is moving on the ground. To compensate, reduce player acceleration as well. Now, the player stops faster without losing too much max speed. --- scenes/constants.h | 2 +- scenes/game_systems.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scenes/constants.h b/scenes/constants.h index 2e51f1b..fc3530a 100644 --- a/scenes/constants.h +++ b/scenes/constants.h @@ -35,7 +35,7 @@ #define PLAYER_MAX_SPEED 800 #define WATER_FRICTION 7.5 -#define GROUND_X_FRICTION 5.8 +#define GROUND_X_FRICTION 6.1 #define GROUND_Y_FRICTION 1.0 #define ARROW_SPEED 350 diff --git a/scenes/game_systems.c b/scenes/game_systems.c index ad326d3..1fbf0f0 100644 --- a/scenes/game_systems.c +++ b/scenes/game_systems.c @@ -761,9 +761,10 @@ void friction_coefficient_update_system(Scene_t* scene) } CPlayerState_t* p_pstate = get_component(p_ent, CPLAYERSTATE_T); - if (p_pstate != NULL && (p_pstate->is_crouch & 1)) + if (p_pstate != NULL) { - p_ct->fric_coeff.x -= 4; + if (p_pstate->is_crouch & 1) p_ct->fric_coeff.x -= 4; + if ((p_mstate->ground_state & 1) && p_pstate->player_dir.x != 0) p_ct->fric_coeff.x *= 0.9; } } }