Game/Source/Map.cpp
// Draw each layer of the map
Draw each layer of the map
Draw each layer of the map
void Map::DrawLayer(int num, bool parallax)
{
	if (num < data.layers.Count())
	{
		MapLayer* layer = data.layers[num];
		for (int y = 0; y < data.height; ++y)
		{
			for (int x = 0; x < data.width; ++x)
			{
				int tileId = layer->Get(x, y);
				if (tileId > 0)
				{
					TileSet* tileset = GetTilesetFromTileId(tileId);
					SDL_Rect rec = tileset->GetTileRect(tileId);
					iPoint pos = MapToWorld(x, y);
					if (parallax == true)
					{
						render->DrawTexture(tileset->texture, pos.x + tileset->offsetX, pos.y + tileset->offsetY, &rec, 1.3f);
					}
					else
					{
						render->DrawTexture(tileset->texture, pos.x + tileset->offsetX, pos.y + tileset->offsetY, &rec);
					}
				}
			}
		}
	}
}
void Map :: DrawLayer ( int num , bool parallax ) { if ( num < data . layers . Count ( ) ) { MapLayer * layer = data . layers [ num ] ; for ( int y = 0 ; y < data . height ; ++ y ) { for ( int x = 0 ; x < data . width ; ++ x ) { int tileId = layer -> Get ( x , y ) ; if ( tileId > 0 ) { TileSet * tileset = GetTilesetFromTileId ( tileId ) ; SDL_Rect rec = tileset -> GetTileRect ( tileId ) ; iPoint pos = MapToWorld ( x , y ) ; if ( parallax == true ) { render -> DrawTexture ( tileset -> texture , pos . x + tileset -> offsetX , pos . y + tileset -> offsetY , & rec , 1.3f ) ; } else { render -> DrawTexture ( tileset -> texture , pos . x + tileset -> offsetX , pos . y + tileset -> offsetY , & rec ) ; } } } } } }
Draw each layer of the map
Draw each layer of the map
//render->scale = scale; //render->scale = 1; // ???