From d6b2e97777248f805ac7be98a883999e1a75a1f3 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 2 Dec 2025 22:11:17 +0100 Subject: [PATCH] afegit nivell de brillo per shape --- source/game/entities/bala.cpp | 6 ++++-- source/game/entities/bala.hpp | 1 + source/game/entities/enemic.cpp | 6 ++++-- source/game/entities/enemic.hpp | 7 ++++--- source/game/entities/nau.cpp | 5 +++-- source/game/entities/nau.hpp | 5 +++-- source/game/escenes/escena_titol.cpp | 3 +-- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/source/game/entities/bala.cpp b/source/game/entities/bala.cpp index 3a97017..40e877e 100644 --- a/source/game/entities/bala.cpp +++ b/source/game/entities/bala.cpp @@ -8,6 +8,7 @@ #include #include "core/audio/audio.hpp" +#include "core/defaults.hpp" #include "core/graphics/shape_loader.hpp" #include "core/rendering/shape_renderer.hpp" #include "game/constants.hpp" @@ -17,7 +18,8 @@ Bala::Bala(SDL_Renderer* renderer) centre_({0.0f, 0.0f}), angle_(0.0f), velocitat_(0.0f), - esta_(false) { + esta_(false), + brightness_(Defaults::Brightness::BALA) { // [NUEVO] Carregar forma compartida des de fitxer forma_ = Graphics::ShapeLoader::load("bullet.shp"); @@ -66,7 +68,7 @@ void Bala::dibuixar() const { if (esta_ && forma_) { // [NUEVO] Usar render_shape en lloc de rota_pol // Les bales no roten visualment (angle sempre 0.0f) - Rendering::render_shape(renderer_, forma_, centre_, 0.0f, 1.0f, true); + Rendering::render_shape(renderer_, forma_, centre_, 0.0f, 1.0f, true, 1.0f, brightness_); } } diff --git a/source/game/entities/bala.hpp b/source/game/entities/bala.hpp index dd4b005..2b3b283 100644 --- a/source/game/entities/bala.hpp +++ b/source/game/entities/bala.hpp @@ -37,6 +37,7 @@ class Bala { float angle_; float velocitat_; bool esta_; + float brightness_; // Factor de brillantor (0.0-1.0) void mou(float delta_time); }; diff --git a/source/game/entities/enemic.cpp b/source/game/entities/enemic.cpp index efe9e18..3c85640 100644 --- a/source/game/entities/enemic.cpp +++ b/source/game/entities/enemic.cpp @@ -8,6 +8,7 @@ #include #include +#include "core/defaults.hpp" #include "core/graphics/shape_loader.hpp" #include "core/rendering/shape_renderer.hpp" #include "game/constants.hpp" @@ -19,7 +20,8 @@ Enemic::Enemic(SDL_Renderer* renderer) velocitat_(0.0f), drotacio_(0.0f), rotacio_(0.0f), - esta_(false) { + esta_(false), + brightness_(Defaults::Brightness::ENEMIC) { // [NUEVO] Carregar forma compartida des de fitxer forma_ = Graphics::ShapeLoader::load("enemy_pentagon.shp"); @@ -79,7 +81,7 @@ void Enemic::actualitzar(float delta_time) { void Enemic::dibuixar() const { if (esta_ && forma_) { // [NUEVO] Usar render_shape en lloc de rota_pol - Rendering::render_shape(renderer_, forma_, centre_, rotacio_, 1.0f, true); + Rendering::render_shape(renderer_, forma_, centre_, rotacio_, 1.0f, true, 1.0f, brightness_); } } diff --git a/source/game/entities/enemic.hpp b/source/game/entities/enemic.hpp index b7feb86..1431cf6 100644 --- a/source/game/entities/enemic.hpp +++ b/source/game/entities/enemic.hpp @@ -34,11 +34,12 @@ class Enemic { // [NUEVO] Estat de la instància (separat de la geometria) Punt centre_; - float angle_; // Angle de moviment + float angle_; // Angle de moviment float velocitat_; - float drotacio_; // Delta rotació visual (rad/s) - float rotacio_; // Rotació visual acumulada + float drotacio_; // Delta rotació visual (rad/s) + float rotacio_; // Rotació visual acumulada bool esta_; + float brightness_; // Factor de brillantor (0.0-1.0) void mou(float delta_time); }; diff --git a/source/game/entities/nau.cpp b/source/game/entities/nau.cpp index c1a8b91..46caf78 100644 --- a/source/game/entities/nau.cpp +++ b/source/game/entities/nau.cpp @@ -19,7 +19,8 @@ Nau::Nau(SDL_Renderer* renderer) centre_({0.0f, 0.0f}), angle_(0.0f), velocitat_(0.0f), - esta_tocada_(false) { + esta_tocada_(false), + brightness_(Defaults::Brightness::NAU) { // [NUEVO] Carregar forma compartida des de fitxer forma_ = Graphics::ShapeLoader::load("ship.shp"); @@ -106,7 +107,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); + Rendering::render_shape(renderer_, forma_, centre_, angle_, escala, true, 1.0f, brightness_); } void Nau::aplicar_fisica(float delta_time) { diff --git a/source/game/entities/nau.hpp b/source/game/entities/nau.hpp index 26e19dd..accb9af 100644 --- a/source/game/entities/nau.hpp +++ b/source/game/entities/nau.hpp @@ -38,9 +38,10 @@ class Nau { // [NUEVO] Estat de la instància (separat de la geometria) Punt centre_; - float angle_; // Angle d'orientació - float velocitat_; // Velocitat (px/s) + float angle_; // Angle d'orientació + float velocitat_; // Velocitat (px/s) bool esta_tocada_; + float brightness_; // Factor de brillantor (0.0-1.0) void aplicar_fisica(float delta_time); }; diff --git a/source/game/escenes/escena_titol.cpp b/source/game/escenes/escena_titol.cpp index 02be840..0be706e 100644 --- a/source/game/escenes/escena_titol.cpp +++ b/source/game/escenes/escena_titol.cpp @@ -32,8 +32,7 @@ EscenaTitol::EscenaTitol(SDLManager& sdl) sdl_.obte_renderer(), centre_pantalla, area_completa, - 100, // densitat: 100 estrelles - 30.0f // velocitat base: 30 px/s + 150 // densitat: 150 estrelles (50 per capa) ); }