GML Question, realted to ds_grids

Posted by foslock on Oct. 20, 2006, 4:21 p.m.

Hey, I have a question for the 64d crowd. I consider myself an experienced GMer but I have failed to learn about data structures. So I decided that I would teach myself. I'm starting with grids, and I am making a game like bejeweled. So far so good, I've gotten it to relate the type of gem to the grid place but I need some help with something.

How do I quickly check for gems in a combination. I pretty much need it to check for 3 or more in a row or column or diagonal. This sounds really, really tough and I have made a script that sorta does half of what I want:

var i,ii;

for (i=0;i(lessthan)ds_grid_width(global.grid);i+=1)

for (ii=0;ii(lessthan)ds_grid_height(global.grid);ii+=1)

{

if ds_grid_get_max(global.grid,i,ii,i+2,ii) != 0

if ds_grid_get_max(global.grid,i,ii,i+2,ii) = ds_grid_get_min(global.grid,i,ii,i+2,ii)

return 1;

if ds_grid_get_max(global.grid,i-2,ii,i,ii) != 0

if ds_grid_get_max(global.grid,i-2,ii,i,ii) = ds_grid_get_min(global.grid,i-2,ii,i,ii)

return 2;

if ds_grid_get_max(global.grid,i-1,ii,i+1,ii) != 0

if ds_grid_get_max(global.grid,i-1,ii,i+1,ii) = ds_grid_get_min(global.grid,i-1,ii,i+1,ii)

return 2;

if ds_grid_get_max(global.grid,i,ii,i,ii+2) != 0

if ds_grid_get_max(global.grid,i,ii,i,ii+2) = ds_grid_get_min(global.grid,i,ii,i,ii+2)

return 4;

if ds_grid_get_max(global.grid,i,ii-2,i,ii) != 0

if ds_grid_get_max(global.grid,i,ii-2,i,ii) = ds_grid_get_min(global.grid,i,ii-2,i,ii)

return 5;

if ds_grid_get_max(global.grid,i,ii-1,i,ii+1) != 0

if ds_grid_get_max(global.grid,i,ii-1,i,ii+1) = ds_grid_get_min(global.grid,i,ii-1,i,ii+1)

return 6;

}

I really have no way to test this and I need some outside help. If JakeX is feeling particulaly gracious he might help me out because I know he did this in ColumnsX.

Any help is much appreciated and would get me one step closer to releasing the WIP. Not that anyone would really care, but the feeling that you just helped someone would remain in your heart [:)].

Thanks for atleast reading this.

Comments

foslock 18 years, 1 month ago

Haha, well, both [:D]