summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-23 02:10:02 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-23 20:52:54 +0300
commitdce838195b3d2ca4703094aa8602038bb1e1e7f3 (patch)
tree1d79540f9f3787129c08c1326ab7e72249a2b27f /src
parentf5536169ce6143ae39bcfd8b353e6495dac76a72 (diff)
downloadmanaverse-dce838195b3d2ca4703094aa8602038bb1e1e7f3.tar.gz
manaverse-dce838195b3d2ca4703094aa8602038bb1e1e7f3.tar.bz2
manaverse-dce838195b3d2ca4703094aa8602038bb1e1e7f3.tar.xz
manaverse-dce838195b3d2ca4703094aa8602038bb1e1e7f3.zip
Reorder map sprites to draw correctly player with more than one tile width.
Diffstat (limited to 'src')
-rw-r--r--src/map.cpp17
-rw-r--r--src/map.h7
-rw-r--r--src/resources/mapreader.cpp4
3 files changed, 21 insertions, 7 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 079477146..23089db4e 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -151,7 +151,7 @@ Image* MapLayer::getTile(int x, int y) const
void MapLayer::draw(Graphics *graphics, int startX, int startY,
int endX, int endY, int scrollX, int scrollY,
- const Actors &actors, int debugFlags) const
+ const Actors &actors, int debugFlags, int yFix) const
{
if (!player_node)
return;
@@ -193,16 +193,17 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY,
for (int y = startY; y < endY; y++)
{
const int y32 = y * 32;
+ const int y32s = (y + yFix) * 32;
const int yWidth = y * mWidth;
// If drawing the fringe layer, make sure all actors above this row of
// tiles have been drawn
if (mIsFringeLayer)
{
- while (ai != actors.end() && (*ai)->getPixelY() <= y32)
+ while (ai != actors.end() && (*ai)->getPixelY() <= y32s)
{
(*ai)->draw(graphics, -scrollX, -scrollY);
- ++ai;
+ ++ ai;
}
}
@@ -242,6 +243,7 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY,
for (int x = startX; x < endX; x++)
{
const int x32 = x * 32;
+
const int px1 = x32 - scrollX;
const int tilePtr = x + yWidth;
int c = 0;
@@ -255,6 +257,7 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY,
|| img->getHeight() <= 32)
{
int width = 0;
+ // here need not draw over player position
c = getTileDrawWidth(tilePtr, endX - x, width);
if (!c)
@@ -381,7 +384,9 @@ Map::Map(int width, int height, int tileWidth, int tileHeight):
mPvp(0),
mTilesetsIndexed(false),
mIndexedTilesets(0),
- mIndexedTilesetsSize(0)
+ mIndexedTilesetsSize(0),
+ mActorFixX(0),
+ mActorFixY(0)
// mSpritesUpdated(true)
{
const int size = mWidth * mHeight;
@@ -580,7 +585,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
(*layeri)->draw(graphics,
startX, startY, endX, endY,
scrollX, scrollY,
- mActors, mDebugFlags);
+ mActors, mDebugFlags, mActorFixY);
break;
}
}
@@ -600,7 +605,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
(*layeri)->draw(graphics,
startX, startY, endX, endY,
scrollX, scrollY,
- mActors, mDebugFlags);
+ mActors, mDebugFlags, mActorFixY);
}
}
diff --git a/src/map.h b/src/map.h
index fbb8e1394..11034a37e 100644
--- a/src/map.h
+++ b/src/map.h
@@ -159,7 +159,7 @@ class MapLayer: public ConfigListener
int endX, int endY,
int scrollX, int scrollY,
const Actors &actors,
- int mDebugFlags) const;
+ int mDebugFlags, int yFix) const;
bool isFringeLayer()
{ return mIsFringeLayer; }
@@ -437,6 +437,9 @@ class Map : public Properties, public ConfigListener
void clearIndexedTilesets();
+ void setActorsFix(int x, int y)
+ { mActorFixX = x; mActorFixY = y; }
+
protected:
friend class Actor;
@@ -523,6 +526,8 @@ class Map : public Properties, public ConfigListener
bool mTilesetsIndexed;
Tileset** mIndexedTilesets;
int mIndexedTilesetsSize;
+ int mActorFixX;
+ int mActorFixY;
SpecialLayer *mSpecialLayer;
SpecialLayer *mTempLayer;
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index b80bc960f..3b7ebd2b1 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -360,6 +360,10 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
map->addRange(objName, MapItem::MUSIC,
objX, objY, objW, objH);
}
+ else if (objType == "ACTORSFIX")
+ {
+ map->setActorsFix(objX, objY);
+ }
else
{
logger->log1(" Warning: Unknown object type");