I have try many things without finding the good solution so here I am.
In my game (2D) I have to check collision with all my Object (house, garage..) which are image inside Rotated Rectangle
, between a ray from a Point A
to Point B
.
I'm using Xna and there some code:
public void Update(List<Obstacle> Lob, DragObj Ldo)
{
bool inter = false;
Point A;
Point B;
A = new Point((int)pos.X, (int)pos.Y);
B = new Point((int)Ldo.Position.X, (int)Ldo.Position.Y);
for (int j = 0; j < Lob.Count(); j++)
{
if (inter = interclass.LineIntersectsRect(A, B, Lob[j].Shape)) // I have this for the moment, Shape is the rectangle but not rotated )
{
inter = true;
islight = false;
}
else
{
inter = false;
}
}
}
So to solve my problem, whether I find a solution to have a rotatedRectangle
Object with a method to check collision with line. Whether totally something else, maybe only check collision between yy straight and each rotated Rectangle Axis?
Thanks for your advices.