diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-06-20 23:08:22 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-06-20 23:08:22 +0100 |
commit | b4dd0c8956f1c81836e4f3020efe2f85b3d91902 (patch) | |
tree | 658f08795c5774df8e0ee646e5212ffa82e09ba3 /src | |
parent | d489b6ef92ae9f61bbceb5f594026a51e71538f2 (diff) | |
download | gold-mine-run-b4dd0c8956f1c81836e4f3020efe2f85b3d91902.tar.gz gold-mine-run-b4dd0c8956f1c81836e4f3020efe2f85b3d91902.zip |
Add menu screen (WIP)
Diffstat (limited to 'src')
-rw-r--r-- | src/data.h | 1 | ||||
-rw-r--r-- | src/game.c | 4 | ||||
-rw-r--r-- | src/main.c | 8 | ||||
-rw-r--r-- | src/menu.c | 35 | ||||
-rw-r--r-- | src/menu.h | 6 |
5 files changed, 49 insertions, 5 deletions
@@ -6,6 +6,7 @@ extern const uint8_t binary_palette_start[]; extern const uint8_t binary_sprites_start[]; extern const uint8_t binary_tiles_start[]; extern const uint8_t binary_font_start[]; +extern const uint8_t binary_title_start[]; extern const uint8_t binary_stage_start[]; @@ -105,6 +105,10 @@ void run_game() wait_vsync(); blit_update(); } + + /* wait for ESC to be release */ + while (keys[KEY_ESC]) + wait_vsync(); } void add_score(uint8_t v) @@ -8,6 +8,7 @@ #include "keyb.h" #include "vga.h" #include "data.h" +#include "menu.h" #include "game.h" /* disable paging because our int handlers are written in C */ @@ -41,11 +42,8 @@ int main(int argc, char *argv[]) return 1; } - blit_erase(0); - wait_vsync(); - blit_update(); - - run_game(); + while (run_menu()) + run_game(); set_mode(3); close_framebuffer(); diff --git a/src/menu.c b/src/menu.c new file mode 100644 index 0000000..02cda24 --- /dev/null +++ b/src/menu.c @@ -0,0 +1,35 @@ +#include <stdint.h> + +#include "keyb.h" +#include "vga.h" +#include "text.h" +#include "data.h" + +uint8_t run_menu() +{ + blit_erase(0); + + put_text(124, 10, "HI 000000"); + + Rect dst = { 80, 45, 160, 38 }; + blit(binary_title_start, &dst); + + put_text(84, 110, "PRESS SPACE TO PLAY"); + + put_text(64, 140, "CODE, GRAPHICS AND MUSIC"); + put_text(96, 150, "JUAN J. MARTINEZ"); + + put_text(96, 180, "_2023 USEBOX.NET"); + + wait_vsync(); + blit_update(); + + while (1) + { + if (keys[KEY_ESC]) + return 0; + + if (keys[KEY_SPACE]) + return 1; + } +} diff --git a/src/menu.h b/src/menu.h new file mode 100644 index 0000000..b367b99 --- /dev/null +++ b/src/menu.h @@ -0,0 +1,6 @@ +#ifdef _MENU_H +#define _MENU_H + +uint8_t run_menu(); + +#endif /* _MENU_H */ |