I think I can take tomorrow a better look. But didnt realise it yesterday yet, but seeing this again now I think I know what is likely the problem.
Thing is, you are assuming there are four different possibilities to collide. Left, Right, Top, Bottom.
But in reality you have only Two collisions happening, the first two: Left and Right.
For thing is, when you have collision that would fulfill TOP or BOTTOM, it will also at same time fulfill one of the LEFT or RIGHT conditions.
Thing is,
Code: Select all
IF Condition 1
ELSEIF Condition 2
ELSEIF Condition 3
ENDIF
Work in such way that if Condition 1 is fulfilled, then it doesnt even check Condition 2 and 3 at all.
So in this case you could have that Condition 2 (LEFT) and Condition 3 (BOTTOM) are both fulfilled, and in this case, only Condition 2 is executed, since it happens first in the list.
Since Collision in your code in practice always happens from two different sides at same time.
As an example:
Code: Select all
AAAAA
A A
A A
XXXXX
XAAAX
B B
B B
BBBBB
You might think that Box B is hitting Box A from Bottom, which is true, but, B is also touching A from LEFT side, since they both have same X.
Therefore in your IF-ELSEIF-ELSEIF, it notices that condition of hitting from LEFT side is already true before it checks the BOTTOM, and hence the BOTTOM check is never checked or executed.