From 961d285edb0bfbfeaed447ed43b925e4df557a42 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Thu, 23 Jun 2022 18:36:15 +0200 Subject: [PATCH] =?UTF-8?q?20220623=20-=20Menu=20de=20s=C3=A9lection=20de?= =?UTF-8?q?=20la=20partie.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gamesettings.h | 1 + src/itemsizes.h | 6 +++++ src/main.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ src/msg_fr.h | 2 ++ 4 files changed, 68 insertions(+) create mode 100644 src/gamesettings.h create mode 100644 src/itemsizes.h create mode 100644 src/main.c create mode 100644 src/msg_fr.h diff --git a/src/gamesettings.h b/src/gamesettings.h new file mode 100644 index 0000000..111d88a --- /dev/null +++ b/src/gamesettings.h @@ -0,0 +1 @@ +# define GAMESNUM 5 // How many games you can save (and play). \ No newline at end of file diff --git a/src/itemsizes.h b/src/itemsizes.h new file mode 100644 index 0000000..23a767b --- /dev/null +++ b/src/itemsizes.h @@ -0,0 +1,6 @@ +# define FONTHEIGHT 8 // Font size (y). +# define LINEHEIGHT 10 // Font size (y) + padding (y) bottom. +# define LINEPADDING 2 // Padding (y) of the font. +# define TITLE_MARGIN 46 // Margin (y) over the text at the top of the tile screen. +# define TITLE_IMAGE_MARGIN 8 // Margin (y) over the image at the top of the tile screen. +# define WORLDSEL_MARGIN 5 // Margin (y) at the top of the game selection menu. \ No newline at end of file diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..771ed19 --- /dev/null +++ b/src/main.c @@ -0,0 +1,59 @@ +#include +#include +#include "msg_fr.h" +#include "itemsizes.h" +#include "gamesettings.h" + +extern bopti_image_t title_img; + +void drawselectedgame(int selected) { + dclear(C_WHITE); + // dimage(16, 8, &title_img); + for(int i=0;i!=GAMESNUM;i++){ + dtext(1, WORLDSEL_MARGIN + i*(LINEHEIGHT+LINEPADDING), C_BLACK, WORLDSEL_EMPTY); + } + drect(1, WORLDSEL_MARGIN+selected*(LINEHEIGHT+LINEPADDING), 128, WORLDSEL_MARGIN+selected*(LINEHEIGHT+LINEPADDING)+LINEHEIGHT, C_INVERT); + dupdate(); +} +int main(void) { + dclear(C_WHITE); + dimage(16, TITLE_IMAGE_MARGIN, &title_img); + dtext(1, TITLE_MARGIN, C_BLACK, TITLE_START); + dupdate(); + int key = 0, game = 0, selected = 0; + while(key != KEY_EXIT){ + key=getkey().key; + ////////// TITLE SCREEN ////////// + if(game == 0){ + if(key==KEY_EXE){ + drawselectedgame(selected); + game = 1; + } + } + ////////// GAME CHOOSING SCREEN ////////// + else if(game == 1){ + if(key==KEY_DOWN){ + if(selected0){ + selected--; + }else{ + selected = GAMESNUM - 1; + } + drawselectedgame(selected); + }else if(key==KEY_EXE){ + dclear(C_WHITE); + game = 2; + + } + }else if(game == 2){ + dupdate(); + } + } + return 1; +} diff --git a/src/msg_fr.h b/src/msg_fr.h new file mode 100644 index 0000000..7dc596e --- /dev/null +++ b/src/msg_fr.h @@ -0,0 +1,2 @@ +# define TITLE_START "[EXE] pour jouer" +# define WORLDSEL_EMPTY "--- VIDE ---" // Empty slot in the game selection menu. \ No newline at end of file