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'm currently thinking about collision and map system that I want to use in my next game and I'm kind of puzzled. Maps are going to be somewhat complex with lots of irregularities and thus tiling is out of question.

I thought about an editor where you'd draw rectangles on the map that would represent areas that are collidable with and then saving such "collision map" with only black/white gfx. Or maybe should I save exact rectangles data with their x/y/width/height into some text file and go from there?

What would you recommend? Thanks.

share|improve this question
up vote 1 down vote accepted

I also use complex maps with "lots of irregularities" in my game (pretty much like the game Worms). I have premade graphical elements which I put at arbitrary positions. These elements have minimal bounding rectangles (MBR's). When a character is inside the MBR of a map element, I do a per-pixel collision detection. It is important, that I'm taking into account only the intersection of the map element's MBR vs the character's MBR.

TL;DR: Minimal bounding rectangles, then a finer (e.g. per-pixel) collision detection when they intersect.

share|improve this answer
If you're using bigger images wouldn't it be better to subdivide the bounding area in smaller areas ( not actually dividing the bitmap just a virtual grid ) so that per pixel checks takes less that? No point is checking the pixels below the image when the character is on top. Or are you only checking from the players position? – Sidar Dec 18 '12 at 1:07
@Sidar When the character's MBR and the map object's (e.g. a tree's) MBR intersect, I only do the per-pixel collision detection on the intersecting area. So if the tree is 1024x1024, the character is 128x128, and the character is completely inside the tree's MBR, I only have to check a 128x128 area. Of course, there are alternatives to the per-pixel collision detection, if it's too slow for your game. I just posted that as an example for a "fine" collision detection method. – Marton Dec 18 '12 at 7:41
I was asking out of curiosity. Thanks for clarifying. – Sidar Dec 18 '12 at 16:52

just wanted to add this article if you are going not to tile, might be useful :)

Good luck!

share|improve this answer

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.