Fase 6e: migrar Bullet al sistema de fisica vectorial

Las balas pasan a ser cinematicas dentro del PhysicsWorld:
- body_.setMass(0.5), radius=0 (no colisionan fisicamente)
- disparar() setea body_.position + body_.velocity cartesiana (140 px/s)
- update() detecta salida del PLAYAREA via body_.position y desactiva
- postUpdate() sincroniza center_ desde body_.position
- desactivar() detiene el body para evitar deriva mientras inactiva

GameScene registra los bodies en init() y llama postUpdate(). El gameplay
sigue gestionando colisiones bullet-enemy/bullet-ship con check_collision
(el radio gameplay es BULLET_RADIUS=3, expuesto via getCollisionRadius).

Renames a camelBack (clang-tidy): get_owner_id->getOwnerId,
get_grace_timer->getGraceTimer.

MIGRATION_PLAN.md actualizado: Fase 6e cerrada, Fase 7 (SDL3 GPU) siguiente.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 13:50:17 +02:00
parent c50ca23135
commit 9993b2d98c
4 changed files with 128 additions and 109 deletions
+11 -4
View File
@@ -205,9 +205,13 @@ void GameScene::init() {
// DON'T call enemy.init() here - stage system handles spawning
}
// Inicialitzar balas (now 6 instead of 3)
// Inicialitzar balas (now 6 instead of 3).
// Se registran en el physics_world para integración cinemática.
// Como su body_.radius=0, no colisionan físicamente con nadie (las
// colisiones de gameplay se gestionan en detectar_col·lisions_*).
for (auto& bullet : bullets_) {
bullet.init();
physics_world_.addBody(&bullet.getBody());
}
// [ELIMINAT] Iniciar música de juego (ara es gestiona en stage_manager)
@@ -230,6 +234,9 @@ void GameScene::update(float delta_time) {
for (auto& enemy : enemies_) {
enemy.postUpdate(delta_time);
}
for (auto& bullet : bullets_) {
bullet.postUpdate(delta_time);
}
// Processar disparos (state-based, no event-based)
if (game_over_state_ == GameOverState::NONE) {
@@ -996,7 +1003,7 @@ void GameScene::detectar_col·lisions_bales_enemics() {
}
// 2. Add score to the player who shot it
uint8_t owner_id = bullet.get_owner_id();
uint8_t owner_id = bullet.getOwnerId();
score_per_player_[owner_id] += points;
// 3. Create floating score number
@@ -1078,11 +1085,11 @@ void GameScene::detectar_col·lisions_bales_jugadors() {
}
// Skip bullets in grace period (prevents instant self-collision)
if (bullet.get_grace_timer() > 0.0F) {
if (bullet.getGraceTimer() > 0.0F) {
continue;
}
uint8_t bullet_owner = bullet.get_owner_id();
uint8_t bullet_owner = bullet.getOwnerId();
// Check collision with BOTH players
for (uint8_t player_id = 0; player_id < 2; player_id++) {