Ok, I have another problem when im trying to save tiledata to a file.
Code: AGS
It should work that pressing f5 saves tiles[].x[] to tiles.dat and f6 loads the stored data back to tiles[].x[]. But from some reason when I load the stored data, only first row of the data is returned (that means tiles[0].x[from 0 to 20]). Values in tiles[1].x[], tiles[2].x[]... are 0. Code is short and simple so the problem should be easy to fiqure out but i just dont see it.
tiles[].x[] is like this:
Code: AGS
if (keycode == eKeyF5) {
File *output = File.Open("tiles.dat",eFileWrite);
if (output == null) Display("Error opening file.");
else {
int tx = 0; int ty = 0;
while (ty < 15) {
while (tx < 20) {
output.WriteInt(tiles[ty].x[tx]);
tx++;
}
ty++;
}
output.Close();
}
}
if (keycode == eKeyF6) {
File *input = File.Open("tiles.dat",eFileRead);
if (input == null) Display("Error opening file.");
else {
int tx = 0; int ty = 0;
while (ty < 15) {
while (tx < 20) {
tiles[ty].x[tx] = input.ReadInt();
tx++;
}
ty++;
}
input.Close();
}
}
It should work that pressing f5 saves tiles[].x[] to tiles.dat and f6 loads the stored data back to tiles[].x[]. But from some reason when I load the stored data, only first row of the data is returned (that means tiles[0].x[from 0 to 20]). Values in tiles[1].x[], tiles[2].x[]... are 0. Code is short and simple so the problem should be easy to fiqure out but i just dont see it.
tiles[].x[] is like this:
struct TileDataSt {
int x[20];
};
TileDataSt tiles[15];