Improve skidding

master
En Yi 2020-01-31 16:06:32 +08:00
parent a60713a723
commit f3a31cef50
2 changed files with 13 additions and 8 deletions

View File

@ -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;

View File

@ -127,8 +127,8 @@ void player_input_check(struct player_obj *player){
set_squish_target_offset(player->image, 1, 0);
if(frame_counter<land_lag_frames){
++frame_counter;
//if (IsKeyDown(JUMP))
// state_buffer = JUMP_SQUAT;
if (IsKeyDown(JUMP))
state_buffer = JUMP_SQUAT;
}
else{
jumps = 1;
@ -185,23 +185,28 @@ void player_input_check(struct player_obj *player){
//Skidding
if (on_ground == true){
if (IsKeyDown(LEFT)){
if (player->kinematic.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;
}
}
}