Fixup dashing
parent
7eca2f3c16
commit
d9544bc441
28
obj/player.c
28
obj/player.c
|
@ -6,7 +6,7 @@
|
||||||
#define RUN_INIT_SPD 230
|
#define RUN_INIT_SPD 230
|
||||||
#define JUMP_SPD 500
|
#define JUMP_SPD 500
|
||||||
#define GRAV 1200
|
#define GRAV 1200
|
||||||
#define DASH_SPD 600
|
#define DASH_SPD 650
|
||||||
|
|
||||||
static bool allow_move = true;
|
static bool allow_move = true;
|
||||||
static bool allow_friction = 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 run_start_frames = 10;
|
||||||
const unsigned int jump_squat_frames = 4;
|
const unsigned int jump_squat_frames = 4;
|
||||||
const unsigned int land_lag_frames = 6;
|
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;
|
unsigned int PLAYER_SIZE = 30;
|
||||||
|
|
||||||
|
@ -187,17 +190,18 @@ void player_input_check(struct player_obj *player){
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DASHING:
|
case DASHING:
|
||||||
create_afterimage(player);
|
|
||||||
player->kinematic.velocity.x = dash_vec.x;
|
player->kinematic.velocity.x = dash_vec.x;
|
||||||
player->kinematic.velocity.y = dash_vec.y;
|
player->kinematic.velocity.y = dash_vec.y;
|
||||||
++frame_counter;
|
++frame_counter;
|
||||||
if (frame_counter > dash_time_frames){
|
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})){
|
if (!place_meeting(&player->kinematic, (Vector2){0,1})){
|
||||||
player->state = JUMPING;
|
player->state = JUMPING;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
player->state = RUNNING;
|
player->state = FALLING;
|
||||||
|
dash_count = 1;
|
||||||
}
|
}
|
||||||
//allow_friction = true;
|
//allow_friction = true;
|
||||||
}
|
}
|
||||||
|
@ -209,6 +213,11 @@ void player_input_check(struct player_obj *player){
|
||||||
|
|
||||||
// Set the hitbox reductions
|
// Set the hitbox reductions
|
||||||
adjust_hitbox(&player->kinematic);
|
adjust_hitbox(&player->kinematic);
|
||||||
|
if (afterimage_fcounter < afterimage_frames){
|
||||||
|
if(afterimage_fcounter%2 == 0)
|
||||||
|
create_afterimage(player);
|
||||||
|
++afterimage_fcounter;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsKeyPressed(JUMP) && jumps > 0){
|
if (IsKeyPressed(JUMP) && jumps > 0){
|
||||||
player->state = JUMP_SQUAT;
|
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;
|
dash_vec.y = dash_vec.y * DASH_SPD/m;
|
||||||
//allow_friction = false;
|
//allow_friction = false;
|
||||||
--dash_count;
|
--dash_count;
|
||||||
frame_counter=0;
|
frame_counter=0;afterimage_fcounter=0;
|
||||||
player->state = DASHING;
|
player->state = DASHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +261,10 @@ void player_input_check(struct player_obj *player){
|
||||||
jumps = 0;
|
jumps = 0;
|
||||||
on_ground = false;
|
on_ground = false;
|
||||||
allow_friction = true;
|
allow_friction = true;
|
||||||
player->state = FALLING;
|
if (player->state != DASHING)
|
||||||
|
player->state = FALLING;
|
||||||
|
else
|
||||||
|
player->state = JUMPING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allow_friction == true)
|
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 (player->state != DASHING && !place_meeting(&player->kinematic, (Vector2){0,1}) ){
|
||||||
if (!place_meeting(&player->kinematic, (Vector2){0,1}) ){
|
if (!place_meeting(&player->kinematic, (Vector2){0,1}) ){
|
||||||
accel.y = GRAV;
|
accel.y = GRAV;
|
||||||
if(player->kinematic.velocity.y > 0)
|
if(player->state != DASHING && player->kinematic.velocity.y > 0)
|
||||||
player->state = FALLING;
|
player->state = FALLING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,14 +150,14 @@ void draw_afterimages(struct player_obj *player){
|
||||||
translate_mat[12] = current->pos.x;
|
translate_mat[12] = current->pos.x;
|
||||||
translate_mat[13] = current->pos.y;
|
translate_mat[13] = current->pos.y;
|
||||||
rlMultMatrixf(translate_mat);
|
rlMultMatrixf(translate_mat);
|
||||||
Color c = (Color){ 0, 0, 0, 255 * current->opacity};
|
Color c = (Color){ 40, 0, 180, 255 * current->opacity};
|
||||||
for(i=0;i<BEZIER_POINTS;++i){
|
for(i=0;i<BEZIER_POINTS;++i){
|
||||||
DrawTriangle(current->top_vertices[i], (Vector2){0,0}, current->top_vertices[i+1], c);
|
DrawTriangle(current->top_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->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->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);
|
DrawTriangle(current->right_vertices[i], (Vector2){0,0}, current->right_vertices[i+1], c);
|
||||||
}
|
}
|
||||||
current->opacity -= 0.1;
|
current->opacity -= 0.2;
|
||||||
rlPopMatrix();
|
rlPopMatrix();
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue