1D array to 2D array conversion help!
Hello.
Im making a game for a certain community and I can load in these map levels. Each level is exactly 592 bytes -
30x20 (30 chars to the right, 20 down) + end of line char and '\n' char. Oh but hte last line is the password for hte level so its only 4x20 if it wree gridded.
Anyways, Im trying to grid it like that in a 2D array. My function:
Code:
void WorkWithMap() {
for(i=0;i<19;i++) {
for(z=0;z<30;z++) {
level[i][z]=map[i*z];
}
}
}
I dont WANT the password in there, so i didnt read up to 20 (hence i<19). This way doesnt work as when printing out, its all random and multiple characters where there is only one of in the file. So... Please help?
I believe one reason is because if
i=0
and z=... say...
z=23
Than
level[i][z] = map[ 0 * 23 ]
thus resulting in map[0] through out the entire thing... Any way to make it work?