R
R
Ribachok2020-07-05 16:55:44
C++ / C#
Ribachok, 2020-07-05 16:55:44

Sprite collision?

You need to make sure that the character is pushed away from the house in the appropriate direction if he comes into contact with it. I'm probably too dumb for that.

if (partridge[1].y >= home.getPosition().y && partridge[1].y < 450 && partridge[1].x < 400)
    {
      if (partridge[1].x + 30 > home.getPosition().x && partridge[1].x < window.getSize().x - home.getPosition().x + 260)
      {
        partridge[1].x--;
      }
      
    }

Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maaGames, 2020-07-05
@maaGames

If the movement speed is low, then check from which side it penetrated less and move in that direction.
If the movement speed is high, then keep the previous position and, in case of penetration, shift towards the previous position.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question