Add a main menu scene with Start/Hard Mode/Music options
The game now boots into a menu (Start Game, Hard Mode toggle, Music toggle) navigated with Up/Down and A/Start, instead of dropping straight into a match. B returns to the menu from a paused or game-over state.
This commit is contained in:
1 parent
0e7477031f
commit
8bf999c33b
5 files changed
+85
-7
No files matched your search
@@ -29,6 +29,43 @@ bool handle_input_frame(InputContext &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.state->scene == Scene::Menu) {
|
||||
if ((keys != 0U) && ((keys & (KEY_UP | KEY_DOWN)) != 0U)) {
|
||||
const int delta = ((keys & KEY_UP) != 0U) ? -1 : 1;
|
||||
ctx.state->menuSelection = (ctx.state->menuSelection + delta + MENU_ITEM_COUNT) % MENU_ITEM_COUNT;
|
||||
draw_menu(*ctx.state, *ctx.renderAssets, audio_is_music_enabled(*ctx.audio));
|
||||
}
|
||||
|
||||
if ((keys != 0U) && (((keys & KEY_A) != 0U) || ((keys & KEY_START) != 0U))) {
|
||||
switch (ctx.state->menuSelection) {
|
||||
case 0:
|
||||
ctx.state->scene = Scene::Playing;
|
||||
ctx.init_game();
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
break;
|
||||
case 1:
|
||||
ctx.state->hardMode = !ctx.state->hardMode;
|
||||
draw_menu(*ctx.state, *ctx.renderAssets, audio_is_music_enabled(*ctx.audio));
|
||||
break;
|
||||
case 2:
|
||||
audio_toggle_music(*ctx.audio);
|
||||
draw_menu(*ctx.state, *ctx.renderAssets, audio_is_music_enabled(*ctx.audio));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((ctx.state->paused || ctx.state->gameOver) && (keys != 0U) && ((keys & KEY_B) != 0U)) {
|
||||
ctx.state->scene = Scene::Menu;
|
||||
ctx.state->paused = false;
|
||||
draw_menu(*ctx.state, *ctx.renderAssets, audio_is_music_enabled(*ctx.audio));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!ctx.state->paused && !ctx.state->gameOver) {
|
||||
const bool cursed = ctx.state->curseTicksRemaining > 0;
|
||||
|
||||
|
||||
Reference in new issue
Block a user