T
Taylor Romey
Guest
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:
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.
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:
Code:
i = 0;
j = 0;
while(i < room_width)
{j = 0;
while (j < room_height)
{
if(place_meeting(i,j,obj_block))
{instance_create_depth(i,j,depth-1,obj_after_block);}
j += 16
}
i += 16
}
instance_create_depth(room_width/2,-16,depth,obj_block);
block_on = 0;
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: