Adds the game type select menu
This commit is contained in:
parent
7005239830
commit
0f66b0f3d0
|
@ -26,6 +26,7 @@ typedef enum GameState_t {
|
||||||
PLAYING,
|
PLAYING,
|
||||||
IN_GAME_MENU,
|
IN_GAME_MENU,
|
||||||
CHARACTER_MENU,
|
CHARACTER_MENU,
|
||||||
|
GAME_SELECT,
|
||||||
GAME_OVER,
|
GAME_OVER,
|
||||||
COMPLETED,
|
COMPLETED,
|
||||||
QUIT
|
QUIT
|
||||||
|
|
57
src/main.c
57
src/main.c
|
@ -147,6 +147,7 @@ static RoomMatrix *gRoomMatrix = NULL;
|
||||||
static Gui *gGui = NULL;
|
static Gui *gGui = NULL;
|
||||||
static SkillBar *gSkillBar = NULL;
|
static SkillBar *gSkillBar = NULL;
|
||||||
static Menu *mainMenu = NULL;
|
static Menu *mainMenu = NULL;
|
||||||
|
static Menu *gameSelectMenu = NULL;
|
||||||
static Menu *inGameMenu = NULL;
|
static Menu *inGameMenu = NULL;
|
||||||
static Menu *charSelectMenu = NULL;
|
static Menu *charSelectMenu = NULL;
|
||||||
static Timer *menuTimer = NULL;
|
static Timer *menuTimer = NULL;
|
||||||
|
@ -426,6 +427,19 @@ goToMainMenu(void *unused)
|
||||||
camera_follow_position(gCamera, &p);
|
camera_follow_position(gCamera, &p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
goToGameSelectMenu(void *unused)
|
||||||
|
{
|
||||||
|
UNUSED(unused);
|
||||||
|
static TEXT_MENU_ITEM menuItems[] = {
|
||||||
|
{ "STANDARD GAME", "", startRegularGame },
|
||||||
|
{ "QUICK GAME", "", startQuickGame },
|
||||||
|
};
|
||||||
|
|
||||||
|
menu_create_text_menu(&gameSelectMenu, &menuItems[0], 2, gRenderer);
|
||||||
|
gGameState = GAME_SELECT;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
showHowToTooltip(void *unused)
|
showHowToTooltip(void *unused)
|
||||||
{
|
{
|
||||||
|
@ -482,12 +496,7 @@ static void
|
||||||
initMainMenu(void)
|
initMainMenu(void)
|
||||||
{
|
{
|
||||||
static TEXT_MENU_ITEM menu_items[] = {
|
static TEXT_MENU_ITEM menu_items[] = {
|
||||||
{ "PLAY",
|
{ "PLAY", "Start game", goToGameSelectMenu },
|
||||||
"Play a standard 20 level game. Recommended for new players",
|
|
||||||
startRegularGame },
|
|
||||||
{ "QUICK PLAY",
|
|
||||||
"Play a 12 level game with more action earlier in the game",
|
|
||||||
startQuickGame },
|
|
||||||
{ "SCORES", "View your top 10 scores", viewScoreScreen },
|
{ "SCORES", "View your top 10 scores", viewScoreScreen },
|
||||||
{ "CREDITS", "View game credits", viewCredits },
|
{ "CREDITS", "View game credits", viewCredits },
|
||||||
{ "QUIT", "Exit game", exitGame },
|
{ "QUIT", "Exit game", exitGame },
|
||||||
|
@ -498,7 +507,7 @@ initMainMenu(void)
|
||||||
|
|
||||||
gMap = map_lua_generator_single_room__run(cLevel, gRenderer);
|
gMap = map_lua_generator_single_room__run(cLevel, gRenderer);
|
||||||
|
|
||||||
menu_create_text_menu(&mainMenu, &menu_items[0], 5, gRenderer);
|
menu_create_text_menu(&mainMenu, &menu_items[0], 4, gRenderer);
|
||||||
mixer_play_music(MENU_MUSIC);
|
mixer_play_music(MENU_MUSIC);
|
||||||
creditsScreen = screen_create_credits(gRenderer);
|
creditsScreen = screen_create_credits(gRenderer);
|
||||||
scoreScreen = screen_create_hiscore(gRenderer);
|
scoreScreen = screen_create_hiscore(gRenderer);
|
||||||
|
@ -526,6 +535,10 @@ resetGame(void)
|
||||||
menu_destroy(charSelectMenu);
|
menu_destroy(charSelectMenu);
|
||||||
charSelectMenu = NULL;
|
charSelectMenu = NULL;
|
||||||
}
|
}
|
||||||
|
if (gameSelectMenu) {
|
||||||
|
menu_destroy(gameSelectMenu);
|
||||||
|
gameSelectMenu = NULL;
|
||||||
|
}
|
||||||
if (characterSelectScreen) {
|
if (characterSelectScreen) {
|
||||||
screen_destroy(characterSelectScreen);
|
screen_destroy(characterSelectScreen);
|
||||||
characterSelectScreen = NULL;
|
characterSelectScreen = NULL;
|
||||||
|
@ -663,16 +676,20 @@ handle_main_input(void)
|
||||||
case SCORE_SCREEN:
|
case SCORE_SCREEN:
|
||||||
gGameState = MENU;
|
gGameState = MENU;
|
||||||
break;
|
break;
|
||||||
|
case GAME_SELECT:
|
||||||
|
menu_destroy(gameSelectMenu);
|
||||||
|
gameSelectMenu = NULL;
|
||||||
|
gGameState = MENU;
|
||||||
|
break;
|
||||||
case CHARACTER_MENU:
|
case CHARACTER_MENU:
|
||||||
|
if (mainMenu == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
screen_destroy(characterSelectScreen);
|
screen_destroy(characterSelectScreen);
|
||||||
characterSelectScreen = NULL;
|
characterSelectScreen = NULL;
|
||||||
menu_destroy(charSelectMenu);
|
menu_destroy(charSelectMenu);
|
||||||
charSelectMenu = NULL;
|
charSelectMenu = NULL;
|
||||||
if (mainMenu == NULL) {
|
gGameState = GAME_SELECT;
|
||||||
resetGame();
|
|
||||||
initMainMenu();
|
|
||||||
}
|
|
||||||
gGameState = MENU;
|
|
||||||
break;
|
break;
|
||||||
case MENU:
|
case MENU:
|
||||||
gGameState = QUIT;
|
gGameState = QUIT;
|
||||||
|
@ -1030,6 +1047,7 @@ run_menu(void)
|
||||||
if (gGameState != MENU
|
if (gGameState != MENU
|
||||||
&& gGameState != CREDITS
|
&& gGameState != CREDITS
|
||||||
&& gGameState != SCORE_SCREEN
|
&& gGameState != SCORE_SCREEN
|
||||||
|
&& gGameState != GAME_SELECT
|
||||||
&& gGameState != CHARACTER_MENU)
|
&& gGameState != CHARACTER_MENU)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1037,6 +1055,8 @@ run_menu(void)
|
||||||
menu_update(mainMenu, &input, gCamera);
|
menu_update(mainMenu, &input, gCamera);
|
||||||
else if (gGameState == CHARACTER_MENU)
|
else if (gGameState == CHARACTER_MENU)
|
||||||
menu_update(charSelectMenu, &input, gCamera);
|
menu_update(charSelectMenu, &input, gCamera);
|
||||||
|
else if (gGameState == GAME_SELECT)
|
||||||
|
menu_update(gameSelectMenu, &input, gCamera);
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(gRenderer, 0, 0, 0, 0);
|
SDL_SetRenderDrawColor(gRenderer, 0, 0, 0, 0);
|
||||||
SDL_RenderClear(gRenderer);
|
SDL_RenderClear(gRenderer);
|
||||||
|
@ -1052,10 +1072,12 @@ run_menu(void)
|
||||||
|
|
||||||
if (gGameState == MENU)
|
if (gGameState == MENU)
|
||||||
menu_render(mainMenu, gCamera);
|
menu_render(mainMenu, gCamera);
|
||||||
if (gGameState == CHARACTER_MENU) {
|
else if (gGameState == CHARACTER_MENU) {
|
||||||
screen_render(characterSelectScreen, gCamera);
|
screen_render(characterSelectScreen, gCamera);
|
||||||
menu_render(charSelectMenu, gCamera);
|
menu_render(charSelectMenu, gCamera);
|
||||||
}
|
}
|
||||||
|
else if (gGameState == GAME_SELECT)
|
||||||
|
menu_render(gameSelectMenu, gCamera);
|
||||||
else if (gGameState == CREDITS)
|
else if (gGameState == CREDITS)
|
||||||
screen_render(creditsScreen, gCamera);
|
screen_render(creditsScreen, gCamera);
|
||||||
else if (gGameState == SCORE_SCREEN)
|
else if (gGameState == SCORE_SCREEN)
|
||||||
|
@ -1111,6 +1133,7 @@ run(void)
|
||||||
case MENU:
|
case MENU:
|
||||||
case CREDITS:
|
case CREDITS:
|
||||||
case SCORE_SCREEN:
|
case SCORE_SCREEN:
|
||||||
|
case GAME_SELECT:
|
||||||
case CHARACTER_MENU:
|
case CHARACTER_MENU:
|
||||||
run_menu();
|
run_menu();
|
||||||
break;
|
break;
|
||||||
|
@ -1162,14 +1185,18 @@ void close(void)
|
||||||
map_destroy(gMap);
|
map_destroy(gMap);
|
||||||
if (mainMenu)
|
if (mainMenu)
|
||||||
menu_destroy(mainMenu);
|
menu_destroy(mainMenu);
|
||||||
|
if (charSelectMenu)
|
||||||
|
menu_destroy(charSelectMenu);
|
||||||
|
if (gameSelectMenu)
|
||||||
|
menu_destroy(gameSelectMenu);
|
||||||
|
if (inGameMenu)
|
||||||
|
menu_destroy(inGameMenu);
|
||||||
if (creditsScreen)
|
if (creditsScreen)
|
||||||
screen_destroy(creditsScreen);
|
screen_destroy(creditsScreen);
|
||||||
if (scoreScreen)
|
if (scoreScreen)
|
||||||
screen_destroy(scoreScreen);
|
screen_destroy(scoreScreen);
|
||||||
if (characterSelectScreen)
|
if (characterSelectScreen)
|
||||||
screen_destroy(characterSelectScreen);
|
screen_destroy(characterSelectScreen);
|
||||||
if (inGameMenu)
|
|
||||||
menu_destroy(inGameMenu);
|
|
||||||
|
|
||||||
sprite_destroy(howto_tooltip);
|
sprite_destroy(howto_tooltip);
|
||||||
sprite_destroy(new_skill_tooltip);
|
sprite_destroy(new_skill_tooltip);
|
||||||
|
|
Loading…
Reference in New Issue