I've made a little toy program that draws a red and white square to the screen. The player controls the red square and when it collides with the white square I pick a random position on the screen to move the white square. It works when I collide with the white square once, but the second time I try to collide with it nothing happens. I think it might have something to do with the square's transformation and its bounding box or something, but I'm not familiar enought with sfml.
Here's the code for the collision:
bool collide(sf::RectangleShape cellOne, sf::RectangleShape cellTwo) {
return cellOne.getGlobalBounds().intersects(cellTwo.getGlobalBounds());
}
Here's where it's called:
if (collide(redCell, whiteCell)) {
whiteCell.setPosition(randomPosition());
}