Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sf::FloatRect player_boundingBox = player.getGlobalBounds();
- sf::FloatRect overlap;
- if (player_boundingBox.intersects(object.getGlobalBounds(), overlap))
- {
- cout << overlap.height << endl;
- cout << overlap.width << endl;
- if (overlap.height > overlap.width)
- {
- if (player.getPosition().x < object.getPosition().x)
- cout << "The player just hit the object from the left side" << endl;
- else if (player.getPosition().x > object.getPosition().x)
- cout << "The player just hit the object from the right side" << endl;
- direction = 0;
- }
- else if (overlap.height < overlap.width)
- {
- if (player.getPosition().y < object.getPosition().y)
- cout << "The player just hit the object from the top side" << endl;
- else if (player.getPosition().y > object.getPosition().y)
- cout << "The player just hit the object from the bottom side" << endl;
- direction = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement