From ffc2dee311f360eec99e2ed8997946e2a1835a8b Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 6 Nov 2026 09:31:48 +0100 Subject: [PATCH] =?UTF-8?q?ja=20tenim=20algo=20de=20gamecontext.=20lo=20pr?= =?UTF-8?q?oxim=20va=20a=20ser=20fer=20algo=20per=20a=20la=20gesti=C3=B3?= =?UTF-8?q?=20del=20temps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/core/rendering/video.cpp | 15 ++++++++++++++- source/core/rendering/video.hpp | 3 +++ source/game/director.cpp | 12 +++++++++--- source/game/director.hpp | 5 ++++- source/game/gamecontext.hpp | 9 +++++++++ source/game/scenes/test.cpp | 8 +++++++- source/game/scenes/test.hpp | 6 ++++++ 7 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 source/game/gamecontext.hpp diff --git a/source/core/rendering/video.cpp b/source/core/rendering/video.cpp index f44c7e7..6e45a84 100644 --- a/source/core/rendering/video.cpp +++ b/source/core/rendering/video.cpp @@ -64,4 +64,17 @@ auto Video::initSDL() -> int { SDL_Delay(1000); return 0; -} \ No newline at end of file +} + +void Video::clean(int color) { + const Uint8 r = static_cast((color >> 16) & 0xFF); + const Uint8 g = static_cast((color >> 8) & 0xFF); + const Uint8 b = static_cast(color & 0xFF); + + SDL_SetRenderDrawColor(renderer_, r, g, b, 255); + SDL_RenderClear(renderer_); +} + +void Video::present() { + SDL_RenderPresent(renderer_); +} diff --git a/source/core/rendering/video.hpp b/source/core/rendering/video.hpp index b01562b..cfbe439 100644 --- a/source/core/rendering/video.hpp +++ b/source/core/rendering/video.hpp @@ -16,6 +16,9 @@ class Video { Video(Config config); ~Video(); + void clean(int color); + void present(); + private: Config config_; diff --git a/source/game/director.cpp b/source/game/director.cpp index 4af4279..54c98d0 100644 --- a/source/game/director.cpp +++ b/source/game/director.cpp @@ -11,13 +11,19 @@ Director::Director() { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Game start!"); - video_ = std::make_shared