blob: a8c01150197380723d565a5f0f88ecd264f1ee9e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/* **************************************
* Includes *
* **************************************/
#include "Menu.h"
#include "HumanPlayer.h"
#include "Game.h"
#include "System.h"
#include <Gamebuino.h>
#include <Arduino.h>
/* **************************************
* Defines *
* **************************************/
#define GAME_NAME "Pocket Empires"
/* **************************************
* Structs and enums *
* **************************************/
/* **************************************
* Local variables *
* **************************************/
/* **************************************
* Functions definition *
* **************************************/
/*****************************************************************//**
*
* \brief Video game entry point. Main menu is shown, allowing
* the user to choose an option.
*
*********************************************************************/
void MainMenu(void)
{
enum
{
CHOICE_SINGLE_PLAYER_GAME,
CHOICE_MULTI_PLAYER_GAME,
CHOICE_OPTIONS,
MAX_CHOICES
};
static const char strMainMenuOptions_0[] PROGMEM = "Single player game";
static const char strMainMenuOptions_1[] PROGMEM = "Multiplayer game";
static const char strMainMenuOptions_2[] PROGMEM = "Options";
static const char* const astrMainMenuOptions[MAX_CHOICES] PROGMEM =
{
[CHOICE_SINGLE_PLAYER_GAME] = strMainMenuOptions_0,
[CHOICE_MULTI_PLAYER_GAME] = strMainMenuOptions_1,
[CHOICE_OPTIONS] = strMainMenuOptions_2
};
/* Show video game name on
* Gamebuino default title screen. */
gb.titleScreen(F(GAME_NAME));
/* Choose which module should be
* executed depending on user input. */
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
};
char strName[GAMEBUINO_MAX_PLAYER_NAME] = {0};
/* Fill strName with default user name. */
gb.getDefaultName(strName);
/* Declare 1 human player instance. */
HumanPlayer h(strName);
const struct tGameConfig c =
{
.pHumanPlayerData = &h,
.u8NHumanPlayers = 1
};
/* Initialize game with defined configuration. */
Game(c);
}
break;
case CHOICE_MULTI_PLAYER_GAME:
/* Not implemented yet. Fall through. */
case CHOICE_OPTIONS:
/* Not implemented yet. Fall through. */
default:
/* Undefined choice. Exit. */
break;
}
}
|