From ec911979fb38d5498caa1a869da25375ebc09e54 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 2 Dec 2025 14:01:53 +0100 Subject: [PATCH] afegit so al LOGO --- Makefile | 2 ++ data/sounds/logo.wav | Bin 0 -> 3281 bytes source/game/escenes/escena_logo.cpp | 24 +++++++++++++++++++++++- source/game/escenes/escena_logo.hpp | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 data/sounds/logo.wav diff --git a/Makefile b/Makefile index 32bcd81..6355d8c 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,8 @@ APP_SOURCES := \ source/main.cpp \ source/core/system/director.cpp \ source/core/system/global_events.cpp \ + source/core/audio/audio.cpp \ + source/core/audio/audio_cache.cpp \ source/core/rendering/sdl_manager.cpp \ source/core/rendering/line_renderer.cpp \ source/core/rendering/color_oscillator.cpp \ diff --git a/data/sounds/logo.wav b/data/sounds/logo.wav new file mode 100644 index 0000000000000000000000000000000000000000..8e5d880189fd20a4b5186c6a2f5801aff30b7cb6 GIT binary patch literal 3281 zcmeH}SyxhF6o!v?U3Ae;=${w~Bq}N*qM;^f+GK-SN;#%bq9P)opol{_D>w_tD2h{> z_J`X0OdJGTtp>VbvCbW9J?H)Q^X~5yiG;$Vn*<@}l?ZC<8*kqt2qFW1{3U{XGKd>Q zjj~bcfd54IBjI4c=k@GtZLY7moXd*~bF+>w(~}e9wo$8P*lZdy3=Zh}d$m2EKdHOB zK6bRXwYGeC-`w=>ZR4AU*RNi_sDJ+K>66EGwU275A1bRJR8~}!EAE$-%1cUQ#nPf8 zNnt^LzBn&8H%FA6eNQM5@Uyb+@_2VLGta-C9337+!l8g~*R!*|xv{qDTwYq3pPfOz z-8N>mjF?SE!=PT*-`5L#4e&cVNWQAM=^8$~0Lh0J0KOFY1vFm-e4&8P2Y&F|+3Cp< zncna7x-tE#YlTif#iln78T52|O)NdYuTNi2rG9#g{$42P z-}Sn;w>H*SohwU=^K&zf>8T0(_}HjrWY}aJ8q^O!axElRcSG{_HaK}2e)Z(3qenI# zy{s7Fg$U0BxCoNN(L-|EWn6G_?5PUg3v3v96h=-dw@oR>j(i+P&MMc(DA!3Tr~1jE z)5?(}Pf!kmXQ?hP5_JRJS@xgmCXcZh-B5Qt^t$iJhJi=+LIMA-$4#lu8MqAxPN|Lq zN7dD+dOKDP2cEQQ*tKM;(*q~jGGt$o4Qj?=CzFk2$7D;W`7g=_Y!p2jC%TJePon5n zMsyvB-ouLC%8K3)w_=zb1G&i^!x5cs87+F~0z^NChVO-gRKuZUoQBhEGu3d0-GwD< zZDC4=!RhtJ*>B|vYQH5m9N8e7GrnXg-7Z*gEZP6q>rikk85W$`>ExZlmh86+PK(Yd z8TU>}VZoE$C+UK7Z?bg3|LNyLy5Q_`*}xB0cDekW8$4Zb?&o64Z*XyeL@JY)DJrX~ O$Lv #include +#include "../../core/audio/audio.hpp" #include "../../core/graphics/shape_loader.hpp" #include "../../core/rendering/shape_renderer.hpp" #include "../../core/system/gestor_escenes.hpp" @@ -42,6 +43,7 @@ EscenaLogo::EscenaLogo(SDLManager& sdl) lletra_explosio_index_(0), temps_des_ultima_explosio_(0.0f) { std::cout << "Escena Logo: Inicialitzant...\n"; + so_reproduit_.fill(false); // Inicialitzar seguiment de sons inicialitzar_lletres(); } @@ -229,11 +231,31 @@ void EscenaLogo::actualitzar(float delta_time) { } break; - case EstatAnimacio::ANIMATION: + case EstatAnimacio::ANIMATION: { + // Reproduir so per cada lletra quan comença a aparèixer + float global_progress = std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0f); + + for (size_t i = 0; i < lletres_.size() && i < so_reproduit_.size(); i++) { + if (!so_reproduit_[i]) { + float letra_progress = calcular_progress_letra( + i, + lletres_.size(), + global_progress, + THRESHOLD_LETRA); + + // Reproduir so quan la lletra comença a aparèixer (progress > 0) + if (letra_progress > 0.0f) { + Audio::get()->playSound("logo.wav", Audio::Group::INTERFACE); + so_reproduit_[i] = true; + } + } + } + if (totes_lletres_completes()) { canviar_estat(EstatAnimacio::POST_ANIMATION); } break; + } case EstatAnimacio::POST_ANIMATION: if (temps_estat_actual_ >= DURACIO_POST_ANIMATION) { diff --git a/source/game/escenes/escena_logo.hpp b/source/game/escenes/escena_logo.hpp index 92768e8..21c0668 100644 --- a/source/game/escenes/escena_logo.hpp +++ b/source/game/escenes/escena_logo.hpp @@ -52,6 +52,9 @@ class EscenaLogo { std::vector lletres_; // 9 lletres: J-A-I-L-G-A-M-E-S + // Seguiment de sons de lletres (evitar reproduccions repetides) + std::array so_reproduit_; // Track si cada lletra ja ha reproduit el so + // Constants d'animació static constexpr float DURACIO_PRE = 1.5f; // Duració PRE_ANIMATION (pantalla negra) static constexpr float DURACIO_ZOOM = 4.0f; // Duració del zoom (segons)