Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to implement collisions using the separating axis theorem. However All I have ever used in terms of polygons is the Rectangle class included in XNA already. How can I make multi-sided polygons?

share|improve this question

You can draw triangles directly using DrawUserIndexedPrimitives and other similar functions. Yes, it is much more work than simply drawing rectangles.

Example code:

share|improve this answer
This is good but I am looking more for a function I can use to draw multi sided polygons, not just triangles – Roger May 23 '13 at 15:52
@Roger There is no such thing built into the XNA framework. You could build something to do it for you, of course. But no matter what you do, a polygon would need to be defined in terms of its component triangles; that's the only format the GPU can process. – Seth Battin May 23 '13 at 16:49
I think the user's question is more to do with collision detection. Question for the user: Are you expecting your polygons to have concave sections? (so that if you're following along its boundary: Do you ever turn "left" instead of right?) This may affect what kinds of collision detection you can use . – Katana314 May 24 '13 at 13:12
@Katana314 I thought the same thing, actually. But that (implicit) question is "how do I do SAT collision physics?", which is too broadly scoped to be answerable, so I ignored it on purpose. I also assumed that any half-hearted implementation of those collisions would have vertex data available. – Seth Battin May 24 '13 at 14:13
@Katana314 Yes I am trying to implement SAT collision following a tutorial if found but its written in AS3. This is the example I am following and trying to replicate on XNA The problem is I'm still pretty new at this and I don't know how to make any other shapes other than rectangles – Roger May 25 '13 at 17:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.