feat(collision): la bala transmet impulse mass-aware al enemic (Fase 2)
- Defaults::Physics::Bullet::IMPACT_IMPULSE (50 px·s placeholder) - detectBulletEnemy: calcula normal bullet→enemy, normalitza (fallback a direcció de bala o (0,-1) si estan solapats) i crida enemy.applyImpulse(normal * IMPACT_IMPULSE) abans de destruir. El destruir() immediat encara zera la velocity, així que l'efecte visual no es nota: serà visible quan la Fase 3 difereixi la mort. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user