- Reestructurat el codi dels gamestates per a que siga mes llegible
This commit is contained in:
@@ -10,13 +10,65 @@ namespace gamestate
|
||||
{
|
||||
namespace prefase
|
||||
{
|
||||
// Variables del gamestate
|
||||
draw::surface *fondo = nullptr;
|
||||
draw::surface *cursor = nullptr;
|
||||
draw::surface *font = nullptr;
|
||||
|
||||
uint8_t num_arounders = 0;
|
||||
uint8_t arounders_necessaris = 0;
|
||||
uint8_t fase = 0;
|
||||
|
||||
// Mètodes del gamestate
|
||||
void carregarMapa();
|
||||
std::string formatejar(const int numero);
|
||||
void drawText(const int x, const int y, std::string text);
|
||||
bool loop();
|
||||
|
||||
|
||||
void init()
|
||||
{
|
||||
fondo = draw::loadSurface("prefase.gif", true);
|
||||
cursor = draw::loadSurface("cursor.gif");
|
||||
font = draw::loadSurface("fuente1.gif");
|
||||
|
||||
int size=0;
|
||||
uint32_t *font_pal = draw::loadPalette("fuente1.gif", &size);
|
||||
draw::setPalette(font_pal+1, 5, 80);
|
||||
|
||||
carregarMapa();
|
||||
|
||||
draw::fadein();
|
||||
game::setState(gamestate::prefase::loop);
|
||||
}
|
||||
|
||||
bool loop()
|
||||
{
|
||||
const int x = input::mouseX();
|
||||
const int y = input::mouseY();
|
||||
|
||||
draw::setTrans(255);
|
||||
draw::setSource(fondo);
|
||||
draw::draw(0, 0, 320, 200, 0, 0);
|
||||
|
||||
draw::setTrans(0);
|
||||
draw::setSource(font);
|
||||
|
||||
drawText(130, 60, "NIVELL");
|
||||
drawText(179, 60, formatejar(game::getConfig("fase")+1));
|
||||
|
||||
drawText(80, 100, formatejar(num_arounders));
|
||||
drawText(101, 100, "AROUNDERS DISPONIBLES");
|
||||
|
||||
drawText(80, 110, formatejar(arounders_necessaris));
|
||||
drawText(101, 110, "AROUNDERS NECESSARIS");
|
||||
|
||||
draw::setSource(cursor);
|
||||
draw::draw(x, y, cursor->w, cursor->h, 0, 0);
|
||||
|
||||
draw::render();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void carregarMapa()
|
||||
{
|
||||
@@ -27,8 +79,7 @@ namespace gamestate
|
||||
|
||||
num_arounders = *(punter++);
|
||||
arounders_necessaris = *punter;
|
||||
fase = game::getConfig("fase")+1;
|
||||
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
@@ -63,49 +114,5 @@ namespace gamestate
|
||||
for (int i=1;i<=5;++i) draw::restorecol(i);
|
||||
}
|
||||
|
||||
bool loop()
|
||||
{
|
||||
const int x = input::mouseX();
|
||||
const int y = input::mouseY();
|
||||
|
||||
draw::setTrans(255);
|
||||
draw::setSource(fondo);
|
||||
draw::draw(0, 0, 320, 200, 0, 0);
|
||||
|
||||
draw::setTrans(0);
|
||||
draw::setSource(font);
|
||||
|
||||
drawText(130, 60, "NIVELL");
|
||||
drawText(179, 60, formatejar(fase));
|
||||
|
||||
drawText(80, 100, formatejar(num_arounders));
|
||||
drawText(101, 100, "AROUNDERS DISPONIBLES");
|
||||
|
||||
drawText(80, 110, formatejar(arounders_necessaris));
|
||||
drawText(101, 110, "AROUNDERS NECESSARIS");
|
||||
|
||||
draw::setSource(cursor);
|
||||
draw::draw(x, y, cursor->w, cursor->h, 0, 0);
|
||||
|
||||
draw::render();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
fondo = draw::loadSurface("prefase.gif", true);
|
||||
cursor = draw::loadSurface("cursor.gif");
|
||||
font = draw::loadSurface("fuente1.gif");
|
||||
|
||||
int size=0;
|
||||
uint32_t *font_pal = draw::loadPalette("fuente1.gif", &size);
|
||||
draw::setPalette(font_pal+1, 5, 80);
|
||||
|
||||
carregarMapa();
|
||||
|
||||
draw::fadein();
|
||||
game::setState(gamestate::prefase::loop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user