-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameMenu.cpp
86 lines (72 loc) · 2.28 KB
/
GameMenu.cpp
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
// This file is part of CasaSoft Arduino Games
//
// CasaSoft Arduino Games is free software:
// you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CasaSoft Arduino Games is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with CasaSoft Arduino Games.
// If not, see <http://www.gnu.org/licenses/>.
#include "GameMenu.h"
void GameMenu::menuInit()
{
menuStatus = menuNone;
}
void GameMenu::menuDisplay()
{
if(menuStatus != menuNone)
return;
GU.showHeader();
menuIconSelected(0);
GLCD.GotoXY(MENU_TEXT_LEFT, MENU_ICON_TOP+1);
GLCD.Puts_P(PSTR("Start Game"));
menuIconUnselected(1);
GLCD.GotoXY(MENU_TEXT_LEFT, MENU_ICON_TOP+1+MENU_VERT_SPACE);
GLCD.Puts_P(PSTR("Hall of Fame"));
menuIconUnselected(2);
GLCD.GotoXY(MENU_TEXT_LEFT, MENU_ICON_TOP+1+MENU_VERT_SPACE*2);
GLCD.Puts_P(PSTR("Enter your name"));
menuStatus = menuStartGame;
}
GameMenu::menuStates GameMenu::menuRun()
{
int y = GP.ReadDigital(Y1);
if(y == DIRECTION_UP && menuStatus > 1) {
int current = static_cast<int>(menuStatus) - 1;
menuIconUnselected(current);
menuIconSelected(current - 1);
menuStatus = static_cast<menuStates>(current);
delay(200);
}
else if(y == DIRECTION_DOWN && menuStatus < 3) {
int current = static_cast<int>(menuStatus);
menuIconUnselected(current - 1);
menuIconSelected(current);
menuStatus = static_cast<menuStates>(current+1);
delay(200);
}
if(GU.anyButton()) {
menuStates ret = menuStatus;
menuStatus = menuNone;
return ret;
}
else
return menuNone;
}
// ---------------
// Private methods
void GameMenu::menuIconUnselected(int row)
{
GLCD.DrawBitmap(CircleEmpty, MENU_ICON_LEFT, MENU_ICON_TOP + MENU_VERT_SPACE * row);
}
void GameMenu::menuIconSelected(int row)
{
GLCD.DrawBitmap(CircleFilled, MENU_ICON_LEFT, MENU_ICON_TOP + MENU_VERT_SPACE * row);
}