Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

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

http://www.ai-blog.net/archives/000152.html

Good luck!

share|improve this answer
add comment

Your Answer

 
discard

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.