diff --git a/data/shapes/bullet.shp b/data/shapes/bullet.shp index 1b3a353..ad9d4e2 100644 --- a/data/shapes/bullet.shp +++ b/data/shapes/bullet.shp @@ -1,23 +1,7 @@ -# bullet.shp - Projectil (petit pentàgon) -# © 1999 Visente i Sergi (versió Pascal) -# © 2025 Port a C++20 amb SDL3 +# bullet.shp - Projectil (octàgon, radi=3) name: bullet scale: 1.0 center: 0, 0 -# Cercle (octàgon regular radi=3) -# 8 punts equidistants (45° entre ells) per aproximar un cercle -# Començant a angle=-90° (amunt), rotant sentit horari -# -# Conversió polar→cartesià (radi=3, SDL: Y creix cap avall): -# angle=-90°: (0.00, -3.00) -# angle=-45°: (2.12, -2.12) -# angle=0°: (3.00, 0.00) -# angle=45°: (2.12, 2.12) -# angle=90°: (0.00, 3.00) -# angle=135°: (-2.12, 2.12) -# angle=180°: (-3.00, 0.00) -# angle=225°: (-2.12, -2.12) - polyline: 0,-3 2.12,-2.12 3,0 2.12,2.12 0,3 -2.12,2.12 -3,0 -2.12,-2.12 0,-3 diff --git a/data/shapes/enemy_pentagon.shp b/data/shapes/enemy_pentagon.shp index 8771dc2..23c84c9 100644 --- a/data/shapes/enemy_pentagon.shp +++ b/data/shapes/enemy_pentagon.shp @@ -1,21 +1,7 @@ -# enemy_pentagon.shp - ORNI enemic (pentàgon regular) -# © 1999 Visente i Sergi (versió Pascal) -# © 2025 Port a C++20 amb SDL3 +# enemy_pentagon.shp - ORNI enemic (pentàgon regular, radi=20) name: enemy_pentagon scale: 1.0 center: 0, 0 -# Pentàgon regular radi=20 -# 5 punts equidistants al voltant d'un cercle (72° entre ells) -# Començant a angle=-90° (amunt), rotant sentit antihorari -# -# Angles: -90°, -18°, 54°, 126°, 198° -# Conversió polar→cartesià (SDL: Y creix cap avall): -# angle=-90°: (0.00, -20.00) -# angle=-18°: (19.02, -6.18) -# angle=54°: (11.76, 16.18) -# angle=126°: (-11.76, 16.18) -# angle=198°: (-19.02, -6.18) - polyline: 0,-20 19.02,-6.18 11.76,16.18 -11.76,16.18 -19.02,-6.18 0,-20 diff --git a/data/shapes/enemy_square.shp b/data/shapes/enemy_square.shp index 2d6f16c..3c17405 100644 --- a/data/shapes/enemy_square.shp +++ b/data/shapes/enemy_square.shp @@ -1,19 +1,7 @@ -# enemy_square.shp - ORNI enemic (quadrat regular) -# © 2025 Port a C++20 amb SDL3 +# enemy_square.shp - ORNI enemic (quadrat regular, radi=20) name: enemy_square scale: 1.0 center: 0, 0 -# Quadrat regular radi=20 (circumscrit) -# 4 punts equidistants al voltant d'un cercle (90° entre ells) -# Començant a angle=-90° (amunt), rotant sentit horari -# -# Angles: -90°, 0°, 90°, 180° -# Conversió polar→cartesià (SDL: Y creix cap avall): -# angle=-90°: (0.00, -20.00) -# angle=0°: (20.00, 0.00) -# angle=90°: (0.00, 20.00) -# angle=180°: (-20.00, 0.00) - polyline: 0,-20 20,0 0,20 -20,0 0,-20 diff --git a/data/shapes/ship.shp b/data/shapes/ship.shp index f4f683e..aebcbe7 100644 --- a/data/shapes/ship.shp +++ b/data/shapes/ship.shp @@ -1,24 +1,8 @@ -# ship.shp - Nau del jugador 1 (triangle amb base còncava - punta de fletxa) -# © 1999 Visente i Sergi (versió Pascal) -# © 2025 Port a C++20 amb SDL3 +# ship.shp - Nau del jugador 1 +# Triangle amb base còncava (punta de fletxa) name: ship scale: 1.0 center: 0, 0 -# Triangle amb base còncava tipus "punta de fletxa" -# Punts originals (polar): -# p1: r=12, angle=270° (3π/2) → punta amunt -# p2: r=12, angle=45° (π/4) → base dreta-darrere -# p3: r=12, angle=135° (3π/4) → base esquerra-darrere -# -# MODIFICACIÓ: afegit p4 al mig de la base, desplaçat cap al centre -# p4: (0, 4) → punt central de la base, cap endins -# -# Conversió polar→cartesià (angle-90° perquè origen visual és amunt): -# p1: (0, -12) → punta -# p2: (8.49, 8.49) → base dreta -# p4: (0, 4) → base centre (cap endins) -# p3: (-8.49, 8.49) → base esquerra - polyline: 0,-12 8.49,8.49 0,4 -8.49,8.49 0,-12 diff --git a/data/shapes/ship2.shp b/data/shapes/ship2.shp index 9d6280c..4bf35d3 100644 --- a/data/shapes/ship2.shp +++ b/data/shapes/ship2.shp @@ -1,30 +1,11 @@ -# ship2.shp - Nau del jugador 2 (triangle amb circulito central) -# © 1999 Visente i Sergi (versió Pascal) -# © 2025 Port a C++20 amb SDL3 +# ship2.shp - Nau del jugador 2 +# Triangle amb cercle central (distintiu visual) name: ship2 scale: 1.0 center: 0, 0 -# Triangle amb base còncava tipus "punta de fletxa" -# (Mateix que ship.shp) -# Punts originals (polar): -# p1: r=12, angle=270° (3π/2) → punta amunt -# p2: r=12, angle=45° (π/4) → base dreta-darrere -# p3: r=12, angle=135° (3π/4) → base esquerra-darrere -# -# MODIFICACIÓ: afegit p4 al mig de la base, desplaçat cap al centre -# p4: (0, 4) → punt central de la base, cap endins -# -# Conversió polar→cartesià (angle-90° perquè origen visual és amunt): -# p1: (0, -12) → punta -# p2: (8.49, 8.49) → base dreta -# p4: (0, 4) → base centre (cap endins) -# p3: (-8.49, 8.49) → base esquerra - -#polyline: 0,-12 8.49,8.49 0,4 -8.49,8.49 0,-12 polyline: 0,-12 8.49,8.49 -8.49,8.49 0,-12 -# Circulito central (octàgon r=2.5) -# Distintiu visual del jugador 2 +# Octàgon central (radi=2.5) polyline: 0,-2.5 1.77,-1.77 2.5,0 1.77,1.77 0,2.5 -1.77,1.77 -2.5,0 -1.77,-1.77 0,-2.5 diff --git a/source/core/defaults.hpp b/source/core/defaults.hpp index 7f04d7a..361cad4 100644 --- a/source/core/defaults.hpp +++ b/source/core/defaults.hpp @@ -101,7 +101,6 @@ constexpr float SCOREBOARD_PADDING_H = 0.0F; // Game::WIDTH * 0.015f; namespace Entities { constexpr int MAX_ORNIS = 15; constexpr int MAX_BALES = 3; -constexpr int MAX_IPUNTS = 30; constexpr float SHIP_RADIUS = 12.0F; constexpr float ENEMY_RADIUS = 20.0F; diff --git a/source/core/graphics/starfield.cpp b/source/core/graphics/starfield.cpp index 945171f..34ac8c9 100644 --- a/source/core/graphics/starfield.cpp +++ b/source/core/graphics/starfield.cpp @@ -162,7 +162,6 @@ void Starfield::dibuixar() { estrella.posicio, 0.0F, // angle (les estrelles no giren) escala, // escala dinàmica - true, // dibuixar 1.0F, // progress (sempre visible) brightness // brightness dinàmica ); diff --git a/source/core/graphics/vector_text.cpp b/source/core/graphics/vector_text.cpp index 80ce303..7ac60b0 100644 --- a/source/core/graphics/vector_text.cpp +++ b/source/core/graphics/vector_text.cpp @@ -224,7 +224,7 @@ void VectorText::render(const std::string& text, const Punt& posicio, float esca // Ajustar X e Y para que posicio represente esquina superior izquierda // (render_shape espera el centro, así que sumamos la mitad de ancho y altura) Punt char_pos = {.x = current_x + (char_width_scaled / 2.0F), .y = posicio.y + (char_height_scaled / 2.0F)}; - Rendering::render_shape(renderer_, it->second, char_pos, 0.0F, escala, true, 1.0F, brightness); + Rendering::render_shape(renderer_, it->second, char_pos, 0.0F, escala, 1.0F, brightness); // Avanzar posición current_x += char_width_scaled + spacing_scaled; diff --git a/source/core/rendering/line_renderer.cpp b/source/core/rendering/line_renderer.cpp index c387288..956e499 100644 --- a/source/core/rendering/line_renderer.cpp +++ b/source/core/rendering/line_renderer.cpp @@ -4,99 +4,35 @@ #include "core/rendering/line_renderer.hpp" -#include - #include "core/rendering/coordinate_transform.hpp" namespace Rendering { -// [NUEVO] Color global compartit (actualitzat per ColorOscillator via -// SDLManager) -SDL_Color g_current_line_color = {255, 255, 255, 255}; // Blanc inicial +// Color global compartit (actualitzat per ColorOscillator via SDLManager) +SDL_Color g_current_line_color = {255, 255, 255, 255}; -bool linea(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, bool dibuixar, float brightness) { - // Algorisme de Bresenham per dibuixar línies - // Basat en el codi Pascal original - - // Helper function: retorna el signe d'un nombre - auto sign = [](int x) -> int { - if (x < 0) { - return -1; - } - if (x > 0) { - return 1; - } - return 0; - }; - - // Variables per a l'algorisme (no utilitzades fins Fase 10 - detecció de - // col·lisions) int x = x1, y = y1; int xs = x2 - x1; int ys = y2 - y1; int - // xm = sign(xs); int ym = sign(ys); xs = std::abs(xs); ys = std::abs(ys); - - // Suprimir warning de variable no usada - (void)sign; - - // Detecció de col·lisió (TODO per Fase 10) - // El codi Pascal original llegia pixels del framebuffer bit-packed - // i comptava col·lisions. Per ara, usem SDL_RenderDrawLine i retornem false. - bool colisio = false; - - // Dibuixar amb SDL3 (més eficient que Bresenham píxel a píxel) - if (dibuixar && (renderer != nullptr)) { - // Transformar coordenades lògiques (640x480) a físiques (resolució real) - float scale = g_current_scale_factor; - int px1 = transform_x(x1, scale); - int py1 = transform_y(y1, scale); - int px2 = transform_x(x2, scale); - int py2 = transform_y(y2, scale); - - // Aplicar brightness al color oscil·lat global - SDL_Color color_final; - color_final.r = static_cast(g_current_line_color.r * brightness); - color_final.g = static_cast(g_current_line_color.g * brightness); - color_final.b = static_cast(g_current_line_color.b * brightness); - color_final.a = 255; - - SDL_SetRenderDrawColor(renderer, color_final.r, color_final.g, color_final.b, 255); - - // Renderitzar amb coordenades físiques - SDL_RenderLine(renderer, static_cast(px1), static_cast(py1), static_cast(px2), static_cast(py2)); +void linea(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, float brightness) { + if (renderer == nullptr) { + return; } - // Algorisme de Bresenham original (conservat per a futura detecció de - // col·lisió) - /* - if (xs > ys) { - // Línia plana (<45 graus) - int count = -(xs / 2); - while (x != x2) { - count = count + ys; - x = x + xm; - if (count > 0) { - y = y + ym; - count = count - xs; - } - // Aquí aniria la detecció de col·lisió píxel a píxel - } - } else { - // Línia pronunciada (>=45 graus) - int count = -(ys / 2); - while (y != y2) { - count = count + xs; - y = y + ym; - if (count > 0) { - x = x + xm; - count = count - ys; - } - // Aquí aniria la detecció de col·lisió píxel a píxel - } - } - */ + // Transformar coordenades lògiques (640x480) a físiques (resolució real) + const float SCALE = g_current_scale_factor; + const int PX1 = transform_x(x1, SCALE); + const int PY1 = transform_y(y1, SCALE); + const int PX2 = transform_x(x2, SCALE); + const int PY2 = transform_y(y2, SCALE); - return colisio; + // Aplicar brightness al color oscil·lat global + const auto R = static_cast(g_current_line_color.r * brightness); + const auto G = static_cast(g_current_line_color.g * brightness); + const auto B = static_cast(g_current_line_color.b * brightness); + + SDL_SetRenderDrawColor(renderer, R, G, B, 255); + SDL_RenderLine(renderer, static_cast(PX1), static_cast(PY1), + static_cast(PX2), static_cast(PY2)); } -// [NUEVO] Establir el color global de les línies void setLineColor(SDL_Color color) { g_current_line_color = color; } } // namespace Rendering diff --git a/source/core/rendering/line_renderer.hpp b/source/core/rendering/line_renderer.hpp index cf154a0..5fba73c 100644 --- a/source/core/rendering/line_renderer.hpp +++ b/source/core/rendering/line_renderer.hpp @@ -6,11 +6,12 @@ #include namespace Rendering { -// Algorisme de Bresenham per dibuixar línies -// Retorna true si hi ha col·lisió (per Fase 10) -// brightness: factor de brillantor (0.0-1.0, default 1.0 = màxima brillantor) -bool linea(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, bool dibuixar, float brightness = 1.0F); -// [NUEVO] Establir el color global de les línies (oscil·lació) +// Dibuixa una línia entre dos punts en coordenades lògiques (640x480). +// brightness: factor de brillantor (0.0-1.0, default 1.0 = màxima brillantor). +void linea(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, float brightness = 1.0F); + +// Estableix el color global de les línies (utilitzat per ColorOscillator). void setLineColor(SDL_Color color); + } // namespace Rendering diff --git a/source/core/rendering/polygon_renderer.cpp b/source/core/rendering/polygon_renderer.cpp deleted file mode 100644 index f4ca471..0000000 --- a/source/core/rendering/polygon_renderer.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// polygon_renderer.cpp - Implementació de renderitzat de polígons -// © 1999 Visente i Sergi (versió Pascal) -// © 2025 Port a C++20 amb SDL3 -// -// ============================================================================== -// DEPRECATED: Use core/rendering/shape_renderer.cpp instead -// ============================================================================== - -#include "core/rendering/polygon_renderer.hpp" - -#include -#include - -#include "core/defaults.hpp" -#include "core/rendering/line_renderer.hpp" - -namespace Rendering { - -void rota_tri(SDL_Renderer* renderer, const Triangle& tri, float angul, float velocitat, bool dibuixar) { - // Rotar i dibuixar triangle (nau) - // Conversió de coordenades polars a cartesianes amb rotació - // Basat en el codi Pascal original: lines 271-284 - - // Convertir cada punt polar a cartesià - // x = (r + velocitat) * cos(angle_punt + angle_nau) + centre.x - // y = (r + velocitat) * sin(angle_punt + angle_nau) + centre.y - - int x1 = static_cast(std::round((tri.p1.r + velocitat) * - std::cos(tri.p1.angle + angul))) + - tri.centre.x; - - int y1 = static_cast(std::round((tri.p1.r + velocitat) * - std::sin(tri.p1.angle + angul))) + - tri.centre.y; - - int x2 = static_cast(std::round((tri.p2.r + velocitat) * - std::cos(tri.p2.angle + angul))) + - tri.centre.x; - - int y2 = static_cast(std::round((tri.p2.r + velocitat) * - std::sin(tri.p2.angle + angul))) + - tri.centre.y; - - int x3 = static_cast(std::round((tri.p3.r + velocitat) * - std::cos(tri.p3.angle + angul))) + - tri.centre.x; - - int y3 = static_cast(std::round((tri.p3.r + velocitat) * - std::sin(tri.p3.angle + angul))) + - tri.centre.y; - - // Dibuixar les 3 línies que formen el triangle - linea(renderer, x1, y1, x2, y2, dibuixar); - linea(renderer, x1, y1, x3, y3, dibuixar); - linea(renderer, x3, y3, x2, y2, dibuixar); -} - -void rota_pol(SDL_Renderer* renderer, const Poligon& pol, float angul, bool dibuixar) { - // Rotar i dibuixar polígon (enemics i bales) - // Conversió de coordenades polars a cartesianes amb rotació - // Basat en el codi Pascal original: lines 286-296 - - // Array temporal per emmagatzemar punts convertits a cartesianes - std::array xy; - - // Convertir cada punt polar a cartesià - for (uint8_t i = 0; i < pol.n; i++) { - xy[i].x = static_cast(std::round( - pol.ipuntx[i].r * std::cos(pol.ipuntx[i].angle + angul))) + - pol.centre.x; - - xy[i].y = static_cast(std::round( - pol.ipuntx[i].r * std::sin(pol.ipuntx[i].angle + angul))) + - pol.centre.y; - } - - // Dibuixar línies entre punts consecutius - for (uint8_t i = 0; i < pol.n - 1; i++) { - linea(renderer, xy[i].x, xy[i].y, xy[i + 1].x, xy[i + 1].y, dibuixar); - } - - // Tancar el polígon (últim punt → primer punt) - linea(renderer, xy[pol.n - 1].x, xy[pol.n - 1].y, xy[0].x, xy[0].y, dibuixar); -} - -} // namespace Rendering diff --git a/source/core/rendering/polygon_renderer.hpp b/source/core/rendering/polygon_renderer.hpp deleted file mode 100644 index 703a25a..0000000 --- a/source/core/rendering/polygon_renderer.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// polygon_renderer.hpp - Renderitzat de polígons polars -// © 1999 Visente i Sergi (versió Pascal) -// © 2025 Port a C++20 amb SDL3 -// -// ============================================================================== -// DEPRECATED: Use core/rendering/shape_renderer.hpp instead -// ============================================================================== -// This file is kept temporarily for chatarra_cosmica_ (Phase 10: explosions) -// TODO Phase 10: Replace with particle system or remove completely - -#pragma once -#include - -#include "core/types.hpp" - -namespace Rendering { -// Rotar i dibuixar triangle (nau) -void rota_tri(SDL_Renderer* renderer, const Triangle& tri, float angul, float velocitat, bool dibuixar); - -// Rotar i dibuixar polígon (enemics i bales) -void rota_pol(SDL_Renderer* renderer, const Poligon& pol, float angul, bool dibuixar); -} // namespace Rendering diff --git a/source/core/rendering/primitives.cpp b/source/core/rendering/primitives.cpp deleted file mode 100644 index dd19167..0000000 --- a/source/core/rendering/primitives.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// primitives.cpp - Implementació de funcions geomètriques -// © 1999 Visente i Sergi (versió Pascal) -// © 2025 Port a C++20 amb SDL3 -// -// ============================================================================== -// DEPRECATED: Use Shape system instead (.shp files + ShapeLoader) -// ============================================================================== - -#include "primitives.hpp" - -#include - -#include "core/defaults.hpp" - -float modul(const Punt& p) { - // Càlcul de la magnitud d'un vector: sqrt(x² + y²) - return std::sqrt((p.x * p.x) + (p.y * p.y)); -} - -void diferencia(const Punt& o, const Punt& d, Punt& p) { - // Resta de vectors (origen - destí) - p.x = o.x - d.x; - p.y = o.y - d.y; -} - -int distancia(const Punt& o, const Punt& d) { - // Distància entre dos punts - Punt p; - diferencia(o, d, p); - return static_cast(std::round(modul(p))); -} - -float angle_punt(const Punt& p) { - // Càlcul de l'angle d'un punt (arctan) - if (p.y != 0) { - return std::atan(p.x / p.y); - } - return 0.0F; -} - -void crear_poligon_regular(Poligon& pol, uint8_t n, float r) { - // Crear un polígon regular amb n costats i radi r - // Distribueix els punts uniformement al voltant d'un cercle - - float interval = 2.0F * Defaults::Math::PI / n; - float act = 0.0F; - - for (uint8_t i = 0; i < n; i++) { - pol.ipuntx[i].r = r; - pol.ipuntx[i].angle = act; - act += interval; - } - - // Inicialitzar propietats del polígon - pol.centre.x = 320.0F; - pol.centre.y = 200.0F; - pol.angle = 0.0F; - // Convertir velocitat de px/frame a px/s: 2 px/frame × 20 FPS = 40 px/s - pol.velocitat = Defaults::Physics::ENEMY_SPEED * 20.0F; - pol.n = n; - // Convertir rotació de rad/frame a rad/s: 0.0785 rad/frame × 20 FPS = 1.57 - // rad/s (~90°/s) - pol.drotacio = 0.078539816F * 20.0F; - pol.rotacio = 0.0F; - pol.esta = true; -} diff --git a/source/core/rendering/primitives.hpp b/source/core/rendering/primitives.hpp deleted file mode 100644 index e97acb3..0000000 --- a/source/core/rendering/primitives.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// primitives.hpp - Funcions geomètriques bàsiques -// © 1999 Visente i Sergi (versió Pascal) -// © 2025 Port a C++20 amb SDL3 -// -// ============================================================================== -// DEPRECATED: Use Shape system instead (.shp files + ShapeLoader) -// ============================================================================== -// This file is kept temporarily for chatarra_cosmica_ (Phase 10: explosions) -// TODO Phase 10: Replace with particle system or remove completely - -#pragma once - -#include - -#include "core/types.hpp" - -// Funcions matemàtiques geomètriques pures (sense dependències d'estat) - -// Càlcul de la magnitud d'un vector -float modul(const Punt& p); - -// Diferència entre dos punts (vector origen - destí) -void diferencia(const Punt& o, const Punt& d, Punt& p); - -// Distància entre dos punts -int distancia(const Punt& o, const Punt& d); - -// Càlcul de l'angle d'un punt -float angle_punt(const Punt& p); - -// Creació de polígons regulars -void crear_poligon_regular(Poligon& pol, uint8_t n, float r); diff --git a/source/core/rendering/shape_renderer.cpp b/source/core/rendering/shape_renderer.cpp index 5aec16b..bd8b3ad 100644 --- a/source/core/rendering/shape_renderer.cpp +++ b/source/core/rendering/shape_renderer.cpp @@ -77,7 +77,6 @@ void render_shape(SDL_Renderer* renderer, const Punt& posicio, float angle, float escala, - bool dibuixar, float progress, float brightness, const Rotation3D* rotation_3d) { @@ -102,7 +101,8 @@ void render_shape(SDL_Renderer* renderer, Punt p1 = transform_point(primitive.points[i], shape_centre, posicio, angle, escala, rotation_3d); Punt p2 = transform_point(primitive.points[i + 1], shape_centre, posicio, angle, escala, rotation_3d); - linea(renderer, static_cast(p1.x), static_cast(p1.y), static_cast(p2.x), static_cast(p2.y), dibuixar, brightness); + linea(renderer, static_cast(p1.x), static_cast(p1.y), + static_cast(p2.x), static_cast(p2.y), brightness); } } else { // PrimitiveType::LINE // LINE: exactament 2 punts @@ -110,7 +110,8 @@ void render_shape(SDL_Renderer* renderer, Punt p1 = transform_point(primitive.points[0], shape_centre, posicio, angle, escala, rotation_3d); Punt p2 = transform_point(primitive.points[1], shape_centre, posicio, angle, escala, rotation_3d); - linea(renderer, static_cast(p1.x), static_cast(p1.y), static_cast(p2.x), static_cast(p2.y), dibuixar, brightness); + linea(renderer, static_cast(p1.x), static_cast(p1.y), + static_cast(p2.x), static_cast(p2.y), brightness); } } } diff --git a/source/core/rendering/shape_renderer.hpp b/source/core/rendering/shape_renderer.hpp index 2eba582..c289f8d 100644 --- a/source/core/rendering/shape_renderer.hpp +++ b/source/core/rendering/shape_renderer.hpp @@ -38,7 +38,6 @@ struct Rotation3D { // - posicio: posició del centre en coordenades mundials // - angle: rotació en radians (0 = amunt, sentit horari) // - escala: factor d'escala (1.0 = mida original) -// - dibuixar: flag per dibuixar (false per col·lisions futures) // - progress: progrés de l'animació (0.0-1.0, default 1.0 = tot visible) // - brightness: factor de brillantor (0.0-1.0, default 1.0 = màxima brillantor) void render_shape(SDL_Renderer* renderer, @@ -46,7 +45,6 @@ void render_shape(SDL_Renderer* renderer, const Punt& posicio, float angle, float escala = 1.0F, - bool dibuixar = true, float progress = 1.0F, float brightness = 1.0F, const Rotation3D* rotation_3d = nullptr); diff --git a/source/core/types.hpp b/source/core/types.hpp index 1c75a3e..09698ee 100644 --- a/source/core/types.hpp +++ b/source/core/types.hpp @@ -1,43 +1,6 @@ #pragma once -#include -#include - -#include "core/defaults.hpp" - -// Punt polar (coordenades polars) -struct IPunt { - float r; // Radi - float angle; // Angle en radians -}; - -// Punt cartesià +// Punt cartesià - ÚNICA estructura de coordenades del joc struct Punt { float x, y; }; - -// ============================================================================== -// DEPRECATED: Legacy types (replaced by Shape system) -// ============================================================================== -// These types are kept temporarily for chatarra_cosmica_ (Phase 10: explosions) -// TODO Phase 10: Replace with particle system or remove completely - -// Nau (triangle) - DEPRECATED: Now using Shape system (ship.shp) -struct Triangle { - IPunt p1, p2, p3; - Punt centre; - float angle; - float velocitat; -}; - -// Polígon (enemics i bales) - DEPRECATED: Now using Shape system (.shp files) -struct Poligon { - std::array ipuntx; - Punt centre; - float angle; - float velocitat; - uint8_t n; - float drotacio; - float rotacio; - bool esta; -}; diff --git a/source/game/constants.hpp b/source/game/constants.hpp index 5b70523..c0d8c65 100644 --- a/source/game/constants.hpp +++ b/source/game/constants.hpp @@ -14,8 +14,7 @@ constexpr int MARGE_DALT = static_cast(Defaults::Zones::PLAYAREA.y); constexpr int MARGE_BAIX = static_cast(Defaults::Zones::PLAYAREA.y + Defaults::Zones::PLAYAREA.h); -// Límits de polígons i objectes -constexpr int MAX_IPUNTS = Defaults::Entities::MAX_IPUNTS; +// Límits d'objectes constexpr int MAX_ORNIS = Defaults::Entities::MAX_ORNIS; constexpr int MAX_BALES = Defaults::Entities::MAX_BALES; diff --git a/source/game/effects/debris_manager.cpp b/source/game/effects/debris_manager.cpp index 273d84b..97c2622 100644 --- a/source/game/effects/debris_manager.cpp +++ b/source/game/effects/debris_manager.cpp @@ -314,7 +314,6 @@ void DebrisManager::dibuixar() const { static_cast(debris.p1.y), static_cast(debris.p2.x), static_cast(debris.p2.y), - true, debris.brightness); } } diff --git a/source/game/effects/debris_manager.hpp b/source/game/effects/debris_manager.hpp index 147a49b..6dc7cc5 100644 --- a/source/game/effects/debris_manager.hpp +++ b/source/game/effects/debris_manager.hpp @@ -7,6 +7,7 @@ #include #include +#include "core/defaults.hpp" #include "core/graphics/shape.hpp" #include "core/types.hpp" #include "debris.hpp" diff --git a/source/game/entities/bala.cpp b/source/game/entities/bala.cpp index 17794cd..208ee4a 100644 --- a/source/game/entities/bala.cpp +++ b/source/game/entities/bala.cpp @@ -87,7 +87,7 @@ void Bala::dibuixar() const { if (esta_ && forma_) { // [NUEVO] Usar render_shape en lloc de rota_pol // Les bales roten segons l'angle de trajectòria - Rendering::render_shape(renderer_, forma_, centre_, angle_, 1.0F, true, 1.0F, brightness_); + Rendering::render_shape(renderer_, forma_, centre_, angle_, 1.0F, 1.0F, brightness_); } } diff --git a/source/game/entities/enemic.cpp b/source/game/entities/enemic.cpp index 022f688..98f3dcc 100644 --- a/source/game/entities/enemic.cpp +++ b/source/game/entities/enemic.cpp @@ -185,7 +185,7 @@ void Enemic::dibuixar() const { float escala = calcular_escala_actual(); // brightness_ is already updated in actualitzar() - Rendering::render_shape(renderer_, forma_, centre_, rotacio_, escala, true, 1.0F, brightness_); + Rendering::render_shape(renderer_, forma_, centre_, rotacio_, escala, 1.0F, brightness_); } } diff --git a/source/game/entities/nau.cpp b/source/game/entities/nau.cpp index de97759..bb8ee34 100644 --- a/source/game/entities/nau.cpp +++ b/source/game/entities/nau.cpp @@ -167,7 +167,7 @@ void Nau::dibuixar() const { float velocitat_visual = velocitat_ / 33.33F; float escala = 1.0F + (velocitat_visual / 12.0F); - Rendering::render_shape(renderer_, forma_, centre_, angle_, escala, true, 1.0F, brightness_); + Rendering::render_shape(renderer_, forma_, centre_, angle_, escala, 1.0F, brightness_); } void Nau::aplicar_fisica(float delta_time) { diff --git a/source/game/escenes/escena_joc.cpp b/source/game/escenes/escena_joc.cpp index be6d3a3..f59d2dc 100644 --- a/source/game/escenes/escena_joc.cpp +++ b/source/game/escenes/escena_joc.cpp @@ -745,10 +745,10 @@ void EscenaJoc::dibuixar_marges() const { int y2 = static_cast(zona.y + zona.h); // 4 línies per formar el rectangle - Rendering::linea(sdl_.obte_renderer(), x1, y1, x2, y1, true); // Top - Rendering::linea(sdl_.obte_renderer(), x1, y2, x2, y2, true); // Bottom - Rendering::linea(sdl_.obte_renderer(), x1, y1, x1, y2, true); // Left - Rendering::linea(sdl_.obte_renderer(), x2, y1, x2, y2, true); // Right + Rendering::linea(sdl_.obte_renderer(), x1, y1, x2, y1); // Top + Rendering::linea(sdl_.obte_renderer(), x1, y2, x2, y2); // Bottom + Rendering::linea(sdl_.obte_renderer(), x1, y1, x1, y2); // Left + Rendering::linea(sdl_.obte_renderer(), x2, y1, x2, y2); // Right } void EscenaJoc::dibuixar_marcador() { @@ -794,11 +794,11 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const { // Línia esquerra: creix des del centre cap a l'esquerra int x1_phase1 = static_cast(cx - ((cx - x1) * phase1_progress)); - Rendering::linea(sdl_.obte_renderer(), cx, y1, x1_phase1, y1, true); + Rendering::linea(sdl_.obte_renderer(), cx, y1, x1_phase1, y1); // Línia dreta: creix des del centre cap a la dreta int x2_phase1 = static_cast(cx + ((x2 - cx) * phase1_progress)); - Rendering::linea(sdl_.obte_renderer(), cx, y1, x2_phase1, y1, true); + Rendering::linea(sdl_.obte_renderer(), cx, y1, x2_phase1, y1); } // --- FASE 2: Línies verticals laterals (33-66%) --- @@ -807,10 +807,10 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const { // Línia esquerra: creix des de dalt cap a baix int y2_phase2 = static_cast(y1 + ((y2 - y1) * phase2_progress)); - Rendering::linea(sdl_.obte_renderer(), x1, y1, x1, y2_phase2, true); + Rendering::linea(sdl_.obte_renderer(), x1, y1, x1, y2_phase2); // Línia dreta: creix des de dalt cap a baix - Rendering::linea(sdl_.obte_renderer(), x2, y1, x2, y2_phase2, true); + Rendering::linea(sdl_.obte_renderer(), x2, y1, x2, y2_phase2); } // --- FASE 3: Línies horitzontals inferiors (66-100%) --- @@ -819,11 +819,11 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const { // Línia esquerra: creix des de l'esquerra cap al centre int x_left_phase3 = static_cast(x1 + ((cx - x1) * phase3_progress)); - Rendering::linea(sdl_.obte_renderer(), x1, y2, x_left_phase3, y2, true); + Rendering::linea(sdl_.obte_renderer(), x1, y2, x_left_phase3, y2); // Línia dreta: creix des de la dreta cap al centre int x_right_phase3 = static_cast(x2 - ((x2 - cx) * phase3_progress)); - Rendering::linea(sdl_.obte_renderer(), x2, y2, x_right_phase3, y2, true); + Rendering::linea(sdl_.obte_renderer(), x2, y2, x_right_phase3, y2); } } diff --git a/source/game/escenes/escena_joc.hpp b/source/game/escenes/escena_joc.hpp index b9d6be3..0894328 100644 --- a/source/game/escenes/escena_joc.hpp +++ b/source/game/escenes/escena_joc.hpp @@ -55,7 +55,6 @@ class EscenaJoc { std::array naus_; // [0]=P1, [1]=P2 std::array orni_; std::array bales_; // 6 balas: P1=[0,1,2], P2=[3,4,5] - Poligon chatarra_cosmica_; std::array itocado_per_jugador_; // Death timers per player (seconds) // Lives and game over system @@ -65,8 +64,7 @@ class EscenaJoc { float continue_tick_timer_; // Timer for countdown tick (1.0s) int continues_usados_; // Continues used this game (0-3 max) float game_over_timer_; // Final GAME OVER timer before title screen - // Punt punt_spawn_; // DEPRECATED: usar obtenir_punt_spawn(player_id) - Punt punt_mort_; // Death position (for respawn, legacy) + Punt punt_mort_; // Death position (for respawn) std::array puntuacio_per_jugador_; // [0]=P1, [1]=P2 // Text vectorial diff --git a/source/game/escenes/escena_logo.cpp b/source/game/escenes/escena_logo.cpp index 30f7b7f..96453d2 100644 --- a/source/game/escenes/escena_logo.cpp +++ b/source/game/escenes/escena_logo.cpp @@ -379,7 +379,6 @@ void EscenaLogo::dibuixar() { pos_actual, 0.0F, escala_actual, - true, 1.0F); } } @@ -403,7 +402,6 @@ void EscenaLogo::dibuixar() { lletra.posicio, 0.0F, ESCALA_FINAL, - true, 1.0F); } } diff --git a/source/game/escenes/escena_titol.cpp b/source/game/escenes/escena_titol.cpp index 2e7d123..0e1de2a 100644 --- a/source/game/escenes/escena_titol.cpp +++ b/source/game/escenes/escena_titol.cpp @@ -593,7 +593,6 @@ void EscenaTitol::dibuixar() { pos_shadow, 0.0F, Defaults::Title::Layout::LOGO_SCALE, - true, 1.0F, // progress = 1.0 (totalment visible) SHADOW_BRIGHTNESS // brightness = 0.4 (brillantor reduïda) ); @@ -611,7 +610,6 @@ void EscenaTitol::dibuixar() { pos_shadow, 0.0F, Defaults::Title::Layout::LOGO_SCALE, - true, 1.0F, // progress = 1.0 (totalment visible) SHADOW_BRIGHTNESS); } @@ -627,7 +625,6 @@ void EscenaTitol::dibuixar() { lletra.posicio, 0.0F, Defaults::Title::Layout::LOGO_SCALE, - true, 1.0F // Brillantor completa ); } @@ -640,7 +637,6 @@ void EscenaTitol::dibuixar() { lletra.posicio, 0.0F, Defaults::Title::Layout::LOGO_SCALE, - true, 1.0F // Brillantor completa ); } diff --git a/source/game/title/ship_animator.cpp b/source/game/title/ship_animator.cpp index 4cdc770..bcc5c51 100644 --- a/source/game/title/ship_animator.cpp +++ b/source/game/title/ship_animator.cpp @@ -67,7 +67,6 @@ void ShipAnimator::dibuixar() const { nau.posicio_actual, 0.0F, // angle (rotació 2D no utilitzada) nau.escala_actual, - true, // dibuixar 1.0F, // progress (sempre visible) 1.0F // brightness (brillantor màxima) );