diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-03-03 21:43:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-03-03 21:43:25 +0300 |
commit | 4039ef116901d4513c3535cc119dc40abd8e14df (patch) | |
tree | 238a2e6734adf42186871a9884a69af12fe8de66 | |
parent | bccb486d184b26638d3e47507bc6260383950b8b (diff) | |
download | plus-4039ef116901d4513c3535cc119dc40abd8e14df.tar.gz plus-4039ef116901d4513c3535cc119dc40abd8e14df.tar.bz2 plus-4039ef116901d4513c3535cc119dc40abd8e14df.tar.xz plus-4039ef116901d4513c3535cc119dc40abd8e14df.zip |
Improve a bit pixel calculation in map layers.
-rw-r--r-- | src/resources/map/maplayer.cpp | 18 | ||||
-rw-r--r-- | 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; |