So, what I'm having trouble with is a simple ai that runs from the player. There are walls scattered about the level that the enemy has to get by, but each time he collides with the wall, he gets stuck. I would greatly appreciate some help, here is the relevent code:
public bool EnemyCollision()
{
Rectangle hWallRect = new Rectangle(
(int)hWallPos.X,
(int)hWallPos.Y,
hWallWidth ,
hWallHeight);
Rectangle enemyRect = new Rectangle(
(int)enemy.enemyPosition.X,
(int)enemy.enemyPosition.Y,
enemy.enemyWidth,
enemy.enemyHeight);
return hWallRect.Intersects(enemyRect);
}
if (EnemyCollision())
{
if (enemy.enemyPosition.X <= hWallPos.X)
enemy.enemyPosition.X += enemy.enemySpeed;
if (enemy.enemyPosition.Y <= hWallPos.Y)
enemy.enemyPosition.Y += enemy.enemySpeed;
if (enemy.enemyPosition.X >= hWallPos.X)
enemy.enemyPosition.X -= enemy.enemySpeed;
if (enemy.enemyPosition.Y >= hWallPos.Y)
enemy.enemyPosition.Y -= enemy.enemySpeed;
}