- Ara gamestate_sequence llig les sequències en format text.
- Llevades totes les sequències en format binari.
This commit is contained in:
BIN
data/seq00.seq
BIN
data/seq00.seq
Binary file not shown.
BIN
data/seq05.seq
BIN
data/seq05.seq
Binary file not shown.
BIN
data/seq10.seq
BIN
data/seq10.seq
Binary file not shown.
BIN
data/seq15.seq
BIN
data/seq15.seq
Binary file not shown.
BIN
data/seq20.seq
BIN
data/seq20.seq
Binary file not shown.
BIN
data/seq25.seq
BIN
data/seq25.seq
Binary file not shown.
BIN
data/seq30.seq
BIN
data/seq30.seq
Binary file not shown.
BIN
data/seqIN.seq
BIN
data/seqIN.seq
Binary file not shown.
@@ -19,30 +19,9 @@ namespace gamestate
|
|||||||
{
|
{
|
||||||
namespace sequence
|
namespace sequence
|
||||||
{
|
{
|
||||||
int num_diapositives = 0;
|
FILE *sequence_file = nullptr;
|
||||||
char *sequence_file = nullptr;
|
|
||||||
char *sfpointer = nullptr;
|
|
||||||
uint32_t wait_until = 0;
|
uint32_t wait_until = 0;
|
||||||
|
|
||||||
uint8_t getByte()
|
|
||||||
{
|
|
||||||
return *(sequence_file++);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getWord()
|
|
||||||
{
|
|
||||||
return getByte() + (getByte() << 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getString()
|
|
||||||
{
|
|
||||||
uint8_t tamanyCadena = getByte();
|
|
||||||
char filename[256];
|
|
||||||
for (int i=0; i<tamanyCadena; i++) filename[i] = getByte();
|
|
||||||
filename[tamanyCadena] = '\0';
|
|
||||||
return std::string(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
void drawPic(std::string filename)
|
void drawPic(std::string filename)
|
||||||
{
|
{
|
||||||
draw::surface *pic = draw::loadSurface(filename, true);
|
draw::surface *pic = draw::loadSurface(filename, true);
|
||||||
@@ -82,13 +61,15 @@ namespace gamestate
|
|||||||
{
|
{
|
||||||
if (!draw::isfading() && (input::anyKeyPressed() || input::mouseBtn(1))) {
|
if (!draw::isfading() && (input::anyKeyPressed() || input::mouseBtn(1))) {
|
||||||
wait_until=0;
|
wait_until=0;
|
||||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) num_diapositives=0;
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) fseek(sequence_file, 0, SEEK_END);
|
||||||
} else {
|
} else {
|
||||||
draw::render();
|
draw::render();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (num_diapositives==0) {
|
if (feof(sequence_file))
|
||||||
|
{
|
||||||
|
fclose(sequence_file);
|
||||||
const int fase = game::getConfig("fase");
|
const int fase = game::getConfig("fase");
|
||||||
if ( fase == -1 || fase == 30) {
|
if ( fase == -1 || fase == 30) {
|
||||||
gamestate::menu::init();
|
gamestate::menu::init();
|
||||||
@@ -96,70 +77,52 @@ namespace gamestate
|
|||||||
gamestate::prefase::init();
|
gamestate::prefase::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
free(sfpointer);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
const char tipo_diapositiva = *(sequence_file++);
|
} else {
|
||||||
switch ( tipo_diapositiva )
|
|
||||||
{
|
char text[100];
|
||||||
case DIAPO_ESPERAR:
|
int x, y, val;
|
||||||
|
int res = fscanf(sequence_file, "%s", text);
|
||||||
|
if (res==1)
|
||||||
{
|
{
|
||||||
const uint16_t time = getWord();
|
std::string command(text);
|
||||||
wait_until = SDL_GetTicks() + time;
|
|
||||||
printf("- Esperar(%i)\n", time);
|
if (command=="ESPERAR") {
|
||||||
break;
|
int res = fscanf(sequence_file, "%i", &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);
|
||||||
|
drawPic(text);
|
||||||
|
draw::render();
|
||||||
|
|
||||||
|
} else if (command=="PRINT") {
|
||||||
|
int res = fscanf(sequence_file, " %i %i %i '%[^']'", &x, &y, &val, text);
|
||||||
|
drawText(x, y, val, text);
|
||||||
|
|
||||||
|
} else if (command=="PLAYMUSIC") {
|
||||||
|
int res = fscanf(sequence_file, " '%[^']'", text);
|
||||||
|
audio::playMusic(audio::loadMusic(text));
|
||||||
|
|
||||||
|
} else if (command=="FADEOUT") {
|
||||||
|
draw::fadeout();
|
||||||
|
wait_until = SDL_GetTicks() + 500;
|
||||||
|
|
||||||
|
} else if (command=="FADEOUTMUSIC") {
|
||||||
|
draw::fadeout();
|
||||||
|
audio::fadeoutMusic();
|
||||||
|
wait_until = SDL_GetTicks() + 500;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case DIAPO_FADEIN:
|
|
||||||
{
|
|
||||||
std::string filename = getString();
|
|
||||||
drawPic(filename);
|
|
||||||
draw::fadein();
|
|
||||||
draw::render();
|
|
||||||
wait_until = SDL_GetTicks() + 500;
|
|
||||||
printf("- FadeIn('%s')\n", filename.c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DIAPO_SHOW:
|
|
||||||
{
|
|
||||||
std::string filename = getString();
|
|
||||||
drawPic(filename);
|
|
||||||
draw::render();
|
|
||||||
printf("- Show('%s')\n", filename.c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DIAPO_PRINT:
|
|
||||||
{
|
|
||||||
const uint16_t x = getWord();
|
|
||||||
const uint16_t y = getWord();
|
|
||||||
const uint8_t col = getByte();
|
|
||||||
std::string text = getString();
|
|
||||||
drawText(x, y, col, text);
|
|
||||||
printf("- Print(%i, %i, %i, '%s')\n", x, y, col, text.c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DIAPO_MUSICA:
|
|
||||||
{
|
|
||||||
std::string filename = getString();
|
|
||||||
audio::playMusic(audio::loadMusic(filename));
|
|
||||||
printf("- PlayMusic('%s')\n", filename.c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DIAPO_FADEOUT:
|
|
||||||
{
|
|
||||||
draw::fadeout();
|
|
||||||
wait_until = SDL_GetTicks() + 500;
|
|
||||||
printf("- FadeOut()\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DIAPO_FADEMUSIC:
|
|
||||||
draw::fadeout();
|
|
||||||
audio::fadeoutMusic();
|
|
||||||
wait_until = SDL_GetTicks() + 500;
|
|
||||||
printf("- FadeOutMusic()\n");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
num_diapositives--;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,20 +134,18 @@ namespace gamestate
|
|||||||
|
|
||||||
switch (fase)
|
switch (fase)
|
||||||
{
|
{
|
||||||
case -1: filename = "seqIN.seq"; break;
|
case -1: filename = "seqIN.txt"; break;
|
||||||
case 0: filename = "seq00.seq"; break;
|
case 0: filename = "seq00.txt"; break;
|
||||||
case 5: filename = "seq05.seq"; break;
|
case 5: filename = "seq05.txt"; break;
|
||||||
case 10: filename = "seq10.seq"; break;
|
case 10: filename = "seq10.txt"; break;
|
||||||
case 15: filename = "seq15.seq"; break;
|
case 15: filename = "seq15.txt"; break;
|
||||||
case 20: filename = "seq20.seq"; break;
|
case 20: filename = "seq20.txt"; break;
|
||||||
case 25: filename = "seq25.seq"; break;
|
case 25: filename = "seq25.txt"; break;
|
||||||
case 30: filename = "seq30.seq"; break;
|
case 30: filename = "seq30.txt"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int filesize;
|
int filesize;
|
||||||
sequence_file = file::getFileBuffer(filename, filesize);
|
sequence_file = file::getFilePointer(filename, filesize);
|
||||||
sfpointer = sequence_file;
|
|
||||||
num_diapositives = *(sequence_file++);
|
|
||||||
|
|
||||||
game::setState(&gamestate::sequence::loop);
|
game::setState(&gamestate::sequence::loop);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user