afegit nivell de brillo per shape

This commit is contained in:
2025-12-02 22:11:17 +01:00
parent 98c90e6075
commit d6b2e97777
7 changed files with 20 additions and 13 deletions

View File

@@ -8,6 +8,7 @@
#include <iostream> #include <iostream>
#include "core/audio/audio.hpp" #include "core/audio/audio.hpp"
#include "core/defaults.hpp"
#include "core/graphics/shape_loader.hpp" #include "core/graphics/shape_loader.hpp"
#include "core/rendering/shape_renderer.hpp" #include "core/rendering/shape_renderer.hpp"
#include "game/constants.hpp" #include "game/constants.hpp"
@@ -17,7 +18,8 @@ Bala::Bala(SDL_Renderer* renderer)
centre_({0.0f, 0.0f}), centre_({0.0f, 0.0f}),
angle_(0.0f), angle_(0.0f),
velocitat_(0.0f), velocitat_(0.0f),
esta_(false) { esta_(false),
brightness_(Defaults::Brightness::BALA) {
// [NUEVO] Carregar forma compartida des de fitxer // [NUEVO] Carregar forma compartida des de fitxer
forma_ = Graphics::ShapeLoader::load("bullet.shp"); forma_ = Graphics::ShapeLoader::load("bullet.shp");
@@ -66,7 +68,7 @@ void Bala::dibuixar() const {
if (esta_ && forma_) { if (esta_ && forma_) {
// [NUEVO] Usar render_shape en lloc de rota_pol // [NUEVO] Usar render_shape en lloc de rota_pol
// Les bales no roten visualment (angle sempre 0.0f) // 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_);
} }
} }

View File

@@ -37,6 +37,7 @@ class Bala {
float angle_; float angle_;
float velocitat_; float velocitat_;
bool esta_; bool esta_;
float brightness_; // Factor de brillantor (0.0-1.0)
void mou(float delta_time); void mou(float delta_time);
}; };

View File

@@ -8,6 +8,7 @@
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include "core/defaults.hpp"
#include "core/graphics/shape_loader.hpp" #include "core/graphics/shape_loader.hpp"
#include "core/rendering/shape_renderer.hpp" #include "core/rendering/shape_renderer.hpp"
#include "game/constants.hpp" #include "game/constants.hpp"
@@ -19,7 +20,8 @@ Enemic::Enemic(SDL_Renderer* renderer)
velocitat_(0.0f), velocitat_(0.0f),
drotacio_(0.0f), drotacio_(0.0f),
rotacio_(0.0f), rotacio_(0.0f),
esta_(false) { esta_(false),
brightness_(Defaults::Brightness::ENEMIC) {
// [NUEVO] Carregar forma compartida des de fitxer // [NUEVO] Carregar forma compartida des de fitxer
forma_ = Graphics::ShapeLoader::load("enemy_pentagon.shp"); forma_ = Graphics::ShapeLoader::load("enemy_pentagon.shp");
@@ -79,7 +81,7 @@ void Enemic::actualitzar(float delta_time) {
void Enemic::dibuixar() const { void Enemic::dibuixar() const {
if (esta_ && forma_) { if (esta_ && forma_) {
// [NUEVO] Usar render_shape en lloc de rota_pol // [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_);
} }
} }

View File

@@ -34,11 +34,12 @@ class Enemic {
// [NUEVO] Estat de la instància (separat de la geometria) // [NUEVO] Estat de la instància (separat de la geometria)
Punt centre_; Punt centre_;
float angle_; // Angle de moviment float angle_; // Angle de moviment
float velocitat_; float velocitat_;
float drotacio_; // Delta rotació visual (rad/s) float drotacio_; // Delta rotació visual (rad/s)
float rotacio_; // Rotació visual acumulada float rotacio_; // Rotació visual acumulada
bool esta_; bool esta_;
float brightness_; // Factor de brillantor (0.0-1.0)
void mou(float delta_time); void mou(float delta_time);
}; };

View File

@@ -19,7 +19,8 @@ Nau::Nau(SDL_Renderer* renderer)
centre_({0.0f, 0.0f}), centre_({0.0f, 0.0f}),
angle_(0.0f), angle_(0.0f),
velocitat_(0.0f), velocitat_(0.0f),
esta_tocada_(false) { esta_tocada_(false),
brightness_(Defaults::Brightness::NAU) {
// [NUEVO] Carregar forma compartida des de fitxer // [NUEVO] Carregar forma compartida des de fitxer
forma_ = Graphics::ShapeLoader::load("ship.shp"); forma_ = Graphics::ShapeLoader::load("ship.shp");
@@ -106,7 +107,7 @@ void Nau::dibuixar() const {
float velocitat_visual = velocitat_ / 33.33f; float velocitat_visual = velocitat_ / 33.33f;
float escala = 1.0f + (velocitat_visual / 12.0f); 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) { void Nau::aplicar_fisica(float delta_time) {

View File

@@ -38,9 +38,10 @@ class Nau {
// [NUEVO] Estat de la instància (separat de la geometria) // [NUEVO] Estat de la instància (separat de la geometria)
Punt centre_; Punt centre_;
float angle_; // Angle d'orientació float angle_; // Angle d'orientació
float velocitat_; // Velocitat (px/s) float velocitat_; // Velocitat (px/s)
bool esta_tocada_; bool esta_tocada_;
float brightness_; // Factor de brillantor (0.0-1.0)
void aplicar_fisica(float delta_time); void aplicar_fisica(float delta_time);
}; };

View File

@@ -32,8 +32,7 @@ EscenaTitol::EscenaTitol(SDLManager& sdl)
sdl_.obte_renderer(), sdl_.obte_renderer(),
centre_pantalla, centre_pantalla,
area_completa, area_completa,
100, // densitat: 100 estrelles 150 // densitat: 150 estrelles (50 per capa)
30.0f // velocitat base: 30 px/s
); );
} }