- [NEW] Ara usa JailAudio - [NEW] Usant última versió de Respak - [NEW] Afegit lagueirtofile
119 lines
3.0 KiB
C++
119 lines
3.0 KiB
C++
#include "gamestates.h"
|
|
#include "jgame.h"
|
|
#include <string>
|
|
#include "aux_font.h"
|
|
|
|
namespace gamestate
|
|
{
|
|
namespace postfase
|
|
{
|
|
namespace state
|
|
{
|
|
const int initial = 0;
|
|
const int victoria = 1;
|
|
const int password = 2;
|
|
}
|
|
|
|
// Variables del gamestate
|
|
static int sub_state = postfase::state::initial;
|
|
|
|
void initVictoria();
|
|
void initPassword();
|
|
bool loop();
|
|
std::string getPassword();
|
|
|
|
|
|
void init()
|
|
{
|
|
sub_state = postfase::state::initial;
|
|
|
|
if (game::getConfig("fase") == 30) {
|
|
gamestate::sequence::init();
|
|
return;
|
|
} else {
|
|
JA_LoadAndPlayMusic("mus3.ogg");
|
|
}
|
|
|
|
if (game::getConfig("fase") % 5 == 0) {
|
|
gamestate::postfase::initVictoria();
|
|
} else {
|
|
gamestate::postfase::initPassword();
|
|
}
|
|
}
|
|
|
|
void initVictoria()
|
|
{
|
|
sub_state = postfase::state::victoria;
|
|
|
|
char filename[12] = "final00.GIF";
|
|
filename[6]= 48 + (game::getConfig("fase") / 5);
|
|
|
|
draw::surface *fondo = draw::loadSurface(filename, true);
|
|
draw::draw(fondo);
|
|
draw::freeSurface(fondo);
|
|
|
|
draw::fadein();
|
|
game::setState(gamestate::postfase::loop);
|
|
}
|
|
|
|
void initPassword()
|
|
{
|
|
sub_state = postfase::state::password;
|
|
std::string password = getPassword();
|
|
|
|
draw::surface *fondo = draw::loadSurface("postfase.gif", true);
|
|
draw::draw(fondo);
|
|
draw::freeSurface(fondo);
|
|
|
|
font::selectFont(font::type::colored);
|
|
font::setColor(font::color::red);
|
|
font::print(175, 166, password);
|
|
|
|
draw::fadein();
|
|
game::setState(gamestate::postfase::loop);
|
|
}
|
|
|
|
bool loop()
|
|
{
|
|
static bool salir = false;
|
|
|
|
draw::render();
|
|
|
|
if (draw::isfading()) return true;
|
|
|
|
if (salir)
|
|
{
|
|
salir = false;
|
|
if (sub_state == postfase::state::victoria) {
|
|
gamestate::postfase::initPassword();
|
|
} else {
|
|
gamestate::sequence::init();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
if (input::anyKeyPressed() || input::mouseBtn(1))
|
|
{
|
|
draw::fadeout();
|
|
salir = true;
|
|
return true;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
std::string getPassword()
|
|
{
|
|
int size;
|
|
char *buffer = file_getfilebuffer("offsets.bal", size);
|
|
|
|
int punter = (game::getConfig("fase")-1)*10;
|
|
char passFile[11];
|
|
for (int i=0;i<10;i++) passFile[i] = uint8_t(buffer[punter++]) - (101+i);
|
|
passFile[10] = 0;
|
|
free(buffer);
|
|
|
|
return passFile;
|
|
}
|
|
|
|
}
|
|
} |