-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.cpp
56 lines (50 loc) · 812 Bytes
/
Menu.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
#include "include.h"
#include <conio.h>
extern bool Game();
const char* _MENU_NAME[] = { "开始游戏", "查看帮助", "退出游戏" };
int Menu::selector = 0;
int Menu::lines = sizeof(_MENU_NAME) / sizeof(_MENU_NAME[0]);
Menu::Menu() {}
Menu::~Menu() {}
void Menu::change_selector(int key)
{
switch (key)
{
case UP: case LEFT:
selector += lines - 1;
break;
case DOWN: case RIGHT:
selector++;
break;
default:
break;
}
selector %= lines;
}
int Menu::choose()
{
switch (selector)
{
case 0:
while (Game());
return 1;
case 1:
showHelp();
while (_getch() != ENTER);
fixFrame();
return 1;
case 2:
{
showExit();
int key = _getch();
while (key != ENTER && key != ESC) key = _getch();
fixFrame();
if (key == ENTER)
return 0;
else
return 1;
}
default:
return 1;
}
}