summaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp45
1 files changed, 21 insertions, 24 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 5256831b..4d5ef171 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -36,7 +36,7 @@ static const int NAME_Y_OFFSET = 30;
Player::Player(int id, int job, Map *map):
Being(id, job, map)
{
- mName = 0;
+ mName = NULL;
}
Player::~Player()
@@ -46,19 +46,21 @@ Player::~Player()
void Player::setName(const std::string &name)
{
- if (mName == 0)
+ if (mName == NULL)
{
if (mIsGM)
{
mNameColor = 0x009000;
- mName = new FlashText("(GM) " + name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET,
- gcn::Graphics::CENTER, gcn::Color(0, 255, 0));
+ mName = new FlashText("(GM) " + name, mPx + NAME_X_OFFSET, mPy +
+ NAME_Y_OFFSET, gcn::Graphics::CENTER,
+ gcn::Color(0, 255, 0));
}
else
{
mNameColor = 0x202020;
mName = new FlashText(name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET,
- gcn::Graphics::CENTER, gcn::Color(255, 255, 255));
+ gcn::Graphics::CENTER,
+ gcn::Color(255, 255, 255));
}
Being::setName(name);
}
@@ -66,7 +68,8 @@ void Player::setName(const std::string &name)
void Player::logic()
{
- switch (mAction) {
+ switch (mAction)
+ {
case STAND:
break;
@@ -81,22 +84,25 @@ void Player::logic()
case WALK:
mFrame = (get_elapsed_time(mWalkTime) * 6) / mWalkSpeed;
- if (mFrame >= 6) {
+
+ if (mFrame >= 6)
nextStep();
- }
+
break;
case ATTACK:
int frames = 4;
- if ( mEquippedWeapon
- && mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW)
+ if (mEquippedWeapon &&
+ mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW)
{
frames = 5;
}
+
mFrame = (get_elapsed_time(mWalkTime) * frames) / mAttackSpeed;
- if (mFrame >= frames) {
+
+ if (mFrame >= frames)
nextStep();
- }
+
break;
}
@@ -111,9 +117,7 @@ Being::Type Player::getType() const
void Player::flash(int time)
{
if (mName)
- {
mName->flash(time);
- }
}
void Player::setGender(Gender gender)
@@ -132,9 +136,7 @@ void Player::setGender(Gender gender)
for (int i = 1; i < VECTOREND_SPRITE; i++)
{
if (mSpriteIDs.at(i) != 0)
- {
setSprite(i, mSpriteIDs.at(i), mSpriteColors.at(i));
- }
}
}
}
@@ -161,9 +163,7 @@ void Player::setSprite(int slot, int id, std::string color)
mSprites[slot] = NULL;
if (slot == WEAPON_SPRITE)
- {
mEquippedWeapon = NULL;
- }
}
else
{
@@ -174,8 +174,9 @@ void Player::setSprite(int slot, int id, std::string color)
{
if (!color.empty())
filename += "|" + color;
- equipmentSprite = AnimatedSprite::load(
- "graphics/sprites/" + filename);
+
+ equipmentSprite = AnimatedSprite::load("graphics/sprites/" +
+ filename);
}
if (equipmentSprite)
@@ -185,9 +186,7 @@ void Player::setSprite(int slot, int id, std::string color)
mSprites[slot] = equipmentSprite;
if (slot == WEAPON_SPRITE)
- {
mEquippedWeapon = &ItemDB::get(id);
- }
setAction(mAction);
}
@@ -198,8 +197,6 @@ void Player::setSprite(int slot, int id, std::string color)
void Player::updateCoords()
{
if (mName)
- {
mName->adviseXY(mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET);
- }
}