- Menú bàsic funcionant
This commit is contained in:
BIN
data/font2.gif
BIN
data/font2.gif
Binary file not shown.
|
Before Width: | Height: | Size: 626 B After Width: | Height: | Size: 627 B |
BIN
data/test.gif
BIN
data/test.gif
Binary file not shown.
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
@@ -253,7 +253,7 @@ namespace modules
|
|||||||
|
|
||||||
bool loop()
|
bool loop()
|
||||||
{
|
{
|
||||||
if (input::keyDown(SDL_SCANCODE_ESCAPE))
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE))
|
||||||
{
|
{
|
||||||
if (console::isEnabled())
|
if (console::isEnabled())
|
||||||
console::toggle();
|
console::toggle();
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ namespace modules
|
|||||||
|
|
||||||
bool loop()
|
bool loop()
|
||||||
{
|
{
|
||||||
if (input::keyDown(SDL_SCANCODE_ESCAPE)) {
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE) ||
|
||||||
|
input::keyPressed(SDL_SCANCODE_SPACE) ||
|
||||||
|
input::keyPressed(SDL_SCANCODE_RETURN) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,25 +8,74 @@ namespace modules
|
|||||||
{
|
{
|
||||||
namespace menu
|
namespace menu
|
||||||
{
|
{
|
||||||
|
draw::surface *surf;
|
||||||
|
int anim_pos=0;
|
||||||
|
int retras=4;
|
||||||
|
|
||||||
|
int selected_option = OPTION_JUGAR;
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
::game::setUpdateTicks(64);
|
::game::setUpdateTicks(64);
|
||||||
|
draw::loadPalette("test.gif");
|
||||||
|
surf = draw::getSurface("test.gif");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loop()
|
int loop()
|
||||||
{
|
{
|
||||||
if (input::keyDown(SDL_SCANCODE_ESCAPE)) {
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||||
return false;
|
return OPTION_EIXIR;
|
||||||
|
}
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_DOWN)) selected_option = (selected_option+1)&3;
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_UP)) selected_option = (selected_option-1)&3;
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN)) {
|
||||||
|
if (selected_option == OPTION_EIXIR || selected_option == OPTION_JUGAR) return selected_option;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw::cls(2);
|
draw::cls(2);
|
||||||
draw::color(1);
|
draw::color(1);
|
||||||
|
|
||||||
|
draw::swapcol(1, WHITE);
|
||||||
|
draw::setSource(surf);
|
||||||
|
draw::draw(142,48,20,32,64+anim_pos*20,32);
|
||||||
|
retras--;
|
||||||
|
if (retras==0) {retras=4; anim_pos=(anim_pos+1)&1; }
|
||||||
|
|
||||||
draw::print2("THE POOL", 16, 3, YELLOW, FONT_ZOOM_VERTICAL);
|
draw::print2("THE POOL", 16, 3, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
|
||||||
|
switch (selected_option)
|
||||||
|
{
|
||||||
|
case OPTION_JUGAR:
|
||||||
|
draw::print2("fg JUGAR AL JOC", 11, 12, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
draw::print2("de REDEFINIR TECLES", 11, 15, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("de CONFIGURAR SO", 11, 17, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("de EIXIR", 11, 19, TEAL, FONT_ZOOM_NONE);
|
||||||
|
break;
|
||||||
|
case OPTION_TECLES:
|
||||||
|
draw::print2("de JUGAR AL JOC", 11, 12, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("fg REDEFINIR TECLES", 11, 14, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
draw::print2("de CONFIGURAR SO", 11, 17, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("de EIXIR", 11, 19, TEAL, FONT_ZOOM_NONE);
|
||||||
|
break;
|
||||||
|
case OPTION_SO:
|
||||||
|
draw::print2("de JUGAR AL JOC", 11, 12, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("de REDEFINIR TECLES", 11, 14, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("fg CONFIGURAR SO", 11, 16, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
draw::print2("de EIXIR", 11, 19, TEAL, FONT_ZOOM_NONE);
|
||||||
|
break;
|
||||||
|
case OPTION_EIXIR:
|
||||||
|
draw::print2("de JUGAR AL JOC", 11, 12, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("de REDEFINIR TECLES", 11, 14, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("de CONFIGURAR SO", 11, 16, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("fg EIXIR", 11, 18, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE);
|
||||||
|
|
||||||
draw::render();
|
draw::render();
|
||||||
return true;
|
return OPTION_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,13 @@ namespace modules
|
|||||||
{
|
{
|
||||||
namespace menu
|
namespace menu
|
||||||
{
|
{
|
||||||
|
#define OPTION_NONE -1
|
||||||
|
#define OPTION_JUGAR 0
|
||||||
|
#define OPTION_TECLES 1
|
||||||
|
#define OPTION_SO 2
|
||||||
|
#define OPTION_EIXIR 3
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
bool loop();
|
int loop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,13 +36,18 @@ void game::init()
|
|||||||
|
|
||||||
bool game::loop()
|
bool game::loop()
|
||||||
{
|
{
|
||||||
|
int option;
|
||||||
switch(current_module)
|
switch(current_module)
|
||||||
{
|
{
|
||||||
case M_LOGO:
|
case M_LOGO:
|
||||||
if (!modules::logo::loop()) { modules::menu::init(); current_module = M_MENU; }
|
if (!modules::logo::loop()) { modules::menu::init(); current_module = M_MENU; }
|
||||||
break;
|
break;
|
||||||
case M_MENU:
|
case M_MENU:
|
||||||
if (!modules::menu::loop()) { modules::game::init(); current_module = M_GAME; }
|
option = modules::menu::loop();
|
||||||
|
if (option != OPTION_NONE) {
|
||||||
|
if (option == OPTION_EIXIR) return false;
|
||||||
|
if (option == OPTION_JUGAR) { modules::game::init(); current_module = M_GAME; }
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case M_GAME:
|
case M_GAME:
|
||||||
return modules::game::loop();
|
return modules::game::loop();
|
||||||
|
|||||||
Reference in New Issue
Block a user