- creat gamestate_menu

This commit is contained in:
2023-10-12 17:08:59 +02:00
parent 9f623b249f
commit 183c095f6d
3 changed files with 93 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
#include "gamestate_sequence.h"
#include "gamestates.h"
#include "jgame.h"
#include "jfile.h"
#include "jinput.h"
@@ -20,7 +20,8 @@ namespace gamestate
namespace sequence
{
int num_diapositives = 0;
const char *sequence_file = nullptr;
char *sequence_file = nullptr;
char *sfpointer = nullptr;
uint32_t wait_until = 0;
uint8_t getByte()
@@ -80,16 +81,20 @@ namespace gamestate
{
if ( (wait_until > 0) && (SDL_GetTicks() < wait_until) )
{
if (input::anyKey() || input::mouseBtn(1))
{
if (!draw::isfading() && (input::anyKeyPressed() || input::mouseBtn(1))) {
wait_until=0;
}
else
{
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) num_diapositives=0;
} else {
draw::render();
return true;
}
}
if (num_diapositives==0) {
gamestate::menu::init();
free(sfpointer);
return true;
}
const char tipo_diapositiva = *(sequence_file++);
switch ( tipo_diapositiva )
{
@@ -149,6 +154,7 @@ namespace gamestate
printf("- FadeOutMusic()\n");
break;
}
num_diapositives--;
return true;
}
@@ -172,6 +178,7 @@ namespace gamestate
int filesize;
sequence_file = file::getFileBuffer(filename, filesize);
sfpointer = sequence_file;
num_diapositives = *(sequence_file++);
game::setState(&gamestate::sequence::loop);