added death animation
This commit is contained in:
parent
cba2ebf03c
commit
2a8724cb7e
5 changed files with 16 additions and 2 deletions
|
@ -21,6 +21,10 @@ bool Actor::update(float deltaTime, sf::RenderWindow *window) {
|
|||
character->setState(PlayerState::attacking);
|
||||
animate = PlayerState::inMidle;
|
||||
}
|
||||
else if (animate == PlayerState::hurt) {
|
||||
character->setState(PlayerState::hurt);
|
||||
animate = PlayerState::inMidle;
|
||||
}
|
||||
else if (animate == PlayerState::inMidle) {
|
||||
if (character->isLastFrame()) animate = PlayerState::idle;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,12 @@ void Character::update(float deltaTime){
|
|||
setState(PlayerState::idle);
|
||||
}
|
||||
|
||||
//Acabar automaticament la animacio de hurt
|
||||
if (actualState == PlayerState::hurt and indexX%4 == 3){
|
||||
setState(PlayerState::idle);
|
||||
}
|
||||
|
||||
|
||||
idleFrame = (idleFrame+1)%4;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +62,8 @@ void Character::setState(PlayerState::playerState state){
|
|||
SoundManager::playSound(sample);
|
||||
std::cout << "playing sample " << sample << std::endl;
|
||||
}
|
||||
else if (false /*state == PlayerState::damaged*/){
|
||||
else if (state == PlayerState::hurt){
|
||||
std::cout << "i am hurt" << std::endl;
|
||||
indexX = 0;
|
||||
indexY = 2 + magicNumber;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ void Combat::update(float deltaTime, sf::RenderWindow *window) {
|
|||
bool aux = enemy->update(deltaTime, window);
|
||||
if (ia) enemyManager(aux); //end of player two ia ritm
|
||||
time += deltaTime;
|
||||
|
||||
_shader.setParameter("time", time);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ enum gameScene{menu,inGame,help,credits};
|
|||
}
|
||||
|
||||
namespace PlayerState {
|
||||
enum playerState{idle, attacking, inMidle};
|
||||
enum playerState{idle, attacking, inMidle, hurt};
|
||||
}
|
||||
|
||||
#endif // COMMONS_HPP
|
||||
|
|
|
@ -30,6 +30,8 @@ bool Player::event(sf::Event e) {
|
|||
else {
|
||||
compas.end();
|
||||
error = true; //weird?
|
||||
if (animate != PlayerState::inMidle) animate = PlayerState::hurt;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Reference in a new issue