From 17f2adad3ba9e6a5c64d2d923d9cbb190f234b6f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 17 Sep 2013 21:09:37 +0300 Subject: fix beings draw order with tile heights. --- src/being/being.cpp | 7 ++++--- src/being/being.h | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/being') diff --git a/src/being/being.cpp b/src/being/being.cpp index 00df60848..6d1307fab 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -147,7 +147,7 @@ Being::Being(const int id, const Type type, const uint16_t subtype, mSpecialParticle(nullptr), mX(0), mY(0), - mOffsetX(0), + mSortOffsetY(0), mOffsetY(0), mOldHeight(0), mDamageTaken(0), @@ -1527,8 +1527,9 @@ void Being::logic() if (!offset) offset = yOffset; - const int yOffset2 = getYOffset() - (mOldHeight * 16) - - (mOffsetY * 16) * (32 - abs(offset)) / 32; + mSortOffsetY = (mOldHeight * 16) + (mOffsetY * 16) + * (32 - abs(offset)) / 32; + const int yOffset2 = yOffset - mSortOffsetY; // Update pixel coordinates setPosition(static_cast(mX * 32 + 16 + xOffset), diff --git a/src/being/being.h b/src/being/being.h index 8ac288137..f6e2d3f49 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -897,6 +897,9 @@ class Being : public ActorSprite, public ConfigListener */ void setPath(const Path &path); + int getSortPixelY() const A_WARN_UNUSED + { return static_cast(mPos.y) - mYDiff - mSortOffsetY; } + protected: /** * Updates name's location. @@ -1001,10 +1004,10 @@ class Being : public ActorSprite, public ConfigListener Being *mOwner; Particle *mSpecialParticle; - int mX; // position in tiles - int mY; // position in tiles - int mOffsetX; // offset in pixels - int mOffsetY; // offset in pixels + int mX; // position in tiles + int mY; // position in tiles + int mSortOffsetY; // caculated offset in pixels based on mOffsetY + int mOffsetY; // fixed tile height offset in pixels uint8_t mOldHeight; int mDamageTaken; -- cgit v1.2.3-70-g09d2