Sorry to bother you! Right now I'm having a "bug" in my game right now and if someone could point out what I'm doing wrong it would be very helpful. What is happening is when I run my code through Xcode the TileMap loads the file fine.
However when I get the executable generated, copy and paste it into a different place, and then paste all the needed data files into the folder (.png files, .txt files), the game works fine except for the fact that the tilemap won't load.
I'm not sure if this bug is due to the file locations changing when I run it in IDE and in stand alone.
Images: (Sorry I don't have enough reputation so here's links)
Game working run from Xcode:
Game not run from Xcode:
This is the part of the code in TileMap.cpp that deals with loading the data from a text file into an array (just to show you it works):
int t_map[20][15] {};
TileMap::TileMap(std::string fileName, std::string picFile)
{
std::ifstream inFS;
inFS.open(fileName.c_str());
if(!(inFS.is_open()))
{
std::cout << "Could not open file.\n";
return;
}
//controlls row
int tt = 0;
while(!inFS.eof())
{
char buff[100];
//move to buffer thing
inFS.getline(buff, 100);
const char * token[20] = {};
int j = 0;
token[0] = strtok(buff, ",");
if(token[0])
{
for(j=1;j<COLMAX;j++)
{
token[j] = strtok(0, ",");
if(!token[j])
break;
}
}
for(int i=0;i<COLMAX;i++)
{
t_map[i][tt] = atoi(token[i]);
}
tt++;
}
inFS.close();
//ends the loading the file and starts the image stuff
TextureManager::Instance()->load(picFile, "tileMap", Game::Instance()->getRenderer());
}
Contents of text file I pass:
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,3
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
Thank you very much for reading and helping.