Possible Duplicate:
Determine if two rectangles overlap each other?
Considering I have 2 squares for which I know the x and y positions and I also know the size, what would be the formula to use if I wanted to see if the objects collide with eachother.
if( ((shapeA->getX() - shapeA->getSize()) > (player->getX() - player->getSize())
&& (shapeA->getX() + shapeA->getSize()) < (player->getX() + player->getSize()))
&& (shapeA->getY() - shapeA->getSize() > player->getY() - player->getSize()
&& (shapeA->getY() + shapeA->getSize()) < (player->getY() + player->getSize()))
)
This works, but it works strange (not all the time). I must be missing something