views:

45

answers:

2

I am trying to use boxes for hit collision. I want to be precise with the collision so I was thinking about making multiple small boxes and checking for collision that way. This maybe a stupid idea or a smart one. Who knows, thats why i am asking you guys. If I do this way will that affect the performance of the game even though the boxes are invisible and wont be drawn on the stage.

Another idea was to map out the object starting from its center outward. Like right, left, top and bottom. I am creating a flying shooter so the plane has a long wing span. I could also map out the wing span and tail and so on.

+1  A: 

Consider using bounding boxes/circles for initial collision, and per-pixel/detailed collision in case if that test passes.

Kornel Kisielewicz
I was told that pixel collision is hard on performance
numerical25
That is why you would run the bounding boxes/circles test first.
TandemAdam
A: 

It's a very common approach in games and physics engines to track objects by their "axis-aligned bounding box" (AABB), which is to say the box specified by their bounds. This will generally save you a lot of performance as long as the objects are small compared to the stage.

The main reason for doing things this way is that there are good ways to use AABBs to achieve very fast collision tests, or more precisely to very quickly eliminate candidates for collision tests (when the objects' AABBs don't overlap). Comparing every object to every other object takes N^2 comparisons, but keeping various data structures based on AABBs can let you eliminate collision candidates in O(N) time (apart from the time needed to maintain the structures).

For a look at how this is done you might like to examine a physics engine, such as box2Dflash, which internally tracks AABBs for collision testing.

fenomas