Repository navigation
Expand file tree
/
Copy pathmenu.cpp
More file actions
73 lines (55 loc) 路 2.71 KB
/
Copy pathmenu.cpp
File metadata and controls
73 lines (55 loc) 路 2.71 KB
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
#include "menu.h"
void Menu::startMenu(int err) {
clearScreen();
drawAscii();
std::cout << bold_on << " Welcome to " << blue << "2048!" << def << bold_off; endl(2);
std::cout << " 1. Play a New Game"; endl();
std::cout << " 2. View Highscores and Statistics"; endl(2);
input(err);
}
void Menu::input(int err) {
if (err) {
std::cout << red << " Invalid input. Please try again." << def; endl(2);
}
std::cout << " Enter Choice: ";
char c;
std::cin >> c;
if (std::cin.eof())
{
std::cout << std::endl;
exit(EXIT_SUCCESS);
}
switch(c) {
case '1':
startGame();
break;
case '2':
showScores();
break;
default:
startMenu(1);
break;
}
}
void Menu::startGame() {
Game g;
g.startGame();
}
void Menu::showScores() {
Scoreboard s;
s.printScore();
s.printStats();
return;
}
void drawAscii() {
endl();
std::cout << green << bold_on << " /\\\\\\\\\\\\\\\\\\ /\\\\\\\\\\\\\\ /\\\\\\ /\\\\\\\\\\\\\\\\\\ " << bold_off << def; endl();
std::cout << green << bold_on << " /\\\\\\///////\\\\\\ /\\\\\\/////\\\\\\ /\\\\\\\\\\ /\\\\\\///////\\\\\\ " << bold_off << def; endl();
std::cout << green << bold_on << " \\/// \\//\\\\\\ /\\\\\\ \\//\\\\\\ /\\\\\\/\\\\\\ \\/\\\\\\ \\/\\\\\\ " << bold_off << def; endl();
std::cout << green << bold_on << " /\\\\\\/ \\/\\\\\\ \\/\\\\\\ /\\\\\\/\\/\\\\\\ \\///\\\\\\\\\\\\\\\\\\/ " << bold_off << def; endl();
std::cout << green << bold_on << " /\\\\\\// \\/\\\\\\ \\/\\\\\\ /\\\\\\/ \\/\\\\\\ /\\\\\\///////\\\\\\ " << bold_off << def; endl();
std::cout << green << bold_on << " /\\\\\\// \\/\\\\\\ \\/\\\\\\ /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ /\\\\\\ \\//\\\\\\ " << bold_off << def; endl();
std::cout << green << bold_on << " /\\\\\\/ \\//\\\\\\ /\\\\\\ \\///////////\\\\\\// \\//\\\\\\ /\\\\\\ " << bold_off << def; endl();
std::cout << green << bold_on << " /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\///\\\\\\\\\\\\\\/ \\/\\\\\\ \\///\\\\\\\\\\\\\\\\\\/ " << bold_off << def; endl();
std::cout << green << bold_on << " \\/////////////// \\/////// \\/// \\///////// " << bold_off << def; endl(4);
};