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);
|
||||
|
||||
// Round DOWN to nearest 0.1 increment (user preference)
|
||||
max_zoom_ = std::floor(max_zoom_unrounded / Defaults::Window::ZOOM_INCREMENT)
|
||||
* Defaults::Window::ZOOM_INCREMENT;
|
||||
max_zoom_ = std::floor(max_zoom_unrounded / Defaults::Window::ZOOM_INCREMENT) * Defaults::Window::ZOOM_INCREMENT;
|
||||
|
||||
// Safety clamp
|
||||
max_zoom_ = std::max(max_zoom_, Defaults::Window::MIN_ZOOM);
|
||||
@@ -211,8 +210,7 @@ void SDLManager::applyZoom(float new_zoom) {
|
||||
std::min(new_zoom, max_zoom_));
|
||||
|
||||
// Round to nearest 0.1 increment
|
||||
new_zoom = std::round(new_zoom / Defaults::Window::ZOOM_INCREMENT)
|
||||
* Defaults::Window::ZOOM_INCREMENT;
|
||||
new_zoom = std::round(new_zoom / Defaults::Window::ZOOM_INCREMENT) * Defaults::Window::ZOOM_INCREMENT;
|
||||
|
||||
// No change?
|
||||
if (std::abs(new_zoom - zoom_factor_) < 0.01f) {
|
||||
|
||||
@@ -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)
|
||||
inline void obtenir_limits_zona_segurs(float radi, float& min_x, float& max_x,
|
||||
float& min_y, float& max_y) {
|
||||
inline void obtenir_limits_zona_segurs(float radi, float& min_x, float& max_x, float& min_y, float& max_y) {
|
||||
const auto& zona = Defaults::Zones::PLAYAREA;
|
||||
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
|
||||
float min_x, max_x, min_y, max_y;
|
||||
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 ||
|
||||
centre_.y < min_y || centre_.y > max_y) {
|
||||
|
||||
@@ -40,7 +40,10 @@ void Enemic::inicialitzar() {
|
||||
// Calcular rangs segurs amb radi de l'enemic
|
||||
float min_x, max_x, min_y, max_y;
|
||||
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
|
||||
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
|
||||
float min_x, max_x, min_y, max_y;
|
||||
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
|
||||
// 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
|
||||
float min_x, max_x, min_y, max_y;
|
||||
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 <=)
|
||||
if (dy >= min_y && dy <= max_y) {
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
#include <set>
|
||||
|
||||
#include "../../core/audio/audio.hpp"
|
||||
#include "../../core/graphics/shape_loader.hpp"
|
||||
#include "../../core/rendering/shape_renderer.hpp"
|
||||
#include "../../core/system/gestor_escenes.hpp"
|
||||
#include "../../core/system/global_events.hpp"
|
||||
#include "core/audio/audio.hpp"
|
||||
#include "core/graphics/shape_loader.hpp"
|
||||
#include "core/rendering/shape_renderer.hpp"
|
||||
#include "core/system/gestor_escenes.hpp"
|
||||
#include "core/system/global_events.hpp"
|
||||
|
||||
// Helper: calcular el progrés individual d'una lletra
|
||||
// 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) {
|
||||
lletra_explosio_index_ = 0;
|
||||
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)
|
||||
@@ -198,8 +209,9 @@ void EscenaLogo::actualitzar_explosions(float delta_time) {
|
||||
// Comprovar si és el moment d'explotar la següent lletra
|
||||
if (temps_des_ultima_explosio_ >= DELAY_ENTRE_EXPLOSIONS) {
|
||||
if (lletra_explosio_index_ < lletres_.size()) {
|
||||
// Explotar lletra actual
|
||||
const auto& lletra = lletres_[lletra_explosio_index_];
|
||||
// Explotar lletra actual (en ordre aleatori)
|
||||
size_t index_actual = ordre_explosio_[lletra_explosio_index_];
|
||||
const auto& lletra = lletres_[index_actual];
|
||||
|
||||
debris_manager_->explotar(
|
||||
lletra.forma, // Forma a explotar
|
||||
@@ -335,7 +347,15 @@ void EscenaLogo::dibuixar() {
|
||||
|
||||
// EXPLOSION: Dibuixar només lletres que encara no han explotat
|
||||
if (estat_actual_ == EstatAnimacio::EXPLOSION) {
|
||||
for (size_t i = lletra_explosio_index_; i < lletres_.size(); i++) {
|
||||
// Crear conjunt de lletres ja explotades
|
||||
std::set<size_t> explotades;
|
||||
for (size_t i = 0; i < lletra_explosio_index_; i++) {
|
||||
explotades.insert(ordre_explosio_[i]);
|
||||
}
|
||||
|
||||
// Dibuixar només lletres que NO han explotat
|
||||
for (size_t i = 0; i < lletres_.size(); i++) {
|
||||
if (explotades.find(i) == explotades.end()) {
|
||||
const auto& lletra = lletres_[i];
|
||||
|
||||
Rendering::render_shape(
|
||||
@@ -348,6 +368,7 @@ void EscenaLogo::dibuixar() {
|
||||
1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// POST_EXPLOSION: No dibuixar lletres, només debris (a baix)
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class EscenaLogo {
|
||||
// Seguiment d'explosions seqüencials
|
||||
size_t lletra_explosio_index_; // Índex de la següent lletra a explotar
|
||||
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
|
||||
struct LetraLogo {
|
||||
@@ -60,8 +61,8 @@ class EscenaLogo {
|
||||
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_EXPLOSION = 3.0f; // Duració POST_EXPLOSION (espera final)
|
||||
static constexpr float DELAY_ENTRE_EXPLOSIONS = 0.15f; // Temps entre explosions de lletres
|
||||
static constexpr float VELOCITAT_EXPLOSIO = 80.0f; // Velocitat base fragments (px/s)
|
||||
static constexpr float DELAY_ENTRE_EXPLOSIONS = 0.1f; // Temps entre explosions de lletres
|
||||
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_FINAL = 0.8f; // Escala final (80%)
|
||||
static constexpr float ESPAI_ENTRE_LLETRES = 10.0f; // Espaiat entre lletres
|
||||
|
||||
@@ -94,7 +94,8 @@ static void loadWindowConfigFromYaml(const fkyaml::node& yaml) {
|
||||
try {
|
||||
auto val = win["zoom_factor"].get_value<float>();
|
||||
window.zoom_factor = (val >= Defaults::Window::MIN_ZOOM && val <= 10.0f)
|
||||
? val : Defaults::Window::BASE_ZOOM;
|
||||
? val
|
||||
: Defaults::Window::BASE_ZOOM;
|
||||
} catch (...) {
|
||||
window.zoom_factor = Defaults::Window::BASE_ZOOM;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user