Attack combo state setup
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
4531e1653c
commit
57f9a1d132
@ -21,6 +21,9 @@ public class Player extends PhysicsObject{
|
|||||||
final static long slide_AnimationWaitTime = TimeUtils.millisToNanos(100);
|
final static long slide_AnimationWaitTime = TimeUtils.millisToNanos(100);
|
||||||
final static long slide_duration = TimeUtils.millisToNanos(700);
|
final static long slide_duration = TimeUtils.millisToNanos(700);
|
||||||
final static long weaponSwingAnimationTime = TimeUtils.millisToNanos(333);
|
final static long weaponSwingAnimationTime = TimeUtils.millisToNanos(333);
|
||||||
|
final static long weaponComboWaitTime = TimeUtils.millisToNanos(60);
|
||||||
|
final static double finalComboJumpBackSpeedX = -150;
|
||||||
|
final static double finalComboJumpBackSpeedY = -96;
|
||||||
|
|
||||||
long weaponSwingTime = 0;
|
long weaponSwingTime = 0;
|
||||||
|
|
||||||
@ -75,6 +78,16 @@ public class Player extends PhysicsObject{
|
|||||||
state=State.IDLE;
|
state=State.IDLE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ATTACK2:
|
||||||
|
if (RabiClone.TIME - weaponSwingTime > weaponSwingAnimationTime) {
|
||||||
|
state=State.IDLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ATTACK3:
|
||||||
|
if (RabiClone.TIME - weaponSwingTime > weaponSwingAnimationTime) {
|
||||||
|
state=State.IDLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case FALLING:
|
case FALLING:
|
||||||
if (prvState != State.FALLING) {
|
if (prvState != State.FALLING) {
|
||||||
jump_slide_fall_StartAnimationTimer = RabiClone.TIME;
|
jump_slide_fall_StartAnimationTimer = RabiClone.TIME;
|
||||||
@ -157,7 +170,8 @@ public class Player extends PhysicsObject{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prvState = state;
|
prvState = state;
|
||||||
if (KeyHeld(Action.JUMP) && RabiClone.TIME - spacebarPressed < jumpHoldTime) {
|
if (KeyHeld(Action.JUMP) && RabiClone.TIME - spacebarPressed < jumpHoldTime
|
||||||
|
&& state!=State.ATTACK2&&state!=State.ATTACK3) {
|
||||||
y_velocity = jump_velocity;
|
y_velocity = jump_velocity;
|
||||||
}
|
}
|
||||||
// System.out.println(state);
|
// System.out.println(state);
|
||||||
@ -183,6 +197,24 @@ public class Player extends PhysicsObject{
|
|||||||
public void KeyPressed(Action a) {
|
public void KeyPressed(Action a) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case ATTACK:
|
case ATTACK:
|
||||||
|
if (a==Action.ATTACK&&RabiClone.TIME-weaponSwingTime>weaponComboWaitTime) {
|
||||||
|
state=State.ATTACK2;
|
||||||
|
weaponSwingTime=RabiClone.TIME;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ATTACK2:
|
||||||
|
if (a==Action.ATTACK&&RabiClone.TIME-weaponSwingTime>weaponComboWaitTime) {
|
||||||
|
state=State.ATTACK3;
|
||||||
|
weaponSwingTime=RabiClone.TIME;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ATTACK3:
|
||||||
|
if (a==Action.ATTACK&&RabiClone.TIME-weaponSwingTime>weaponComboWaitTime) {
|
||||||
|
state=State.ATTACK4;
|
||||||
|
weaponSwingTime=RabiClone.TIME;
|
||||||
|
y_velocity = finalComboJumpBackSpeedY;
|
||||||
|
x_velocity = finalComboJumpBackSpeedX*(facing_direction?1:-1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case IDLE:
|
case IDLE:
|
||||||
if (a == Action.SLIDE || a == Action.FALL) {
|
if (a == Action.SLIDE || a == Action.FALL) {
|
||||||
@ -217,7 +249,8 @@ public class Player extends PhysicsObject{
|
|||||||
weaponSwingTime=RabiClone.TIME;
|
weaponSwingTime=RabiClone.TIME;
|
||||||
}
|
}
|
||||||
if (groundCollision) {
|
if (groundCollision) {
|
||||||
if (spacebarReleased && (a == Action.JUMP) && jumpCount > 0) {
|
if (spacebarReleased && (a == Action.JUMP) && jumpCount > 0
|
||||||
|
&&state!=State.ATTACK2&&state!=State.ATTACK3) {
|
||||||
state = State.JUMP;
|
state = State.JUMP;
|
||||||
jumpCount--;
|
jumpCount--;
|
||||||
y_velocity = jump_velocity;
|
y_velocity = jump_velocity;
|
||||||
@ -356,12 +389,12 @@ public class Player extends PhysicsObject{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean rightKeyHeld() {
|
public boolean rightKeyHeld() {
|
||||||
return KeyHeld(Action.MOVE_RIGHT);
|
return state!=State.ATTACK2&&state!=State.ATTACK3&&KeyHeld(Action.MOVE_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean leftKeyHeld() {
|
public boolean leftKeyHeld() {
|
||||||
return KeyHeld(Action.MOVE_LEFT);
|
return state!=State.ATTACK2&&state!=State.ATTACK3&&KeyHeld(Action.MOVE_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getYVelocity() {
|
public double getYVelocity() {
|
||||||
|
@ -6,6 +6,9 @@ public enum State{
|
|||||||
JUMP,
|
JUMP,
|
||||||
FALLING,
|
FALLING,
|
||||||
ATTACK,
|
ATTACK,
|
||||||
|
ATTACK2,
|
||||||
|
ATTACK3,
|
||||||
|
ATTACK4,
|
||||||
STAGGER,
|
STAGGER,
|
||||||
UNCONTROLLABLE
|
UNCONTROLLABLE
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user