Merge branch 'master' of github.com:ralucado/WaveGGJ17

This commit is contained in:
Ralusama19 2017-01-21 20:57:45 +01:00
commit d8858018de
3 changed files with 9 additions and 10 deletions

View file

@ -3,7 +3,7 @@
Character::Character(int player){
playerNum = player;
ASSERT(texture.loadFromFile(spriteFile));
height = texture.getSize().y/6;
height = texture.getSize().y/8;
width = texture.getSize().x/4;
timestamp = indexX = idleFrame = 0;
indexY = magicNumber;
@ -18,7 +18,7 @@ Character::Character(int player){
}
else{
setPosition(posX2, posY2);
magicNumber = 3;
magicNumber = 4;
}
}
@ -35,16 +35,10 @@ void Character::update(float deltaTime){
indexX = (indexX+1)%4;
//Acabar automaticament la animacio de attack
if (actualState == PlayerState::attacking and indexX%4 == 3){
if ((actualState == PlayerState::attacking or actualState == PlayerState::hurt or actualState == PlayerState::success) and indexX%4 == 3){
setState(PlayerState::idle);
}
//Acabar automaticament la animacio de hurt
if (actualState == PlayerState::hurt and indexX%4 == 3){
setState(PlayerState::idle);
}
idleFrame = (idleFrame+1)%4;
}
}
@ -67,6 +61,11 @@ void Character::setState(PlayerState::playerState state){
indexX = 0;
indexY = 2 + magicNumber;
}
else if (state == PlayerState::success){
std::cout << "i am succeed!" << std::endl;
indexX = 0;
indexY = 3 + magicNumber;
}
}
bool Character::isLastFrame(){

View file

@ -43,7 +43,7 @@ enum gameScene{menu,inGame,help,credits};
}
namespace PlayerState {
enum playerState{idle, attacking, inMidle, hurt};
enum playerState{idle, attacking, inMidle, hurt, success};
}
#endif // COMMONS_HPP