diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-17 16:46:06 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-17 16:46:06 +0200 |
commit | 914d3de7c324cb1ec456892702689718352a7842 (patch) | |
tree | eb05c251adb6f012a40f3d7de4eb42ab854b7d94 /src/actorspritemanager.cpp | |
parent | faf0a45d6b8b85acd2836cf5e8e7f7c5b161931d (diff) | |
download | mana-914d3de7c324cb1ec456892702689718352a7842.tar.gz mana-914d3de7c324cb1ec456892702689718352a7842.tar.bz2 mana-914d3de7c324cb1ec456892702689718352a7842.tar.xz mana-914d3de7c324cb1ec456892702689718352a7842.zip |
First pass on removing tile hard coded values.
Every files has been checked against the hard coded
32 values except the map.cpp file.
I also added convenience functions in the Game class,
centralized the default item icon size, and removed two
unused defines in being.cpp.
Diffstat (limited to 'src/actorspritemanager.cpp')
-rw-r--r-- | src/actorspritemanager.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 0134dd63..fedf880c 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -21,6 +21,7 @@ #include "actorspritemanager.h" +#include "game.h" #include "localplayer.h" #include "utils/dtor.h" @@ -37,12 +38,17 @@ class FindBeingFunctor { if (actor->getType() == ActorSprite::FLOOR_ITEM) return false; + Game *game = Game::instance(); + if (!game) + return false; + Being* b = static_cast<Being*>(actor); uint16_t other_y = y + ((b->getType() == ActorSprite::NPC) ? 1 : 0); const Vector &pos = b->getPosition(); - return ((int) pos.x / 32 == x && - ((int) pos.y / 32 == y || (int) pos.y / 32 == other_y) && + return ((int) pos.x / game->getCurrentTileWidth() == x && + ((int) pos.y / game->getCurrentTileHeight() == y + || (int) pos.y / game->getCurrentTileHeight() == other_y) && b->isAlive() && (type == ActorSprite::UNKNOWN || b->getType() == type)); } @@ -272,10 +278,14 @@ Being *ActorSpriteManager::findNearestLivingBeing(int x, int y, ActorSprite::Type type, Being *excluded) const { + Game *game = Game::instance(); + if (!game) + return 0; + Being *closestBeing = 0; int dist = 0; - const int maxDist = maxTileDist * 32; + const int maxDist = maxTileDist * game->getCurrentTileWidth(); for_actors { |