summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-13 23:33:45 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-13 23:33:45 +0300
commitaad864d74e74e89e9d8ec11774d115046a3668cb (patch)
tree36636714c652a8891f8618763017438855c7dbb1
parent1da8072253138fe2b6f4139cf3b2488edaff74c4 (diff)
downloadplus-aad864d74e74e89e9d8ec11774d115046a3668cb.tar.gz
plus-aad864d74e74e89e9d8ec11774d115046a3668cb.tar.bz2
plus-aad864d74e74e89e9d8ec11774d115046a3668cb.tar.xz
plus-aad864d74e74e89e9d8ec11774d115046a3668cb.zip
Fix dead mobs and floor items Y sorting position.
-rw-r--r--src/actor.cpp3
-rw-r--r--src/actor.h7
-rw-r--r--src/being.cpp2
-rw-r--r--src/flooritem.cpp1
-rw-r--r--src/map.cpp2
-rw-r--r--src/particle.h6
-rw-r--r--src/textparticle.h4
7 files changed, 23 insertions, 2 deletions
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
@@ -88,6 +88,12 @@ public:
{ return static_cast<int>(mPos.y); }
/**
+ * Returns the pixel Y coordinate of the actor for sorting only.
+ */
+ virtual int getSortPixelY() const
+ { return static_cast<int>(mPos.y) - mYDiff; }
+
+ /**
* Returns the x coordinate in tiles of the actor.
*/
virtual int getTileX() const;
@@ -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
@@ -114,6 +114,12 @@ class Particle : public Actor
{ return static_cast<int>(mPos.y) - 16; }
/**
+ * Necessary for sorting with the other sprites for sorting only.
+ */
+ virtual int getSortPixelY() const
+ { return static_cast<int>(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<int>(mPos.y + mPos.z); }
+ // hack to improve text visibility (for sorting only)
+ virtual int getSortPixelY() const
+ { return static_cast<int>(mPos.y + mPos.z); }
+
private:
std::string mText; /**< Text of the particle. */
gcn::Font *mTextFont; /**< Font used for drawing the text. */