getter
This commit is contained in:
parent
350c07715d
commit
1184a03f5f
3 changed files with 18 additions and 9 deletions
|
@ -3,14 +3,14 @@
|
||||||
Character::Character(int player){
|
Character::Character(int player){
|
||||||
playerNum = player;
|
playerNum = player;
|
||||||
ASSERT(texture.loadFromFile(spriteFile));
|
ASSERT(texture.loadFromFile(spriteFile));
|
||||||
height = texture.getSize().y/5;
|
height = texture.getSize().y/6;
|
||||||
width = texture.getSize().x/5;
|
width = texture.getSize().x/4;
|
||||||
next = timestamp = indexX = 0;
|
timestamp = indexX = 0;
|
||||||
indexY = magicNumber;
|
indexY = magicNumber;
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
||||||
setTextureRect(rect);
|
setTextureRect(rect);
|
||||||
actualState = previousState = PlayerState::idle;
|
actualState = PlayerState::idle;
|
||||||
|
|
||||||
if (playerNum == 0){
|
if (playerNum == 0){
|
||||||
setPosition(posX1, posY1);
|
setPosition(posX1, posY1);
|
||||||
|
@ -18,7 +18,7 @@ Character::Character(int player){
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
setPosition(posX2, posY2);
|
setPosition(posX2, posY2);
|
||||||
magicNumber = 2;
|
magicNumber = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,15 +40,23 @@ void Character::update(float deltaTime){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::setState(PlayerState::playerState state){
|
void Character::setState(PlayerState::playerState state){
|
||||||
previousState = actualState;
|
|
||||||
actualState = state;
|
actualState = state;
|
||||||
if (state == PlayerState::idle){
|
if (state == PlayerState::idle){
|
||||||
indexX = 0;
|
indexX = 0;
|
||||||
indexY = 0 + magicNumber;
|
indexY = 0 + magicNumber;
|
||||||
}
|
}
|
||||||
else{
|
else if (state == PlayerState::attacking){
|
||||||
indexX = 0;
|
indexX = 0;
|
||||||
indexY = 1 + magicNumber;
|
indexY = 1 + magicNumber;
|
||||||
}
|
}
|
||||||
|
else if (false /*state == PlayerState::damaged*/){
|
||||||
|
indexX = 0;
|
||||||
|
indexY = 2 + magicNumber;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Character::isLastFrame(){
|
||||||
|
return indexX == 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,15 @@ private:
|
||||||
sf::Texture texture;
|
sf::Texture texture;
|
||||||
int indexX, indexY, width, height;
|
int indexX, indexY, width, height;
|
||||||
int playerNum;
|
int playerNum;
|
||||||
PlayerState::playerState actualState, previousState;
|
PlayerState::playerState actualState;
|
||||||
float timestamp, next;
|
float timestamp;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Character();
|
Character();
|
||||||
Character(int player);
|
Character(int player);
|
||||||
void update(float deltaTime);
|
void update(float deltaTime);
|
||||||
void setState(PlayerState::playerState state);
|
void setState(PlayerState::playerState state);
|
||||||
|
bool isLastFrame();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Binary file not shown.
Reference in a new issue