ds_grid - inserting rows

F

freaky

Guest
Hello guys,

I am working on a procedural room generation , however I am storing all the data in a ds_grid before creating everything. The thing is that let's say I make a ds_grid which is for instance 40x40 and if I need to expand it I can just use ds_grid_resize. However this adds extra rolls and columns at the end and in my case sometimes I need to add additional rows and columns at the beginning of the ds_grid. I tried creating a temporary second ds_grid which is bigger and then copying the first grid on another position but I get strange results o_O
Code:
        var temp_w = width+path_length;
        var temp_h = width+path_length;
        var t_grid = ds_grid_create(temp_w,temp_h);
        ds_grid_set_region(t_grid,0,0,temp_w,temp_h,-1);
        ds_grid_copy(grid,t_grid);
        ds_grid_resize(grid,temp_w,temp_h);
        ds_grid_clear(grid,-1);
        ds_grid_set_grid_region(t_grid,grid,0,0,width,height,path_length,path_length);
        ds_grid_destroy(t_grid);
        width+=path_length;
        height+=path_length;
        xx+=path_length;
        yy+=path_length;
xx and yy are the coords of the current position.
Any ideas what's wrong?
 
W

whale_cancer

Guest
What are your strange results? From what you describe, I suspect ds_grid_copy copies the size of the grid as well its contents, but I don't see anything about that in the documentation.

Edit: Wait, why do you resize the grid after performing the copy?
 
J

Jason Curry

Guest
ds_grid_resize(index, w, h);

lots of great info in the help file. I don't think I ever have GM:S open without the help file open as well.
 
Top