diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-13 11:36:36 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-13 11:36:36 +0000 |
commit | afc770043be553998555e9ac1cffca68dc482d48 (patch) | |
tree | 60e99ade9464b0a1de2ec246724a7bfe0957eec4 /src/player.cpp | |
parent | cfcc1bc3a756185bd39dd858ebbe69b5916ac11b (diff) | |
download | mana-afc770043be553998555e9ac1cffca68dc482d48.tar.gz mana-afc770043be553998555e9ac1cffca68dc482d48.tar.bz2 mana-afc770043be553998555e9ac1cffca68dc482d48.tar.xz mana-afc770043be553998555e9ac1cffca68dc482d48.zip |
Merged cleanups and content changes from the trunk. Also fixed compiling with
OpenGL enabled.
Diffstat (limited to 'src/player.cpp')
-rw-r--r-- | src/player.cpp | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/src/player.cpp b/src/player.cpp index 05825f6e..3fe608c7 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -23,8 +23,7 @@ #include "player.h" -#include "animation.h" -#include "equipment.h" +#include "animatedsprite.h" #include "game.h" #include "graphics.h" @@ -91,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); @@ -107,8 +108,16 @@ Player::setHairColor(Uint16 color) if (color != mHairColor && mHairStyle > 0) { 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); } + Being::setHairColor(color); } @@ -118,8 +127,16 @@ Player::setHairStyle(Uint16 style) if (style != mHairStyle && mHairColor > 0) { 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); } + Being::setHairStyle(style); } @@ -139,18 +156,24 @@ Player::setVisibleEquipment(Uint8 slot, Uint8 id) position = TOPCLOTHES_SPRITE; break; } + + delete mSprites[position]; + mSprites[position] = NULL; + // id = 0 means unequip - if (mSprites[position]) { - delete mSprites[position]; - mSprites[position] = 0; - } if (id) { char stringId[4]; sprintf(stringId, "%03i", id); - printf("Id: %i %i %s\n", id, slot, stringId); - mSprites[position] = new AnimatedSprite( + + AnimatedSprite *equipmentSprite = new AnimatedSprite( "graphics/sprites/item" + toString(stringId) + ".xml", 0); + equipmentSprite->setDirection(getSpriteDirection()); + + mSprites[position] = equipmentSprite; + + setAction(mAction); } + Being::setVisibleEquipment(slot, id); } |