From b0167b595a952e1decc48c239c95c52e1bc057d7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 26 Oct 2013 21:40:47 +0300 Subject: show main layers based on map mask. --- src/map.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/map.cpp') diff --git a/src/map.cpp b/src/map.cpp index 362693722..3c0c9f4a4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -172,6 +172,7 @@ Map::Map(const int width, const int height, mDrawY(-1), mDrawScrollX(-1), mDrawScrollY(-1), + mMask(1), mAtlas(nullptr), mHeights(nullptr), mRedrawMap(true), @@ -430,6 +431,9 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) layeri != layeri_end && !overFringe; ++ layeri) { MapLayer *const layer = *layeri; + if (!(layer->mMask & mMask)) + continue; + if (layer->isFringeLayer()) { layer->setSpecialLayer(mSpecialLayer); @@ -597,6 +601,8 @@ void Map::updateAmbientLayers(const float scrollX, const float scrollY) const float dy = scrollY - mLastAScrollY; const int timePassed = get_elapsed_time(lastTick); + // need check mask to update or not to update + FOR_EACH (AmbientLayerVectorCIter, i, mBackgrounds) (*i)->update(timePassed, dx, dy); @@ -637,6 +643,7 @@ void Map::drawAmbientLayers(Graphics *const graphics, const LayerType type, // Draw overlays FOR_EACHP (AmbientLayerVectorCIter, i, layers) { + // need check mask to draw or not to draw if (*i) (*i)->draw(graphics, graphics->mWidth, graphics->mHeight); @@ -1603,4 +1610,7 @@ uint8_t Map::getHeightOffset(const int x, const int y) const void Map::setMask(const int mask) { + if (mask != mMask) + mRedrawMap = true; + mMask = mask; } -- cgit v1.2.3-70-g09d2