I have an enemy rectangle
public void Update(GameTime gameTime)
{
enemyRectangle = new Rectangle((int)enemyPosition.X, (int)enemyPosition.Y, enemyTexture.Width, enemyTexture.Height);
...
I have a foreach
loop, looping through a list of rectangles and a method that checks if these two rectangles have intersected which will return a boolean.
foreach (Bounds bounds in bounds.boundsList)
{
if (bounds.EnemyWallIntersects(testEnemy.enemyRectangle, bounds.CurrentRectangle))
{
testEnemy.isEnemyCurrentlyColliding = true;
}
testEnemy.isEnemyCurrentlyColliding = false;
}
I am certain these rectangles should be intersecting but I have no clue what is happening now. I have used a breakpoint and the rectangle is meant to be intersecting with getting to the point where it has the same X and Y as the enemy rectangle.
This is the "EnemyWallIntersects" method.
public bool EnemyWallIntersects(Rectangle rect1, Rectangle rect2)
{
if (rect1.Intersects(rect2))
{
return true;
}
else
return false;
}