#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
void selectPlayer(bool* palayer);
int main()
{
char field[3][3];//игровое поле
bool player2 = false;
selectPlayer(&player2);
char c = 0;
while (c != 13)
{
c = _getch();
if (c == 72 || c == 80)//38 и 40 - стрелки вверх и вниз у таблице ASCII
selectPlayer(&player2);
}
return 0;
}
void clearScreen() {
static HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdOut,
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
system("cls");
}
void selectPlayer(bool* player) {
clearScreen();
COORD coord = { 50, 10 };
static HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hStdOut, coord);
if (*player) {
SetConsoleTextAttribute(hStdOut,
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
cout << "1 PLAYER";
SetConsoleTextAttribute(hStdOut,
BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY | BACKGROUND_RED);
coord = { 50, 11 };
SetConsoleCursorPosition(hStdOut, coord);
cout << "2 PLAYERS";
*player = false;
}
else {
SetConsoleTextAttribute(hStdOut,
BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY | BACKGROUND_RED);
cout << "1 PLAYER";
SetConsoleTextAttribute(hStdOut,
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
coord = { 50, 11 };
SetConsoleCursorPosition(hStdOut, coord);
cout << "2 PLAYERS";
*player = true;
}
}
printf("Name-> ");
char name[MAX_CHAR];
gets_s(name ,MAX_CHAR);