the loading and saving:
Code: Select all
void Level::Save_Map(string save, int H, int W)
{
ofstream Save;
cout<<"Saving to: "<< save <<endl;
Save.open( save.c_str() );
Save<<"H "<< H <<" W "<< W <<"\n\n";
if(!Save.bad())
{
for(int a = 0; a < z; a++)
{
for(int b = 0; b < x; b++)
{
for(int c = 0; c < y; c++)
{
Save<<"Layer "<< a << " Tile "<< c;
Save<<" X "<< tile[a][b][c].x <<" Y " << tile[a][b][c].y;
Save<<" Strip_x "<< tile[a][b][c].s_x;
Save<<" Strip_y "<<tile[a][b][c].s_y;
Save<<" Hieght "<< H;
Save<<" Width "<< W;
Save<<" END \n\n";
}
Save<<"\n";
}
Save<<"\n \n \n";
}
}
else
{
cout<<"File failed creation"<<endl;
}
Save.close();
}
void Level::Load_Map(string load)
{
ifstream Load;
Load.open( load.c_str() );
string temp;
if(Load.is_open())
{
cout<<"Found file"<<endl;
while(Load>>temp)
{
if(temp == "Layer")
{
Load>>layer;
}
if(temp == "Tile")
{
Load>>tile_count;
}
if(temp == "X")
{
Load>>x_coord;
}
if(temp == "Y")
{
Load>>y_coord;
}
if(temp == "Strip_x")
{
Load>>strip_x;
}
if(temp == "Strip_y")
{
Load>>strip_y;
}
if(temp == "H")
{
Load>>h;
}
if(temp == "W")
{
Load>>w;
}
if(temp == "END")
{
tile[layer][x_coord / w][y_coord / h].x = x_coord;
tile[layer][x_coord / w][y_coord / h].y = y_coord;
tile[layer][x_coord / w][y_coord / h].s_x = strip_x;
tile[layer][x_coord / w][y_coord / h].s_y = strip_y;
tile[layer][x_coord / w][y_coord / h].h = h;
tile[layer][x_coord / w][y_coord / h].w = w;
}
}
}
else
{
cout<<"Could not open file:"<< load <<endl;
}
Load.close();
}
Code: Select all
level.Save_Map(console.entered,32,32);
which proves that its gettin it but not loadin or savin.
ex: in Level::Save():
Code: Select all
cout<<"Saving to: "<< save <<endl;
