afegit efecte de "colp" quan el jugador es "alcanssat" per un globo

This commit is contained in:
2025-07-25 13:45:55 +02:00
parent f001e433e0
commit b165484e03
11 changed files with 145 additions and 12 deletions

View File

@@ -24,6 +24,25 @@ auto distanceSquared(int x1, int y1, int x2, int y2) -> double {
return DELTA_X * DELTA_X + DELTA_Y * DELTA_Y;
}
// Obtiene el punto de colisión entre dos circulos
auto getCollisionPoint(const Circle &a, const Circle &b) -> SDL_FPoint {
float dx = b.x - a.x;
float dy = b.y - a.y;
float dist = std::sqrt(dx * dx + dy * dy);
// Normaliza el vector
float nx = dx / dist;
float ny = dy / dist;
// Punto en el borde del círculo A hacia B
SDL_FPoint contact;
contact.x = a.x + nx * a.r;
contact.y = a.y + ny * a.r;
return contact;
}
// Detector de colisiones entre dos circulos
auto checkCollision(const Circle &a, const Circle &b) -> bool {
// Calcula el radio total al cuadrado