# SHMUP: who's in charge of collision detection? [duplicate]

Simple design question here:

In a Shoot'Em Up, where you often have to deal with hundreds of bullets / missiles / weird flying stuff, who's in charge of detecting collisions? The weapon or the ship?

As there is usualy less ships than bullets displayed on screen, I tend to believe that would be smarter if ships could be in charge of it. But is it really smarter?

• It really depends on the technology you are using. If there are a large amount of objects, I personally prefer to use manager classes that house all subtypes of an object and handle things on a group level. Sep 21, 2014 at 7:59
• @BenjaminDangerJohnson according to bcrist's answer I will probably do a manager, an external object, dedicated to collision checking. Thank you for your suggestion. Sep 22, 2014 at 7:43

With this system, there's probably no optimization required. Each object in one list can be tested against every object in the other. If we have N units and M munitions then we end up doing N*M collision checks. We may have a very large M, on the order of several hundred or more, but N is probably on the order of 3-6, perhaps up to a dozen.