From aad864d74e74e89e9d8ec11774d115046a3668cb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 13 Nov 2011 23:33:45 +0300 Subject: Fix dead mobs and floor items Y sorting position. --- src/actor.cpp | 3 ++- src/actor.h | 7 +++++++ src/being.cpp | 2 ++ src/flooritem.cpp | 1 + src/map.cpp | 2 +- src/particle.h | 6 ++++++ src/textparticle.h | 4 ++++ 7 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/actor.cpp b/src/actor.cpp index 095f3d959..150f6042b 100644 --- a/src/actor.cpp +++ b/src/actor.cpp @@ -29,7 +29,8 @@ #include "debug.h" Actor::Actor(): - mMap(nullptr) + mMap(nullptr), + mYDiff(0) {} Actor::~Actor() diff --git a/src/actor.h b/src/actor.h index 654141221..9afaff93d 100644 --- a/src/actor.h +++ b/src/actor.h @@ -87,6 +87,12 @@ public: virtual int getPixelY() const { return static_cast(mPos.y); } + /** + * Returns the pixel Y coordinate of the actor for sorting only. + */ + virtual int getSortPixelY() const + { return static_cast(mPos.y) - mYDiff; } + /** * Returns the x coordinate in tiles of the actor. */ @@ -121,6 +127,7 @@ public: protected: Map *mMap; Vector mPos; /**< Position in pixels relative to map. */ + int mYDiff; private: Actors::iterator mMapActor; diff --git a/src/being.cpp b/src/being.cpp index 036f823e6..73675318d 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1017,6 +1017,8 @@ void Being::setAction(Action action, int attackType A_UNUSED) currentAction = SpriteAction::DEAD; if (mInfo) sound.playSfx(mInfo->getSound(SOUND_EVENT_DIE), mX, mY); + if (mType == MONSTER) + mYDiff = 31; break; case STAND: currentAction = SpriteAction::STAND; diff --git a/src/flooritem.cpp b/src/flooritem.cpp index fa6cbf618..cf1ee16dc 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -80,6 +80,7 @@ FloorItem::FloorItem(int id, const ItemInfo &info = ItemDB::get(itemId); setupSpriteDisplay(info.getDisplay(), true, 1, info.getDyeColorsString(mColor)); + mYDiff = 31; } const ItemInfo &FloorItem::getInfo() const diff --git a/src/map.cpp b/src/map.cpp index bcf2b22fe..e706f120b 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -85,7 +85,7 @@ class ActorFunctuator { if (!a || !b) return false; - return a->getPixelY() < b->getPixelY(); + return a->getSortPixelY() < b->getSortPixelY(); } } actorCompare; diff --git a/src/particle.h b/src/particle.h index 0a4a2253d..2e3aa8740 100644 --- a/src/particle.h +++ b/src/particle.h @@ -113,6 +113,12 @@ class Particle : public Actor virtual int getPixelY() const { return static_cast(mPos.y) - 16; } + /** + * Necessary for sorting with the other sprites for sorting only. + */ + virtual int getSortPixelY() const + { return static_cast(mPos.y) - 16; } + /** * Creates a blank particle as a child of the current particle * Useful for creating target particles diff --git a/src/textparticle.h b/src/textparticle.h index db9dc1766..b37f25732 100644 --- a/src/textparticle.h +++ b/src/textparticle.h @@ -45,6 +45,10 @@ class TextParticle : public Particle virtual int getPixelY() const { return static_cast(mPos.y + mPos.z); } + // hack to improve text visibility (for sorting only) + virtual int getSortPixelY() const + { return static_cast(mPos.y + mPos.z); } + private: std::string mText; /**< Text of the particle. */ gcn::Font *mTextFont; /**< Font used for drawing the text. */ -- cgit v1.2.3-70-g09d2