Let's assume I'm using this character.
How would you implement collision detection for it? Using a bounding box doesn't seem to be a good approximation, because the bird's shape is nowhere near a square.
I was thinking of having a sort of quad tree data structure inside the object that represents portions of the image. Each leaf could be either
false (in case it covers the white/transparent space outside the bird) or
true (in case it represents an area of the bird i.e. beak, eye etc). Then somehow test the only obstacle in the scene for collision with the bird.
But my problems in my approach are:
- I don't know how to initialize the quad tree.
- Once the quad tree is initialized, I'm not sure how to traverse & use it once the obstacle is within the coordinates of the image.
How would you do collision detection with non-squarish characters?
LE: The other approach I've seen was to use multiple bounding boxes. For example I'd have one or a few bounding boxes for the beak, then a few of them for the hair or the tail. But it can get tedious. If this is a valid approach in my case, how would I generate those bounding boxes? I doubt I'd have to have them hardcoded in my program.
LE2: I care about fairly precise collisions. I can't imagine how a single bounding box or circle can at least approximate decently that shape, so this approach won't work.