A
AiNaKa
Guest
I'm trying to work on a tetris clone, most mainly for practice, but I can't seem to get the collisions to work properly, the pieces won't fit into certain spaces properly. I can't imagine why the collisions aren't working, but I've tried many different approaches to a collision system, but each one is just worse anyways. This is as good as I can seem to get it and it still won't work.
Here is some of my collision code:
And here is the code that controls the falling of the pieces and solidification into individual blocks (which is mostly managed in a seperate line of code):
So far, I've only coded "I" pieces and "T" pieces. The I pieces function completely as intended, but the T pieces get screwed up when trying to land them properly as shown in this screenshot. I can't seem to figure out why this is happening, nor can I fix it. I've also tried solutions using collision_rectangle, but it gets even worse and ends up glitching outside of the box.
Here is some of my collision code:
GML:
///collision
if not place_empty(x,y)
{
if place_empty(x-8,y)
{
x -= 8;
}
if place_empty(x+8,y)
{
x += 8;
}
if place_empty (x,y-8)
{
y -= 8;
}
}
GML:
///drop
if global.drop > 30
{
if place_empty(x,y+1)
{
y += 8
global.drop = 0;
}
else
{
solidify = true;
}
}
So far, I've only coded "I" pieces and "T" pieces. The I pieces function completely as intended, but the T pieces get screwed up when trying to land them properly as shown in this screenshot. I can't seem to figure out why this is happening, nor can I fix it. I've also tried solutions using collision_rectangle, but it gets even worse and ends up glitching outside of the box.