fix(ship-death): debris hereten inèrcia (captura velocitat abans del markHit) i comparteixen dispersió amb enemics
This commit is contained in:
@@ -723,30 +723,36 @@ void GameScene::tocado(uint8_t player_id) {
|
||||
if (hit_timer_per_player_[player_id] == 0.0F) {
|
||||
// *** PHASE 1: TRIGGER DEATH ***
|
||||
|
||||
// Capturar velocitat ABANS del markHit (que la reseteja a zero).
|
||||
// Sense això, els debris no hereten cap inèrcia de la nau.
|
||||
const Vec2 SHIP_VEL_PRE_DEATH = ships_[player_id].getVelocityVector();
|
||||
const Vec2 SHIP_POS = ships_[player_id].getCenter();
|
||||
const float SHIP_ANGLE = ships_[player_id].getAngle();
|
||||
const float SHIP_BRIGHT = ships_[player_id].getBrightness();
|
||||
|
||||
// Mark ship as dead (stops rendering and input)
|
||||
ships_[player_id].markHit();
|
||||
|
||||
// Create ship explosion
|
||||
const Vec2& ship_pos = ships_[player_id].getCenter();
|
||||
float ship_angle = ships_[player_id].getAngle();
|
||||
Vec2 vel_nau = ships_[player_id].getVelocityVector();
|
||||
// Reduir la velocity heretada per la ship segons defaults (més realista)
|
||||
constexpr float INHERIT = Defaults::Physics::Debris::SHIP_VELOCITY_INHERITANCE;
|
||||
Vec2 vel_nau_80 = {.x = vel_nau.x * INHERIT, .y = vel_nau.y * INHERIT};
|
||||
const Vec2 INHERITED_VEL = SHIP_VEL_PRE_DEATH *
|
||||
Defaults::Physics::Debris::SHIP_VELOCITY_INHERITANCE;
|
||||
|
||||
// Mateixa dispersió i efecte que els debris d'enemic (lifetime,
|
||||
// friction, segment_multiplier alineats); només canvien sound i color.
|
||||
debris_manager_.explode(
|
||||
ships_[player_id].getShape(), // Ship shape (3 lines)
|
||||
ship_pos, // Center position
|
||||
ship_angle, // Ship orientation
|
||||
1.0F, // Normal scale
|
||||
Defaults::Physics::Debris::VELOCITAT_BASE, // 80 px/s
|
||||
ships_[player_id].getBrightness(), // Heredar brightness
|
||||
vel_nau_80, // Heredar 80% velocity
|
||||
0.0F, // Nave: trayectorias rectas (sin drotacio)
|
||||
0.0F, // Sin herencia visual (rotación aleatoria)
|
||||
Defaults::Sound::EXPLOSION2, // Sonido alternativo para la explosión
|
||||
Defaults::Palette::SHIP // Debris hereda color de la nave
|
||||
);
|
||||
ships_[player_id].getShape(),
|
||||
SHIP_POS,
|
||||
SHIP_ANGLE,
|
||||
1.0F,
|
||||
Defaults::Physics::Debris::VELOCITAT_BASE,
|
||||
SHIP_BRIGHT,
|
||||
INHERITED_VEL,
|
||||
0.0F, // sense herència angular
|
||||
0.0F, // sin herencia visual
|
||||
Defaults::Sound::EXPLOSION2,
|
||||
Defaults::Palette::SHIP,
|
||||
Defaults::Physics::Debris::ENEMY_LIFETIME,
|
||||
Defaults::Physics::Debris::ENEMY_FRICTION,
|
||||
Defaults::Physics::Debris::ENEMY_SEGMENT_MULTIPLIER);
|
||||
|
||||
// Start death timer (non-zero to avoid re-triggering)
|
||||
hit_timer_per_player_[player_id] = Defaults::Game::HIT_TIMER_TRIGGER_DEATH;
|
||||
|
||||
Reference in New Issue
Block a user