diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-09-13 18:08:22 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-09-13 18:08:22 +0200 |
commit | d6248271842aa6edc26135568d92150f69491292 (patch) | |
tree | cc8c659fb55215f5f60d1ad56c79612004e212cd /src/map.cpp | |
parent | 135da0b9b7604d3348bf6955f4dae35211dd307c (diff) | |
parent | 7b68fc4ec5c2779a83ecfd214d23687132b3432a (diff) | |
download | mana-d6248271842aa6edc26135568d92150f69491292.tar.gz mana-d6248271842aa6edc26135568d92150f69491292.tar.bz2 mana-d6248271842aa6edc26135568d92150f69491292.tar.xz mana-d6248271842aa6edc26135568d92150f69491292.zip |
Merge github.com:mana/mana
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 15 |
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; |