Last Updated: February 25, 2016
·
888
· ilyax

Simple Collision XNA

lately very much interested in XNA, i wanted to write some of the issues

private void SimpleCollision()
{
Rectangle rectangle1;
Rectangle rectangle2;

    foreach (var blt in lstBullet)
    {

        rectangle1 = new Rectangle((int)blt.position.X, (int)blt.position.Y, blt.bull.Width, blt.bull.Height);

        foreach (var enm in lstEnemy)
        {
            rectangle2 = new Rectangle((int)enm.enemyPosition.X,
                (int)enm.enemyPosition.Y, enm.enemy.Width, enm.enemy.Height);

            if (rectangle1.Intersects(rectangle2))
            {
                enm.status = false;
                blt.status = false;
            }
        }
    }
}