summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-02-10 12:26:57 -0700
committerIra Rice <irarice@gmail.com>2009-02-10 12:26:57 -0700
commit02e60b55b359002ae1f26f36b40f8fa78ea1a708 (patch)
tree0264392528cf174e2275bb79a84472b77c5245d2 /src/map.cpp
parenta8a992ade40c9d68c9faec1cc3a54e7f064fb9d5 (diff)
downloadmana-02e60b55b359002ae1f26f36b40f8fa78ea1a708.tar.gz
mana-02e60b55b359002ae1f26f36b40f8fa78ea1a708.tar.bz2
mana-02e60b55b359002ae1f26f36b40f8fa78ea1a708.tar.xz
mana-02e60b55b359002ae1f26f36b40f8fa78ea1a708.zip
Simplified target drawing so that it actually uses the SimpleAnimation
that it creates when initializing the target cursors in the first place. This behavior was carried over in the first place from the Viewport class. Also moved target drawing responsibility from the map to the being being targeted in the first place. This allows for assuring that targets are always drawn below the sprite being targeted (which the previous solution was designed to do, but didn't do correctly). Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 716e9aee..16882540 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -25,9 +25,9 @@
#include "configuration.h"
#include "game.h"
#include "graphics.h"
-#include "localplayer.h"
#include "map.h"
#include "particle.h"
+#include "simpleanimation.h"
#include "sprite.h"
#include "tileset.h"
@@ -63,34 +63,35 @@ struct Location
};
TileAnimation::TileAnimation(Animation *ani):
- mAnimation(ani),
mLastImage(NULL)
{
+ mAnimation = new SimpleAnimation(ani);
}
TileAnimation::~TileAnimation()
{
- delete mLastImage;
+ delete mAnimation;
}
void TileAnimation::update()
{
+ if (!mAnimation)
+ return;
+
//update animation
- mAnimation.update(1);
+ mAnimation->update(1);
// exchange images
- Image *img = mAnimation.getCurrentImage();
+ Image *img = mAnimation->getCurrentImage();
if (img != mLastImage)
{
- for (std::list<std::pair<MapLayer*, int> >::iterator i = mAffected.begin();
- i != mAffected.end();
- i++)
+ for (std::list<std::pair<MapLayer*, int> >::iterator i =
+ mAffected.begin(); i != mAffected.end(); i++)
{
i->first->setTile(i->second, img);
}
mLastImage = img;
}
-
}
MapLayer::MapLayer(int x, int y, int width, int height, bool isFringeLayer):
@@ -140,9 +141,10 @@ void MapLayer::draw(Graphics *graphics,
{
// If drawing the fringe layer, make sure all sprites above this row of
// tiles have been drawn
- if (mIsFringeLayer) {
- player_node->drawTargetCursor(graphics, scrollX, scrollY);
- while (si != sprites.end() && (*si)->getPixelY() <= y * 32 - 32) {
+ if (mIsFringeLayer)
+ {
+ while (si != sprites.end() && (*si)->getPixelY() <= y * 32 - 32)
+ {
(*si)->draw(graphics, -scrollX, -scrollY);
si++;
}
@@ -151,7 +153,8 @@ void MapLayer::draw(Graphics *graphics,
for (int x = startX; x < endX; x++)
{
Image *img = getTile(x, y);
- if (img) {
+ if (img)
+ {
const int px = (x + mX) * 32 - scrollX;
const int py = (y + mY) * 32 - scrollY + 32 - img->getHeight();
graphics->drawImage(img, px, py);