diff --git a/source/core/defaults/physics.hpp b/source/core/defaults/physics.hpp index 7a204ba..218cdba 100644 --- a/source/core/defaults/physics.hpp +++ b/source/core/defaults/physics.hpp @@ -10,6 +10,11 @@ namespace Defaults::Physics { constexpr float MAX_VELOCITY = 120.0F; // px/s constexpr float FRICTION = 20.0F; // px/s² + // Bullet — impacto físico contra enemigo (impulse mass-aware). + namespace Bullet { + constexpr float IMPACT_IMPULSE = 50.0F; // Magnitud del impulse en la dirección bullet→enemy + } // namespace Bullet + // Explosions (debris physics) namespace Debris { constexpr float VELOCITAT_BASE = 80.0F; // Velocidad inicial (px/s) diff --git a/source/game/systems/collision_system.cpp b/source/game/systems/collision_system.cpp index ff1f6f9..f610d4c 100644 --- a/source/game/systems/collision_system.cpp +++ b/source/game/systems/collision_system.cpp @@ -23,6 +23,17 @@ namespace Systems::Collision { // *** COLISIÓN bullet → enemy *** const Vec2& enemy_pos = enemy.getCenter(); + // Empuje físico: impulse en la dirección bullet→enemy (fallback a la + // dirección de la bala si están exactamente solapados). + Vec2 normal = enemy_pos - bullet.getCenter(); + if (normal.lengthSquared() > 0.000001F) { + normal = normal.normalized(); + } else { + const Vec2 BVEL = bullet.getBody().velocity; + normal = (BVEL.lengthSquared() > 0.0F) ? BVEL.normalized() : Vec2{.x = 0.0F, .y = -1.0F}; + } + enemy.applyImpulse(normal * Defaults::Physics::Bullet::IMPACT_IMPULSE); + // 1. Puntos según tipo int points = 0; switch (enemy.getType()) {