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;
}
}
}
}
Written by Ilyas Kolasinac
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Xna
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#