9

I'm being really ambitious and working on a 2D Shoot 'em Up game that will have, hopefully, hundreds of entities running around.

What I'm having trouble wrapping my brain around, is how the bullet will detect when it makes a collision with an object, without it checking for every object on the map. The reason is that I feel that if I have four dozen bullets on the screen, each checking for collision with every entity on the map, every cycle, I will see some fairly significant performance loss.

So what would be the best way to detect for collisions without checking every single entity?

I can handle the collision algorithm when I have my two objects, I just can't seem to find a way to get those two object to see each other without checking everyone else first.

I'm working in Java and OpenGL with (soon to be textured) QUADS.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982

1 Answers1

8

You should investigate quadtrees; they're often used for efficient 2D lookup.

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680