How to detect the collision with the floor SDL2

0

I'm developing a learning game using C ++ with SDL2, and I want to check when my character touches the floor. For this I created the class "Collider", with the following function (adapted):

bool isCollinding (SDL_Rect a, SDL_Rect b)
{
  if(a.x > b.x + b.w || // Esquerda de A a direita do lado direito de B
     a.x + a.w < b.x || // Direita de A a esquerda do lado esquerdo de B
     a.y > b.y + b.h || // Topo de A abaixo da base de B
     a.y + a.h < b.y)   // Base de A acima do topo de B
  {
    return 0;
  }
  return 1;
}

But with this method, I can only know if it is colliding, but I do not know if it's the bottom or etc. How would you know if what's colliding is the underside easily?

    
asked by anonymous 02.06.2017 / 03:49

0 answers