I'm really stumped. I'm using Code::Blocks and SDL.
I'm trying to load some images, and it runs fine through the Code::Blocks, but when run through the explorer it fails every time.
I've tried putting the images essentially everywhere, I even used to absolute path to them and it still couldn't find 'em.
Here is the function that doesn't give any trouble in the IDE, but won't work outside:
Code:
bool loadResources()
{
/*Load boards*/
surfaces[SURF_TTT1] = IMG_Load("ttt1.png");
if (!surfaces[SURF_TTT1]) {
return false;
}
surfaces[SURF_TTT2] = IMG_Load("ttt2.png");
if (!surfaces[SURF_TTT2]) {
return false;
}
surfaces[SURF_TTT3] = IMG_Load("ttt3.png");
if (!surfaces[SURF_TTT3]) {
return false;
}
surfaces[SURF_TTT4] = IMG_Load("ttt4.png");
if (!surfaces[SURF_TTT4]) {
return false;
}
surfaces[SURF_TTT5] = IMG_Load("ttt5.png");
if (!surfaces[SURF_TTT5]) {
return false;
}
/*Load Xs*/
surfaces[SURF_X1] = IMG_Load("x1.png");
if (!surfaces[SURF_X1]) {
return false;
}
surfaces[SURF_X2] = IMG_Load("x2.png");
if (!surfaces[SURF_X2]) {
return false;
}
surfaces[SURF_X3] = IMG_Load("x3.png");
if (!surfaces[SURF_X3]) {
return false;
}
surfaces[SURF_X4] = IMG_Load("x4.png");
if (!surfaces[SURF_X4]) {
return false;
}
surfaces[SURF_X5] = IMG_Load("x5.png");
if (!surfaces[SURF_X5]) {
return false;
}
/*Load Os*/
surfaces[SURF_O1] = IMG_Load("o1.png");
if (!surfaces[SURF_O1]) {
return false;
}
surfaces[SURF_O2] = IMG_Load("o2.png");
if (!surfaces[SURF_O2]) {
return false;
}
surfaces[SURF_O3] = IMG_Load("o3.png");
if (!surfaces[SURF_O3]) {
return false;
}
surfaces[SURF_O4] = IMG_Load("o4.png");
if (!surfaces[SURF_O4]) {
return false;
}
surfaces[SURF_O5] = IMG_Load("o5.png");
if (!surfaces[SURF_O5]) {
return false;
}
/*Load Positions*/
imagePos[POS_TTT].x = (int)((0.5*xr)-(0.5*400));
imagePos[POS_TTT].y = (int)((0.5*yr)-(0.5*400));
imagePos[POS_1].x = imagePos[POS_TTT].x + 15;
imagePos[POS_1].y = imagePos[POS_TTT].y + 15;
imagePos[POS_2].x = imagePos[POS_TTT].x + 15 + 130;
imagePos[POS_2].y = imagePos[POS_TTT].y + 15;
imagePos[POS_3].x = imagePos[POS_TTT].x + 15 + 260;
imagePos[POS_3].y = imagePos[POS_TTT].y + 15;
imagePos[POS_4].x = imagePos[POS_TTT].x + 15;
imagePos[POS_4].y = imagePos[POS_TTT].y + 15 + 130;
imagePos[POS_5].x = imagePos[POS_TTT].x + 15 + 130;
imagePos[POS_5].y = imagePos[POS_TTT].y + 15 + 130;
imagePos[POS_6].x = imagePos[POS_TTT].x + 15 + 260;
imagePos[POS_6].y = imagePos[POS_TTT].y + 15 + 130;
imagePos[POS_7].x = imagePos[POS_TTT].x + 15;
imagePos[POS_7].y = imagePos[POS_TTT].y + 15 + 260;
imagePos[POS_8].x = imagePos[POS_TTT].x + 15 + 130;
imagePos[POS_8].y = imagePos[POS_TTT].y + 15 + 260;
imagePos[POS_9].x = imagePos[POS_TTT].x + 15 + 260;
imagePos[POS_9].y = imagePos[POS_TTT].y + 15 + 260;
return true;
}
It loads some static images, and does a few other things. It returns false if any of the images could not be loaded.
Does anyone have suggestions?