forked from jaildesigner-jailgames/jaildoctors_dilemma
AHORA SI: Colisiones finalizadas
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user