Merge branch 'master' of https://github.com/ralucado/WaveGGJ17
This commit is contained in:
commit
704bbb068c
2 changed files with 17 additions and 3 deletions
|
@ -5,8 +5,11 @@ Character::Character(){
|
||||||
ASSERT(texture.loadFromFile(spriteFile));
|
ASSERT(texture.loadFromFile(spriteFile));
|
||||||
height = texture.getSize().y;
|
height = texture.getSize().y;
|
||||||
width = texture.getSize().x;
|
width = texture.getSize().x;
|
||||||
next = 0;
|
next = timestamp = indexX = indexY = 0;
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
|
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
||||||
|
setTextureRect(rect);
|
||||||
|
actualState = previousState = PlayerState::idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::update(float deltaTime){
|
void Character::update(float deltaTime){
|
||||||
|
@ -26,11 +29,15 @@ void Character::update(float deltaTime){
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
indexX = 0;
|
indexX = 0;
|
||||||
if (actualState == PlayerState::idle)
|
if (actualState == PlayerState::idle){
|
||||||
|
indexY = 1;
|
||||||
actualState = PlayerState::attacking;
|
actualState = PlayerState::attacking;
|
||||||
|
}
|
||||||
|
|
||||||
else if (actualState == PlayerState::attacking)
|
else if (actualState == PlayerState::attacking){
|
||||||
|
indexY = 0;
|
||||||
actualState = PlayerState::idle;
|
actualState = PlayerState::idle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
||||||
|
@ -38,3 +45,8 @@ void Character::update(float deltaTime){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Character::setState(PlayerState::playerState state){
|
||||||
|
previousState = actualState;
|
||||||
|
actualState = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
class Character : public sf::Sprite{
|
class Character : public sf::Sprite{
|
||||||
private:
|
private:
|
||||||
|
//CONSTS
|
||||||
const double frameTime = 0.2;
|
const double frameTime = 0.2;
|
||||||
const int numFrames = 4;
|
const int numFrames = 4;
|
||||||
const std::string spriteFile = "";
|
const std::string spriteFile = "";
|
||||||
|
//CONSTS
|
||||||
|
|
||||||
int indexX, indexY, width, height;
|
int indexX, indexY, width, height;
|
||||||
int posX, posY;
|
int posX, posY;
|
||||||
|
|
Reference in a new issue