summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-29 11:27:29 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-29 18:35:05 +0300
commit3941d588a3233176416edf90d1f248ac4cb0fe5e (patch)
treeb5cb4e2adbdda4e7ee3ae930ea012162badf27e7
parent3b8a3b84346700abffa52745245310bf3eae6b18 (diff)
downloadmanaverse-3941d588a3233176416edf90d1f248ac4cb0fe5e.tar.gz
manaverse-3941d588a3233176416edf90d1f248ac4cb0fe5e.tar.bz2
manaverse-3941d588a3233176416edf90d1f248ac4cb0fe5e.tar.xz
manaverse-3941d588a3233176416edf90d1f248ac4cb0fe5e.zip
Fix sprites draw order with non zero map heights.
-rw-r--r--src/being/being.cpp19
-rw-r--r--src/being/being.h11
2 files changed, 22 insertions, 8 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 0d86aad94..f5c4611ef 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -177,6 +177,7 @@ Being::Being(const int id,
mY(0),
mSortOffsetY(0),
mOffsetY(0),
+ mFixedOffsetY(0),
mOldHeight(0),
mDamageTaken(0),
mHP(0),
@@ -1358,6 +1359,7 @@ void Being::nextTile()
mY = pos.y;
const uint8_t height = mMap->getHeightOffset(mX, mY);
mOffsetY = height - mOldHeight;
+ mFixedOffsetY = height;
mNeedPosUpdate = true;
setAction(BeingAction::MOVE, 0);
}
@@ -1436,15 +1438,22 @@ void Being::logic()
if (!xOffset && !yOffset)
mNeedPosUpdate = false;
+/*
mSortOffsetY = (mOldHeight * mapTileSize / 2)
+ (mOffsetY * mapTileSize / 2)
- * (mapTileSize - abs(offset)) / mapTileSize;
- const int yOffset2 = yOffset - mSortOffsetY;
+ * (mapTileSize - abs(offset)) / mapTileSize - mFixedOffsetY * mapTileSize / 2;
+ const int yOffset2 = yOffset - mSortOffsetY - mFixedOffsetY * mapTileSize / 2;
+*/
+ const int halfTile = mapTileSize / 2;
+ const float offset2 = mOffsetY * abs(offset) / 2;
+ mSortOffsetY = (mOldHeight - mFixedOffsetY + mOffsetY)
+ * halfTile - offset2;
+ const float yOffset3 = (mY + 1) * mapTileSize + yOffset
+ - (mOldHeight + mOffsetY) * halfTile + offset2;
// Update pixel coordinates
setPosition(static_cast<float>(mX * mapTileSize
- + mapTileSize / 2 + xOffset), static_cast<float>(
- mY * mapTileSize + mapTileSize + yOffset2));
+ + mapTileSize / 2 + xOffset), yOffset3);
}
if (mEmotionSprite)
@@ -3313,6 +3322,7 @@ void Being::setTileCoords(const int x, const int y)
if (mMap)
{
mOffsetY = mMap->getHeightOffset(mX, mY);
+ mFixedOffsetY = mOffsetY;
mNeedPosUpdate = true;
}
}
@@ -3323,6 +3333,7 @@ void Being::setMap(Map *const map)
if (mMap)
{
mOffsetY = mMap->getHeightOffset(mX, mY);
+ mFixedOffsetY = mOffsetY;
mNeedPosUpdate = true;
}
}
diff --git a/src/being/being.h b/src/being/being.h
index 776af36dc..c9d343659 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -872,6 +872,7 @@ class Being notfinal : public ActorSprite,
int getSortPixelY() const A_WARN_UNUSED
{ return static_cast<int>(mPos.y) - mYDiff - mSortOffsetY; }
+// { return static_cast<int>(mPos.y) - mYDiff - mSortOffsetY + 16; }
void setMap(Map *const map);
@@ -1008,10 +1009,12 @@ class Being notfinal : public ActorSprite,
Being *mOwner;
Particle *mSpecialParticle;
- 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
+ int mX; // position in tiles
+ int mY; // position in tiles
+ int mSortOffsetY; // caculated offset in pixels based on mOffsetY
+ int mOffsetY; // tile height offset in pixels
+ // calculated between tiles
+ int mFixedOffsetY; // fixed tile height offset in pixels for tile
uint8_t mOldHeight;
int mDamageTaken;