From ece24d4562a7f1c9d900157e86be46536ecd8be2 Mon Sep 17 00:00:00 2001 From: JailDoctor Date: Fri, 13 Oct 2023 14:53:50 +0200 Subject: [PATCH] =?UTF-8?q?-=20Ara=20gestionem=20la=20finalitzaci=C3=B3=20?= =?UTF-8?q?dels=20fades=20de=20altra=20forma=20m=C3=A9s=20segura.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/gamestate_sequence.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/gamestate_sequence.cpp b/source/gamestate_sequence.cpp index b7cb912..3f172eb 100644 --- a/source/gamestate_sequence.cpp +++ b/source/gamestate_sequence.cpp @@ -57,9 +57,13 @@ namespace gamestate bool loop() { + if (draw::isfading()) { + draw::render(); + return true; + } if ( (wait_until > 0) && (SDL_GetTicks() < wait_until) ) { - if (!draw::isfading() && (input::anyKeyPressed() || input::mouseBtn(1))) { + if (input::anyKeyPressed() || input::mouseBtn(1)) { wait_until=0; if (input::keyPressed(SDL_SCANCODE_ESCAPE)) fseek(sequence_file, 0, SEEK_END); } else { @@ -67,6 +71,7 @@ namespace gamestate return true; } } + if (feof(sequence_file)) { fclose(sequence_file); @@ -90,14 +95,13 @@ namespace gamestate if (command=="ESPERAR") { int res = fscanf(sequence_file, "%i", &val); + printf("ESPERAR %i\n", val); wait_until = SDL_GetTicks() + val; } else if (command=="FADEIN") { int res = fscanf(sequence_file, " '%[^']'", text); drawPic(text); draw::fadein(); - draw::render(); - wait_until = SDL_GetTicks() + 500; } else if (command=="SHOW") { int res = fscanf(sequence_file, " '%[^']'", text); @@ -114,12 +118,10 @@ namespace gamestate } else if (command=="FADEOUT") { draw::fadeout(); - wait_until = SDL_GetTicks() + 500; } else if (command=="FADEOUTMUSIC") { draw::fadeout(); audio::fadeoutMusic(); - wait_until = SDL_GetTicks() + 500; } } }