Skip to main content
Add const& in function arguments
Source Link
Dessus
  • 300
  • 1
  • 8

SFML implements functionalities that allow you to determine if two rectangles intersect. You can significantly shorten your current code:

const bool Game::isColliding(const sf::RectangleShapeRectangleShape& player, const sf::RectangleShapeRectangleShape& enemy) const 
{
    return player.getGlobalBounds().intersects(enemy.getGlobalBounds());
}

See more:

SFML implements functionalities that allow you to determine if two rectangles intersect. You can significantly shorten your current code:

const bool Game::isColliding(sf::RectangleShape player, sf::RectangleShape enemy) const 
{
    return player.getGlobalBounds().intersects(enemy.getGlobalBounds());
}

See more:

SFML implements functionalities that allow you to determine if two rectangles intersect. You can significantly shorten your current code:

const bool Game::isColliding(const sf::RectangleShape& player, const sf::RectangleShape& enemy) const 
{
    return player.getGlobalBounds().intersects(enemy.getGlobalBounds());
}

See more:

Source Link
Dessus
  • 300
  • 1
  • 8

SFML implements functionalities that allow you to determine if two rectangles intersect. You can significantly shorten your current code:

const bool Game::isColliding(sf::RectangleShape player, sf::RectangleShape enemy) const 
{
    return player.getGlobalBounds().intersects(enemy.getGlobalBounds());
}

See more: