AHORA SI: Colisiones finalizadas

This commit is contained in:
2022-09-09 14:01:49 +02:00
parent 00b47a5910
commit 36fc848779
3 changed files with 10 additions and 41 deletions

View File

@@ -152,13 +152,13 @@ bool checkCollision(h_line_t &l, SDL_Rect &r)
}
// Comprueba si la linea esta por debajo del rectangulo
if (l.y > r.y + r.h)
if (l.y >= r.y + r.h)
{
return false;
}
// Comprueba si el inicio de la linea esta a la derecha del rectangulo
if (l.x1 > r.x + r.w)
if (l.x1 >= r.x + r.w)
{
return false;
}
@@ -178,27 +178,19 @@ bool checkCollision(v_line_t &l, SDL_Rect &r)
{
// Comprueba si la linea esta por la izquierda del rectangulo
if (l.x < r.x)
{
return false;
}
// Comprueba si la linea esta por la derecha del rectangulo
if (l.x > r.x + r.w)
{
if (l.x >= r.x + r.w)
return false;
}
// Comprueba si el inicio de la linea esta debajo del rectangulo
if (l.y1 > r.y + r.h)
{
if (l.y1 >= r.y + r.h)
return false;
}
// Comprueba si el final de la linea esta encima del rectangulo
if (l.y2 < r.y)
{
return false;
}
// Si ha llegado hasta aquí, hay colisión
return true;