Thanks for the response. You're right, 50 and 100 are still fairly few objects, but if I were to expand this into something like a simple platformer there might be upwards of 2000-3000 blocks in a "level" and it seems downright wasteful to check if the player sprite is in collision with every single block in a stage every frame. Note that I'm not comparing every object to every object here, just a few "mobile" objects against immobile objects and other mobile objects.
That might be easy in the first term, but just out of interest: How would you find out which collision function to call, depending on the types to check; e.g. paddle <-> ball, brick <-> ball, ball <-> ball (in case of multiple balls)?
The plan in that situation would be for each object to have a type identifier member. The actual Collision methods I linked to above would just be for determining if a collision exists, and the specific implementation for each different type of object would handle the multiple types of collisions. Basically a three step process:
1.)Scan the object array looking at coordinates to determine proximity.
2.)Run collision on objects in close proximity.
3.)If collision returns true, access the type member of the colliding object and preform the appropriate action.
I'll check out the link you posted as well. You're right that this isn't a problem for the scope of my current project, but I am very interested in the theory behind a more robust algorithm, since that's what I'm going to need if I ever scale my projects up to something truly large.
EDIT: Looking at some articles on Quadtrees and Space Partitioning. I'm not seeing a solution to the problem of having to examine the co-ordinates of every object in existence every frame, even if Quadtrees and SP seem to help with the proximity issues. Am I missing something, or is that just how things have to work?
EDIT2:Okay, this is interesting:
The QuadTree is designed to be faster at querying the spatial domain than iteration, but the performance of the index depends on the distribution of objects in the domain. If items are clustered together, the tree tends to have many items in one branch which defeats the strategy of being able to cull large regions, and reduce the number of intersection tests.
Culling large amounts of space isn't a problem in my system, since things aren't organized spatially. I don't expend time looking for empty regions since I'm iterating over an array filled with solid objects. So I'm not sure if the QuadTree is going to be very helpful specifically. What does interest me though is finding a way focus the search over time, to hone in on objects in proximity to the test object, and not spend time checking the co-ordinates of other objects. To do that I'm pretty sure I need a tree structure so that I can ignore branches. Perhaps initiating a one-time organization system once all objects have been created...