Fase 8a+b: paleta semantica de color por entidad

Cada entity declara su color de linea via parametro opcional. Cuando
alpha==0 el pipeline cae al color global del oscilador (compatibilidad
con el comportamiento anterior).

Defaults::Palette (defaults.hpp):
- SHIP        = blanco neutro
- BULLET      = verde laser
- PENTAGON    = azul "esquivador"
- QUADRAT     = rojo "tank"
- MOLINILLO   = magenta agresivo

Pipeline:
- linea(): parametro SDL_Color color (default {0,0,0,0}). En .cpp,
  fuente del color = color.a>0 ? color : g_current_line_color.
- render_shape(): parametro SDL_Color color que propaga a cada linea
  del shape.
- Debris: campo color en la struct; explode() recibe SDL_Color color
  y lo guarda en cada fragment; draw() lo pasa a linea().

Aplicacion:
- Ship::draw -> Palette::SHIP.
- Bullet::draw -> Palette::BULLET.
- Enemy::draw -> Palette::{PENTAGON,QUADRAT,MOLINILLO} segun type_.
- CollisionSystem detectBulletEnemy: debris hereda color del enemy.
- GameScene::tocado: debris hereda Palette::SHIP.

Smoke test xvfb OK.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-20 08:04:56 +02:00
parent 5c9f6e6613
commit 6d7060ceb5
13 changed files with 73 additions and 41 deletions
+6 -4
View File
@@ -53,7 +53,8 @@ void DebrisManager::explode(const std::shared_ptr<Graphics::Shape>& shape,
const Vec2& velocitat_objecte,
float velocitat_angular,
float factor_herencia_visual,
const std::string& sound) {
const std::string& sound,
SDL_Color color) {
if (!shape || !shape->isValid()) {
return;
}
@@ -195,8 +196,9 @@ void DebrisManager::explode(const std::shared_ptr<Graphics::Shape>& shape,
debris->temps_max = Defaults::Physics::Debris::TEMPS_VIDA;
debris->factor_shrink = Defaults::Physics::Debris::SHRINK_RATE;
// 8. Heredar brightness
// 8. Heredar brightness y color del padre
debris->brightness = brightness;
debris->color = color;
// 9. Activar
debris->active = true;
@@ -308,13 +310,13 @@ void DebrisManager::draw() const {
continue;
}
// Dibuixar segment de línia con brightness heretat
// Dibujar segmento con brightness y color heredados del padre.
Rendering::linea(renderer_,
static_cast<int>(debris.p1.x),
static_cast<int>(debris.p1.y),
static_cast<int>(debris.p2.x),
static_cast<int>(debris.p2.y),
debris.brightness);
debris.brightness, 0.0F, debris.color);
}
}