summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2011-06-06 00:37:29 -0600
committerJared Adams <jaxad0127@gmail.com>2011-06-07 08:24:04 -0600
commit9b1c970c70f30733d5d851b834a860365819409c (patch)
tree860f19199c810d50fdd166a397f9c78b0c46ce10
parent70a0d0bd23a3f2df5441f037c204604e52935974 (diff)
downloadmana-9b1c970c70f30733d5d851b834a860365819409c.tar.gz
mana-9b1c970c70f30733d5d851b834a860365819409c.tar.bz2
mana-9b1c970c70f30733d5d851b834a860365819409c.tar.xz
mana-9b1c970c70f30733d5d851b834a860365819409c.zip
Fix particle positions
Particles were being drawn with wrong positions due to their Z coordinate being taken into account when sorting actors. Z is now only taken into account when drawing them. Reviewed-by: Bertram
-rw-r--r--src/actor.h8
-rw-r--r--src/actorsprite.cpp2
-rw-r--r--src/being.cpp14
-rw-r--r--src/localplayer.cpp2
-rw-r--r--src/particle.h2
5 files changed, 17 insertions, 11 deletions
diff --git a/src/actor.h b/src/actor.h
index 1442d4b3..240b5097 100644
--- a/src/actor.h
+++ b/src/actor.h
@@ -83,10 +83,16 @@ public:
/**
* Returns the pixel Y coordinate of the actor.
*/
- virtual int getPixelY() const
+ int getPixelY() const
{ return (int) mPos.y; }
/**
+ * Returns the pixel Y coordinate that the actor should be drawn at.
+ */
+ virtual int getDrawPixelY() const
+ { return getPixelY(); }
+
+ /**
* Returns the x coordinate in tiles of the actor.
*/
virtual int getTileX() const;
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 3d8eaced..1e0db70e 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -69,7 +69,7 @@ ActorSprite::~ActorSprite()
bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const
{
int px = getPixelX() + offsetX;
- int py = getPixelY() + offsetY;
+ int py = getDrawPixelY() + offsetY;
if (mUsedTargetCursor)
{
diff --git a/src/being.cpp b/src/being.cpp
index 9c50ca1d..c9dd5b08 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -302,7 +302,7 @@ void Being::setSpeech(const std::string &text, int time)
delete mText;
mText = new Text(mSpeech,
- getPixelX(), getPixelY() - getHeight(),
+ getPixelX(), getDrawPixelY() - getHeight(),
gcn::Graphics::CENTER,
&userPalette->getColor(UserPalette::PARTICLE),
true);
@@ -364,7 +364,7 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
// Show damage number
particleEngine->addTextSplashEffect(damage,
- getPixelX(), getPixelY() - 16,
+ getPixelX(), getDrawPixelY() - 16,
color, font, true);
if (amount > 0)
@@ -895,7 +895,7 @@ void Being::logic()
void Being::drawSpeech(int offsetX, int offsetY)
{
const int px = getPixelX() - offsetX;
- const int py = getPixelY() - offsetY;
+ const int py = getDrawPixelY() - offsetY;
const int speech = config.getIntValue("speech");
// Draw speech above this being
@@ -929,7 +929,7 @@ void Being::drawSpeech(int offsetX, int offsetY)
if (! mText)
{
mText = new Text(mSpeech,
- getPixelX(), getPixelY() - getHeight(),
+ getPixelX(), getDrawPixelY() - getHeight(),
gcn::Graphics::CENTER,
&userPalette->getColor(UserPalette::PARTICLE),
true);
@@ -953,9 +953,9 @@ void Being::updateCoords()
// Monster names show above the sprite instead of below it
if (getType() == MONSTER)
- mDispName->adviseXY(getPixelX(), getPixelY() - getHeight());
+ mDispName->adviseXY(getPixelX(), getDrawPixelY() - getHeight());
else
- mDispName->adviseXY(getPixelX(), getPixelY() + mDispName->getHeight());
+ mDispName->adviseXY(getPixelX(), getDrawPixelY() + mDispName->getHeight());
}
void Being::flashName(int time)
@@ -1004,7 +1004,7 @@ void Being::showName()
font = boldFont;
}
- mDispName = new FlashText(mDisplayName, getPixelX(), getPixelY(),
+ mDispName = new FlashText(mDisplayName, getPixelX(), getDrawPixelY(),
gcn::Graphics::CENTER, mNameColor, font);
updateCoords();
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index bc041def..a1914c78 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -119,7 +119,7 @@ void LocalPlayer::logic()
particleEngine->addTextRiseFadeOutEffect(
info.first,
getPixelX(),
- getPixelY() - 48,
+ getDrawPixelY() - 48,
&userPalette->getColor(info.second),
gui->getInfoParticleFont(), true);
diff --git a/src/particle.h b/src/particle.h
index bb8b17fe..a09648ee 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -95,7 +95,7 @@ class Particle : public Actor
/**
* Necessary for sorting with the other sprites.
*/
- virtual int getPixelY() const
+ virtual int getDrawPixelY() const
{ return (int) (mPos.y + mPos.z) - 64; }
/**