Tag Archives: XNA


Determining if two lines intersect

Today we are going to take a look at intersecting lines. There are some information on this scattered around the internet, but a good example is hard to find. The uses for this is mainly in 2D, it can be applied to lighting, physics and all other applications using rays. To solve this, we want […]

Drawing lines in XNA

As there is no built in way of drawing lines in XNA(which is really weird), I thought that I should share this little snippet. public void drawLine(SpriteBatch spriteBatch, Vector2 p1, Vector2 p2, Texture2D texture) { float length = (float)Math.Sqrt((p2x – p1x) * (p2x – p1x) + (p2y – p1y) * (p2y – p1y)); spriteBatch.Draw(texture, new […]

Fast collision detection in XNA

I have been helping a friend of mine with a way of doing quick 2D collision detection in XNA. One of the common problems with collision detection in 2D is when you rotate it. Most functions do pixel perfect collisions by parsing the whole images, as it can be tricky to get the correct pixels […]