millorada la gestio d'escenes i opcions
This commit is contained in:
@@ -13,16 +13,26 @@
|
||||
#include "core/audio/audio.hpp"
|
||||
#include "core/input/mouse.hpp"
|
||||
#include "core/rendering/line_renderer.hpp"
|
||||
#include "core/system/gestor_escenes.hpp"
|
||||
#include "core/system/context_escenes.hpp"
|
||||
#include "core/system/global_events.hpp"
|
||||
#include "game/stage_system/stage_loader.hpp"
|
||||
|
||||
EscenaJoc::EscenaJoc(SDLManager& sdl)
|
||||
// Using declarations per simplificar el codi
|
||||
using GestorEscenes::ContextEscenes;
|
||||
using Escena = ContextEscenes::Escena;
|
||||
using Opcio = ContextEscenes::Opcio;
|
||||
|
||||
EscenaJoc::EscenaJoc(SDLManager& sdl, ContextEscenes& context)
|
||||
: sdl_(sdl),
|
||||
context_(context),
|
||||
debris_manager_(sdl.obte_renderer()),
|
||||
nau_(sdl.obte_renderer()),
|
||||
itocado_(0),
|
||||
text_(sdl.obte_renderer()) {
|
||||
// Consumir opcions (preparació per MODE_DEMO futur)
|
||||
auto opcio = context_.consumir_opcio();
|
||||
(void)opcio; // Suprimir warning de variable no usada
|
||||
|
||||
// Inicialitzar bales amb renderer
|
||||
for (auto& bala : bales_) {
|
||||
bala = Bala(sdl.obte_renderer());
|
||||
@@ -43,7 +53,7 @@ void EscenaJoc::executar() {
|
||||
SDL_Event event;
|
||||
Uint64 last_time = SDL_GetTicks();
|
||||
|
||||
while (GestorEscenes::actual == GestorEscenes::Escena::JOC) {
|
||||
while (GestorEscenes::actual == Escena::JOC) {
|
||||
// Calcular delta_time real
|
||||
Uint64 current_time = SDL_GetTicks();
|
||||
float delta_time = (current_time - last_time) / 1000.0f;
|
||||
@@ -68,7 +78,7 @@ void EscenaJoc::executar() {
|
||||
}
|
||||
|
||||
// Events globals (F1/F2/F3/ESC/QUIT)
|
||||
if (GlobalEvents::handle(event, sdl_)) {
|
||||
if (GlobalEvents::handle(event, sdl_, context_)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -158,8 +168,9 @@ void EscenaJoc::actualitzar(float delta_time) {
|
||||
if (game_over_timer_ <= 0.0f) {
|
||||
// Aturar música de joc abans de tornar al títol
|
||||
Audio::get()->stopMusic();
|
||||
// Auto-transition to title screen
|
||||
GestorEscenes::actual = GestorEscenes::Escena::TITOL;
|
||||
// Transició a pantalla de títol
|
||||
context_.canviar_escena(Escena::TITOL);
|
||||
GestorEscenes::actual = Escena::TITOL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user