diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 14 | ||||
-rw-r--r-- | src/being.h | 3 | ||||
-rw-r--r-- | src/beingmanager.cpp | 10 |
3 files changed, 20 insertions, 7 deletions
diff --git a/src/being.cpp b/src/being.cpp index 3fc679da..ad5f4204 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -571,11 +571,14 @@ int Being::getWidth() const { if (mSprites[BASE_SPRITE]) { - return mSprites[BASE_SPRITE]->getWidth(); + const int width = mSprites[BASE_SPRITE]->getWidth() > Being::DEFAULT_WIDTH ? + mSprites[BASE_SPRITE]->getWidth() : + Being::DEFAULT_WIDTH; + return width; } else { - return 0; + return Being::DEFAULT_WIDTH; } } @@ -584,11 +587,14 @@ int Being::getHeight() const { if (mSprites[BASE_SPRITE]) { - return mSprites[BASE_SPRITE]->getHeight(); + const int height = mSprites[BASE_SPRITE]->getHeight() > Being::DEFAULT_HEIGHT ? + mSprites[BASE_SPRITE]->getHeight() : + Being::DEFAULT_HEIGHT; + return height; } else { - return 0; + return Being::DEFAULT_HEIGHT; } } diff --git a/src/being.h b/src/being.h index 80295db8..a43297ad 100644 --- a/src/being.h +++ b/src/being.h @@ -432,6 +432,9 @@ class Being : public Sprite */ int getOffset(char pos, char neg) const; + static const int DEFAULT_WIDTH = 32; + static const int DEFAULT_HEIGHT = 32; + // Speech Bubble components SpeechBubble *mSpeechBubble; diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index b2dc330b..6b71b3bf 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -129,12 +129,16 @@ Being* BeingManager::findBeingByPixel(Uint16 x, Uint16 y) for (; itr != itr_end; ++itr) { Being *being = (*itr); + + int xtol = being->getWidth(); + int uptol = being->getHeight(); + if ((being->mAction != Being::DEAD) && (being != player_node) && (being->getPixelX() <= x) && - (being->getPixelX() + being->getWidth() >= x) && - (being->getPixelY() <= y) && - (being->getPixelY() + being->getHeight() >= y)) + (being->getPixelX() + xtol >= x) && + (being->getPixelY() - (uptol / 2) <= y) && + (being->getPixelY() + (uptol / 2) >= y)) { return being; } |