summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/map.cpp b/src/map.cpp
index ac287be4..3e5e8e12 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -121,8 +121,10 @@ Image* MapLayer::getTile(int x, int y) const
return mTiles[x + y * mWidth];
}
-void MapLayer::draw(Graphics *graphics, int startX, int startY,
- int endX, int endY, int scrollX, int scrollY,
+void MapLayer::draw(Graphics *graphics,
+ int startX, int startY,
+ int endX, int endY,
+ int scrollX, int scrollY,
const Actors &actors, int debugFlags) const
{
startX -= mX;
@@ -218,8 +220,9 @@ int MapLayer::getTileDrawWidth(int x1, int y1, int endX, int &width) const
Map::Map(int width, int height, int tileWidth, int tileHeight):
mWidth(width), mHeight(height),
mTileWidth(tileWidth), mTileHeight(tileHeight),
- mMaxTileHeight(height),
- mDebugFlags(0),
+ mMaxTileHeight(tileHeight),
+ mMaxTileWidth(tileWidth),
+ mDebugFlags(MAP_NORMAL),
mOnClosedList(1), mOnOpenList(2),
mLastScrollX(0.0f), mLastScrollY(0.0f)
{
@@ -321,6 +324,8 @@ void Map::addTileset(Tileset *tileset)
if (tileset->getHeight() > mMaxTileHeight)
mMaxTileHeight = tileset->getHeight();
+ if (tileset->getWidth() > mMaxTileWidth)
+ mMaxTileWidth = tileset->getWidth();
}
bool actorCompare(const Actor *a, const Actor *b)
@@ -344,7 +349,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
// Calculate range of tiles which are on-screen
int endPixelY = graphics->getHeight() + scrollY + mTileHeight - 1;
endPixelY += mMaxTileHeight - mTileHeight;
- int startX = scrollX / mTileWidth;
+ int startX = (scrollX - mMaxTileWidth + mTileWidth) / mTileWidth;
int startY = scrollY / mTileHeight;
int endX = (graphics->getWidth() + scrollX + mTileWidth - 1) / mTileWidth;
int endY = endPixelY / mTileHeight;