diff --git a/obj/player.c b/obj/player.c index 7615355..781845a 100644 --- a/obj/player.c +++ b/obj/player.c @@ -67,14 +67,48 @@ void player_input_check(struct player_obj *player){ accel.x = PLAYER_ACCEL*(IsKeyDown(KEY_RIGHT)-IsKeyDown(KEY_LEFT)); } } + set_squish_target_offset(player->image, 0, 0); + set_squish_target_offset(player->image, 2, 0); + if (player->kinematic.velocity.x == 0){ + if (run_dir == 1){ + player->kinematic.dim_reduction[0] = 20; + set_squish_target_offset(player->image, 0, 15); + }else{ + player->kinematic.dim_reduction[2] = 20; + set_squish_target_offset(player->image, 2, 15); + } + } break; case RUN_END: if(player->kinematic.velocity.x < 10 && player->kinematic.velocity.x > -10){ + 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; if(IsKeyDown(LEFT) || IsKeyDown(RIGHT)){ player->state = RUNNING; }else{ player->state = IDLE; } + }else{ + //Skidding + if (player->kinematic.velocity.x > 0){ + 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(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; + } + } } break; case TURN_AROUND: @@ -183,30 +217,5 @@ void player_input_check(struct player_obj *player){ move(&player->kinematic, accel); - //Skidding - if (on_ground == true){ - 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 (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; - } - } + } diff --git a/obj/squishy.c b/obj/squishy.c index fd80cd3..af42186 100644 --- a/obj/squishy.c +++ b/obj/squishy.c @@ -1,9 +1,10 @@ #include "header.h" #include +#include #define INTERP_FACTOR 0.2 #define OFFSET_VALUE 20 - +#define SHEAR_NORMALISE 100 float shear_mat[16] = {1.0, 0.0, 0, 0, 0.1, 1.0, 0, 0, 0, 0, 1.0, 0, @@ -123,6 +124,7 @@ void calc_offsets(struct squishy_square *square){ void draw_squishy(struct squishy_square *square){ rlPushMatrix(); // TODO: Need a correction term to put the square in the box???? + shear_mat[4] = -square->parent->velocity.x / 600; rlMultMatrixf(shear_mat); translate_mat[12] = square->center.x; translate_mat[13] = square->center.y;