From d9544bc441aa16a7994393ab9f7c58b972b9617a Mon Sep 17 00:00:00 2001 From: En Yi Date: Fri, 21 Feb 2020 21:59:24 +0800 Subject: [PATCH] Fixup dashing --- obj/player.c | 28 ++++++++++++++++++++-------- obj/squishy.c | 4 ++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/obj/player.c b/obj/player.c index 921d14d..e2e89cb 100644 --- a/obj/player.c +++ b/obj/player.c @@ -6,7 +6,7 @@ #define RUN_INIT_SPD 230 #define JUMP_SPD 500 #define GRAV 1200 -#define DASH_SPD 600 +#define DASH_SPD 650 static bool allow_move = true; static bool allow_friction = true; @@ -22,7 +22,10 @@ static Vector2 dash_vec = (Vector2){0.0, 0.0}; const unsigned int run_start_frames = 10; const unsigned int jump_squat_frames = 4; const unsigned int land_lag_frames = 6; -const unsigned int dash_time_frames = 5; +const unsigned int dash_time_frames = 6; + +static unsigned int afterimage_fcounter = 10; +const unsigned int afterimage_frames = 10; unsigned int PLAYER_SIZE = 30; @@ -187,17 +190,18 @@ void player_input_check(struct player_obj *player){ break; case DASHING: - create_afterimage(player); player->kinematic.velocity.x = dash_vec.x; player->kinematic.velocity.y = dash_vec.y; ++frame_counter; if (frame_counter > dash_time_frames){ - dash_count = 1; + player->kinematic.velocity.x *= 0.6; + player->kinematic.velocity.y *= 0.6; if (!place_meeting(&player->kinematic, (Vector2){0,1})){ player->state = JUMPING; } else{ - player->state = RUNNING; + player->state = FALLING; + dash_count = 1; } //allow_friction = true; } @@ -209,6 +213,11 @@ void player_input_check(struct player_obj *player){ // Set the hitbox reductions adjust_hitbox(&player->kinematic); + if (afterimage_fcounter < afterimage_frames){ + if(afterimage_fcounter%2 == 0) + create_afterimage(player); + ++afterimage_fcounter; + } if (IsKeyPressed(JUMP) && jumps > 0){ player->state = JUMP_SQUAT; @@ -243,7 +252,7 @@ void player_input_check(struct player_obj *player){ dash_vec.y = dash_vec.y * DASH_SPD/m; //allow_friction = false; --dash_count; - frame_counter=0; + frame_counter=0;afterimage_fcounter=0; player->state = DASHING; } @@ -252,7 +261,10 @@ void player_input_check(struct player_obj *player){ jumps = 0; on_ground = false; allow_friction = true; - player->state = FALLING; + if (player->state != DASHING) + player->state = FALLING; + else + player->state = JUMPING; } if (allow_friction == true) @@ -264,7 +276,7 @@ void player_input_check(struct player_obj *player){ //if (player->state != DASHING && !place_meeting(&player->kinematic, (Vector2){0,1}) ){ if (!place_meeting(&player->kinematic, (Vector2){0,1}) ){ accel.y = GRAV; - if(player->kinematic.velocity.y > 0) + if(player->state != DASHING && player->kinematic.velocity.y > 0) player->state = FALLING; } diff --git a/obj/squishy.c b/obj/squishy.c index b0fd915..5de30c6 100644 --- a/obj/squishy.c +++ b/obj/squishy.c @@ -150,14 +150,14 @@ void draw_afterimages(struct player_obj *player){ translate_mat[12] = current->pos.x; translate_mat[13] = current->pos.y; rlMultMatrixf(translate_mat); - Color c = (Color){ 0, 0, 0, 255 * current->opacity}; + Color c = (Color){ 40, 0, 180, 255 * current->opacity}; for(i=0;itop_vertices[i], (Vector2){0,0}, current->top_vertices[i+1], c); DrawTriangle(current->bottom_vertices[i], (Vector2){0,0}, current->bottom_vertices[i+1], c); DrawTriangle(current->left_vertices[i], (Vector2){0,0}, current->left_vertices[i+1], c); DrawTriangle(current->right_vertices[i], (Vector2){0,0}, current->right_vertices[i+1], c); } - current->opacity -= 0.1; + current->opacity -= 0.2; rlPopMatrix(); current = current->next; }