diff --git a/VaporWaveWars/character.cpp b/VaporWaveWars/character.cpp index 4a822fd..61c226d 100644 --- a/VaporWaveWars/character.cpp +++ b/VaporWaveWars/character.cpp @@ -3,14 +3,14 @@ Character::Character(int player){ playerNum = player; ASSERT(texture.loadFromFile(spriteFile)); - height = texture.getSize().y/5; - width = texture.getSize().x/5; - next = timestamp = indexX = 0; + height = texture.getSize().y/6; + width = texture.getSize().x/4; + timestamp = indexX = 0; indexY = magicNumber; setTexture(texture); sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height); setTextureRect(rect); - actualState = previousState = PlayerState::idle; + actualState = PlayerState::idle; if (playerNum == 0){ setPosition(posX1, posY1); @@ -18,7 +18,7 @@ Character::Character(int player){ } else{ setPosition(posX2, posY2); - magicNumber = 2; + magicNumber = 3; } } @@ -40,15 +40,23 @@ void Character::update(float deltaTime){ } void Character::setState(PlayerState::playerState state){ - previousState = actualState; actualState = state; if (state == PlayerState::idle){ indexX = 0; indexY = 0 + magicNumber; } - else{ + else if (state == PlayerState::attacking){ indexX = 0; indexY = 1 + magicNumber; } + else if (false /*state == PlayerState::damaged*/){ + indexX = 0; + indexY = 2 + magicNumber; + } } +bool Character::isLastFrame(){ + return indexX == 3; +} + + diff --git a/VaporWaveWars/character.hpp b/VaporWaveWars/character.hpp index a06ce68..0d62351 100644 --- a/VaporWaveWars/character.hpp +++ b/VaporWaveWars/character.hpp @@ -19,14 +19,15 @@ private: sf::Texture texture; int indexX, indexY, width, height; int playerNum; - PlayerState::playerState actualState, previousState; - float timestamp, next; + PlayerState::playerState actualState; + float timestamp; public: Character(); Character(int player); void update(float deltaTime); void setState(PlayerState::playerState state); + bool isLastFrame(); }; diff --git a/build-VaporWaveWars-Desktop_Qt_5_7_0_GCC_64bit-Debug/VaporWaveWars b/build-VaporWaveWars-Desktop_Qt_5_7_0_GCC_64bit-Debug/VaporWaveWars index 642efd5..d1ece01 100755 Binary files a/build-VaporWaveWars-Desktop_Qt_5_7_0_GCC_64bit-Debug/VaporWaveWars and b/build-VaporWaveWars-Desktop_Qt_5_7_0_GCC_64bit-Debug/VaporWaveWars differ