retocs disseny en LOGO
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -195,8 +195,7 @@ void SDLManager::calculateMaxZoom() {
|
|||||||
float max_zoom_unrounded = std::min(max_zoom_width, max_zoom_height);
|
float max_zoom_unrounded = std::min(max_zoom_width, max_zoom_height);
|
||||||
|
|
||||||
// Round DOWN to nearest 0.1 increment (user preference)
|
// Round DOWN to nearest 0.1 increment (user preference)
|
||||||
max_zoom_ = std::floor(max_zoom_unrounded / Defaults::Window::ZOOM_INCREMENT)
|
max_zoom_ = std::floor(max_zoom_unrounded / Defaults::Window::ZOOM_INCREMENT) * Defaults::Window::ZOOM_INCREMENT;
|
||||||
* Defaults::Window::ZOOM_INCREMENT;
|
|
||||||
|
|
||||||
// Safety clamp
|
// Safety clamp
|
||||||
max_zoom_ = std::max(max_zoom_, Defaults::Window::MIN_ZOOM);
|
max_zoom_ = std::max(max_zoom_, Defaults::Window::MIN_ZOOM);
|
||||||
@@ -208,11 +207,10 @@ void SDLManager::calculateMaxZoom() {
|
|||||||
void SDLManager::applyZoom(float new_zoom) {
|
void SDLManager::applyZoom(float new_zoom) {
|
||||||
// Clamp to valid range
|
// Clamp to valid range
|
||||||
new_zoom = std::max(Defaults::Window::MIN_ZOOM,
|
new_zoom = std::max(Defaults::Window::MIN_ZOOM,
|
||||||
std::min(new_zoom, max_zoom_));
|
std::min(new_zoom, max_zoom_));
|
||||||
|
|
||||||
// Round to nearest 0.1 increment
|
// Round to nearest 0.1 increment
|
||||||
new_zoom = std::round(new_zoom / Defaults::Window::ZOOM_INCREMENT)
|
new_zoom = std::round(new_zoom / Defaults::Window::ZOOM_INCREMENT) * Defaults::Window::ZOOM_INCREMENT;
|
||||||
* Defaults::Window::ZOOM_INCREMENT;
|
|
||||||
|
|
||||||
// No change?
|
// No change?
|
||||||
if (std::abs(new_zoom - zoom_factor_) < 0.01f) {
|
if (std::abs(new_zoom - zoom_factor_) < 0.01f) {
|
||||||
@@ -339,7 +337,7 @@ bool SDLManager::handleWindowEvent(const SDL_Event& event) {
|
|||||||
// Calculate zoom from actual size (may not align to 0.1 increments)
|
// Calculate zoom from actual size (may not align to 0.1 increments)
|
||||||
float new_zoom = static_cast<float>(current_width_) / Defaults::Window::WIDTH;
|
float new_zoom = static_cast<float>(current_width_) / Defaults::Window::WIDTH;
|
||||||
zoom_factor_ = std::max(Defaults::Window::MIN_ZOOM,
|
zoom_factor_ = std::max(Defaults::Window::MIN_ZOOM,
|
||||||
std::min(new_zoom, max_zoom_));
|
std::min(new_zoom, max_zoom_));
|
||||||
|
|
||||||
// Update windowed cache (if not in fullscreen)
|
// Update windowed cache (if not in fullscreen)
|
||||||
if (!is_fullscreen_) {
|
if (!is_fullscreen_) {
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ class SDLManager {
|
|||||||
int max_height_;
|
int max_height_;
|
||||||
|
|
||||||
// [ZOOM SYSTEM]
|
// [ZOOM SYSTEM]
|
||||||
float zoom_factor_; // Current zoom (0.5x to max_zoom_)
|
float zoom_factor_; // Current zoom (0.5x to max_zoom_)
|
||||||
int windowed_width_; // Saved size before fullscreen
|
int windowed_width_; // Saved size before fullscreen
|
||||||
int windowed_height_; // Saved size before fullscreen
|
int windowed_height_; // Saved size before fullscreen
|
||||||
float max_zoom_; // Maximum zoom (calculated from display)
|
float max_zoom_; // Maximum zoom (calculated from display)
|
||||||
|
|
||||||
// [NUEVO] Funcions internes
|
// [NUEVO] Funcions internes
|
||||||
void calculateMaxWindowSize(); // Llegir resolució del display
|
void calculateMaxWindowSize(); // Llegir resolució del display
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ inline void obtenir_limits_zona(float& min_x, float& max_x, float& min_y, float&
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtenir límits segurs (compensant radi de l'entitat)
|
// Obtenir límits segurs (compensant radi de l'entitat)
|
||||||
inline void obtenir_limits_zona_segurs(float radi, float& min_x, float& max_x,
|
inline void obtenir_limits_zona_segurs(float radi, float& min_x, float& max_x, float& min_y, float& max_y) {
|
||||||
float& min_y, float& max_y) {
|
|
||||||
const auto& zona = Defaults::Zones::PLAYAREA;
|
const auto& zona = Defaults::Zones::PLAYAREA;
|
||||||
constexpr float MARGE_SEGURETAT = 10.0f; // Safety margin
|
constexpr float MARGE_SEGURETAT = 10.0f; // Safety margin
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,10 @@ void Bala::mou(float delta_time) {
|
|||||||
// CORRECCIÓ: Usar límits segurs amb radi de la bala
|
// CORRECCIÓ: Usar límits segurs amb radi de la bala
|
||||||
float min_x, max_x, min_y, max_y;
|
float min_x, max_x, min_y, max_y;
|
||||||
Constants::obtenir_limits_zona_segurs(Defaults::Entities::BULLET_RADIUS,
|
Constants::obtenir_limits_zona_segurs(Defaults::Entities::BULLET_RADIUS,
|
||||||
min_x, max_x, min_y, max_y);
|
min_x,
|
||||||
|
max_x,
|
||||||
|
min_y,
|
||||||
|
max_y);
|
||||||
|
|
||||||
if (centre_.x < min_x || centre_.x > max_x ||
|
if (centre_.x < min_x || centre_.x > max_x ||
|
||||||
centre_.y < min_y || centre_.y > max_y) {
|
centre_.y < min_y || centre_.y > max_y) {
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ void Enemic::inicialitzar() {
|
|||||||
// Calcular rangs segurs amb radi de l'enemic
|
// Calcular rangs segurs amb radi de l'enemic
|
||||||
float min_x, max_x, min_y, max_y;
|
float min_x, max_x, min_y, max_y;
|
||||||
Constants::obtenir_limits_zona_segurs(Defaults::Entities::ENEMY_RADIUS,
|
Constants::obtenir_limits_zona_segurs(Defaults::Entities::ENEMY_RADIUS,
|
||||||
min_x, max_x, min_y, max_y);
|
min_x,
|
||||||
|
max_x,
|
||||||
|
min_y,
|
||||||
|
max_y);
|
||||||
|
|
||||||
// Spawn aleatori dins dels límits segurs
|
// Spawn aleatori dins dels límits segurs
|
||||||
int range_x = static_cast<int>(max_x - min_x);
|
int range_x = static_cast<int>(max_x - min_x);
|
||||||
@@ -102,7 +105,10 @@ void Enemic::mou(float delta_time) {
|
|||||||
// Obtenir límits segurs compensant el radi de l'enemic
|
// Obtenir límits segurs compensant el radi de l'enemic
|
||||||
float min_x, max_x, min_y, max_y;
|
float min_x, max_x, min_y, max_y;
|
||||||
Constants::obtenir_limits_zona_segurs(Defaults::Entities::ENEMY_RADIUS,
|
Constants::obtenir_limits_zona_segurs(Defaults::Entities::ENEMY_RADIUS,
|
||||||
min_x, max_x, min_y, max_y);
|
min_x,
|
||||||
|
max_x,
|
||||||
|
min_y,
|
||||||
|
max_y);
|
||||||
|
|
||||||
// Lògica Pascal: Actualitza Y si dins, sinó ajusta angle aleatòriament
|
// Lògica Pascal: Actualitza Y si dins, sinó ajusta angle aleatòriament
|
||||||
// if (dy>marge_dalt) and (dy<marge_baix) then orni.centre.y:=round(Dy)
|
// if (dy>marge_dalt) and (dy<marge_baix) then orni.centre.y:=round(Dy)
|
||||||
|
|||||||
@@ -127,7 +127,10 @@ void Nau::aplicar_fisica(float delta_time) {
|
|||||||
// CORRECCIÓ: Usar límits segurs i inequalitats inclusives
|
// CORRECCIÓ: Usar límits segurs i inequalitats inclusives
|
||||||
float min_x, max_x, min_y, max_y;
|
float min_x, max_x, min_y, max_y;
|
||||||
Constants::obtenir_limits_zona_segurs(Defaults::Entities::SHIP_RADIUS,
|
Constants::obtenir_limits_zona_segurs(Defaults::Entities::SHIP_RADIUS,
|
||||||
min_x, max_x, min_y, max_y);
|
min_x,
|
||||||
|
max_x,
|
||||||
|
min_y,
|
||||||
|
max_y);
|
||||||
|
|
||||||
// Inequalitats inclusives (>= i <=)
|
// Inequalitats inclusives (>= i <=)
|
||||||
if (dy >= min_y && dy <= max_y) {
|
if (dy >= min_y && dy <= max_y) {
|
||||||
|
|||||||
@@ -293,11 +293,11 @@ void EscenaJoc::detectar_col·lisions_bales_enemics() {
|
|||||||
|
|
||||||
// 2. Crear explosió de fragments
|
// 2. Crear explosió de fragments
|
||||||
debris_manager_.explotar(
|
debris_manager_.explotar(
|
||||||
enemic.get_forma(), // Forma vectorial del pentàgon
|
enemic.get_forma(), // Forma vectorial del pentàgon
|
||||||
pos_enemic, // Posició central
|
pos_enemic, // Posició central
|
||||||
0.0f, // Angle (enemic té rotació interna)
|
0.0f, // Angle (enemic té rotació interna)
|
||||||
1.0f, // Escala normal
|
1.0f, // Escala normal
|
||||||
VELOCITAT_EXPLOSIO // 50 px/s (explosió suau)
|
VELOCITAT_EXPLOSIO // 50 px/s (explosió suau)
|
||||||
);
|
);
|
||||||
|
|
||||||
// 3. Desactivar bala
|
// 3. Desactivar bala
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ class EscenaJoc {
|
|||||||
// Funcions privades
|
// Funcions privades
|
||||||
void tocado();
|
void tocado();
|
||||||
void detectar_col·lisions_bales_enemics(); // Col·lisions bala-enemic
|
void detectar_col·lisions_bales_enemics(); // Col·lisions bala-enemic
|
||||||
void dibuixar_marges() const; // Dibuixar vores de la zona de joc
|
void dibuixar_marges() const; // Dibuixar vores de la zona de joc
|
||||||
void dibuixar_marcador(); // Dibuixar marcador de puntuació
|
void dibuixar_marcador(); // Dibuixar marcador de puntuació
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ESCENA_JOC_HPP
|
#endif // ESCENA_JOC_HPP
|
||||||
|
|||||||
@@ -6,12 +6,14 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <random>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "../../core/audio/audio.hpp"
|
#include "core/audio/audio.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 "../../core/system/gestor_escenes.hpp"
|
#include "core/system/gestor_escenes.hpp"
|
||||||
#include "../../core/system/global_events.hpp"
|
#include "core/system/global_events.hpp"
|
||||||
|
|
||||||
// Helper: calcular el progrés individual d'una lletra
|
// Helper: calcular el progrés individual d'una lletra
|
||||||
// en funció del progrés global (efecte seqüencial)
|
// en funció del progrés global (efecte seqüencial)
|
||||||
@@ -181,6 +183,15 @@ void EscenaLogo::canviar_estat(EstatAnimacio nou_estat) {
|
|||||||
if (nou_estat == EstatAnimacio::EXPLOSION) {
|
if (nou_estat == EstatAnimacio::EXPLOSION) {
|
||||||
lletra_explosio_index_ = 0;
|
lletra_explosio_index_ = 0;
|
||||||
temps_des_ultima_explosio_ = 0.0f;
|
temps_des_ultima_explosio_ = 0.0f;
|
||||||
|
|
||||||
|
// Generar ordre aleatori d'explosions
|
||||||
|
ordre_explosio_.clear();
|
||||||
|
for (size_t i = 0; i < lletres_.size(); i++) {
|
||||||
|
ordre_explosio_.push_back(i);
|
||||||
|
}
|
||||||
|
std::random_device rd;
|
||||||
|
std::mt19937 g(rd());
|
||||||
|
std::shuffle(ordre_explosio_.begin(), ordre_explosio_.end(), g);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[EscenaLogo] Canvi a estat: " << static_cast<int>(nou_estat)
|
std::cout << "[EscenaLogo] Canvi a estat: " << static_cast<int>(nou_estat)
|
||||||
@@ -198,8 +209,9 @@ void EscenaLogo::actualitzar_explosions(float delta_time) {
|
|||||||
// Comprovar si és el moment d'explotar la següent lletra
|
// Comprovar si és el moment d'explotar la següent lletra
|
||||||
if (temps_des_ultima_explosio_ >= DELAY_ENTRE_EXPLOSIONS) {
|
if (temps_des_ultima_explosio_ >= DELAY_ENTRE_EXPLOSIONS) {
|
||||||
if (lletra_explosio_index_ < lletres_.size()) {
|
if (lletra_explosio_index_ < lletres_.size()) {
|
||||||
// Explotar lletra actual
|
// Explotar lletra actual (en ordre aleatori)
|
||||||
const auto& lletra = lletres_[lletra_explosio_index_];
|
size_t index_actual = ordre_explosio_[lletra_explosio_index_];
|
||||||
|
const auto& lletra = lletres_[index_actual];
|
||||||
|
|
||||||
debris_manager_->explotar(
|
debris_manager_->explotar(
|
||||||
lletra.forma, // Forma a explotar
|
lletra.forma, // Forma a explotar
|
||||||
@@ -335,17 +347,26 @@ void EscenaLogo::dibuixar() {
|
|||||||
|
|
||||||
// EXPLOSION: Dibuixar només lletres que encara no han explotat
|
// EXPLOSION: Dibuixar només lletres que encara no han explotat
|
||||||
if (estat_actual_ == EstatAnimacio::EXPLOSION) {
|
if (estat_actual_ == EstatAnimacio::EXPLOSION) {
|
||||||
for (size_t i = lletra_explosio_index_; i < lletres_.size(); i++) {
|
// Crear conjunt de lletres ja explotades
|
||||||
const auto& lletra = lletres_[i];
|
std::set<size_t> explotades;
|
||||||
|
for (size_t i = 0; i < lletra_explosio_index_; i++) {
|
||||||
|
explotades.insert(ordre_explosio_[i]);
|
||||||
|
}
|
||||||
|
|
||||||
Rendering::render_shape(
|
// Dibuixar només lletres que NO han explotat
|
||||||
sdl_.obte_renderer(),
|
for (size_t i = 0; i < lletres_.size(); i++) {
|
||||||
lletra.forma,
|
if (explotades.find(i) == explotades.end()) {
|
||||||
lletra.posicio,
|
const auto& lletra = lletres_[i];
|
||||||
0.0f,
|
|
||||||
ESCALA_FINAL,
|
Rendering::render_shape(
|
||||||
true,
|
sdl_.obte_renderer(),
|
||||||
1.0f);
|
lletra.forma,
|
||||||
|
lletra.posicio,
|
||||||
|
0.0f,
|
||||||
|
ESCALA_FINAL,
|
||||||
|
true,
|
||||||
|
1.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ class EscenaLogo {
|
|||||||
std::unique_ptr<Effects::DebrisManager> debris_manager_;
|
std::unique_ptr<Effects::DebrisManager> debris_manager_;
|
||||||
|
|
||||||
// Seguiment d'explosions seqüencials
|
// Seguiment d'explosions seqüencials
|
||||||
size_t lletra_explosio_index_; // Índex de la següent lletra a explotar
|
size_t lletra_explosio_index_; // Índex de la següent lletra a explotar
|
||||||
float temps_des_ultima_explosio_; // Temps des de l'última explosió
|
float temps_des_ultima_explosio_; // Temps des de l'última explosió
|
||||||
|
std::vector<size_t> ordre_explosio_; // Ordre aleatori d'índexs de lletres
|
||||||
|
|
||||||
// Estructura per a cada lletra del logo
|
// Estructura per a cada lletra del logo
|
||||||
struct LetraLogo {
|
struct LetraLogo {
|
||||||
@@ -60,15 +61,15 @@ class EscenaLogo {
|
|||||||
static constexpr float DURACIO_ZOOM = 4.0f; // Duració del zoom (segons)
|
static constexpr float DURACIO_ZOOM = 4.0f; // Duració del zoom (segons)
|
||||||
static constexpr float DURACIO_POST_ANIMATION = 3.0f; // Duració POST_ANIMATION (logo complet)
|
static constexpr float DURACIO_POST_ANIMATION = 3.0f; // Duració POST_ANIMATION (logo complet)
|
||||||
static constexpr float DURACIO_POST_EXPLOSION = 3.0f; // Duració POST_EXPLOSION (espera final)
|
static constexpr float DURACIO_POST_EXPLOSION = 3.0f; // Duració POST_EXPLOSION (espera final)
|
||||||
static constexpr float DELAY_ENTRE_EXPLOSIONS = 0.15f; // Temps entre explosions de lletres
|
static constexpr float DELAY_ENTRE_EXPLOSIONS = 0.1f; // Temps entre explosions de lletres
|
||||||
static constexpr float VELOCITAT_EXPLOSIO = 80.0f; // Velocitat base fragments (px/s)
|
static constexpr float VELOCITAT_EXPLOSIO = 240.0f; // Velocitat base fragments (px/s)
|
||||||
static constexpr float ESCALA_INICIAL = 0.1f; // Escala inicial (10%)
|
static constexpr float ESCALA_INICIAL = 0.1f; // Escala inicial (10%)
|
||||||
static constexpr float ESCALA_FINAL = 0.8f; // Escala final (80%)
|
static constexpr float ESCALA_FINAL = 0.8f; // Escala final (80%)
|
||||||
static constexpr float ESPAI_ENTRE_LLETRES = 10.0f; // Espaiat entre lletres
|
static constexpr float ESPAI_ENTRE_LLETRES = 10.0f; // Espaiat entre lletres
|
||||||
|
|
||||||
// Constants d'animació seqüencial
|
// Constants d'animació seqüencial
|
||||||
static constexpr float THRESHOLD_LETRA = 0.6f; // Umbral per activar següent lletra (0.0-1.0)
|
static constexpr float THRESHOLD_LETRA = 0.6f; // Umbral per activar següent lletra (0.0-1.0)
|
||||||
static constexpr float ORIGEN_ZOOM_X = Defaults::Game::WIDTH * 0.5f; // Punt inicial X del zoom
|
static constexpr float ORIGEN_ZOOM_X = Defaults::Game::WIDTH * 0.5f; // Punt inicial X del zoom
|
||||||
static constexpr float ORIGEN_ZOOM_Y = Defaults::Game::HEIGHT * 0.4f; // Punt inicial Y del zoom
|
static constexpr float ORIGEN_ZOOM_Y = Defaults::Game::HEIGHT * 0.4f; // Punt inicial Y del zoom
|
||||||
|
|
||||||
// Mètodes privats
|
// Mètodes privats
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ static void loadWindowConfigFromYaml(const fkyaml::node& yaml) {
|
|||||||
try {
|
try {
|
||||||
auto val = win["zoom_factor"].get_value<float>();
|
auto val = win["zoom_factor"].get_value<float>();
|
||||||
window.zoom_factor = (val >= Defaults::Window::MIN_ZOOM && val <= 10.0f)
|
window.zoom_factor = (val >= Defaults::Window::MIN_ZOOM && val <= 10.0f)
|
||||||
? val : Defaults::Window::BASE_ZOOM;
|
? val
|
||||||
|
: Defaults::Window::BASE_ZOOM;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
window.zoom_factor = Defaults::Window::BASE_ZOOM;
|
window.zoom_factor = Defaults::Window::BASE_ZOOM;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user