summaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-02 23:05:46 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-02 23:05:46 +0000
commit8676da1517a86105e4cb4970fd3a7886f7d0c214 (patch)
tree5c4b3b7748c62d9375799f375e13c4b58a89498a /src/player.cpp
parent8714de88fe9715b5a4014f16d15bc55f8860cdcf (diff)
downloadmana-8676da1517a86105e4cb4970fd3a7886f7d0c214.tar.gz
mana-8676da1517a86105e4cb4970fd3a7886f7d0c214.tar.bz2
mana-8676da1517a86105e4cb4970fd3a7886f7d0c214.tar.xz
mana-8676da1517a86105e4cb4970fd3a7886f7d0c214.zip
Some cleanups, fixes and a small start on a solution for the animated sprite
synchronization problem (resetting all animations).
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 096520cb..2e119e2d 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -90,11 +90,13 @@ Player::setSex(Uint8 sex)
delete mSprites[BASE_SPRITE];
if (sex == 0)
{
- mSprites[BASE_SPRITE] = new AnimatedSprite("graphics/sprites/player_male_base.xml", 0);
+ mSprites[BASE_SPRITE] = new AnimatedSprite(
+ "graphics/sprites/player_male_base.xml", 0);
}
else
{
- mSprites[BASE_SPRITE] = new AnimatedSprite("graphics/sprites/player_female_base.xml", 0);
+ mSprites[BASE_SPRITE] = new AnimatedSprite(
+ "graphics/sprites/player_female_base.xml", 0);
}
}
Being::setSex(sex);
@@ -109,10 +111,17 @@ Player::setHairColor(Uint16 color)
{
delete mSprites[HAIR_SPRITE];
}
- mSprites[HAIR_SPRITE] = new AnimatedSprite("graphics/sprites/hairstyle"+toString(mHairStyle)+".xml", color - 1);
+
+ AnimatedSprite *newHairSprite = new AnimatedSprite(
+ "graphics/sprites/hairstyle" + toString(mHairStyle) + ".xml",
+ color - 1);
+ newHairSprite->setDirection(getSpriteDirection());
+
+ mSprites[HAIR_SPRITE] = newHairSprite;
+
+ setAction(mAction);
}
- setDirection(mDirection);
- setAction(mAction);
+
Being::setHairColor(color);
};
@@ -125,10 +134,17 @@ Player::setHairStyle(Uint16 style)
{
delete mSprites[HAIR_SPRITE];
}
- mSprites[HAIR_SPRITE] = new AnimatedSprite("graphics/sprites/hairstyle"+toString(style)+".xml", mHairColor - 1);
+
+ AnimatedSprite *newHairSprite = new AnimatedSprite(
+ "graphics/sprites/hairstyle" + toString(style) + ".xml",
+ mHairColor - 1);
+ newHairSprite->setDirection(getSpriteDirection());
+
+ mSprites[HAIR_SPRITE] = newHairSprite;
+
+ setAction(mAction);
}
- setDirection(mDirection);
- setAction(mAction);
+
Being::setHairStyle(style);
};
@@ -151,16 +167,21 @@ Player::setVisibleEquipment(Uint8 slot, Uint8 id)
// id = 0 means unequip
if (mSprites[position]) {
delete mSprites[position];
- mSprites[position] = 0;
+ mSprites[position] = NULL;
}
if (id) {
char stringId[4];
sprintf(stringId, "%03i", id);
- mSprites[position] = new AnimatedSprite(
+
+ AnimatedSprite *equipmentSprite = new AnimatedSprite(
"graphics/sprites/item" + toString(stringId) + ".xml", 0);
+ equipmentSprite->setDirection(getSpriteDirection());
+
+ mSprites[position] = equipmentSprite;
+
+ setAction(mAction);
}
- setDirection(mDirection);
- setAction(mAction);
+
Being::setVisibleEquipment(slot, id);
}