@ -379,6 +379,7 @@ void AiL::HandleUserInput(float fElapsedTime){
return std : : string ( " NONE " ) ;
} ;
std : : string staircaseDirection = GetPlayerStaircaseDirection ( ) ;
vf2d newAimingAngle { } ;
if ( RightHeld ( ) ) {
player - > SetX ( player - > GetX ( ) + fElapsedTime * " Player.MoveSpd " _F * player - > GetMoveSpdMult ( ) ) ;
player - > movementVelocity . x = " Player.MoveSpd " _F ;
@ -394,6 +395,9 @@ void AiL::HandleUserInput(float fElapsedTime){
if ( player - > GetState ( ) = = State : : NORMAL | | player - > GetState ( ) = = State : : PREP_CAST ) {
player - > UpdateWalkingAnimation ( RIGHT ) ;
}
newAimingAngle + = vf2d { 1 , 0 } ;
setIdleAnimation = false ;
heldDownMovementKey = true ;
}
@ -414,6 +418,9 @@ void AiL::HandleUserInput(float fElapsedTime){
player - > UpdateWalkingAnimation ( LEFT ) ;
}
}
newAimingAngle - = vf2d { 1 , 0 } ;
setIdleAnimation = false ;
heldDownMovementKey = true ;
}
@ -426,6 +433,9 @@ void AiL::HandleUserInput(float fElapsedTime){
player - > UpdateWalkingAnimation ( UP ) ;
}
}
newAimingAngle - = vf2d { 0 , 1 } ;
setIdleAnimation = false ;
heldDownMovementKey = true ;
}
@ -438,9 +448,15 @@ void AiL::HandleUserInput(float fElapsedTime){
player - > UpdateWalkingAnimation ( DOWN ) ;
}
}
newAimingAngle + = vf2d { 0 , 1 } ;
setIdleAnimation = false ;
heldDownMovementKey = true ;
}
if ( newAimingAngle ! = vf2d { } ) {
player - > aimingAngle = newAimingAngle . norm ( ) . polar ( ) ;
}
}
if ( UpReleased ( ) ) {
player - > SetLastReleasedMovementKey ( UP ) ;
@ -567,13 +583,7 @@ void AiL::UpdateCamera(float fElapsedTime){
worldShakeTime - = fElapsedTime ;
if ( worldShakeTime < = 0 ) {
camera . SetTarget ( player - > GetPos ( ) ) ;
# pragma region Gamepad Stop Vibration
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected ) {
gamepad - > stopVibration ( ) ;
}
}
# pragma endregion
Input : : StopVibration ( ) ;
}
if ( lastWorldShakeAdjust = = 0 ) {
lastWorldShakeAdjust = 0.02f ;
@ -1050,10 +1060,10 @@ void AiL::RenderWorld(float fElapsedTime){
float precastSize = GetPlayer ( ) - > castPrepAbility - > precastInfo . size ;
float precastRange = GetPlayer ( ) - > castPrepAbility - > precastInfo . range ;
vf2d scale = vf2d { precastSize , precastSize } * 2 / 3.f ;
vf2d centerPoint = GetWorldMousePos ( ) - vf2d { GFX [ " circle.png " ] . Sprite ( ) - > width * scale . x / 2 , GFX [ " circle.png " ] . Sprite ( ) - > height * scale . y / 2 } ;
float distance = float ( sqrt ( pow ( player - > GetX ( ) - GetWorldMousePos ( ) . x , 2 ) + pow ( player - > GetY ( ) - GetWorldMousePos ( ) . y , 2 ) ) ) ;
vf2d centerPoint = GetPlayer ( ) - > GetWorldAimingLocation ( ) - vf2d { GFX [ " circle.png " ] . Sprite ( ) - > width * scale . x / 2 , GFX [ " circle.png " ] . Sprite ( ) - > height * scale . y / 2 } ;
float distance = float ( sqrt ( pow ( player - > GetX ( ) - GetPlayer ( ) - > GetWorldAimingLocation ( ) . x , 2 ) + pow ( player - > GetY ( ) - GetPlayer ( ) - > GetWorldAimingLocation ( ) . y , 2 ) ) ) ;
if ( distance > precastRange ) { //Clamp the distance.
vf2d pointToCursor = { GetWorldMousePos ( ) . x - player - > GetX ( ) , GetWorldMousePos ( ) . y - player - > GetY ( ) } ;
vf2d pointToCursor = { GetPlayer ( ) - > GetWorldAimingLocation ( ) . x - player - > GetX ( ) , GetPlayer ( ) - > GetWorldAimingLocation ( ) . y - player - > GetY ( ) } ;
pointToCursor = pointToCursor . norm ( ) * precastRange ;
vf2d centerPoint = player - > GetPos ( ) + pointToCursor - vf2d { GFX [ " circle.png " ] . Sprite ( ) - > width * scale . x / 2 , GFX [ " circle.png " ] . Sprite ( ) - > height * scale . y / 2 } ;
view . DrawDecal ( centerPoint , GFX [ " circle.png " ] . Decal ( ) , scale , { 255 , 0 , 0 , 96 } ) ;
@ -1379,6 +1389,31 @@ Player*AiL::GetPlayer(){
}
void AiL : : RenderHud ( ) {
auto RenderAimingCursor = [ & ] ( ) {
if ( Input : : UsingGamepad ( ) & & Input : : AxesActive ( ) ) {
vf2d aimingLocation = player - > GetAimingLocation ( ) ;
float analogStickDistance = geom2d : : line < float > ( GetScreenSize ( ) / 2 , aimingLocation ) . length ( ) ;
if ( analogStickDistance > 12.f ) {
float aimingDist = geom2d : : line < float > ( view . WorldToScreen ( player - > GetPos ( ) ) , aimingLocation ) . length ( ) ;
if ( aimingDist > " Player.Aiming Cursor Max Distance " _F / 100 * 24.f ) {
//Clamp the line to the max possible distance.
aimingLocation = geom2d : : line < float > ( view . WorldToScreen ( player - > GetPos ( ) ) , aimingLocation ) . rpoint ( " Player.Aiming Cursor Max Distance " _F / 100 * 24.f ) ;
aimingDist = geom2d : : line < float > ( view . WorldToScreen ( player - > GetPos ( ) ) , aimingLocation ) . length ( ) ;
}
geom2d : : line < float > aimingLine = geom2d : : line < float > ( view . WorldToScreen ( player - > GetPos ( ) ) , aimingLocation ) ;
DrawRotatedDecal ( aimingLocation , GFX [ " aiming_target.png " ] . Decal ( ) , 0.f , GFX [ " aiming_target.png " ] . Sprite ( ) - > Size ( ) / 2 , { 1.0f , 1.0f } , { 255 , 255 , 255 , 128 } ) ;
vf2d lineScale = vf2d ( GFX [ " aiming_line.png " ] . Sprite ( ) - > Size ( ) ) * vf2d { aimingDist / GFX [ " aiming_line.png " ] . Sprite ( ) - > width , 1 } ;
DrawPartialRotatedDecal ( view . WorldToScreen ( player - > GetPos ( ) ) , GFX [ " aiming_line.png " ] . Decal ( ) , aimingLine . vector ( ) . polar ( ) . y , { 0 , 0 } , { 0 , 0 } , lineScale , vf2d { aimingDist , 1.f } / lineScale , { 255 , 255 , 255 , 192 } ) ;
}
}
} ;
RenderAimingCursor ( ) ;
ItemOverlay : : Draw ( ) ;
RenderCooldowns ( ) ;
@ -1560,13 +1595,7 @@ void AiL::SetupWorldShake(float duration){
worldShakeTime = duration ;
worldShake = vf2d { player - > GetPos ( ) } ;
camera . SetTarget ( worldShake ) ;
# pragma region Controller Vibration
for ( GamePad * gamepad : GamePad : : getGamepads ( ) ) {
if ( gamepad - > stillConnected ) {
gamepad - > startVibration ( ) ;
}
}
# pragma endregion
Input : : StartVibration ( ) ;
}
@ -2315,7 +2344,7 @@ void AiL::InitializeDefaultKeybinds(){
Player : : KEY_ABILITY3 . AddKeybind ( { KEY , R } ) ;
Player : : KEY_ABILITY3 . AddKeybind ( { CONTROLLER , static_cast < int > ( GPButtons : : FACE_R ) } ) ;
Player : : KEY_ABILITY4 . AddKeybind ( { KEY , F } ) ;
Player : : KEY_ABILITY4 . AddKeybind ( { CONTROLLER , static_cast < int > ( GPButtons : : L2 ) } ) ;
Player : : KEY_ABILITY4 . AddKeybind ( { CONTROLLER , static_cast < int > ( GPButtons : : FACE_D ) } ) ;
Player : : KEY_DEFENSIVE . AddKeybind ( { MOUSE , Mouse : : RIGHT } ) ;
Player : : KEY_DEFENSIVE . AddKeybind ( { KEY , SPACE } ) ;
Player : : KEY_DEFENSIVE . AddKeybind ( { CONTROLLER , static_cast < int > ( GPButtons : : R2 ) } ) ;
@ -2326,7 +2355,7 @@ void AiL::InitializeDefaultKeybinds(){
Player : : KEY_ITEM3 . AddKeybind ( { KEY , K3 } ) ;
Player : : KEY_ITEM3 . AddKeybind ( { CONTROLLER , static_cast < int > ( GPButtons : : R3 ) } ) ;
KEY_ATTACK . AddKeybind ( { MOUSE , Mouse : : LEFT } ) ;
KEY_ATTACK . AddKeybind ( { CONTROLLER , static_cast < int > ( GPButtons : : FACE_D ) } ) ;
KEY_ATTACK . AddKeybind ( { CONTROLLER , static_cast < int > ( GPButtons : : L2 ) } ) ;
KEY_LEFT . AddKeybind ( { KEY , LEFT } ) ;
KEY_LEFT . AddKeybind ( { KEY , A } ) ;
KEY_LEFT . AddKeybind ( { CONTROLLER , static_cast < int > ( GPButtons : : DPAD_L ) } ) ;