20220623 - Menu de sélection de la partie.

This commit is contained in:
mibi88 2022-06-23 18:34:20 +02:00
parent 373bad1025
commit b17e99b6e5
5 changed files with 97 additions and 0 deletions

29
CMakeLists.txt Normal file
View File

@ -0,0 +1,29 @@
# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the
# toolchain file and module path of the fxSDK
cmake_minimum_required(VERSION 3.15)
project(builder)
include(GenerateG1A)
include(Fxconv)
find_package(Gint 2.1 REQUIRED)
set(SOURCES
src/main.c
# ...
)
set(ASSETS_fx
assets-fx/title.png
# ...
)
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os)
target_link_libraries(myaddin Gint::Gint)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
generate_g1a(TARGET myaddin OUTPUT "Builder.g1a"
NAME "Builder" ICON assets-fx/icon.png)
endif()

1
gamesettings.h Normal file
View File

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

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