summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-03 17:08:47 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-03 17:08:47 +0300
commit545017e651250e14656a8ab21c3ab36b8b2fa760 (patch)
tree85d70f7ca099320591ff547dd8e0531f578bf194
parent4f00e33aae207561fc0b34ee7d181d7a74755fd5 (diff)
downloadplus-545017e651250e14656a8ab21c3ab36b8b2fa760.tar.gz
plus-545017e651250e14656a8ab21c3ab36b8b2fa760.tar.bz2
plus-545017e651250e14656a8ab21c3ab36b8b2fa760.tar.xz
plus-545017e651250e14656a8ab21c3ab36b8b2fa760.zip
Fix floor items position if tile height is not zero.
-rw-r--r--src/flooritem.cpp9
-rw-r--r--src/flooritem.h1
2 files changed, 7 insertions, 3 deletions
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index 4abe9047f..1d0b9948d 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -50,6 +50,7 @@ FloorItem::FloorItem(const int id, const int itemId, const int x, const int y,
mY(y),
mDropTime(cur_time),
mAmount(amount),
+ mHeightPosDiff(0),
mPickupCount(0),
mCursor(Cursor::CURSOR_PICKUP),
mColor(color),
@@ -73,21 +74,23 @@ void FloorItem::postInit(Map *const map, int subX, int subY)
subY = max;
else if (subY < -max)
subY = -max;
+ mHeightPosDiff = map->getHeightOffset(mX, mY) * 16;
mPos.x = static_cast<float>(mX * map->getTileWidth()
+ subX + mapTileSize / 2 - 8);
mPos.y = static_cast<float>(mY * map->getTileHeight()
- + subY + mapTileSize - 8);
+ + subY + mapTileSize - 8 - mHeightPosDiff);
+ mYDiff = 31 - mHeightPosDiff;
}
else
{
mPos.x = 0;
mPos.y = 0;
+ mYDiff = 31;
}
mCursor = info.getPickupCursor();
setupSpriteDisplay(info.getDisplay(), true, 1,
info.getDyeColorsString(mColor));
- mYDiff = 31;
}
const ItemInfo &FloorItem::getInfo() const
@@ -112,7 +115,7 @@ void FloorItem::draw(Graphics *const graphics,
BLOCK_START("FloorItem::draw")
const int x = mX * mMap->getTileWidth() + offsetX;
- const int y = mY * mMap->getTileHeight() + offsetY;
+ const int y = mY * mMap->getTileHeight() + offsetY - mHeightPosDiff;
Font *font = nullptr;
if (mHighlight)
diff --git a/src/flooritem.h b/src/flooritem.h
index c884d8db3..846a27802 100644
--- a/src/flooritem.h
+++ b/src/flooritem.h
@@ -104,6 +104,7 @@ class FloorItem final : public ActorSprite
int mX, mY;
int mDropTime;
int mAmount;
+ int mHeightPosDiff;
unsigned int mPickupCount;
Cursor::Cursor mCursor;
unsigned char mColor;