- Code: Select all
int MAP[16][10][8];
// Saves ALL levels
void save_levels()
{
FILE * map = fopen("Levels", "w");
int i,j,k;
for(k=0; k<16; k++)
{
for(j=0; j<10; j++)
{
for(i=0; i<8; i++)
{
fputc(MAP[k][j][i], map);
}
}
}
fclose(map);
}
// Loads ALL levels
void load_levels()
{
FILE * map = fopen("Levels", "r");
int i,j,k;
for(k=0; k<16; k++)
{
for(j=0; j<10; j++)
{
for(i=0; i<8; i++)
{
MAP[k][j][i] = fgetc(map);
}
}
}
fclose(map);
}
// Display NUM level
void display_map(int num)
{
int i,j;
for(j=0; j<10; j++)
{
for(i=0; i<8; i++)
{
if(MAP[num][j][i]>0 && MAP[num][j][i] < 10)
{
char * anim = getAnimName(MAP[num][j][i]-1);
CreateActor("tile", anim, "(none)", "(none)", 30*j, 30*i, true);
}
else if(MAP[num][j][i] >= 10)
{
char * anim = getAnimName(MAP[num][j][i]-9);
CreateActor("goal", anim, "(none)", "(none)", 30*j, 30*i, true);
}
}
}
}
My question is this: It seems to work now, but can this cause problems in the future? I just have this feeling that I messed up the thinking somehow. Or does someone have a better way to do this? I don't want to have 16 level files sitting in the same folder as the .exe. Too bad GE can't get into folders.
Thanks
EDIT: I lied, I filled the whole screen and tried to save then load and display only to find several squares missing