From 4039ef116901d4513c3535cc119dc40abd8e14df Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 3 Mar 2016 21:43:25 +0300 Subject: Improve a bit pixel calculation in map layers. --- src/resources/map/maplayer.cpp | 18 ++++++++++-------- src/resources/map/maplayer.h | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp index 6567b2177..0c18bf289 100644 --- a/src/resources/map/maplayer.cpp +++ b/src/resources/map/maplayer.cpp @@ -55,6 +55,8 @@ MapLayer::MapLayer(const int x, const int tileCondition) : mX(x), mY(y), + mPixelX(mX * mapTileSize), + mPixelY(mY * mapTileSize + mapTileSize), mWidth(width), mHeight(height), mTiles(new TileInfo[mWidth * mHeight]), @@ -125,8 +127,8 @@ void MapLayer::draw(Graphics *const graphics, if (endY > mHeight) endY = mHeight; - const int dx = (mX * mapTileSize) - scrollX; - const int dy = (mY * mapTileSize) - scrollY + mapTileSize; + const int dx = mPixelX - scrollX; + const int dy = mPixelY - scrollY; for (int y = startY; y < endY; y++) { @@ -222,8 +224,8 @@ void MapLayer::updateSDL(const Graphics *const graphics, if (endY > mHeight) endY = mHeight; - const int dx = (mX * mapTileSize) - scrollX; - const int dy = (mY * mapTileSize) - scrollY + mapTileSize; + const int dx = mPixelX - scrollX; + const int dy = mPixelY - scrollY; for (int y = startY; y < endY; y++) { @@ -290,8 +292,8 @@ void MapLayer::updateOGL(Graphics *const graphics, if (endY > mHeight) endY = mHeight; - const int dx = (mX * mapTileSize) - scrollX; - const int dy = (mY * mapTileSize) - scrollY + mapTileSize; + const int dx = mPixelX - scrollX; + const int dy = mPixelY - scrollY; MapRowVertexes *const row = new MapRowVertexes(); mTempRows.push_back(row); @@ -412,8 +414,8 @@ void MapLayer::drawFringe(Graphics *const graphics, ActorsCIter ai = actors.begin(); const ActorsCIter ai_end = actors.end(); - const int dx = (mX * mapTileSize) - scrollX; - const int dy = (mY * mapTileSize) - scrollY + mapTileSize; + const int dx = mPixelX - scrollX; + const int dy = mPixelY - scrollY; const int specialWidth = mSpecialLayer->mWidth; const int specialHeight = mSpecialLayer->mHeight; diff --git a/src/resources/map/maplayer.h b/src/resources/map/maplayer.h index 1fd3552e1..b4aec3ac3 100644 --- a/src/resources/map/maplayer.h +++ b/src/resources/map/maplayer.h @@ -174,6 +174,8 @@ class MapLayer final: public ConfigListener private: const int mX; const int mY; + const int mPixelX; + const int mPixelY; const int mWidth; const int mHeight; TileInfo *restrict const mTiles; -- cgit v1.2.3-70-g09d2