summaryrefslogtreecommitdiff
path: root/src/being/being.cpp
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 /src/being/being.cpp
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.
Diffstat (limited to 'src/being/being.cpp')
-rw-r--r--src/being/being.cpp19
1 files changed, 15 insertions, 4 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;
}
}