diff options
Diffstat (limited to 'Menu.cpp')
| -rw-r--r-- | Menu.cpp | 74 |
1 files changed, 42 insertions, 32 deletions
@@ -32,6 +32,8 @@ * Local prototypes declaration * ******************************************************************/ +static void MainMenuSinglePlayer(void); + /* ******************************************************************* * Functions definition * ******************************************************************/ @@ -75,38 +77,7 @@ void MainMenu(void) switch (gb.menu(astrMainMenuOptions, MAX_CHOICES)) { case CHOICE_SINGLE_PLAYER_GAME: - { - enum - { - /* Maximum number of characters for - * player name, as specified on - * Gamebuino documentation. */ - GAMEBUINO_MAX_PLAYER_NAME = 10 - }; - - Camera cam; - - char strName[GAMEBUINO_MAX_PLAYER_NAME] = {0}; - - /* Fill strName with default user name. */ - gb.getDefaultName(strName); - - /* Declare 1 human player instance. */ - HumanPlayer h(strName, cam); - - const struct tGameConfig c = - { - .pHumanPlayerData = &h, - .u8NHumanPlayers = 1, - .cam = cam - }; - - /* Set global camera for sprites. */ - Sprite::setCamera(&c.cam); - - /* Initialize game with defined configuration. */ - Game(c); - } + MainMenuSinglePlayer(); break; case CHOICE_MULTI_PLAYER_GAME: @@ -118,3 +89,42 @@ void MainMenu(void) break; } } + +/*****************************************************************//** + * + * \brief Executes single player mode. + * + *********************************************************************/ +static void MainMenuSinglePlayer(void) +{ + enum + { + /* Maximum number of characters for + * player name, as specified on + * Gamebuino documentation. */ + GAMEBUINO_MAX_PLAYER_NAME = 10 + }; + + char strName[GAMEBUINO_MAX_PLAYER_NAME] = {0}; + + /* Fill strName with default user name. */ + gb.getDefaultName(strName); + + Camera cam; + + /* Declare 1 human player instance. */ + HumanPlayer h(strName, cam); + + const struct tGameConfig c = + { + .pHumanPlayerData = &h, + .u8NHumanPlayers = 1, + .cam = cam + }; + + /* Set global camera for sprites. */ + Sprite::setCamera(&c.cam); + + /* Initialize game with defined configuration. */ + Game(c); +} |
