OK so Ive been playing with this function and changed it to accept a map instead.
I want the function to check if the shape collides with ANY element that lives within the map I send it, yet it only returns true if the shape collides with the first element of my map and none other so I'm guessing my logic is out:
static bool bounceCheck(const sf::CircleShape& shape, std::map<string, sf::Sprite>& Sprite){
// returns true if a ball collides with any element of the map
for (map<string, sf::Sprite>::iterator it = Sprite.begin(); it!=Sprite.end();it++)
{
return (it->second.getGlobalBounds().intersects(shape.getGlobalBounds()));
}
return false;
}
how do i get it to say "Well yes you are part of the map so return true"
Thanks again
Martin
p.s Also having just tested my code and outputting the it->first element at collision point the console is informing me that when the shape collides with an element of the map (sprite) it returns more than one file it collides with. As it waits until it collides with the first element then passes true that it collides with the others for as long as the shape collides with the first. Do I need to also check for a match with filename, map key etc?