tweak(friendly-fire): la bala empeny la nau abans de morir → els debris hereten la inèrcia

This commit is contained in:
2026-05-22 23:24:42 +02:00
parent d618b6d561
commit 7e52eaeddb
+6 -1
View File
@@ -273,7 +273,12 @@ namespace Systems::Collision {
} }
// *** TEAMMATE HIT (friendly fire) *** // *** TEAMMATE HIT (friendly fire) ***
// Víctima perd 1 vida, atacant en guanya 1. // Víctima perd 1 vida, atacant en guanya 1. Apliquem l'impuls
// de la bala a la nau ABANS de on_player_hit perquè tocado()
// captura la velocitat per als debris (si no, queden quiets).
const Vec2 BULLET_IMPULSE = bullet.getBody().velocity *
(bullet.getBody().mass * Defaults::Physics::Bullet::IMPACT_MOMENTUM_FACTOR);
ctx.ships[player_id].getBody().applyImpulse(BULLET_IMPULSE);
ctx.on_player_hit(player_id); ctx.on_player_hit(player_id);
ctx.lives_per_player[BULLET_OWNER]++; ctx.lives_per_player[BULLET_OWNER]++;
Audio::get()->playSound(Defaults::Sound::FRIENDLY_FIRE_HIT, Audio::Group::GAME); Audio::get()->playSound(Defaults::Sound::FRIENDLY_FIRE_HIT, Audio::Group::GAME);