diff --git a/data/font2.gif b/data/font2.gif index b81cdee..68266da 100644 Binary files a/data/font2.gif and b/data/font2.gif differ diff --git a/data/test.gif b/data/test.gif index 5cdce5d..ed7b382 100644 Binary files a/data/test.gif and b/data/test.gif differ diff --git a/source/m_game.cpp b/source/m_game.cpp index 0fccd5f..68decde 100644 --- a/source/m_game.cpp +++ b/source/m_game.cpp @@ -253,7 +253,7 @@ namespace modules bool loop() { - if (input::keyDown(SDL_SCANCODE_ESCAPE)) + if (input::keyPressed(SDL_SCANCODE_ESCAPE)) { if (console::isEnabled()) console::toggle(); diff --git a/source/m_logo.cpp b/source/m_logo.cpp index fa41ef7..cbf787f 100644 --- a/source/m_logo.cpp +++ b/source/m_logo.cpp @@ -54,7 +54,9 @@ namespace modules 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; } diff --git a/source/m_menu.cpp b/source/m_menu.cpp index ac02f2c..ec6a890 100644 --- a/source/m_menu.cpp +++ b/source/m_menu.cpp @@ -8,25 +8,74 @@ namespace modules { namespace menu { + draw::surface *surf; + int anim_pos=0; + int retras=4; + + int selected_option = OPTION_JUGAR; + void init() { ::game::setUpdateTicks(64); - + draw::loadPalette("test.gif"); + surf = draw::getSurface("test.gif"); } - bool loop() + int loop() { - if (input::keyDown(SDL_SCANCODE_ESCAPE)) { - return false; + if (input::keyPressed(SDL_SCANCODE_ESCAPE)) { + 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::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); + 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(); - return true; + return OPTION_NONE; } } } diff --git a/source/m_menu.h b/source/m_menu.h index ebc55b0..ef12b69 100644 --- a/source/m_menu.h +++ b/source/m_menu.h @@ -4,7 +4,13 @@ namespace modules { namespace menu { + #define OPTION_NONE -1 + #define OPTION_JUGAR 0 + #define OPTION_TECLES 1 + #define OPTION_SO 2 + #define OPTION_EIXIR 3 + void init(); - bool loop(); + int loop(); } } diff --git a/source/main.cpp b/source/main.cpp index 14b30dd..f8bc919 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -36,13 +36,18 @@ void game::init() bool game::loop() { + int option; switch(current_module) { case M_LOGO: if (!modules::logo::loop()) { modules::menu::init(); current_module = M_MENU; } break; 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; case M_GAME: return modules::game::loop();