From f3a31cef502d8438323f6f5373979dd5ce93d065 Mon Sep 17 00:00:00 2001 From: En Yi Date: Fri, 31 Jan 2020 16:06:32 +0800 Subject: [PATCH] Improve skidding --- obj/kinematics.c | 2 +- obj/player.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/obj/kinematics.c b/obj/kinematics.c index 76a6269..5e67598 100644 --- a/obj/kinematics.c +++ b/obj/kinematics.c @@ -45,7 +45,7 @@ void move(struct kinematic_obj *obj, Vector2 acceleration){ current = kinematic_HEAD; while(current != NULL){ if(current->obj != obj){ - // SAT: If any projected axis is non overlapping, exit + // SAT method - If any projected axis is non overlapping, exit if (obj->rect.x + obj->rect.width < current->obj->rect.x) goto iter; if (current->obj->rect.x + current->obj->rect.width < obj->rect.x) goto iter; if (obj->rect.y + obj->rect.height < current->obj->rect.y) goto iter; diff --git a/obj/player.c b/obj/player.c index d441b5e..7615355 100644 --- a/obj/player.c +++ b/obj/player.c @@ -127,8 +127,8 @@ void player_input_check(struct player_obj *player){ set_squish_target_offset(player->image, 1, 0); if(frame_counterkinematic.velocity.x > 0){ + if (player->kinematic.velocity.x > 3){ + if (!IsKeyDown(RIGHT)){ set_squish_target_offset(player->image, 0, 15); player->kinematic.dim_reduction[0] = 10; }else{ set_squish_target_offset(player->image, 0, 0); player->kinematic.dim_reduction[0] = 0; } - } - else if(IsKeyDown(RIGHT)){ - if (player->kinematic.velocity.x < 0){ + }else if (player->kinematic.velocity.x < -3){ + if (!IsKeyDown(LEFT)){ set_squish_target_offset(player->image, 2, 15); player->kinematic.dim_reduction[2] = 10; }else{ set_squish_target_offset(player->image, 2, 0); player->kinematic.dim_reduction[2] = 0; } + }else{ + player->kinematic.velocity.x = 0; + set_squish_target_offset(player->image, 2, 0); + player->kinematic.dim_reduction[2] = 0; + set_squish_target_offset(player->image, 0, 0); + player->kinematic.dim_reduction[0] = 0; } } }