I am using the following code to know if a point is inside a rectangle:
public bool Intersect(ÍcaroDantasCollisions.Rectangle rectangle)
{
if(x >= rectangle.x && x <= rectangle.x + rectangle.width)
{
if(y >= rectangle.y && y <= rectangle.y + rectangle.height)
{
return true;
}
}
return false;
}
Obs1: The 'x' and 'y' loose in the code refer to the coordinates of the 'point'.
Obs2: In the rectangle class only the declaration of the variables x, y, width and height are present.
Now the question, let's say that this rectangle is rotated by 45 °, how do you know if the point is colliding with it? Should I use polygons?