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
+13 -22
View File
@@ -79,40 +79,31 @@ void render_shape(Rendering::Renderer* renderer,
float scale,
float progress,
float brightness,
const Rotation3D* rotation_3d) {
// Verificar que la shape es vàlida
const Rotation3D* rotation_3d,
SDL_Color color) {
if (!shape || !shape->isValid()) {
return;
}
// Si progress < 1.0, no draw (tot o res)
if (progress < 1.0F) {
return;
}
// Obtenir el centro de la shape para transformacions
const Vec2& shape_centre = shape->getCenter();
const Vec2& SHAPE_CENTRE = shape->getCenter();
// Iterar sobre todas las primitives
for (const auto& primitive : shape->get_primitives()) {
if (primitive.type == Graphics::PrimitiveType::POLYLINE) {
// POLYLINE: connectar points consecutius
// POLYLINE: conectar puntos consecutivos.
for (size_t i = 0; i < primitive.points.size() - 1; i++) {
Vec2 p1 = transform_point(primitive.points[i], shape_centre, position, angle, scale, rotation_3d);
Vec2 p2 = transform_point(primitive.points[i + 1], shape_centre, position, angle, scale, rotation_3d);
linea(renderer, static_cast<int>(p1.x), static_cast<int>(p1.y),
static_cast<int>(p2.x), static_cast<int>(p2.y), brightness);
}
} else { // PrimitiveType::LINE
// LINE: exactament 2 points
if (primitive.points.size() >= 2) {
Vec2 p1 = transform_point(primitive.points[0], shape_centre, position, angle, scale, rotation_3d);
Vec2 p2 = transform_point(primitive.points[1], shape_centre, position, angle, scale, rotation_3d);
linea(renderer, static_cast<int>(p1.x), static_cast<int>(p1.y),
static_cast<int>(p2.x), static_cast<int>(p2.y), brightness);
const Vec2 P1 = transform_point(primitive.points[i], SHAPE_CENTRE, position, angle, scale, rotation_3d);
const Vec2 P2 = transform_point(primitive.points[i + 1], SHAPE_CENTRE, position, angle, scale, rotation_3d);
linea(renderer, static_cast<int>(P1.x), static_cast<int>(P1.y),
static_cast<int>(P2.x), static_cast<int>(P2.y), brightness, 0.0F, color);
}
} else if (primitive.points.size() >= 2) { // LINE
const Vec2 P1 = transform_point(primitive.points[0], SHAPE_CENTRE, position, angle, scale, rotation_3d);
const Vec2 P2 = transform_point(primitive.points[1], SHAPE_CENTRE, position, angle, scale, rotation_3d);
linea(renderer, static_cast<int>(P1.x), static_cast<int>(P1.y),
static_cast<int>(P2.x), static_cast<int>(P2.y), brightness, 0.0F, color);
}
}
}