• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker ds_grid size (w,h) is that actually (r,c)?

J

jb skaggs

Guest
Also in the manual it says:

ind=ds_grid_create(w,h)


but it seems w seems to be the number of rows and h seems to be the number of columns when I try and use it.

Am I misunderstanding?

JB
 

GMWolf

aka fel666
Also in the manual it says:

ind=ds_grid_create(w,h)


but it seems w seems to be the number of rows and h seems to be the number of columns when I try and use it.

Am I misunderstanding?

JB
yes, w stands for width, and h for height.
They are the same thing.
 
J

jb skaggs

Guest
if I create grid 4,3
Code:
mygrid=(ds_grid_create(4,3);
repeat ds_grid_width(mygrid)
{
         repeat ds_grid_height(mygrid)
{
                   mygrid[#,i,j]=0;
                    j++;
}
j=0;
i++;
}
actually for me ends up with:
0 0 0
0 0 0
0 0 0
0 0 0

which seems backwards of w,h
 
H

Homunculus

Guest
If you do ds_grid_create(4,3), you address the cell at the "bottom right" with grid[# 3,2].
 
J

jb skaggs

Guest
Thanks, I gotcha. What I was referring was more to the w, h thing which W on a spreadsheet would be number of columns and H would be number of rows.

but in this function it is reversed. So that W is number of rows, and H is number of columns.
 
To be honest, I find it to be a bit backwards too. When I see "grid [# 0, 3]" I think row 0 column 3, but it feels backward cause rows should be the y coordinate and columns the x coordinate, buts it's actually "grid [# x, y]". Feels wrong to me.

Edit: Wait. I'm dumb, it's [y, x]. the backwards part is defining it with [w, h].
 
Last edited:
J

jb skaggs

Guest
To be honest, I find it to be a bit backwards too. When I see "grid [# 0, 3]" I think row 0 column 3, but it feels backward cause rows should be the y coordinate and columns the x coordinate, buts it's actually "grid [# x, y]". Feels wrong to me.

I keep thinking what am I missing? Glad to know Im not alone.
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
if I create grid 4,3
Code:
var i = 0, j = 0;

mygrid=ds_grid_create(4,3);
repeat ds_grid_height(mygrid)  {
      repeat ds_grid_width(mygrid)
      {
            mygrid[# i, j]=0;
            j++;
      }
      j = 0;
      i++;
}
you used ds_grid_width and ds_grid_height in the wrong place!
 
Last edited:
Top