From 9b1c970c70f30733d5d851b834a860365819409c Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 6 Jun 2011 00:37:29 -0600 Subject: 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 --- src/actor.h | 8 +++++++- src/actorsprite.cpp | 2 +- src/being.cpp | 14 +++++++------- src/localplayer.cpp | 2 +- src/particle.h | 2 +- 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,9 +83,15 @@ 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. */ 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; } /** -- cgit v1.2.3-60-g2f50