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).
After that, in a create event, these Dead objects send their coordinates to a ds_grid and the active piece instance gets removed.
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.
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.)
//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.)