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
+7 -5
View File
@@ -16,7 +16,8 @@ float g_current_line_thickness = 1.5F;
void linea(Renderer* renderer,
int x1, int y1, int x2, int y2,
float brightness,
float thickness) {
float thickness,
SDL_Color color) {
if (renderer == nullptr) {
return;
}
@@ -28,10 +29,11 @@ void linea(Renderer* renderer,
const float FX2 = static_cast<float>(x2);
const float FY2 = static_cast<float>(y2);
// Color: aplicar brightness al color oscilatorio global. Convertir 0..255 → 0..1.
const float R = (static_cast<float>(g_current_line_color.r) * brightness) / 255.0F;
const float G = (static_cast<float>(g_current_line_color.g) * brightness) / 255.0F;
const float B = (static_cast<float>(g_current_line_color.b) * brightness) / 255.0F;
// color.alpha==0 → usar global del oscilador. alpha>0 → color directo.
const SDL_Color SOURCE = (color.a > 0) ? color : g_current_line_color;
const float R = (static_cast<float>(SOURCE.r) * brightness) / 255.0F;
const float G = (static_cast<float>(SOURCE.g) * brightness) / 255.0F;
const float B = (static_cast<float>(SOURCE.b) * brightness) / 255.0F;
const float W = (thickness > 0.0F) ? thickness : g_current_line_thickness;