diff options
author | David Athay <ko2fan@gmail.com> | 2011-11-17 20:22:17 -0600 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2011-11-17 20:22:17 -0600 |
commit | 41a8c0406301fdb3d92374774066837c42eed112 (patch) | |
tree | b0e2ef0862d38057ec3ed045500ca463b120109d /src/map.cpp | |
parent | cd0caeb87a10bc8ed645223c7155c9576b6fb102 (diff) | |
parent | 965cad21750b45206ceea4523d94b7ec92bb8ac6 (diff) | |
download | mana-41a8c0406301fdb3d92374774066837c42eed112.tar.gz mana-41a8c0406301fdb3d92374774066837c42eed112.tar.bz2 mana-41a8c0406301fdb3d92374774066837c42eed112.tar.xz mana-41a8c0406301fdb3d92374774066837c42eed112.zip |
Merge branch '0.5' of github.com:mana/mana into 0.50.5
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/map.cpp b/src/map.cpp index f845f2ff..9e6d865d 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -120,8 +120,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 MapSprites &sprites, int debugFlags) const { startX -= mX; @@ -178,7 +180,8 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY, Map::Map(int width, int height, int tileWidth, int tileHeight): mWidth(width), mHeight(height), mTileWidth(tileWidth), mTileHeight(tileHeight), - mMaxTileHeight(height), + mMaxTileHeight(tileHeight), + mMaxTileWidth(tileWidth), mDebugFlags(MAP_NORMAL), mOnClosedList(1), mOnOpenList(2), mLastScrollX(0.0f), mLastScrollY(0.0f) @@ -281,6 +284,8 @@ void Map::addTileset(Tileset *tileset) if (tileset->getHeight() > mMaxTileHeight) mMaxTileHeight = tileset->getHeight(); + if (tileset->getWidth() > mMaxTileWidth) + mMaxTileWidth = tileset->getWidth(); } bool spriteCompare(const Sprite *a, const Sprite *b) @@ -304,7 +309,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; |