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:
phillip committed 2026-09-03 22:27:49 +02:00
1 parent 0e7477031f
commit 8bf999c33b
5 files changed
+85 -7

No files matched your search

+29
View File
@@ -143,9 +143,14 @@ void draw_stats(const GameState &state, bool internals, bool musicEnabled, uint8
}
if (!state.paused) {
if (state.gameOver) {
iprintf("\x1b[23;0HB = Main Menu");
}
return;
}
iprintf("\x1b[21;0HB = Main Menu");
if (musicEnabled) {
iprintf("\x1b[23;0HX = Disable Music");
} else {
@@ -159,6 +164,30 @@ void draw_stats(const GameState &state, bool internals, bool musicEnabled, uint8
}
}
void draw_menu(const GameState &state, const RenderAssets &assets, bool musicEnabled) {
oamClear(&oamSub, 0, 0);
oamUpdate(&oamSub);
consoleSelect(assets.bottomScreen);
consoleClear();
consoleSelect(assets.topScreen);
consoleClear();
iprintf("\x1b[3;10HSNAKE PLUS");
iprintf("\x1b[5;5H---------------------");
const char *hardModeLabel = state.hardMode ? "ON " : "OFF";
const char *musicLabel = musicEnabled ? "ON " : "OFF";
iprintf("\x1b[8;7H%c Start Game", state.menuSelection == 0 ? '>' : ' ');
iprintf("\x1b[10;7H%c Hard Mode: %s", state.menuSelection == 1 ? '>' : ' ', hardModeLabel);
iprintf("\x1b[12;7H%c Music: %s", state.menuSelection == 2 ? '>' : ' ', musicLabel);
iprintf("\x1b[19;3HUP/DOWN: Navigate");
iprintf("\x1b[20;3HA/START: Select");
}
void blink_apples(const GameState &state, u16 *gfx_apple) {
if (state.ticks % 4) {
dmaCopy(get_sprite_pointer(5), gfx_apple, 64);