diff --git a/src/menu.c b/src/menu.c new file mode 100644 index 0000000..44a58cb --- /dev/null +++ b/src/menu.c @@ -0,0 +1,44 @@ +#include +#include +#include "render.h" +#include "events.h" +#include "hiscore.h" +#include "sdl.h" + +///////////////// MAIN MENU //////////////////////////// +int menu(void) { + quit = false; + Ren_menu(); + + while (quit == false) { +// SDL_Delay(20); + SDL_PollEvent(&event); + switch (event.type) { + case SDL_KEYDOWN: + if (event.key.keysym.sym == SDLK_q) { + quit = true; // quit + } + if (event.key.keysym.sym == SDLK_a) { + Ren_about(); // about + check_key(); + Ren_menu(); + } + if (event.key.keysym.sym == SDLK_i) { + Ren_info(); // info (instructions) + check_key(); + Ren_menu(); + } + if (event.key.keysym.sym > SDLK_0 && event.key.keysym.sym < SDLK_7) { + if (event.key.keysym.sym == SDLK_1) {speed = 1.0;} + if (event.key.keysym.sym == SDLK_2) {speed = 1.5;} + if (event.key.keysym.sym == SDLK_3) {speed = 2.0;} + if (event.key.keysym.sym == SDLK_4) {speed = 2.5;} + if (event.key.keysym.sym == SDLK_5) {speed = 3.0;} + if (event.key.keysym.sym == SDLK_6) {speed = 3.5;} + handle_events(); // game levels + end_game(); + Ren_menu(); + } + } + } +}