Exemple #1
0
void
TileCell::Draw(Bitmap* bitmap, GFX::rect *rect, bool advanceFrame, bool full)
{
	MapOverlay* overlayZero = fOverlays[0];
	if (overlayZero == NULL)
		return;

	TileMap* tileMapZero = overlayZero->TileMapForTileCell(fNumber);
	if (tileMapZero == NULL) {
		std::cerr << "Tilemap Zero is NULL!" << std::endl;
		return;
	}
	const int8 mask = tileMapZero->Mask();
	int maxOverlay = full ? fNumOverlays : 1;
	for (int i = maxOverlay - 1; i >= 0; i--) {
		if (!ShouldDrawOverlay(i, mask))
			continue;
	    MapOverlay *overlay = fOverlays[i];
		TileMap *map = overlay->TileMapForTileCell(i == 0 ? fNumber : 0);
		if (map == NULL)
			continue;

		int16 index = map->TileIndex(advanceFrame);
		if (fDoor != NULL && !fDoor->Opened()) {
			int16 secondaryIndex = map->SecondaryTileIndex();
			if (secondaryIndex != -1)
				index = secondaryIndex;
			else
				std::cerr << "TileCell::Draw(): secondary index is -1. BUG?." << std::endl;
		}

		TISResource *tis = gResManager->GetTIS(overlay->TileSet());
		Bitmap *cell = tis->TileAt(index);
		assert(cell != NULL);

		gResManager->ReleaseResource(tis);

		GFX::Color *color = NULL;
		if (i == 0 && mask != 0) {
			color = &sTransparentColor;
			//color = &cell->format->palette->colors[255];
		}

		_DrawOverlay(bitmap, cell, *rect, color);

		cell->Release();
	}
}
Exemple #2
0
void
TileCell::AdvanceFrame()
{
	MapOverlay* overlayZero = fOverlays[0];
	if (overlayZero == NULL)
		return;

	TileMap* tileMapZero = overlayZero->TileMapForTileCell(fNumber);
	if (tileMapZero == NULL)
		return;

	const int8 mask = tileMapZero->Mask();
	for (int i = fNumOverlays - 1; i >= 0; i--) {
		if (!ShouldDrawOverlay(i, mask))
			continue;
		MapOverlay *overlay = fOverlays[i];
		TileMap *map = overlay->TileMapForTileCell(i == 0 ? fNumber : 0);
		if (map != NULL)
			map->TileIndex(true);
	}
}