ABC_Sprite GetSpriteFromTile(const ABC_Tile& tile, Uint16 startTile, Uint16 endTile, Uint16 time, Uint8 r, Uint8 g, Uint8 b, bool transparent) { file.open("liteharochdar.txt"); ABC_Sprite tmpSpr; tmpSpr.m_Width = tile.m_tileW; tmpSpr.m_Height = tile.m_tileH; tmpSpr.m_BBox.x = 0; tmpSpr.m_BBox.y = 0; tmpSpr.m_BBox.w = tile.m_tileW; tmpSpr.m_BBox.h = tile.m_tileH; //tmp_tlX = temporary tile X //tmp_tlY = temporary tile Y //tpr = tiles per row //dh = difference in height per tile Uint16 tmp_tlX, tmp_tlY, tpr, dW, dH; tpr = (tile.m_width-tile.m_offsetX)/(tile.m_tileW+tile.m_spaceW); dW = tile.m_tileW + tile.m_spaceW; dH = tile.m_tileH + tile.m_spaceH; file << "tpr-" << tpr << endl << "dW-" << dW << endl << "dH-" << dH << endl << endl; //Calculate the startPosition tmp_tlY = startTile/tpr; tmp_tlX = startTile - tpr*tmp_tlY; file << "tmp_tlY-" << tmp_tlY << endl << "tmp_tlX-" << tmp_tlX << endl << "startTile-" << startTile << endl << endl; //Iterate through the chosen tiles for (int i = startTile; i <= endTile; i++) { ABC_Image tmpImg; tmpImg.m_time = time; SDL_Rect tmpRct; tmpRct.w = tile.m_tileW; tmpRct.h = tile.m_tileH; tmpRct.x = tmp_tlX * (tile.m_tileW+tile.m_spaceW) + tile.m_offsetX; tmpRct.y = tmp_tlY * (tile.m_tileH+tile.m_spaceH) + tile.m_offsetY; file << tmpRct.x << "x" << tmpRct.y << endl; //SDL_Surface* bajs; //SDL_BlitSurface(tile.m_surface, &tmpRct, bajs, NULL); //SDL_BlitSurface(bajs, NULL, tmpImg.m_surface, NULL); SDL_BlitSurface(tile.m_surface, &tmpRct, tmpImg.m_surface, NULL); /* if (transparent) SDL_SetColorKey(tmpImg.m_surface, SDL_SRCCOLORKEY, SDL_MapRGB(tmpImg.m_surface->format, r, g, b)); */ file << "hee!" << endl; tmpSpr.m_ImageList.push_back(tmpImg); tmp_tlX++; if (tmp_tlX >= tpr) { tmp_tlY++; tmp_tlX = 0; } } //tmpSpr.m_ImageList.push_back(tmpImg); //SDL_BlitSurface(tile.m_surface, NULL, tmpImg.m_surface, NULL); //tmpSpr.m_ImageList.push_back(tmpImg); file.close(); return tmpSpr; }