I am making a C++ SFML version of Frogger and currently trying to implement collision detection between the frog and other objects (cars, trucks, logs etc). I have separate classes for the frog and the game objects and want to use bounding boxes to detect intersections as shown below.
// get the bounding box of the entity
sf::FloatRect boundingBox = entity.getGlobalBounds();
// check collision with another box (like the bounding box of another
entity)
sf::FloatRect otherBox = ...;
if (boundingBox.intersects(otherBox))
{
// collision!
}
The problem I am having is that I have no idea how to make this work with two sprites from separate classes and after days of searching I can't find an explanation of how to do it.