- gamestate_sequence ja funciona
This commit is contained in:
@@ -30,7 +30,7 @@ namespace gamestate
|
|||||||
|
|
||||||
uint16_t getWord()
|
uint16_t getWord()
|
||||||
{
|
{
|
||||||
return (getByte() << 8) + getByte();
|
return getByte() + (getByte() << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getString()
|
std::string getString()
|
||||||
@@ -46,18 +46,39 @@ namespace gamestate
|
|||||||
{
|
{
|
||||||
draw::surface *pic = draw::loadSurface(filename);
|
draw::surface *pic = draw::loadSurface(filename);
|
||||||
draw::setSource(pic);
|
draw::setSource(pic);
|
||||||
|
draw::loadPalette(filename);
|
||||||
draw::draw(0, 0, 320, 200, 0, 0);
|
draw::draw(0, 0, 320, 200, 0, 0);
|
||||||
draw::freeSurface(pic);
|
draw::freeSurface(pic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawText(const int x, const int y, const uint8_t color, std::string text)
|
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()
|
bool loop()
|
||||||
{
|
{
|
||||||
if (wait_until>0 && SDL_GetTicks() < wait_until)
|
if ( (wait_until > 0) && (SDL_GetTicks() < wait_until) )
|
||||||
{
|
{
|
||||||
if (input::anyKey() || input::mouseBtn(1))
|
if (input::anyKey() || input::mouseBtn(1))
|
||||||
{
|
{
|
||||||
@@ -65,44 +86,75 @@ namespace gamestate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
draw::render();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char tipo_diapositiva = *(sequence_file++);
|
const char tipo_diapositiva = *(sequence_file++);
|
||||||
switch ( tipo_diapositiva )
|
switch ( tipo_diapositiva )
|
||||||
{
|
{
|
||||||
case DIAPO_ESPERAR:
|
case DIAPO_ESPERAR:
|
||||||
wait_until = SDL_GetTicks() + getWord();
|
{
|
||||||
|
const uint16_t time = getWord();
|
||||||
|
wait_until = SDL_GetTicks() + time;
|
||||||
|
printf("- Esperar(%i)\n", time);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DIAPO_FADEIN:
|
case DIAPO_FADEIN:
|
||||||
drawPic(getString());
|
{
|
||||||
|
std::string filename = getString();
|
||||||
|
drawPic(filename);
|
||||||
draw::fadein();
|
draw::fadein();
|
||||||
wait_until = SDL_GetTicks() + 250;
|
draw::render();
|
||||||
|
wait_until = SDL_GetTicks() + 500;
|
||||||
|
printf("- FadeIn('%s')\n", filename.c_str());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DIAPO_SHOW:
|
case DIAPO_SHOW:
|
||||||
drawPic(getString());
|
{
|
||||||
|
std::string filename = getString();
|
||||||
|
drawPic(filename);
|
||||||
|
draw::render();
|
||||||
|
printf("- Show('%s')\n", filename.c_str());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DIAPO_PRINT:
|
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;
|
break;
|
||||||
|
}
|
||||||
case DIAPO_MUSICA:
|
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;
|
break;
|
||||||
|
}
|
||||||
case DIAPO_FADEOUT:
|
case DIAPO_FADEOUT:
|
||||||
|
{
|
||||||
draw::fadeout();
|
draw::fadeout();
|
||||||
wait_until = SDL_GetTicks() + 250;
|
wait_until = SDL_GetTicks() + 500;
|
||||||
|
printf("- FadeOut()\n");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DIAPO_FADEMUSIC:
|
case DIAPO_FADEMUSIC:
|
||||||
draw::fadeout();
|
draw::fadeout();
|
||||||
audio::fadeoutMusic();
|
audio::fadeoutMusic();
|
||||||
wait_until = SDL_GetTicks() + 250;
|
wait_until = SDL_GetTicks() + 500;
|
||||||
|
printf("- FadeOutMusic()\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
|
draw::setTrans(255);
|
||||||
const int fase = game::getConfig("fase");
|
const int fase = game::getConfig("fase");
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include "jinput.h"
|
#include "jinput.h"
|
||||||
#include "jaudio.h"
|
#include "jaudio.h"
|
||||||
|
|
||||||
|
#include "gamestate_sequence.h"
|
||||||
|
|
||||||
void game::init()
|
void game::init()
|
||||||
{
|
{
|
||||||
draw::init("Arounders", 320, 200, 3);
|
draw::init("Arounders", 320, 200, 3);
|
||||||
@@ -12,5 +14,14 @@ void game::init()
|
|||||||
game::setUpdateTicks(16);
|
game::setUpdateTicks(16);
|
||||||
game::setConfig("fase", -1);
|
game::setConfig("fase", -1);
|
||||||
|
|
||||||
game::setState(nullptr);
|
gamestate::sequence::init();
|
||||||
|
|
||||||
|
/*
|
||||||
|
draw::surface *pic = draw::loadSurface("sprites.gif");
|
||||||
|
draw::setSource(pic);
|
||||||
|
draw::loadPalette("sprites.gif");
|
||||||
|
draw::draw(0, 0, 320, 200, 0, 0);
|
||||||
|
draw::freeSurface(pic);
|
||||||
|
draw::render();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user