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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#include <iostream>
#include <cctype>
#include <conio.h>
#include <windows.h>
using namespace std;
enum { RETURN = 13, UP = 72, LEFT = 75, RIGHT = 77, DOWN = 80 };
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
void gotoXY(short x, short y) {
SetConsoleCursorPosition(console, COORD{ x, y });
}
void ShowCursor(bool show) {
CONSOLE_CURSOR_INFO cursor;
GetConsoleCursorInfo(console, &cursor);
cursor.bVisible = show;
SetConsoleCursorInfo(console, &cursor);
}
void settings(bool& rcb, bool& rpgf) {
char menu_choice = 0;
cout << "Randomized colored board (Y/N): ";
cin >> menu_choice;
rcb = (toupper(menu_choice) == 'Y');
cout << "\nRandom player goes first (Y/N): ";
cin >> menu_choice;
rpgf = (toupper(menu_choice) == 'Y');
cin.ignore(999, '\n');
}
void multiplayer() {
cout << "Multiplayer\n";
}
int main() {
int menu_item = 0;
bool running = true;
bool rcb = false, rpgf = false;
int x = 7;
ShowCursor(false);
gotoXY(18, 5);
cout << "Main Menu";
gotoXY(20, 7);
cout << "1) Multiplayer";
gotoXY(20, 8);
cout << "2) Settings";
gotoXY(20, 9);
cout << "3) Quit Program";
gotoXY(18, 7);
cout << "->";
while (running) {
gotoXY(18, 5);
cout << "Main Menu";
gotoXY(20, 7);
cout << "1) Multiplayer";
gotoXY(20, 8);
cout << "2) Settings";
gotoXY(20, 9);
cout << "3) Quit Program";
int ch = _getch();
if (ch == 224) {
ch = _getch();
if (ch == DOWN && menu_item != 2) {
gotoXY(18, menu_item + 7);
cout << " ";
x++;
gotoXY(18, x);
cout << "->";
++menu_item;
}
else if (ch == UP && menu_item != 0) {
gotoXY(18, menu_item + 7);
cout << " ";
x--;
gotoXY(18, x);
cout << "->";
--menu_item;
}
}
else if (ch == RETURN) {
switch (menu_item) {
case 0:
gotoXY(20, 16);
cout << "You chose Multiplayer!";
Sleep(1000);
system("cls");
multiplayer();
running = false;
break;
case 1:
gotoXY(20, 16);
cout << "You chose Settings!";
Sleep(1000);
system("cls");
settings(rcb, rpgf);
break;
case 2:
gotoXY(20, 16);
cout << "Terminating...";
Sleep(1000);
system("cls");
running = false;
break;
}
}
}
gotoXY(20, 21);
ShowCursor(true);
}
|