Well, there's diffrent way to do this. Usually, the less complex the solution, the more CPU time will it take (except if it's a really great solution ).
I did a game recently who involved collision detection (see this post: http://cboard.cprogramming.com/showp...0&postcount=84). First of all, i was using 2 surfaces for every "object" i had. One surface was for displaying, while the other surface was for doing collision detection and/or action detection (basically, one surface had some kind of information on it while the other was just for display). Since i had only one object who had to detect collision, this was fairly simple.
First of all, while loading the game, i was creating and array of coordinate for all the "peripherical" pixel of the object, relative to the (0,0) point of its surface. Then, for every frame, i was checking if any of those peripherical points had a specific color on the static object (that's it, object that weren't moving: terrain) and also doing some calculation to see if they were in the range of the dynamic object. If they do were (surfaces were overlapping), then, i had to check if it were really on the object or not by doing some simple math to define the coordinate of the pixel on the other surface and testing if the color of that pixel was the one corresponding to "a collision".
Well, it may not be totally clear. You may want to check my game for further investigation hah. But it can be quite a pain to understand, since, first of all, my first language isn't english, and it's written in C, and it's a bit voluminous (that's it, more or less 3 000 lines). And has some hard-to-understand-at-first-glance instruction, like this one:
Code:
// Le point se trouve sur l'image de l'auto ordi numero j
pixel = (Uint32 *) voituresOrdi[j].patron->masque[voituresOrdi[j].orientationCourante]->pixels
+ (ptCourant.y - ((int) voituresOrdi[j].posCentre.y - voituresOrdi[j].patron->centre.y))
* voituresOrdi[j].patron->masque[voituresOrdi[j].orientationCourante]->w
+ (ptCourant.x - ((int) voituresOrdi[j].posCentre.x - voituresOrdi[j].patron->centre.x));
Anyway. This was fairly simple. And was the first game i made. And also the first thing i tought about how to detect 2D collision of object of any shape.