summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-05-31 22:23:23 +0300
committerAndrei Karas <akaras@inbox.ru>2012-05-31 22:23:23 +0300
commitfc5ba333f8832f3d8e054e7c74df1e3cd353645f (patch)
tree16aabceaaa2b197d006bd357d3176acac292cde7 /src/map.cpp
parent9875c00dc37b1d7b55e1154075a0cd2d997a490d (diff)
downloadmv-fc5ba333f8832f3d8e054e7c74df1e3cd353645f.tar.gz
mv-fc5ba333f8832f3d8e054e7c74df1e3cd353645f.tar.bz2
mv-fc5ba333f8832f3d8e054e7c74df1e3cd353645f.tar.xz
mv-fc5ba333f8832f3d8e054e7c74df1e3cd353645f.zip
Add sittop sprites support.
Add groundtop collision support (not collision but special selected tiles).
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp109
1 files changed, 30 insertions, 79 deletions
diff --git a/src/map.cpp b/src/map.cpp
index f843479c0..6afaaa727 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -465,6 +465,29 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
drawAmbientLayers(graphics, FOREGROUND_LAYERS, mOverlayDetail);
}
+#define fillCollision(collision, color) \
+ if (x < endX && mMetaTiles[tilePtr].blockmask & collision)\
+ {\
+ width = 32;\
+ for (int x2 = tilePtr + 1; x < endX; x2 ++)\
+ {\
+ if (!(mMetaTiles[x2].blockmask & collision))\
+ break;\
+ width += 32;\
+ x ++;\
+ tilePtr ++;\
+ }\
+ if (width && userPalette)\
+ {\
+ graphics->setColor(userPalette->getColorWithAlpha(\
+ UserPalette::color));\
+ graphics->fillRectangle(gcn::Rectangle(\
+ x0 * mTileWidth - scrollX,\
+ y * mTileHeight - scrollY,\
+ width, 32));\
+ }\
+ }\
+
void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
int debugFlags)
{
@@ -500,85 +523,10 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
int width = 0;
int x0 = x;
- if (mMetaTiles[tilePtr].blockmask & BLOCKMASK_WALL)
- {
- width = 32;
- for (int x2 = tilePtr + 1; x < endX; x2 ++)
- {
- if (!(mMetaTiles[x2].blockmask
- & BLOCKMASK_WALL))
- {
- break;
- }
- width += 32;
- x ++;
- tilePtr ++;
- }
- if (width && userPalette)
- {
- graphics->setColor(userPalette->getColorWithAlpha(
- UserPalette::COLLISION_HIGHLIGHT));
-
- graphics->fillRectangle(gcn::Rectangle(
- x0 * mTileWidth - scrollX,
- y * mTileHeight - scrollY,
- width, 32));
- }
- }
-
- if (x < endX && mMetaTiles[tilePtr].blockmask
- & BLOCKMASK_AIR)
- {
- width = 32;
- for (int x2 = tilePtr + 1; x < endX; x2 ++)
- {
- if (!(mMetaTiles[x2].blockmask
- & BLOCKMASK_AIR))
- {
- break;
- }
- width += 32;
- x ++;
- tilePtr ++;
- }
- if (width && userPalette)
- {
- graphics->setColor(userPalette->getColorWithAlpha(
- UserPalette::AIR_COLLISION_HIGHLIGHT));
-
- graphics->fillRectangle(gcn::Rectangle(
- x0 * mTileWidth - scrollX,
- y * mTileHeight - scrollY,
- width, 32));
- }
- }
-
- if (x < endX && mMetaTiles[tilePtr].blockmask
- & BLOCKMASK_WATER)
- {
- width = 32;
- for (int x2 = tilePtr + 1; x < endX; x2 ++)
- {
- if (!(mMetaTiles[x2].blockmask
- & BLOCKMASK_WATER))
- {
- break;
- }
- width += 32;
- x ++;
- tilePtr ++;
- }
- if (width && userPalette)
- {
- graphics->setColor(userPalette->getColorWithAlpha(
- UserPalette::WATER_COLLISION_HIGHLIGHT));
-
- graphics->fillRectangle(gcn::Rectangle(
- x0 * mTileWidth - scrollX,
- y * mTileHeight - scrollY,
- width, 32));
- }
- }
+ fillCollision(BLOCKMASK_WALL, COLLISION_HIGHLIGHT);
+ fillCollision(BLOCKMASK_AIR, AIR_COLLISION_HIGHLIGHT);
+ fillCollision(BLOCKMASK_WATER, WATER_COLLISION_HIGHLIGHT);
+ fillCollision(BLOCKMASK_GROUNDTOP, GROUNDTOP_COLLISION_HIGHLIGHT);
}
}
}
@@ -691,6 +639,9 @@ void Map::blockTile(int x, int y, BlockType type)
case BLOCKTYPE_GROUND:
mMetaTiles[tileNum].blockmask |= BLOCKMASK_GROUND;
break;
+ case BLOCKTYPE_GROUNDTOP:
+ mMetaTiles[tileNum].blockmask |= BLOCKMASK_GROUNDTOP;
+ break;
default:
case BLOCKTYPE_NONE:
case NB_BLOCKTYPES: