Add sliding acceleration and slowdown via holding a key while sliding. Additionally add a walking speed limit. Allow slides to go above the walking limit
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
537bc7c744
commit
d296527e2f
@ -37,8 +37,6 @@ Underwater / Water Dashing (Propelling motion)
|
||||
Side Roll -> Slide
|
||||
Wall Jumping
|
||||
|
||||
Keybind Management - https://stackoverflow.com/questions/17413690/java-jinput-rescan-reload-controllers
|
||||
Sliding Key Buffer
|
||||
Movement Systems
|
||||
Collectibles
|
||||
Combat Systems
|
||||
|
Binary file not shown.
@ -21,15 +21,18 @@ public class Player extends AnimatedObject{
|
||||
final static int slide_AnimationWaitTime = 100;
|
||||
final static int slide_duration = 700;
|
||||
|
||||
final static double WALKING_SPEED_LIMIT = 164;
|
||||
|
||||
double y_acceleration = GRAVITY;
|
||||
double y_acceleration_limit = 100;
|
||||
double x_acceleration = 0;
|
||||
double x_acceleration_limit = 100;
|
||||
double x_velocity = 0;
|
||||
double x_velocity_limit = 164;
|
||||
double x_velocity_limit = 246;
|
||||
double y_velocity = 5;
|
||||
double y_velocity_limit = 500;
|
||||
double sliding_velocity = 164;
|
||||
double sliding_acceleration = 60;
|
||||
|
||||
double horizontal_drag = 2000;
|
||||
double horizontal_friction = NORMAL_FRICTION;
|
||||
@ -132,6 +135,18 @@ public class Player extends AnimatedObject{
|
||||
}
|
||||
state=State.IDLE;
|
||||
}
|
||||
if (KeyHeld(Action.MOVE_LEFT)&&!KeyHeld(Action.MOVE_RIGHT)) {
|
||||
if (facing_direction==LEFT&&x_velocity>-sliding_velocity*1.5||
|
||||
facing_direction==RIGHT&&x_velocity>sliding_velocity*0.5) {
|
||||
x_velocity-=sliding_acceleration*updateMult;
|
||||
}
|
||||
} else
|
||||
if (KeyHeld(Action.MOVE_RIGHT)&&!KeyHeld(Action.MOVE_LEFT)) {
|
||||
if (facing_direction==LEFT&&x_velocity<-sliding_velocity*0.5||
|
||||
facing_direction==RIGHT&&x_velocity<sliding_velocity*1.5) {
|
||||
x_velocity+=sliding_acceleration*updateMult;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case STAGGER:
|
||||
break;
|
||||
@ -407,7 +422,7 @@ public class Player extends AnimatedObject{
|
||||
|
||||
|
||||
private void handleKeyboardMovement(double updateMult, int movement, double friction, double drag) {
|
||||
if (movement!=0) {
|
||||
if (movement!=0&&Math.abs(x_velocity)<WALKING_SPEED_LIMIT) {
|
||||
x_acceleration=drag*(movement);
|
||||
} else {
|
||||
if (x_velocity!=0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user