@ -453,6 +453,7 @@ void AiL::HandleUserInput(float fElapsedTime){
if ( KEY_MENU . Released ( ) ) {
Menu : : OpenMenu ( MenuType : : PAUSE ) ;
}
float animationSpd = 0.f ;
if ( player - > GetVelocity ( ) . mag ( ) < " Player.Move Allowed Velocity Lower Limit " _F & & player - > CanMove ( ) ) {
auto GetPlayerStaircaseDirection = [ & ] ( ) {
for ( LayerTag & layer : MAP_DATA [ GetCurrentLevel ( ) ] . LayerData ) {
@ -469,20 +470,29 @@ void AiL::HandleUserInput(float fElapsedTime){
std : : string staircaseDirection = GetPlayerStaircaseDirection ( ) ;
vf2d newAimingAngle { } ;
if ( RightHeld ( ) ) {
player - > SetX ( player - > GetX ( ) + fElapsedTime * " Player.MoveSpd " _F * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . x = " Player.MoveSpd " _F ;
float moveAmt = " Player.MoveSpd " _F ;
if ( Input : : UsingGamepad ( ) & & KEY_SCROLLHORZ_L . Analog ( ) > = 0.2f ) {
float controllerAmt = abs ( KEY_SCROLLHORZ_L . Analog ( ) ) ;
if ( controllerAmt > = 0.8f ) controllerAmt = 1.f ; //Edge zone.
if ( controllerAmt > animationSpd ) {
animationSpd = controllerAmt ;
}
moveAmt * = controllerAmt ;
} else
if ( ! Input : : UsingGamepad ( ) ) {
animationSpd = 1.f ;
}
player - > SetX ( player - > GetX ( ) + fElapsedTime * moveAmt * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . x = moveAmt * fElapsedTime * player - > GetMoveSpdMult ( ) ;
if ( staircaseDirection = = " RIGHT " ) {
player - > SetY ( player - > GetY ( ) - " Player.StaircaseClimbSpd " _F * fElapsedTime * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . y = - " Player.StaircaseClimbSpd " _F ;
player - > movementVelocity . y = - " Player.StaircaseClimbSpd " _F * fElapsedTime * player - > GetMoveSpdMult ( ) ;
} else
if ( staircaseDirection = = " LEFT " ) {
player - > SetY ( player - > GetY ( ) + " Player.StaircaseClimbSpd " _F * fElapsedTime * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . y = " Player.StaircaseClimbSpd " _F ;
player - > movementVelocity . y = " Player.StaircaseClimbSpd " _F * fElapsedTime * player - > GetMoveSpdMult ( ) ;
}
player - > SetFacingDirection ( RIGHT ) ;
if ( player - > GetState ( ) = = State : : NORMAL | | player - > GetState ( ) = = State : : PREP_CAST ) {
player - > UpdateWalkingAnimation ( RIGHT ) ;
}
newAimingAngle + = vf2d { 1 , 0 } ;
@ -490,21 +500,27 @@ void AiL::HandleUserInput(float fElapsedTime){
heldDownMovementKey = true ;
}
if ( LeftHeld ( ) ) {
player - > SetX ( player - > GetX ( ) - fElapsedTime * " Player.MoveSpd " _F * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . x = - " Player.MoveSpd " _F ;
float moveAmt = " Player.MoveSpd " _F ;
if ( Input : : UsingGamepad ( ) & & KEY_SCROLLHORZ_L . Analog ( ) < = - 0.2f ) {
float controllerAmt = abs ( KEY_SCROLLHORZ_L . Analog ( ) ) ;
if ( controllerAmt > = 0.8f ) controllerAmt = 1.f ; //Edge zone.
if ( controllerAmt > animationSpd ) {
animationSpd = controllerAmt ;
}
moveAmt * = abs ( KEY_SCROLLHORZ_L . Analog ( ) ) ;
} else
if ( ! Input : : UsingGamepad ( ) ) {
animationSpd = 1.f ;
}
player - > SetX ( player - > GetX ( ) - fElapsedTime * moveAmt * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . x = - moveAmt * fElapsedTime * player - > GetMoveSpdMult ( ) ;
if ( staircaseDirection = = " RIGHT " ) {
player - > SetY ( player - > GetY ( ) + " Player.StaircaseClimbSpd " _F * fElapsedTime * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . y = " Player.StaircaseClimbSpd " _F ;
player - > movementVelocity . y = " Player.StaircaseClimbSpd " _F * fElapsedTime * player - > GetMoveSpdMult ( ) ;
} else
if ( staircaseDirection = = " LEFT " ) {
player - > SetY ( player - > GetY ( ) - " Player.StaircaseClimbSpd " _F * fElapsedTime * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . y = - " Player.StaircaseClimbSpd " _F ;
}
if ( setIdleAnimation ) {
player - > SetFacingDirection ( LEFT ) ;
if ( player - > GetState ( ) = = State : : NORMAL | | player - > GetState ( ) = = State : : PREP_CAST ) {
player - > UpdateWalkingAnimation ( LEFT ) ;
}
player - > movementVelocity . y = - " Player.StaircaseClimbSpd " _F * fElapsedTime * player - > GetMoveSpdMult ( ) ;
}
newAimingAngle - = vf2d { 1 , 0 } ;
@ -513,14 +529,20 @@ void AiL::HandleUserInput(float fElapsedTime){
heldDownMovementKey = true ;
}
if ( UpHeld ( ) ) {
player - > SetY ( player - > GetY ( ) - fElapsedTime * " Player.MoveSpd " _F * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . y = - " Player.MoveSpd " _F * fElapsedTime ;
if ( setIdleAnimation ) {
player - > SetFacingDirection ( UP ) ;
if ( player - > GetState ( ) = = State : : NORMAL | | player - > GetState ( ) = = State : : PREP_CAST ) {
player - > UpdateWalkingAnimation ( UP ) ;
}
float moveAmt = " Player.MoveSpd " _F ;
if ( Input : : UsingGamepad ( ) & & KEY_SCROLLVERT_L . Analog ( ) < = - 0.2f ) {
float controllerAmt = abs ( KEY_SCROLLVERT_L . Analog ( ) ) ;
if ( controllerAmt > = 0.8f ) controllerAmt = 1.f ; //Edge zone.
if ( controllerAmt > animationSpd ) {
animationSpd = controllerAmt ;
}
moveAmt * = abs ( KEY_SCROLLVERT_L . Analog ( ) ) ;
} else
if ( ! Input : : UsingGamepad ( ) ) {
animationSpd = 1.f ;
}
player - > SetY ( player - > GetY ( ) - fElapsedTime * moveAmt * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . y = - moveAmt * fElapsedTime * player - > GetMoveSpdMult ( ) ;
newAimingAngle - = vf2d { 0 , 1 } ;
@ -528,14 +550,20 @@ void AiL::HandleUserInput(float fElapsedTime){
heldDownMovementKey = true ;
}
if ( DownHeld ( ) ) {
player - > SetY ( player - > GetY ( ) + fElapsedTime * " Player.MoveSpd " _F * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . y = " Player.MoveSpd " _F * fElapsedTime ;
if ( setIdleAnimation ) {
player - > SetFacingDirection ( DOWN ) ;
if ( player - > GetState ( ) = = State : : NORMAL | | player - > GetState ( ) = = State : : PREP_CAST ) {
player - > UpdateWalkingAnimation ( DOWN ) ;
}
float moveAmt = " Player.MoveSpd " _F ;
if ( Input : : UsingGamepad ( ) & & KEY_SCROLLVERT_L . Analog ( ) > = 0.2f ) {
float controllerAmt = abs ( KEY_SCROLLVERT_L . Analog ( ) ) ;
if ( controllerAmt > = 0.8f ) controllerAmt = 1.f ; //Edge zone.
if ( controllerAmt > animationSpd ) {
animationSpd = controllerAmt ;
}
moveAmt * = abs ( KEY_SCROLLVERT_L . Analog ( ) ) ;
} else
if ( ! Input : : UsingGamepad ( ) ) {
animationSpd = 1.f ;
}
player - > SetY ( player - > GetY ( ) + fElapsedTime * moveAmt * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . y = moveAmt * fElapsedTime * player - > GetMoveSpdMult ( ) ;
newAimingAngle + = vf2d { 0 , 1 } ;
@ -546,6 +574,23 @@ void AiL::HandleUserInput(float fElapsedTime){
player - > aimingAngle = newAimingAngle . norm ( ) . polar ( ) ;
}
}
if ( heldDownMovementKey ) {
if ( abs ( player - > movementVelocity . x ) > abs ( player - > movementVelocity . y ) ) { //Greater Horizontal movement.
if ( player - > movementVelocity . x ! = 0.f ) {
player - > SetFacingDirection ( player - > movementVelocity . x > 0 ? RIGHT : LEFT ) ;
if ( player - > GetState ( ) = = State : : NORMAL | | player - > GetState ( ) = = State : : PREP_CAST ) {
player - > UpdateWalkingAnimation ( player - > GetFacingDirection ( ) , animationSpd ) ;
}
}
} else { //Greater Vertical movement.
if ( player - > movementVelocity . y ! = 0.f ) {
player - > SetFacingDirection ( player - > movementVelocity . y > 0 ? DOWN : UP ) ;
if ( player - > GetState ( ) = = State : : NORMAL | | player - > GetState ( ) = = State : : PREP_CAST ) {
player - > UpdateWalkingAnimation ( player - > GetFacingDirection ( ) , animationSpd ) ;
}
}
}
}
if ( UpReleased ( ) ) {
player - > SetLastReleasedMovementKey ( UP ) ;
player - > movementVelocity . y = 0 ;
@ -612,7 +657,7 @@ void AiL::HandleUserInput(float fElapsedTime){
}
if ( heldDownMovementKey ) {
player - > footstepTimer + = GetElapsedTime ( ) ;
player - > footstepTimer + = GetElapsedTime ( ) * animationSpd ;
if ( player - > footstepTimer > " Player.Footstep Timer " _F ) {
player - > footstepTimer - = " Player.Footstep Timer " _F ;