- gamestate_sequence ja funciona
This commit is contained in:
@@ -30,7 +30,7 @@ namespace gamestate
|
||||
|
||||
uint16_t getWord()
|
||||
{
|
||||
return (getByte() << 8) + getByte();
|
||||
return getByte() + (getByte() << 8);
|
||||
}
|
||||
|
||||
std::string getString()
|
||||
@@ -46,18 +46,39 @@ namespace gamestate
|
||||
{
|
||||
draw::surface *pic = draw::loadSurface(filename);
|
||||
draw::setSource(pic);
|
||||
draw::loadPalette(filename);
|
||||
draw::draw(0, 0, 320, 200, 0, 0);
|
||||
draw::freeSurface(pic);
|
||||
}
|
||||
|
||||
void drawText(const int x, const int y, const uint8_t color, std::string text)
|
||||
{
|
||||
|
||||
draw::surface *pic = draw::loadSurface("fuente2.gif");
|
||||
draw::setSource(pic);
|
||||
draw::setTrans(0);
|
||||
draw::setPaletteEntry(64, 255, 255, 255);
|
||||
draw::setPaletteEntry(65, 255, 0, 0);
|
||||
draw::setPaletteEntry(66, 0, 255, 0);
|
||||
draw::setPaletteEntry(67, 0, 0, 255);
|
||||
draw::setPaletteEntry(68, 0, 0, 0);
|
||||
draw::swapcol(1, color+64);
|
||||
draw::swapcol(2, 68);
|
||||
const int len = text.length();
|
||||
for (int i=0;i<len;++i)
|
||||
{
|
||||
char chr = text[i];
|
||||
draw::draw(x+i*7, y, 6, 6, (int(chr)-32)*7, 0);
|
||||
}
|
||||
draw::setTrans(255);
|
||||
draw::restorecol(1);
|
||||
draw::restorecol(2);
|
||||
draw::freeSurface(pic);
|
||||
draw::render();
|
||||
}
|
||||
|
||||
bool loop()
|
||||
{
|
||||
if (wait_until>0 && SDL_GetTicks() < wait_until)
|
||||
if ( (wait_until > 0) && (SDL_GetTicks() < wait_until) )
|
||||
{
|
||||
if (input::anyKey() || input::mouseBtn(1))
|
||||
{
|
||||
@@ -65,44 +86,75 @@ namespace gamestate
|
||||
}
|
||||
else
|
||||
{
|
||||
draw::render();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const char tipo_diapositiva = *(sequence_file++);
|
||||
switch ( tipo_diapositiva )
|
||||
{
|
||||
case DIAPO_ESPERAR:
|
||||
wait_until = SDL_GetTicks() + getWord();
|
||||
{
|
||||
const uint16_t time = getWord();
|
||||
wait_until = SDL_GetTicks() + time;
|
||||
printf("- Esperar(%i)\n", time);
|
||||
break;
|
||||
}
|
||||
case DIAPO_FADEIN:
|
||||
drawPic(getString());
|
||||
{
|
||||
std::string filename = getString();
|
||||
drawPic(filename);
|
||||
draw::fadein();
|
||||
wait_until = SDL_GetTicks() + 250;
|
||||
draw::render();
|
||||
wait_until = SDL_GetTicks() + 500;
|
||||
printf("- FadeIn('%s')\n", filename.c_str());
|
||||
break;
|
||||
}
|
||||
case DIAPO_SHOW:
|
||||
drawPic(getString());
|
||||
{
|
||||
std::string filename = getString();
|
||||
drawPic(filename);
|
||||
draw::render();
|
||||
printf("- Show('%s')\n", filename.c_str());
|
||||
break;
|
||||
}
|
||||
case DIAPO_PRINT:
|
||||
drawText(getWord(), getWord(), getByte(), getString());
|
||||
{
|
||||
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:
|
||||
audio::playMusic(audio::loadMusic(getString()));
|
||||
{
|
||||
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() + 250;
|
||||
wait_until = SDL_GetTicks() + 500;
|
||||
printf("- FadeOut()\n");
|
||||
break;
|
||||
}
|
||||
case DIAPO_FADEMUSIC:
|
||||
draw::fadeout();
|
||||
audio::fadeoutMusic();
|
||||
wait_until = SDL_GetTicks() + 250;
|
||||
wait_until = SDL_GetTicks() + 500;
|
||||
printf("- FadeOutMusic()\n");
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
draw::setTrans(255);
|
||||
const int fase = game::getConfig("fase");
|
||||
std::string filename;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user