Implement collision detection for rectangles