Ya detecta las plataformas móviles bajo los pies

This commit is contained in:
2022-08-26 20:41:48 +02:00
parent 5ff62a6950
commit dda1e049c6
9 changed files with 122 additions and 18 deletions

View File

@@ -502,5 +502,32 @@ int Map::actorCollision(SDL_Rect &rect)
index++;
}
return -1;
}
// Indica si hay colision con un actor a partir de un rectangulo
int Map::actorCollision(SDL_Point &p)
{
int index = 0;
for (auto actor : actors)
{
if (checkCollision(p, actor->getCollider()))
{
return index;
}
index++;
}
return -1;
}
// Devuelve el nombre del actor a pàrtir de un índice
int Map::getActorName(int index)
{
if (index != -1)
{
return actors[index]->getName();
}
return -1;
}