XNA, C# - Check if a Vector2 path crosses another Vector2 path.
- by Nick
Hello all,
I have an XNA question for those with more experience in these matters than myself (maths).
Background: I have a game that implements a boundary class, this simply hosts 2 Vector2 objects, a start and an end point. The current implementation crudely handles collision detection by assuming boundaries are always vertical or horizontal, i.e. if start.x and end.x are the same check I am not trying to pass x etc.
Ideally what I would like to implement is a method that accepts two Vector2 parameters. The first being a current location, the second being a requested location (where I would like to move it to assuming no objections). The method would also accept a boundary object. What the method should then do is tell me if I am going to cross the boundry in this move. this could be a bool or ideally something representing how far I can actually move.
This empty method might explain better than I can in words.
/// <summary>
/// Checks the move.
/// </summary>
/// <param name="current">The current.</param>
/// <param name="requested">The requested.</param>
/// <param name="boundry">The boundry.</param>
/// <returns></returns>
public bool CheckMove(Vector2 current, Vector2 requested, Boundry boundry)
{
//return a bool that indicated if the suggested move will cross the boundry.
return true;
}