diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-09-17 17:53:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-09-17 20:36:02 +0300 |
commit | 01e2baa778318150bdd1829836cfff9e677cf72c (patch) | |
tree | 8ee3cd0913f2b4b3e81f869a68413f9789d3e43e /src/being/being.cpp | |
parent | d6da03bf0c4bd2e89429448f2d33c2bdc5083733 (diff) | |
download | manaplus-01e2baa778318150bdd1829836cfff9e677cf72c.tar.gz manaplus-01e2baa778318150bdd1829836cfff9e677cf72c.tar.bz2 manaplus-01e2baa778318150bdd1829836cfff9e677cf72c.tar.xz manaplus-01e2baa778318150bdd1829836cfff9e677cf72c.zip |
add walking on map height.
using collisions from actual and not drawing tile.
still have issue with fringe layer objects.
Diffstat (limited to 'src/being/being.cpp')
-rw-r--r-- | src/being/being.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index 1b3d8f15e..00df60848 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -147,6 +147,9 @@ Being::Being(const int id, const Type type, const uint16_t subtype, mSpecialParticle(nullptr), mX(0), mY(0), + mOffsetX(0), + mOffsetY(0), + mOldHeight(0), mDamageTaken(0), mHP(0), mMaxHP(0), @@ -1352,8 +1355,12 @@ void Being::nextTile() else mSpeed = mWalkSpeed.x; + if (mX != pos.x || mY != pos.y) + mOldHeight = mMap->getHeightOffset(mX, mY); mX = pos.x; mY = pos.y; + const uint8_t height = mMap->getHeightOffset(mX, mY); + mOffsetY = height - mOldHeight; setAction(MOVE); } @@ -1514,9 +1521,18 @@ void Being::logic() } } + const int xOffset = getXOffset(); + const int yOffset = getYOffset(); + int offset = xOffset; + if (!offset) + offset = yOffset; + + const int yOffset2 = getYOffset() - (mOldHeight * 16) + - (mOffsetY * 16) * (32 - abs(offset)) / 32; + // Update pixel coordinates - setPosition(static_cast<float>(mX * 32 + 16 + getXOffset()), - static_cast<float>(mY * 32 + 32 + getYOffset())); + setPosition(static_cast<float>(mX * 32 + 16 + xOffset), + static_cast<float>(mY * 32 + 32 + yOffset2)); } if (mEmotionSprite) |