E
Edi
Guest
I am making a game similar to sudoku. I have 3 arrays, arrayS is for the solution, arrayP is for the puzzle (the numbers that are shown to the user) and finally array, which is all the numbers placed and displayed. Once array equals arrayS for every instance, the player wins the game. I want the player to be able to save the game so I need to save all 3 arrays. Currently I have the following in the left pressed event (saving the game everytime the player makes a change)
I then try and reload the game with the following code
The arrays don't get filled with the previous values. In fact, two of the arrays don't have any values. I'm unsure how to solve this issue, i've been looking for a solution for hours. Any help is appreciated
Code:
GridArrayS = ds_grid_create(8, 8);
GridArrayP = ds_grid_create(8, 8);
GridArray = ds_grid_create(8, 8);
i = 0;
j = 0;
repeat (ds_grid_width(GridArrayS))
{
repeat (ds_grid_height(GridArrayS))
{
ds_grid_set(GridArrayS, i, j, global.arrayS[i, j]);
j += 1;
}
j = 0;
i += 1;
}
i = 0;
j = 0;
repeat (ds_grid_width(GridArrayP))
{
repeat (ds_grid_height(GridArrayP))
{
ds_grid_set(GridArrayP, i, j, global.arrayP[i, j]);
j += 1;
}
j = 0;
i += 1;
}
i = 0;
j = 0;
repeat (ds_grid_width(GridArray))
{
repeat (ds_grid_height(GridArray))
{
ds_grid_set(GridArray, i, j, global.array[i, j]);
j += 1;
}
j = 0;
i += 1;
}
ini_open("Save.ini");
ini_write_string("Save", "0", ds_grid_write(GridArrayS));
ini_write_string("Save", "1", ds_grid_write(GridArrayP));
ini_write_string("Save", "2", ds_grid_write(GridArray));
ini_close();
ds_grid_destroy(GridArrayS);
ds_grid_destroy(GridArrayP);
ds_grid_destroy(GridArray);
Code:
GridArrayS = ds_grid_create(8, 8);
GridArrayP = ds_grid_create(8, 8);
GridArray = ds_grid_create(8, 8);
ini_open("Save.ini");
ds_grid_read(GridArrayS, ini_read_string("Save", "0", ""));
ds_grid_read(GridArrayP, ini_read_string("Save", "1", ""));
ds_grid_read(GridArray, ini_read_string("Save", "2", ""));
ini_close();
for (i=0; i<8; i++)
{
for (j=0; j<8; j++)
{
global.arrayS [i , j] = ds_grid_get(GridArrayS, i, j);
}
}
for (i=0; i<8; i++)
{
for (j=0; j<8; j++)
{
global.arrayP [i , j] = ds_grid_get(GridArrayP, i, j);
}
}
for (i=0; i<8; i++)
{
for (j=0; j<8; j++)
{
global.array [i , j] = ds_grid_get(GridArray, i, j);
}
}
ds_grid_destroy(GridArrayS);
ds_grid_destroy(GridArrayP);
ds_grid_destroy(GridArray);