I am developing an Android game and I would like to know how to detect the collision of a rectangle knowing its position (x and y), width and height and a triangle knowing x,y, width and height. Triangles are always right triangles as the result of dividing a rectangle through its diagonal so the (x,y) parameter will be a position in the hypotenuse, not the center of the triangle.
Any help would be appreciated!
I am developing an Android game and I would like to know how to
Share
I´ve finally done this using the function intersect for two lines. Lines are defined with initial point (x,y) and final point (x,y)
To know if a triagle intersects a rectangle you check the intersection of every line from the triangle with every line from the rectangle with function above.