diff --git a/CMakeLists.txt b/CMakeLists.txt index b20f1d6..16e7c4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ set(APP_SOURCES source/core/system/director.cpp source/core/rendering/sdl_manager.cpp source/core/rendering/line_renderer.cpp + source/core/rendering/color_oscillator.cpp source/core/rendering/polygon_renderer.cpp source/core/rendering/primitives.cpp source/game/options.cpp diff --git a/Makefile b/Makefile index 4298a91..771cde0 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ APP_SOURCES := \ source/core/system/director.cpp \ source/core/rendering/sdl_manager.cpp \ source/core/rendering/line_renderer.cpp \ + source/core/rendering/color_oscillator.cpp \ source/core/rendering/polygon_renderer.cpp \ source/core/rendering/primitives.cpp \ source/game/options.cpp \ diff --git a/source/core/rendering/sdl_manager.cpp b/source/core/rendering/sdl_manager.cpp index 9126ba9..1dcd8d9 100644 --- a/source/core/rendering/sdl_manager.cpp +++ b/source/core/rendering/sdl_manager.cpp @@ -3,6 +3,7 @@ #include "sdl_manager.hpp" #include "core/defaults.hpp" +#include "core/rendering/line_renderer.hpp" #include "game/options.hpp" #include "project.h" #include @@ -277,7 +278,12 @@ void SDLManager::neteja(uint8_t r, uint8_t g, uint8_t b) { if (!renderer_) return; - SDL_SetRenderDrawColor(renderer_, r, g, b, 255); + // [MODIFICAT] Usar color oscil·lat del fons en lloc dels paràmetres + (void)r; + (void)g; + (void)b; // Suprimir warnings + SDL_Color bg = color_oscillator_.getCurrentBackgroundColor(); + SDL_SetRenderDrawColor(renderer_, bg.r, bg.g, bg.b, 255); SDL_RenderClear(renderer_); } @@ -287,3 +293,11 @@ void SDLManager::presenta() { SDL_RenderPresent(renderer_); } + +// [NUEVO] Actualitzar colors amb oscil·lació +void SDLManager::updateColors(float delta_time) { + color_oscillator_.update(delta_time); + + // Actualitzar color global de línies + Rendering::setLineColor(color_oscillator_.getCurrentLineColor()); +} diff --git a/source/core/rendering/sdl_manager.hpp b/source/core/rendering/sdl_manager.hpp index 68d6467..52788e5 100644 --- a/source/core/rendering/sdl_manager.hpp +++ b/source/core/rendering/sdl_manager.hpp @@ -6,6 +6,7 @@ #include #include +#include "core/rendering/color_oscillator.hpp" class SDLManager { public: @@ -29,6 +30,9 @@ public: void neteja(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0); void presenta(); + // [NUEVO] Actualització de colors (oscil·lació) + void updateColors(float delta_time); + // Getters SDL_Renderer *obte_renderer() { return renderer_; } @@ -47,6 +51,9 @@ private: void calculateMaxWindowSize(); // Llegir resolució del display void applyWindowSize(int width, int height); // Canviar mida + centrar void updateLogicalPresentation(); // Actualitzar viewport + + // [NUEVO] Oscil·lador de colors + Rendering::ColorOscillator color_oscillator_; }; #endif // SDL_MANAGER_HPP