Here is my collision detection function:

/Collision detection function int inside(int x, int y, int left, int top, int right, int bottom) { if(x > left && x < right && y > top && y < bottom) return 1; else return 0; }

I want to detect collision when my character touches a coin/ring/object for example I do this:

//checks if player collected a ring void collectRings() { int n, x, y, x1, y1, x2, y2; for(n = 0; n < RINGS; n++) { if(rings[n]->alive) { //find the center of the player x = player->x + player->width/2; y = player->y + player->height/2; //get the rings bounding rectangle x1 = rings[n]->x - mapxoff; y1 = rings[n]->y - mapyoff; x2 = x1 + rings[n]->width; y2 = y1 + rings[n]->height; //now check for collision if(inside(x, y, x1, y1, x2, y2)) { rings[n]->alive = 0; stop_sample(ringSound); play_sample(ringSound, VOL+100, PAN, FREQ, FALSE); ringCounter++; score += 10; } } } }

So If the center of my character goes inside the bounding box of a ring it should detect the collision, but it doesn't. For some reason nothing happens. I don't know why. If someone knows why, please let me know.