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 "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_);
}
}

View File

@@ -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);
};

View File

@@ -8,6 +8,7 @@
#include <cstdlib>
#include <iostream>
#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_);
}
}

View File

@@ -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);
};

View File

@@ -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) {

View File

@@ -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);
};