diff --git a/VaporWaveWars/character.cpp b/VaporWaveWars/character.cpp index 97c30ea..6be6e65 100644 --- a/VaporWaveWars/character.cpp +++ b/VaporWaveWars/character.cpp @@ -1,6 +1,7 @@ #include "character.hpp" -Character::Character(){ +Character::Character(int player){ + playerNum = player; ASSERT(texture.loadFromFile(spriteFile)); height = texture.getSize().y/5; width = texture.getSize().x/5; @@ -9,6 +10,13 @@ Character::Character(){ sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height); setTextureRect(rect); actualState = previousState = PlayerState::idle; + + if (playerNum == 0){ + setPosition(posX1, posY1); + } + else{ + setPosition(posX2, posY2); + } } void Character::update(float deltaTime){ @@ -17,8 +25,7 @@ void Character::update(float deltaTime){ timestamp = 0; if (actualState == PlayerState::attacking and indexX >= 3){ - actualState = PlayerState::idle; - indexX = 0; + setState(PlayerState::idle); } else { indexX = (indexX+1)%4; diff --git a/VaporWaveWars/character.hpp b/VaporWaveWars/character.hpp index 3f84c1a..c6bf67f 100644 --- a/VaporWaveWars/character.hpp +++ b/VaporWaveWars/character.hpp @@ -8,16 +8,20 @@ private: const double frameTime = 0.2; const int numFrames = 4; const std::string spriteFile = "./Resources/spreadsheet.png"; + //POSICIO PLAYER 1 + float posX1 = 0, posY1 = 0; + //POSICIO PLAYER 2 + float posX2 = 300, posY2 = 0; //END CONFIG sf::Texture texture; int indexX, indexY, width, height; - int posX, posY; + int playerNum; PlayerState::playerState actualState, previousState; float timestamp, next; public: - Character(); + Character(int player); void update(float deltaTime); void setState(PlayerState::playerState state); 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 caf5d43..714c3a9 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