- Actualitzem tots els gamestate per a usar els nous mòduls.
This commit is contained in:
@@ -2,14 +2,7 @@
|
||||
#include "jgame.h"
|
||||
#include <string>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#define DIAPO_ESPERAR 0
|
||||
#define DIAPO_FADEIN 1
|
||||
#define DIAPO_SHOW 2
|
||||
#define DIAPO_PRINT 3
|
||||
#define DIAPO_MUSICA 4
|
||||
#define DIAPO_FADEOUT 5
|
||||
#define DIAPO_FADEMUSIC 6
|
||||
#include "aux_font.h"
|
||||
|
||||
namespace gamestate
|
||||
{
|
||||
@@ -19,17 +12,16 @@ namespace gamestate
|
||||
uint32_t wait_until = 0;
|
||||
|
||||
void drawPic(std::string filename);
|
||||
void drawText(const int x, const int y, const uint8_t color, std::string text);
|
||||
bool loop();
|
||||
|
||||
|
||||
void init()
|
||||
{
|
||||
draw::setTrans(255);
|
||||
const int fase = game::getConfig("fase");
|
||||
font::selectFont(font::type::colored);
|
||||
|
||||
std::string filename;
|
||||
|
||||
switch (fase)
|
||||
switch (game::getConfig("fase"))
|
||||
{
|
||||
case -1: filename = "seqIN.txt"; break;
|
||||
case 0: filename = "seq00.txt"; break;
|
||||
@@ -39,11 +31,10 @@ namespace gamestate
|
||||
case 20: filename = "seq20.txt"; break;
|
||||
case 25: filename = "seq25.txt"; break;
|
||||
case 30: filename = "seq30.txt"; break;
|
||||
default: gamestate::prefase::init();
|
||||
default: gamestate::prefase::init(); return; break;
|
||||
}
|
||||
|
||||
int filesize;
|
||||
sequence_file = file::getFilePointer(filename, &filesize);
|
||||
sequence_file = file::getFilePointer(filename);
|
||||
|
||||
game::setState(&gamestate::sequence::loop);
|
||||
}
|
||||
@@ -54,6 +45,7 @@ namespace gamestate
|
||||
draw::render();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( (wait_until > 0) && (SDL_GetTicks() < wait_until) )
|
||||
{
|
||||
if (input::anyKeyPressed() || input::mouseBtn(1)) {
|
||||
@@ -87,30 +79,26 @@ namespace gamestate
|
||||
std::string command(text);
|
||||
|
||||
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();
|
||||
|
||||
} 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);
|
||||
font::setColor(val);
|
||||
font::print(x, y, text);
|
||||
|
||||
} else if (command=="PLAYMUSIC") {
|
||||
//int res =
|
||||
fscanf(sequence_file, " '%[^']'", text);
|
||||
audio::loadMusic(text);
|
||||
audio::playMusic();
|
||||
@@ -135,27 +123,5 @@ namespace gamestate
|
||||
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);
|
||||
switch (color) {
|
||||
case 0: draw::setPaletteEntry(63, 255, 255, 255); break;
|
||||
case 1: draw::setPaletteEntry(63, 255, 0, 0); break;
|
||||
case 2: draw::setPaletteEntry(63, 0, 255, 0); break;
|
||||
case 3: draw::setPaletteEntry(63, 0, 0, 255); break;
|
||||
}
|
||||
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::freeSurface(pic);
|
||||
draw::render();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user