Added controller vibration for world shake events/player hurt events.
This commit is contained in:
@@ -51,6 +51,7 @@ All rights reserved.
|
||||
#include "config.h"
|
||||
#include <string_view>
|
||||
#include "SoundEffect.h"
|
||||
#include "olcPGEX_Gamepad.h"
|
||||
|
||||
INCLUDE_MONSTER_DATA
|
||||
INCLUDE_MONSTER_LIST
|
||||
@@ -284,6 +285,18 @@ void Player::Update(float fElapsedTime){
|
||||
notEnoughManaDisplay.second=std::max(0.f,notEnoughManaDisplay.second-fElapsedTime);
|
||||
notificationDisplay.second=std::max(0.f,notificationDisplay.second-fElapsedTime);
|
||||
lastHitTimer=std::max(0.f,lastHitTimer-fElapsedTime);
|
||||
if(hurtRumbleTime>0.f){
|
||||
hurtRumbleTime=std::max(0.f,hurtRumbleTime-fElapsedTime);
|
||||
if(hurtRumbleTime==0.f){
|
||||
#pragma region Gamepad Stop Vibration
|
||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||
if(gamepad->stillConnected){
|
||||
gamepad->stopVibration();
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
}
|
||||
}
|
||||
blockTimer=std::max(0.f,blockTimer-fElapsedTime);
|
||||
lastCombatTime=lastCombatTime+fElapsedTime;
|
||||
manaTickTimer-=fElapsedTime;
|
||||
@@ -704,6 +717,16 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z){
|
||||
SoundEffect::PlaySFX("Player Hit",SoundEffect::CENTERED);
|
||||
}
|
||||
hp=std::max(0,hp-int(mod_dmg));
|
||||
|
||||
#pragma region Gamepad Vibration
|
||||
hurtRumbleTime="Player.Hurt Rumble Time"_F;
|
||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||
if(gamepad->stillConnected){
|
||||
gamepad->startVibration();
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
if(lastHitTimer>0){
|
||||
damageNumberPtr.get()->damage+=int(mod_dmg);
|
||||
damageNumberPtr.get()->pauseTime=0.4f;
|
||||
|
||||
Reference in New Issue
Block a user