-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.cpp
98 lines (88 loc) · 2.51 KB
/
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
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
#include "Menu.h"
void Menu::printDificultyMenu()const
{
cout << "Choose dificulty level: " << endl << "(a) BEST" << endl << "(b) GOOD" << endl << "(c) NOVICE" << endl << endl;
}
bool Menu::isValidLevel(char& level)const
{
if (level == 'a' || level == 'A')
{
level = 'a';
return true;
}
else if (level == 'b' || level == 'B')
{
level = 'b';
return true;
}
else if (level == 'c' || level == 'C')
{
level = 'c';
return true;
}
else
{
return false;
}
}
bool Menu::isValidChoice(char choice)const
{
if (choice != '1' && choice != '7' && choice != '8' && choice != '9' && choice != '5')
return false;
return true;
}
void Menu::printManualInstrctions()const
{
if (Board::IsColorOn())
setTextColor(Color::WHITE);
clrscr();
cout << "Hello there!, in this game you play the pacMan game." << endl
<< "controlls are:" << endl << endl << "W -> up\nX -> down\nA -> left\nD -> right\nS -> STAY Mode" << endl << endl
<< "You have 3 Lives, when ever a ghost \"eats\" you, your life gets reduce by one." << endl
<< "Your score increase by one every time you eat a breadcrumb, to win you need to eat all the breadcrumbs in 3 diffrent maps" << endl
<< "Sometimes a fruit represting random number apears on the screen, eating the fruit will grant you extra bonus points" << endl
<< "If you want to Pause the game you can Press ESC,\nWhen ever you want to continue from the exact same point that you paused the game, press ESC again." << endl << endl;
}
char Menu::printMenu(char& level)const
{
clrscr();
if (Board::IsColorOn())
setTextColor(Color::WHITE);
char choice = 0;
while (isValidChoice(choice) == false)
{
cout << menu;
cout << endl << "(1) Start a new game with existed map file" << endl << "(5) start without Colors" << endl
<< "(7) Start a new game with map file of your own" << endl << "(8) Present instructions and keys" << endl << "(9) Exit" << endl << endl;
choice = _getch();
if (isValidChoice(choice))
{
if (choice == EXIT)
return choice;
printDificultyMenu();
level = _getch();
while (isValidLevel(level) == false)
{
printDificultyMenu();
level = _getch();
if (isValidLevel(level))
{
break;
}
else
{
clrscr();
cout << endl << "Invalid level Choice please try again! " << endl << endl;
continue;
}
}
}
else
{
clrscr();
cout << "Invalid Choice please try again! " << endl << endl;
continue;
}
}
return choice;
}