- [NEW] Mogut tot el codi de lloc

This commit is contained in:
2025-07-02 13:36:48 +02:00
parent 4670b52378
commit 81c5011bc7
34 changed files with 52 additions and 52 deletions

View File

@@ -0,0 +1,77 @@
#include "gamestates.h"
#include "../japi/game.h"
#include <string>
#include "../aux/font.h"
#include "../entities/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::draw(fondo);
draw::setSource(cursor);
draw::draw(input::mouseX(), input::mouseY());
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;
}
}
}