GMS 2 Need help retrieving (reading) data from ds_grid

Lens

Member
Hello! I'm making a tile-matching game (Tetris). After a piece fall down and collides for a second its' underneath collision rectangle, it creates "Dead tiles" so to say ( gets converted into 4 "dead" objects).


//In one of the pieces Triggered alarm
if collidedU = 1
{
global.Morph = 1;
instance_create_layer(x, y - 30, "Pieces", Dead7);
instance_create_layer(x + 30, y - 30, "Pieces", Dead4);
instance_create_layer(x + 60, y - 30, "Pieces", Dead1);
instance_create_layer(x, y, "Pieces", Dead8);
global.Encaixado = 1;
instance_destroy();
}
}


After that, in a create event, these Dead objects send their coordinates to a ds_grid and the active piece instance gets removed.


//In the Dead "Create"
global.Deaderino1X = self.x;
global.Deaderino1Y = self.y;

// v In a "manager object" step event v

ds_grid_set(jam, (global.Deaderino1X /30) - 1, (global.Deaderino1Y - 179)/30 - 1, 1);


Now, once you have more than 10 dead objects in the same line, they all get removed (by a line collision), and all the lines (above said line row) in ds_grid gets taken down by 1 row.


//In "manager object" Step event
list = ds_list_create();
num = collision_line_list(45, 1033, 310, 1037, Dead, false, true, list, false);
if num >= 10
{
for (var i = 0; i < num; ++i;)
{
getalldown = true;
instance_destroy(list[| i]);
}
}
ds_list_destroy(list);

if global.Combo >= 1
{
if(alarm[0] == -1)
{
alarm[0]= 25;
}
}

//and this one is for the ds_grid

if ds_grid_get_min(jam, 0, 28, 10, 28) > 0
{
ds_grid_set_grid_region(jam, jam, 0, 0, 10, 28, 0, 1);
}


The issue is, how to take the pieces down using the ds_grid? (I've tried using the dead pieces to move down, but considering their ammount (dozens, maybe hundreds at a time) running step events nonstop, completely depleted the cpu; thus, I believe that using the ds_grid to realocate them might be a better idea, just don't know how.)
 

flyinian

Member
Just an idea: You could maybe break the blocks into chunks and move each chunk down one at a time. This may lessen the amount of processing that needs to be done at one time. While the these chunks are shifting, disable player input.
 

Lens

Member
Just an idea: You could maybe break the blocks into chunks and move each chunk down one at a time. This may lessen the amount of processing that needs to be done at one time. While the these chunks are shifting, disable player input.
Thank you for your answer!
Are chunks buffers? How can I create chunks on GMS2? Also, could making them so, affect the detection of the dead pieces by the active one?
 

flyinian

Member
Thank you for your answer!
Are chunks buffers? How can I create chunks on GMS2? Also, could making them so, affect the detection of the dead pieces by the active one?
I'm not competent enough with GML to answer any of that.

Sorry about that.
 
Top