I am making the collision resolution system for my 2d top-down game, and I managed to find a solution where I query which surfaces of other AABBs the current entity can collide with in the next frame.
To resolve the new location of the player however, I need to find which surface the entity collides with first.
I have a list of lines, which is LinkedList<int[4]> collidedLines
. a line is {x1,y1,x2,y1}
, however in this case, they are axis-aligned, so either x1==x2 or y1==y2.
I also have the entity, which has the following properties:
int posX
int posY
int speedX // The amount to move in the
int speedY // next step of the game.
int size // The halfwidth of the square AABB.
How can I find the first line the entity collides with? Thanks for your help!