diff options
Diffstat (limited to 'src/being')
-rw-r--r-- | src/being/being.cpp | 27 | ||||
-rw-r--r-- | src/being/being.h | 3 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index c146ecb00..2737f2b8a 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -5422,3 +5422,30 @@ void Being::stopCast(const bool b) if (b && mAction == BeingAction::CAST) setAction(BeingAction::STAND, 0); } + +void Being::fixDirectionOffsets(int &offsetX, + int &offsetY) const +{ + const uint8_t dir = mDirection; + if (dir & BeingDirection::DOWN) + { + // do nothing + } + else if (dir & BeingDirection::UP) + { + offsetX = -offsetX; + offsetY = -offsetY; + } + else if (dir & BeingDirection::LEFT) + { + const int tmp = offsetY; + offsetY = offsetX; + offsetX = -tmp; + } + else if (dir & BeingDirection::RIGHT) + { + const int tmp = offsetY; + offsetY = -offsetX; + offsetX = tmp; + } +} diff --git a/src/being/being.h b/src/being/being.h index 90c57a4ae..40658fa68 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -1068,6 +1068,9 @@ class Being notfinal : public ActorSprite, const int range, const int waitTimeTicks); + void fixDirectionOffsets(int &offsetX, + int &offsetY) const; + protected: void drawPlayerSpriteAt(Graphics *restrict const graphics, const int x, |