Here's the function (sorry for length, I'm planning on rewriting it):
void displayTileMapSimply(game *App, int widthPerRow)
{
//This will display the ENTIRE tilemap as simply as possible
std::cout << "wpr at beginning: " << widthPerRow << std::endl;
int u=0; //The current index in the index[];
int intBuffer=0;
int row;
int column;
int top, left, bottom, right;
int posX, posY; //The posiiton that the tile should be displayed at
posX=posY=0;
row=column=0;
std::cout <<"Displaying tile map simply..." << std::endl;
top=left=bottom=right=0;
int currentRow=1;
int currentTile=0;
//int currentColumn=widthPerRow;
while (1) //man, I don't really use these too well
{
row=column=intBuffer=0;
intBuffer=index[u];
if (intBuffer==0)
{
std::cout << "FOUND 0 [END CHARACTER]" << std::endl;
break;
}
if (intBuffer>=32422)
{
std::cout<<"intBuffer is a stupid value..." << std::endl;
u++;
intBuffer=index[u];
}
row=intBuffer;
u++;
intBuffer=index[u];
if (intBuffer==0)
{
std::cout << "FOUND 0 [END CHARACTER]" << std::endl;
break;
}
column=intBuffer;
u++;
//std::cout << "Row-Column: " << row << "-" << column << std::endl;
//if (row>36445) row=1; //Random number, you get the idea
currentTile++;
//std::cout << "--Current Tile: " << currentTile << std::endl;
//Now the code for displaying it from these numbers
//TOP LEFT BOTTOM RIGHT
top=tileY*(row-1);
left=tileX*(column-1);
bottom=tileY*row;
right=tileX*column;
//std::cout << row << "," << column << std::endl;
//std::cout << top <<"-"<< left <<"-"<< bottom <<"-"<< right << std::endl;
tileSheet.setSubRect(top, left, bottom, right);
///////////////////////////////////////////////////////////////////////////////////////////
posX=(currentTile-1)*tileX;
tileSheet.setPosition(posX, posY);
//posY, u + 1(row1 is 1-20), width per row(10), and the row number (1)
//std::cout << "Width Per Row-CurrentTile-PossiblyTrueWPR: " << widthPerRow <<"-"<<currentTile<<"-"<<currentColumn<<std::endl;
if (currentTile==widthPerRow)
{
posY=currentRow*tileY;
currentRow++;
currentTile=0;
}
//std::cout <<"PosX,PosY: "<<posX<<","<<posY<<std::endl;
//if(currentTile==10) posY-=tileY;
App->drawObj(tileSheet);
top=left=bottom=right=0;
//std::cout<<"CurrentTile: " << currentTile << std::endl;
}
}
I've isolated SFML from most of the code because I am planning on making a multi-platform library (PS3 Xbox 360 etc.) so you don't need to change your code.