GML Tetris: Break Blocks up into Pieces (To destroy rows)


Taylor Romey

Hi everyone,

I am creating a Tetris game and am trying to make it so that the rows get destroyed when a row is filled with blocks.
I have 7 different sprites for the block pieces and they all contain 4 cells worth of blocks (each 16 pixels wide and long)
In order to destroy a row, I would need to take all the parts of the pieces that are in that row and destroy them. (Not destroy the entire piece).
To do this I am trying to separate each piece into individual blocks by creating blocks on top of the piece that just settled. So for a block piece with 4 parts, 4 individual objects will be created on top of the parts and then the original block gets destroyed. That way when I need to destroy a row, I can just destroy all blocks in that row.

Now I think I could have made each piece for separate objects from the beginning, but then I thought it would be a little complicated with the rotating. I've seen other Tetris game videos where people form their blocks using an array system, but the system I have now seems to works pretty well. (Block pieces having their own sprite)

In order the create individual dead blocks on top of the the original block piece I am using the following code:

i = 0;
j = 0;

while(i < room_width)
    {j = 0;
    while (j < room_height)
        j += 16
    i += 16
block_on = 0;
This code executes when a block has stopped with a solid block underneath it. It basically uses while loops to check every 16x16 cell in the room and creates dead blocks on top of any cell that contains a block. The original block also gets deleted just so that it doesn't constantly keep creating more dead blocks on top of blocks that are already dead.

For some reason it is creating blocks randomly around the blocks. Each block's dimensions are a multiple of 16 and the collisions are set to precise (per frame) so I'm not sure if it could be an issue with the borders of the sprite.

In the image below, the coloured bocks are where thea blocks land after touching the floor, and the grey blocks are dead blocks that are created to replace the original blocks. There are also grey blocks underneath the coloured blocks but I put the coloured ones on top so you can see the grey blocks created in locations where they are not supposed to be. Grey blocks also get created inside the walls as well for some reason.


Last edited by a moderator:


Try using position_meeting() instead of place_meeting.

Postion_meeting() will check only one pixel (which will be the top left corner of each grid). Place_meeting() is moving the instance calling the code to the x,y position you have passed and then checking for a collision with the passed object. This may mean you are checking a much larger area than you imagine depending on what instance is calling this code.
  • Like
Reactions: Yal


Maybe consider using a grid, which I guess is probably the array method you mentioned. Would simplify a lot of your code methinks.


šŸ§ *penguin noises*
GMC Elder
Try using position_meeting() instead of place_meeting.
Seconding this, place_meeting() checks a much larger area than you want in this case so you'll get lots of false positives, resulting in those random blocks you see.

EDIT: I'm also pretty sure place_meeting() won't return collisions with the calling instance, so that would explain why blocks aren't created in the actual live block's cells.


I'm also currently making a tetris clone, however I'm using 2D arrays and a single block to make my shapes instead of sprite shapes, I then use collision_point() to check for full lines by checking each block position ( I have a 10x26 grid for my play area assigned to vars) and it works just fine.

Taylor Romey

I see. The position meeting solved the problem :) Thanks guys!

And it seems like there are a lot of ways to go about making a Tetris clone. Good luck with yours @trichome