20220623 - Menu de sélection de la partie.

This commit is contained in:
mibi88 2022-06-23 18:36:15 +02:00
parent 268686699f
commit 961d285edb
4 changed files with 68 additions and 0 deletions

1
src/gamesettings.h Normal file
View File

@ -0,0 +1 @@
# define GAMESNUM 5 // How many games you can save (and play).

6
src/itemsizes.h Normal file
View File

@ -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.

59
src/main.c Normal file
View File

@ -0,0 +1,59 @@
#include <gint/display.h>
#include <gint/keyboard.h>
#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(selected<GAMESNUM - 1){
selected++;
}else{
selected = 0;
}
drawselectedgame(selected);
}else if(key==KEY_UP){
if(selected>0){
selected--;
}else{
selected = GAMESNUM - 1;
}
drawselectedgame(selected);
}else if(key==KEY_EXE){
dclear(C_WHITE);
game = 2;
}
}else if(game == 2){
dupdate();
}
}
return 1;
}

2
src/msg_fr.h Normal file
View File

@ -0,0 +1,2 @@
# define TITLE_START "[EXE] pour jouer"
# define WORLDSEL_EMPTY "--- VIDE ---" // Empty slot in the game selection menu.