Files
arounders/source/gamestate_prefase.cpp

81 lines
2.0 KiB
C++

#include "gamestates.h"
#include "jgame.h"
#include <string>
#include "aux_font.h"
#include "proc_mapa.h"
namespace gamestate
{
namespace prefase
{
// Variables del gamestate
draw::surface *fondo = nullptr;
draw::surface *cursor = nullptr;
// Mètodes del gamestate
bool loop();
void init()
{
// Carrega el gif del fondo
fondo = draw::loadSurface("prefase.gif", true);
cursor = draw::loadSurface("cursor.gif");
// Carrega el mapa
mapa::carregar();
// Pinta el text en el fondo
draw::setDestination(fondo);
font::selectFont(font::type::normal);
font::print(130, 60, "NIVELL");
font::print(179, 60, game::getConfig("fase")+1);
font::print(80, 100, mapa::arounders::totals);
font::print(101, 100, "AROUNDERS DISPONIBLES");
font::print(80, 110, mapa::arounders::necessaris);
font::print(101, 110, "AROUNDERS NECESSARIS");
draw::setDestination(nullptr);
// Comencem el bucle
draw::fadein();
game::setState(gamestate::prefase::loop);
}
bool loop()
{
static bool salir = false;
draw::setTrans(255);
draw::setSource(fondo);
draw::draw(0, 0, 320, 200, 0, 0);
draw::setTrans(0);
draw::setSource(cursor);
draw::draw(input::mouseX(), input::mouseY(), cursor->w, cursor->h, 0, 0);
draw::render();
if (draw::isfading()) return true;
if (salir)
{
salir = false;
gamestate::play::init();
return true;
}
if (input::anyKeyPressed() || input::mouseBtn(1))
{
draw::fadeout();
salir = true;
return true;
}
return true;
}
}
}