Original Post
I''ve been hunting around for a decent collision algorithm for something I''m working on in my spare time away from uni. It''s heading towards a basic predator / prey simulator. I''ve got a 640 x 480 window with 400 particles bouncing around with random movement. I''ve got them bouncing off the edges (easy enough bit of trig to reverse their angle when they hit a certain x / y co-ord) but I want them to be able to tell when they''ve hit each other, so I can start to simulate the predatorial aspect of the design.
The program solely uses SDL for drawing and input. The particles are 4 x 4 pixel squares. red for prey, green for predators. My current thinking is to have a grid of 16 x 16 squares set up, each holding a vector of the current contents. So I can just check the grid squares with predators in for collision rather than checking every single particle each frame. (I tried that when I first started, it managed about 5 hits in 2 minutes of run time!)
I''ve only got a the psuedo code written up for the grid system, I would just like to know if anyone could think of a better way of reducing the overhead on the collision checking before I implement it!
Thanks for any help,
Ging