I didn't wanted you to show me the code and yes, I read the information from sf::Rect and I was trying to implement in my code. I only asked if exist some tutorials...
This is what I maked:
sf::IntRect playerr(player.getPosition().x, player.getPosition().y, 50, 50);
sf::IntRect floor1r(floor1.getPosition().x, floor1.getPosition().y, 600, 50);
sf::IntRect intersectr;
intersect = playerr.intersects(floor1r, intersectr);
if (!intersect)
{
player.move(0, playerDownSpeed * deltaTime);
}
Modify: How to stop my shape, if don't touch another shape( the floor) he is falling down. I think to do a loop to verify every time if he is touching a shape but when running the code he froze when press space:
while (!sf::FloatRect(player.getPosition(), player.getSize()).intersects(sf::FloatRect(floor1.getPosition(), floor1.getSize())))
{
player.move(0, playerDownSpeed * deltaTime);
}
if (!sf::FloatRect(player.getPosition(), player.getSize()).intersects(sf::FloatRect(floor1.getPosition(), floor1.getSize())))
{
do
{
player.move(0, playerDownSpeed * deltaTime);
} while (!sf::FloatRect(player.getPosition(), player.getSize()).intersects(sf::FloatRect(floor1.getPosition(), floor1.getSize())));
}
do
{
player.move(0, playerDownSpeed * deltaTime);
} while (!sf::FloatRect(player.getPosition(), player.getSize()).intersects(sf::FloatRect(floor1.getPosition(), floor1.getSize())));
Those(3) were my attempts with the loop. Att all 3 when pressed space the app frozen.